<?php

//////////////////////////////////////////////////////////////
//===========================================================
// addserver_theme.php
//===========================================================
// SOFTACULOUS VIRTUALIZOR
// Version : 1.0
// Inspired by the DESIRE to be the BEST OF ALL
// ----------------------------------------------------------
// Started by: Alons
// Date:       8th Mar 2010
// Time:       23:00 hrs
// Site:       https://www.virtualizor.com/ (SOFTACULOUS VIRTUALIZOR)
// ----------------------------------------------------------
// Please Read the Terms of use at https://www.virtualizor.com
// ----------------------------------------------------------
//===========================================================
// (c)Softaculous Ltd.
//===========================================================
//////////////////////////////////////////////////////////////

if(!defined('VIRTUALIZOR')){

	die('Hacking Attempt');

}

function getSortHeader($header_name, $sort_column, $sort_column_by, $column ,$size = 90){

	global $theme, $globals;
	
	$str = '<div class="d-inline-flex align-items-center" style="width:'.$size.'px;">
		<div class="mr-2">
			<span class="" >'.$header_name.'</span>
		</div>
		<span class="sorter">
			<a class="text-always-white" href="'.$globals['index'].'act=tasks&sortcolumn='.$column.'&sortby=asc"><i class="fas fa-sort-up"></i></a><br>
			<a class="text-always-white" href="'.$globals['index'].'act=tasks&sortcolumn='.$column.'&sortby=desc"><i class="fas fa-sort-down"></i></a>
		</span>
	</div>';
	return $str;
}

