<?php

/*
 * Squelette : ../prive/squelettes/contenu/job_queue.html
 * Date :      Sun, 21 Jun 2020 17:08:17 GMT
 * Compile :   Wed, 30 Aug 2023 11:50:13 GMT
 * Boucles :   _jobs
 */ 

function BOUCLE_jobshtml_5fdc4db5224717155c454283dcad1082(&$Cache, &$Pile, &$doublons, &$Numrows, $SP) {

	static $command = array();
	static $connect;
	$command['connect'] = $connect = '';
	$command['pagination'] = array((isset($Pile[0]['debut_jobs']) ? $Pile[0]['debut_jobs'] : null), 20);
	if (!isset($command['table'])) {
		$command['table'] = 'jobs';
		$command['id'] = '_jobs';
		$command['from'] = array('jobs' => 'spip_jobs');
		$command['type'] = array();
		$command['groupby'] = array();
		$command['select'] = array("jobs.date",
		"jobs.id_job",
		"jobs.status",
		"jobs.priorite",
		"jobs.descriptif",
		"jobs.args",
		"jobs.fonction");
		$command['orderby'] = array('jobs.date');
		$command['where'] = 
			array();
		$command['join'] = array();
		$command['limit'] = '';
		$command['having'] = 
			array();
	}
	if (defined("_BOUCLE_PROFILER")) $timer = time()+(float)microtime();
	$t0 = "";
	// REQUETE
	$iter = IterFactory::create(
		"SQL",
		$command,
		array('../prive/squelettes/contenu/job_queue.html','html_5fdc4db5224717155c454283dcad1082','_jobs',5,$GLOBALS['spip_lang'])
	);
	if (!$iter->err()) {
	
	// COMPTEUR
	$Numrows['_jobs']['compteur_boucle'] = 0;
	$Numrows['_jobs']['total'] = @intval($iter->count());
	$debut_boucle = isset($Pile[0]['debut_jobs']) ? $Pile[0]['debut_jobs'] : _request('debut_jobs');
	if(substr($debut_boucle,0,1)=='@'){
		$debut_boucle = $Pile[0]['debut_jobs'] = quete_debut_pagination('id_job',$Pile[0]['@id_job'] = substr($debut_boucle,1),20,$iter);
		$iter->seek(0);
	}
	$debut_boucle = intval($debut_boucle);
	$debut_boucle = (($tout=($debut_boucle == -1))?0:($debut_boucle));
	$debut_boucle = max(0,min($debut_boucle,floor(($Numrows['_jobs']['total']-1)/(20))*(20)));
	$debut_boucle = intval($debut_boucle);
	$fin_boucle = min(($tout ? $Numrows['_jobs']['total'] : $debut_boucle + 19), $Numrows['_jobs']['total'] - 1);
	$Numrows['_jobs']['grand_total'] = $Numrows['_jobs']['total'];
	$Numrows['_jobs']["total"] = max(0,$fin_boucle - $debut_boucle + 1);
	if ($debut_boucle>0 AND $debut_boucle < $Numrows['_jobs']['grand_total'] AND $iter->seek($debut_boucle,'continue'))
		$Numrows['_jobs']['compteur_boucle'] = $debut_boucle;
	
	
	$l1 = _T('public|spip|ecrire:annuler');
	$l2 = _T('public|spip|ecrire:queue_executer_maintenant');$SP++;
	// RESULTATS
	while ($Pile[$SP]=$iter->fetch()) {

		$Numrows['_jobs']['compteur_boucle']++;
		if ($Numrows['_jobs']['compteur_boucle'] <= $debut_boucle) continue;
		if ($Numrows['_jobs']['compteur_boucle']-1 > $fin_boucle) break;
		$t0 .= (
'
				<li class="item' .
(($t1 = strval(interdire_scripts(($Pile[$SP]['status'] ? 'scheduled':'pending'))))!=='' ?
		(' ' . $t1) :
		'') .
'">
					<div class="date">' .
interdire_scripts(date_relative(normaliser_date($Pile[$SP]['date']))) .
(($t1 = strval(interdire_scripts((($Pile[$SP]['status']) ?'' :' '))))!=='' ?
		(' ' . $t1 . '(en cours)') :
		'') .
(($t1 = strval(interdire_scripts((($Pile[$SP]['priorite']) ?' ' :''))))!=='' ?
		($t1 . (	'&#91;' .
	interdire_scripts($Pile[$SP]['priorite']) .
	'&#93;')) :
		'') .
'</div>
					' .
(($t1 = strval(interdire_scripts(PtoBR(propre($Pile[$SP]['descriptif'], $connect, $Pile[0])))))!=='' ?
		('<strong class="description">' . $t1 . '</strong>') :
		'') .
'
					' .
(($t1 = strval(interdire_scripts(filtre_implode_dist(unserialize($Pile[$SP]['args']),','))))!=='' ?
		((	'<span class="small">| ' .
	interdire_scripts($Pile[$SP]['fonction']) .
	'(') . $t1 . ')</span>') :
		'') .
'
					' .
(($t1 = strval(invalideur_session($Cache, ((((function_exists("autoriser")||include_spip("inc/autoriser"))&&autoriser('annuler', 'job', invalideur_session($Cache, $Pile[$SP]['id_job']))?" ":"")) ?' ' :''))))!=='' ?
		($t1 . (	'
					<div class="actions">
						' .
	bouton_action($l1,invalideur_session($Cache, generer_action_auteur('annuler_job',invalideur_session($Cache, $Pile[$SP]['id_job']),invalideur_session($Cache, self()))),'ajax') .
	'
						' .
	bouton_action($l2,invalideur_session($Cache, generer_action_auteur('forcer_job',invalideur_session($Cache, $Pile[$SP]['id_job']),invalideur_session($Cache, self())))) .
	'
					</div>
					')) :
		'') .
'
				</li>
			');
	}
	$iter->free();
	}
	if (defined("_BOUCLE_PROFILER")
	AND 1000*($timer = (time()+(float)microtime())-$timer) > _BOUCLE_PROFILER)
		spip_log(intval(1000*$timer)."ms BOUCLE_jobs @ ../prive/squelettes/contenu/job_queue.html","profiler"._LOG_AVERTISSEMENT);
	return $t0;
}

//
// Fonction principale du squelette ../prive/squelettes/contenu/job_queue.html
// Temps de compilation total: 12.857 ms
//

function html_5fdc4db5224717155c454283dcad1082($Cache, $Pile, $doublons = array(), $Numrows = array(), $SP = 0) {

	if (isset($Pile[0]["doublons"]) AND is_array($Pile[0]["doublons"]))
		$doublons = nettoyer_env_doublons($Pile[0]["doublons"]);

	$connect = '';
	$page = (
'<'.'?php header("X-Spip-Cache: 0"); ?'.'>'.'<'.'?php header("Cache-Control: no-cache, must-revalidate"); ?'.'><'.'?php header("Pragma: no-cache"); ?'.'>' .
invalideur_session($Cache, sinon_interdire_acces(((function_exists("autoriser")||include_spip("inc/autoriser"))&&autoriser('administrer', 'queue')?" ":""))) .
'
' .
job_queue_block_and_watch('') .
'
<h1 class="grostitre">' .
_T('public|spip|ecrire:queue_titre') .
'</h1>
' .
(($t1 = BOUCLE_jobshtml_5fdc4db5224717155c454283dcad1082($Cache, $Pile, $doublons, $Numrows, $SP))!=='' ?
		((	'
	<div class="liste">
		<h3>' .
		singulier_ou_pluriel((isset($Numrows['_jobs']['grand_total'])
			? $Numrows['_jobs']['grand_total'] : $Numrows['_jobs']['total']),'queue_one_job_in_queue','queue_nb_jobs_in_queue') .
		'</h3>
		<p>' .
		vide($Pile['vars'][$_zzz=(string)'nb'] = queue_sleep_time_to_next_job('')) .
		_T('public|spip|ecrire:queue_next_job_in_nb_sec', array('nb' => table_valeur($Pile["vars"], (string)'nb', null))) .
		'</p>
		' .
		(($t3 = strval(filtre_pagination_dist($Numrows["_jobs"]["grand_total"],
 		'_jobs',
		isset($Pile[0]['debut_jobs'])?$Pile[0]['debut_jobs']:intval(_request('debut_jobs')),
		20, true, 'prive', '', array())))!=='' ?
				('<p class="pagination">' . $t3 . '</p>') :
				'') .
		'
		<ul class="liste-items">
			') . $t1 . (	'
		</ul>
		' .
		(($t3 = strval(filtre_pagination_dist($Numrows["_jobs"]["grand_total"],
 		'_jobs',
		isset($Pile[0]['debut_jobs'])?$Pile[0]['debut_jobs']:intval(_request('debut_jobs')),
		20, true, 'prive', '', array())))!=='' ?
				('<p class="pagination">' . $t3 . '</p>') :
				'') .
		'
		' .
		(($t3 = strval(invalideur_session($Cache, ((((function_exists("autoriser")||include_spip("inc/autoriser"))&&autoriser('purger', 'queue')?" ":"")) ?' ' :''))))!=='' ?
				($t3 . (	'
		<p>' .
			_T('public|spip|ecrire:queue_info_purger') .
			'</p>
		<div class="actions">
			' .
			bouton_action(_T('public|spip|ecrire:queue_purger_queue'),invalideur_session($Cache, generer_action_auteur('purger_queue','x',invalideur_session($Cache, self()))),'ajax') .
			'
		</div>
		')) :
				'') .
		'
		</div>
')) :
		((	'
	<h3>' .
	_T('public|spip|ecrire:queue_no_job_in_queue') .
	'</h3>
	' .
	(($t2 = strval(invalideur_session($Cache, ((((function_exists("autoriser")||include_spip("inc/autoriser"))&&autoriser('purger', 'queue')?" ":"")) ?' ' :''))))!=='' ?
			($t2 . (	'
	<p>' .
		_T('public|spip|ecrire:queue_info_purger') .
		'</p>
	<div class="actions">
		' .
		bouton_action(_T('public|spip|ecrire:queue_purger_queue'),invalideur_session($Cache, generer_action_auteur('purger_queue','x',invalideur_session($Cache, self()))),'ajax') .
		'
	</div>
	')) :
			'') .
	'
'))) .
'
<script type="text/javascript">/*<![CDATA[*/
function queue_reload(){jQuery(\'h1\').ajaxReload();}
if (window.jQuery) setTimeout(queue_reload,60000);
/*]]>*/</script>');

	return analyse_resultat_skel('html_5fdc4db5224717155c454283dcad1082', $Cache, $page, '../prive/squelettes/contenu/job_queue.html');
}
?>