function tasks_theme(){

global $theme, $globals, $servers, $user, $l, $list, $cluster, $error, $done, $servergroups, $migrate_status, $cpu, $progress, $migrate_done, $migrate_run, $mprog, $tasks,$sort_column, $sort_column_by, $task_action;

softheader($l['<title>']);
										
// If we need to find the next sub task for MAIN task
$find_actid = optREQ('find_actid');
$find_action = optREQ('find_action');
$find_vps = optREQ('find_vps');

// All three values are compulsary
if(!empty($find_actid)){

	$token_vals = array();
	$token_vals[':vpsid'] = $find_vps;
	$slaveactid = optREQ('slaveactid');
	$serid = optREQ('serid');
	
	// We need to handle this for slave. To show it properly on slave servers, because on slave server slaveactid will be 0
	if(!empty($globals['slave']) && !empty($slaveactid)){
		$find_actid = $slaveactid;
		$slaveactid = 0;
	}
	
	// If the task s from slave server then we will have to check in slaveactid 
	if(isset($serid) && !empty($slaveactid)){
		
		$serid = (int) $serid;
		$tmp_query = 'slaveactid = :slaveactid AND 
					serid = :serid';
		$token_vals[':slaveactid'] = $slaveactid;
		$token_vals[':serid'] = $serid;
	// Search for specifi actid (like startvps, poweroff etc...)
	}else if(empty($find_action)){
		$tmp_query = "actid = :actid";
		$token_vals[':actid'] = $find_actid;
	// If main process has multiple tasks then those actid will be > current actid (Like addvs, rebuild etc..)
	}else{
		$tmp_query = "actid > :actid AND 
					action = :action";
		$token_vals[':actid'] = $find_actid;
		$token_vals[':action'] = $find_action;
	}
	
	$res = makequery('SELECT logs FROM tasks WHERE 
				'.$tmp_query.' AND
				vpsid = :vpsid
				LIMIT 0,1', $token_vals);
				
	if(vsql_num_rows($res) < 1){
		return false;
	}
	
	$row = vsql_fetch_assoc($res);
	echo $row['logs'];
	return true;
}

echo '
<style>
i.fas.text-danger.fa-2x.fa-times-circle{
	font-size:24px !important;
}
</style>';

$GLOBALS['breadcrumbs'] = array('dashboard', 'lm_tasks');

echo page_header(__('Tasks List'), 'fas fa-tasks', '', 1, 0, '');

error_handle($error);

echo '<script language="javascript" type="text/javascript"><!-- // --><![CDATA[
var prog = 0;
function make_progress(index, progress){
	var steps = 20;
	var start = $("#pbar"+index).text();
	start = (start.slice(0, -1));
	if(isNaN(start)){
		start = 0;
	}
	var step = (progress - start)/steps;
	if(step < 0){ step = 0;}
	var increment = function(){
		var val = $("#pbar"+index).text();
		val = Number(val.slice(0, - 1));
		prog = parseInt(val + Math.round(step));
		//alert("progr"+prog);
		if(prog > progress){ prog = progress;}
		if(prog < parseInt("100")){
			$("#pbar"+index).text(prog + "%");
			$("#progressbar"+index).width(prog + "%");
		}else{
			$("#progressbar"+index).width(100 + "%");
		}
		if (prog < progress){setTimeout(increment, 500);}
	};
	increment();
};

function csv_download(filename = ""){

	filename = (typeof filename !== "object") ? "&filename="+filename : ""; 
	window.location.href = "'.$globals['index'].'act=vs&download=1"+filename;
	
}

function make_table(id, data){
		
	try{
		data = JSON.parse(data);
	}catch(e){
		return;
	}
	
	var html = "<div>";
	$.each(data, function(i, item){
		if(i != "progress"){
			html += "<b>"+i+"&nbsp;:&nbsp;&nbsp;</b>"+item+"<br>";
		}
	});
	html += "</div>";
	$(id).attr("tooltip", html);
	$(id).html(html);
};

function get_taskprogress(act){
	var search = $("#task_search").find("input[type=text], select").serialize();
	$.ajax({type: "GET",
		url: "'.$globals['index'].'&act=tasks&page='.optREQ('page').'&reslen='.optREQ('reslen').'&sortcolumn='.optREQ('sortcolumn').'&sortby='.optREQ('sortby').'&"+search+"&api=json",
		dataType : "json",
		success:function(data){
			var tasks = data.tasks;
			$.each(tasks, function(index, value){
				if(tasks[index]["progress"] == 100){
					$("#status"+index).removeAttr("tooltip");
					$("#status"+index).unbind();
					$("#status"+index).text("'.__J('Completed').'");
					$("#pbar"+index).html("<i style=\"font-size:24px !important;\" class=\"fas fa-2x text-success fa-check-circle\"></i>");
					$("#progressbar"+index).hide();
					$("#progressbar"+index).parent().css("border", "0px");
					$("#progressbar"+index).parent().removeClass("progress");
				}else if(tasks[index]["status"] == -1){
					$("#status"+index).html(tasks[index]["status_txt"]);
					if(!empty(tasks[index]["status_txt"])){
						$("#status"+index).attr("tooltip",tasks[index]["status_txt"]);
					}
					$("#pbar"+index).html("<i style=\"font-size:24px !important;\" class=\"fas text-danger fa-2x fa-times-circle\"></i>");
					$("#progressbar"+index).hide();
					$("#progressbar"+index).parent().css("border", "0px");
					$("#progressbar"+index).parent().removeClass("progress");
				}else{
					// We have to create the table in case of migrate and clone
					if(tasks[index]["action"] == "migrate2" || tasks[index]["action"] == "clone2" || tasks[index]["action"] == "multimigrateprog" || tasks[index]["action"] == "multicloneprog" || tasks[index]["action"] == "migrate_disk2"){
						make_table("#status"+index, tasks[index]["status_txt"]);
						
					}else{
						$("#status"+index).text(tasks[index]["status_txt"]);
						if(!empty(tasks[index]["status_txt"])){
							$("#status"+index).attr("tooltip",tasks[index]["status_txt"]);
						}
						$("#progressbar"+index).hide();
						$("#progressbar"+index).parent().css("border", "0px");
						$("#progressbar"+index).parent().removeClass("progress");
					}
					
					if(isNaN(tasks[index]["progress"])){
						$("#pbar"+index).unbind();
						$("#pbar"+index).text(tasks[index]["progress"]);
						$("#progressbar"+index).hide();
						$(".progress_"+index).hide();
					}else{
						$("#progressbar"+index).parent().addClass("progress");
						make_progress(index, Number(tasks[index]["progress"]));
						$("#progressbar"+index).show();
					}
				}
				$("#started"+index).html(tasks[index]["started"]);
				$("#updated"+index).html(tasks[index]["updated"]);
				$("#ended"+index).html(tasks[index]["ended"]);
			});
			show_tooltip();
		}
	});
	setTimeout(function(){get_taskprogress(act);}, 10000);
};

$(document).ready(function(){
	var act = new Array();';
	if(count($tasks) > 0){
		foreach($tasks as $k => $v){
			echo 'act.push('.$v['actid'].');';
		}
		echo 'get_taskprogress(act);';
	}
	echo '
	
});


// ]]></script><script>
$(document).ready(function(){
  $("#search_task").on("keyup", function(e) {
	var value = $(this).val().toLowerCase();

	$("#myTable tr").filter(function() {
		if(value.length >= 2 ){
			$(this).toggle($(this).find("#actid").text().toLowerCase().indexOf(value) > -1 || $(this).find("#vpsid").text().toLowerCase().indexOf(value) > -1 || $(this).find("#email").text().toLowerCase().indexOf(value) > -1 || $(this).find("#action").text().toLowerCase().indexOf(value) > -1)
		}else{
			$(this).show();
		}
		//
		if($(this).find("#actid").text().toLowerCase().indexOf(value) > -1  && value.length > 0){
			var txt = $(this).find("#actid").text().toLowerCase().replace(value, \'<span class="highlight">\' + value +  \'</span>\');
			$(this).find("#actid").html(txt);
		}else{
			var txt1 = $(this).find("#actid").text().replace(\'<span class="highlight">\', \'\');
			txt1 = $(this).find("#actid").text().toLowerCase().replace(\'</span>\',\'\');
			$(this).find("#actid").html(txt1);
		}
		//
		if($(this).find("#vpsid").text().toLowerCase().indexOf(value) > -1  && value.length > 0){
			var txt = $(this).find("#vpsid").text().toLowerCase().replace(value, \'<span class="highlight">\' + value +  \'</span>\');
			$(this).find("#vpsid").html(txt);
		}else{
			var txt1 = $(this).find("#vpsid").text().replace(\'<span class="highlight">\', \'\');
			txt1 = $(this).find("#vpsid").text().toLowerCase().replace(\'</span>\',\'\');
			$(this).find("#vpsid").html(txt1);
		}

		if($(this).find("#action").text().toLowerCase().indexOf(value) > -1  && value.length > 0){
			var og = $(this).text().substr($(this).text().toLowerCase().indexOf(value), value.length);
			var txt = $(this).find("#action").text().replace(og, \'<span class="highlight">\' + og +  \'</span>\');
			$(this).find("#action").html(txt);
		}else{
			var txt1 = $(this).find("#action").text().replace(\'<span class="highlight">\', \'\');
			txt1 = $(this).find("#action").text().replace(\'</span>\',\'\');
			$(this).find("#action").html(txt1);
		}
		//
		if($(this).find("#email").text().toLowerCase().indexOf(value) > -1  && value.length > 0){
			var txt = $(this).find("#email").text().toLowerCase().replace(value, \'<span class="highlight">\' + value +  \'</span>\');
			$(this).find("#email").html(txt);
		}else{
			var txt1 = $(this).find("#email").text().replace(\'<span class="highlight">\', \'\');
			txt1 = $(this).find("#email").text().toLowerCase().replace(\'</span>\',\'\');
			$(this).find("#email").html(txt1);
		}
	});
  });
});
</script>';

// Take this for display notice when no process available
echo '<div class="card p-2 mx-3">
<div id="showsearch" style="display:'.(optREQ('search') || (!empty($tasks) && !empty($globals['showsearch'])) ? "" : "none").';">
<form accept-charset="'.$globals['charset'].'"  class="form-horizontal" name="tasks" method="GET" action="" id="task_search">
<input type="hidden" name="act" value="tasks">
<input type="hidden" name="page" value="1">
<input type="hidden" name="reslen" value="50">
<div class="form-group_head">
	<div class="row mx-auto w-100">
		<div class="col-sm-4">
			<label>'.__('Actid').'</label>
			<input type="text" class="form-control" name="actid" id="actid" size="15" value="'.REQval('actid','').'" />
		</div>
		<div class="col-sm-4">
			<label>'.__('VPS ID').'</label>
			<input type="text" class="form-control" name="vpsid" id="vpsid" size="15" value="'.REQval('vpsid','').'" />
		</div>
		<div class="col-sm-4">
			<label>'.__('User').'</label>
			<input type="text" class="form-control" name="username" id="username" size="15" value="'.REQval('username','').'" />
		</div>
	</div>
	<div class="row mx-auto w-100">
		<div class="col-sm-4 server-select-lg">
			<label>'.__('Action').'</label>
			<select class="custom-select virt-select" name="action" id="action">
				<option value="0">---</option>
				<option value="addvs" '.REQselect('action', 'addvs').'>'.__('Creating VPS').'</option>
				<option value="addvs_restore" '.REQselect('action', 'addvs_restore').'>'.__('Creating VPS for Restore').'</option>
				<option value="rebuildvs" '.REQselect('action', 'rebuildvs').'>'.__('Rebuilding VPS').'</option>
				<option value="vpsbackups" '.REQselect('action', 'vpsbackups').'>'.__('Backing up VPS').'</option>
				<option value="restorevps" '.REQselect('action', 'restorevps').'>'.__('Restoring VPS').'</option>
				<option value="migrate2" '.REQselect('action', 'migrate2').'>'.__('Migrating VPS').'</option>
				<option value="multimigrateprog" '.REQselect('action', 'multimigrateprog').'>'.__('Multiple Migrate').'</option>
				<option value="clone2" '.REQselect('action', 'clone2').'>'.__('Cloning VPS').'</option>
				<option value="multicloneprog" '.REQselect('action', 'multicloneprog').'>'.__('Multiple Clone').'</option>
				<option value="deletevs" '.REQselect('action', 'deletevs').'>'.__('Deleting VPS').'</option>
				<option value="createtemplate" '.REQselect('action', 'createtemplate').'>'.__('Creating Template').'</option>
				<option value="fstab_handle" '.REQselect('action', 'fstab_handle').'>'.__('FS Tab Handle').'</option>
				<option value="fstrim_handle" '.REQselect('action', 'fstrim_handle').'>'.__('Fstrim Handle').'</option>
				<option value="editxcpvs" '.REQselect('action', 'editxcpvs').'>'.__('Edit XCP VPS').'</option>
				<option value="resizevps" '.REQselect('action', 'resizevps').'>'.__('Resizing VPS').'</option>
				<option value="multivirt" '.REQselect('action', 'multivirt').'>'.__('Enabling Multivirt').'</option>
				<option value="getos" '.REQselect('action', 'getos').'>'.__('Downloading OS').'</option>
				<option value="addiso" '.REQselect('action', 'addiso').'>'.__('Add ISO').'</option>
				<option value="change_dnsnameserver" '.REQselect('action', 'change_dnsnameserver').'>'.__('Changing DNS Nameserver').'</option>
				<option value="changepassword" '.REQselect('action', 'changepassword').'>'.__('Changing VPS Password').'</option>
				<option value="install_cp" '.REQselect('action', 'install_cp').'>'.__('Install Control Panel').'</option>
				<option value="hostname" '.REQselect('action', 'hostname').'>'.__('Changing VPS Hostname').'</option>
				<option value="install_recipe" '.REQselect('action', 'install_recipe').'>'.__('Install Recipe').'</option>
				<option value="bandwidth_unsuspend" '.REQselect('action', 'bandwidth_unsuspend').'>'.__('Unsuspend Bandwidth').'</option>
				<option value="suspend_callback" '.REQselect('action', 'suspend_callback').'>'.__('Suspend Callback').'</option>
				<option value="unsuspend_callback" '.REQselect('action', 'unsuspend_callback').'>'.__('Unsuspend Callback').'</option>
				<option value="editvps_callback" '.REQselect('action', 'editvps_callback').'>'.__('Edit VPS Callback').'</option>
				<option value="terminate_callback" '.REQselect('action', 'terminate_callback').'>'.__('Terminate VPS Callback').'</option>
				<option value="get_crt" '.REQselect('action', 'get_crt').'>'.__('SSL Install Certificate').'</option>
				<option value="renew_crt" '.REQselect('action', 'renew_crt').'>'.__('SSL Renew Certificate').'</option>
				<option value="cron_crt" '.REQselect('action', 'cron_crt').'>'.__('SSL Renew Certificate Cron Task').'</option>
				<option value="haproxy_cron" '.REQselect('action', 'haproxy_cron').'>'.__('HAProxy Rebuild').'</option>
				<option value="vpsbackups_plan" '.REQselect('action', 'vpsbackups_plan').'>'.__('VPS Backups').'</option>
				<option value="restorevps_plan" '.REQselect('action', 'restorevps_plan').'>'.__('VPS Restore').'</option>
				<option value="backuply_vpsbackups_plan" '.REQselect('action', 'backuply_vpsbackups_plan').'>'.__('VPS Backuply Backups').'</option>
				<option value="vps_backup_master_task" '.REQselect('action', 'vps_backup_master_task').'>'.__('VPS Backup Master Task').'</option>
				<option value="backuply_restorevps_plan" '.REQselect('action', 'backuply_restorevps_plan').'>'.__('VPS Backuply Restore').'</option>
				<option value="addsshkeys" '.REQselect('action', 'addsshkeys').'>'.__('Adding SSH Keys').'</option>
				<option value="removesshkeys" '.REQselect('action', 'removesshkeys').'>'.__('Removing SSH Keys').'</option>
				<option value="installxentools" '.REQselect('action', 'installxentools').'>'.__('Installing Xenserver Tools').'</option>
				<option value="dbbackups" '.REQselect('action', 'dbbackups').'>'.__('Database Backup').'</option>
				<option value="install_script" '.REQselect('action', 'install_script').'>'.__('Installing Apps').'</option>
				<option value="migrate_disk2" '.REQselect('action', 'migrate_disk2').'>'.__('Migrating Disk').'</option>
				<option value="create_vps" '.REQselect('action', 'create_vps').'>'.__('Create VPS Operation').'</option>
				<option value="edit_vps" '.REQselect('action', 'edit_vps').'>'.__('Edit VPS Operation').'</option>
				<option value="edit_logs" '.REQselect('action', 'edit_logs').'>'.__('VPS Edit Logs').'</option>
				<option value="install_ga" '.REQselect('action', 'install_ga').'>'.__('Installing qemu guest agent').'</option>
				<option value="remotedesktop" '.REQselect('action', 'remotedesktop').'>'.__('Remote Desktop Task').'</option>
				<option value="change_vncpass" '.REQselect('action', 'change_vncpass').'>'.__('Change VNC Password').'</option>
				<option value="multi_deletevs" '.REQselect('action', 'multi_deletevs').'>'.__('Deleting VPS(s)').'</option>
				<option value="updates" '.REQselect('action', 'updates').'>'.__('Server Update').'</option>
				<option value="update_servers" '.REQselect('action', 'update_servers').'>'.__('Multiple Server Update').'</option>
				<option value="enable_rescuevs" '.REQselect('action', 'enable_rescuevs').'>'.__('Enable Rescue').'</option>
				<option value="disable_rescuevs" '.REQselect('action', 'disable_rescuevs').'>'.__('Disable Rescue').'</option>
				<option value="delete_vpsdisks" '.REQselect('action', 'delete_vpsdisks').'>'.__('Deleting VPS Disks').'</option>
				<option value="suspend_vps" '.REQselect('action', 'suspend_vps').'>'.__('Suspending VPS').'</option>
				<option value="unsuspend_vps" '.REQselect('action', 'unsuspend_vps').'>'.__('Unsuspending VPS').'</option>
				<option value="change_winips" '.REQselect('action', 'change_winips').'>'.__('Configuring windows IPs').'</option>
				<option value="installha" '.REQselect('action', 'installha').'>'.__('Install HA').'</option>
				<option value="addvolume" '.REQselect('action', 'addvolume').'>'.__('Add Volume').'</option>
				<option value="delete_volume" '.REQselect('action', 'delete_volume').'>'.__('Delete Volume').'</option>
				<option value="resize_volume" '.REQselect('action', 'resize_volume').'>'.__('Resize Volume').'</option>
				<option value="detach_volume" '.REQselect('action', 'detach_volume').'>'.__('Detach Volume').'</option>
				<option value="hotplug_disk" '.REQselect('action', 'hotplug_disk').'>'.__('Hotplug Volume').'</option>
				<option value="exportascsv" '.REQselect('action', 'exportascsv').'>'.__('Exporting VPS details').'</option>
				<option value="import_vps_backups" '.REQselect('action', 'import_vps_backups').'>'.__('Import VPS Backups in DB').'</option>
				<option value="sync_backups" '.REQselect('action', 'sync_backups').'>'.__('Sync Backups').'</option>
			</select>
		</div>
		<div class="col-sm-4">
			<label>'.__('Status').'</label>
			<select class="custom-select" name="status" id="status">
				<option value="">---</option>
				<option value="1" '.REQselect('status', '1').'>'.__('In Progress').'</option>
				<option value="2" '.REQselect('status', '2').'>'.__('Completed').'</option>
				<option value="3" '.REQselect('status', '3').'>'.__('Not Updated').'</option>
				<option value="-1" '.REQselect('status', '-1').'>'.__('Errored').'</option>			
			</select>
		</div>
		<div class="col-sm-4">
			<label>'.__('Server').'</label>
			<select class="custom-select virt-select" name="server">';
				echo "<option value='-1' ".REQselect('server', '-1').">---</option>";
				foreach ($servers as $serid => $server_name) {
					echo "<option value='$serid' ".REQselect('server', $serid).">".$server_name['server_name']."</option>";
				}
	echo	'</select>
		</div>
	</div>
	<div class="row mx-auto w-100 my-2">
		<div class="col-sm-12 text-center"><input type="submit" name="search" value="'.__('Search').'" class="go_btn mt-2"/></div>
	</div>
</div>


</form>
</div>';

// Take this for display notice when no process available
if(empty($tasks)){
	echo '<div class="notice" id="complete"><b>'.__('Note').' : </b> &nbsp; '.__('Currently there are no active tasks.').'</div>';
}else{
	echo'<div class="row mx-auto w-100 mb-3">
			<div class="col-sm-12 col-lg-5 col-md-5 mb-3 mb-sm-3 mb-md-0 d-flex align-items-center justify-content-end p-0">
				<input id="search_task" placeholder="'.__('Quick Search (actid, vpsid, user, action)').'" class="w-100 form-control h-100 d-inline-block search-box p-2">
			</div>
			<div class="col-sm-12 col-lg-5 col-md-5 p-0 d-flex mb-3 mb-sm-3 mb-md-0 d-md-flex d-lg-flex align-items-center justify-content-lg-center justify-content-center">';
				page_links($globals['num_res'], $globals['cur_page'], $globals['reslen']);
				echo'
			</div>
			<div class="col-sm-12 col-lg-2 col-md-2 d-flex p-0 mb-3 mb-sm-3 mb-md-0 d-md-flex d-lg-flex align-items-center justify-content-lg-end justify-content-center">';
				echo get_num_records($globals['num_res'], "ml-4").'
			</div>
		</div>';

echo '<div class="scrollbar-virt task_table">
<table class="table table-hover tablesorter common-table tasks_table">
<tr class="table_heading">
	<th class="min_width">'.getSortHeader(__('Actid'), $sort_column, $sort_column_by, 'actid','50').'</td>
	<th class="min_width">'.getSortHeader(__('VPS ID'), $sort_column, $sort_column_by, 'vpsid','55').'</th>
	<th style="width: 55px;"><span class="">'.__('User').'</span><br>'.getSortHeader(__('Server').'('.__('ID').')', $sort_column, $sort_column_by, 'server').' </th>
	<th class="min_width">'.getSortHeader(__('Started'), $sort_column, $sort_column_by, 'started', '70').'</th>
	<th class="min_width">'.getSortHeader(__('Updated'), $sort_column, $sort_column_by, 'updated', '70').'</th>
	<th class="min_width">'.getSortHeader(__('Ended'), $sort_column, $sort_column_by, 'ended', '70').'</th>
	<th class="min_width"><span class="">'.__('Action').'</span></th>
	<th class="min_width">'.getSortHeader(__('Status'), $sort_column, $sort_column_by, 'status', 70).'</th>
	<th class="min_width text-center"><span class="">'.__('Progress').'</span></th>
	<th class="min_width text-center"><span class="">'.__('Logs').'</span></th>
</tr><tbody id="myTable">';

$i = 1;
foreach($tasks as $k => $v){
	echo '<tr>
		<td align="center" id="actid">'.$v['actid'].'</td>
		<td id="vpsid">'.$v['vpsid'].'</td>
		<td><span id="email" class="userflare">'.$v['email'].'</span><br>'.(!empty($v['server_name']) ? $v['server_name'].' ('.$v['serid'].')' : __('Unslaved Server')).'</td>
		<td><span id="started'.$v['actid'].'">'.$v['started'].'</span></td>
		<td><span id="updated'.$v['actid'].'">'.$v['updated'].'</span></td>
		<td><span id="ended'.$v['actid'].'">'.$v['ended'].'</span></td>
		<td id="action">'.__($task_action[$v['action']]).'</td>
		<td id="status'.$v['actid'].'" class="wrap text-left"></td>
		<td class="d-flex align-items-center justify-items-center">
			<div class="progress-cont" id="progress-cont'.$v['actid'].'">
			<center><div id="pbar'.$v['actid'].'">'.$v['progress'].'%</center>
			<div class="progress progress_'.$v['actid'].'">
				<div class="progress-bar bg-primary progress-bar-striped progress-bar-animated" style="width:0px;" id="progressbar'.$v['actid'].'">
				</div>
			</div>
		</td>
		<td align="center" class="text-center">
			<a href="javascript:void(0);" onclick="return loadlogs('.$v['actid'].');" class="btn px-2 py-1 mt-2 mb-2">'.__('Show').'</a>
		</td>
	</tr>';
	$i++;
	}
	echo '</tbody></table></div>';
}
echo'<div class="row mx-auto w-100 mt-5">
		<div class="col-sm-4 col-lg-4 col-md-6 text-right d-flex align-items-center">
		</div>
		<div class="col-sm-8 col-lg-8 col-md-8 mb-3 d-flex align-items-center justify-content-end p-0">';
			page_links($globals['num_res'], $globals['cur_page'], $globals['reslen']);
			echo'
		</div>
	</div>
<br></div>';

softfooter();
}

?>