Griglia giochi / partecipanti

get_results($queryFiscalCodeName );
$fc = array();
foreach ($result as $row) {
$fc[$row->{‘fiscalcode’}] = $row->{‘userName’};
}
$query = “SELECT * FROM (
SELECT `submit_time` AS ‘Submitted’, max(if(`field_name`=’userName’, `field_value`, null )) AS ‘userName’, max(if(`field_name`=’nickName’, `field_value`, null )) AS ‘nickName’, max(if(`field_name`=’fiscalcode’, `field_value`, null )) AS ‘fiscalcode’, max(if(`field_name`=’gameBring’, `field_value`, null )) AS ‘gameBring’, max(if(`field_name`=’gameLike’, `field_value`, null )) AS ‘gameLike’, max(if(`field_name`=’availability’, `field_value`, null )) AS ‘availability’, max(if(`field_name`=’edizione’, `field_value`, null )) AS ‘edizione’
FROM `wp1_cf7dbplugin_submits`
WHERE `form_name` = ‘RegistrazioneDBL’
GROUP BY `submit_time`
ORDER BY `submit_time` DESC) as T WHERE edizione = ” . $GLOBALS[‘YEAR’];

$result = $wpdb->get_results($query);
$games = array();
$players = array();

//Primo ciclo
foreach ($result as $row) {
//$date = date(“Y”, $row->{‘Submitted’});
//if ($date != $GLOBALS[‘YEAR’]) continue;

$userName = $row->{‘userName’};
if ($userName == ”) {
$userName = $fc[$row->{‘fiscalcode’}];
}

$nickName = $row->{‘nickName’};

$user = $userName;
if(!empty($nickName))
$user .= ‘ (‘ . $nickName . ‘)’;

//Controllo giocatori censiti
if(in_array($user, $players))
continue;
array_push($players, $user);

//Caricamento giochi
if (!empty($row->{‘gameBring’})) {
$vGameList = explode(“;”, $row->{‘gameBring’});

foreach($vGameList as $game) {
$part = explode(‘|’, $game);
if(!empty(trim($part[0]))) {
$game = str_replace(“\r\n”, “”, $part[0]);

if (array_key_exists($game, $games)) {
if(!in_array($user, $games[$game][‘proprietari’]))
array_push($games[$game][‘proprietari’], $user);
}
else {
$games[$game] = array(‘title’ => $part[0],’url’ => $part[1],’proprietari’ => array(),’partecipanti’ => array(),’availability’ => array());
array_push($games[$game][‘proprietari’], $user);
}

//Caricamento disponibilita
if (!empty($row->{‘availability’})) {
$availability = trim($row->{‘availability’});
array_push($games[$game][‘availability’], $availability);
}
}
}
}
}

//Caricamento Partecipanti
foreach ($result as $row) {
//$date = date(“Y”, $row->{‘Submitted’});
//if ($date != $GLOBALS[‘YEAR’]) continue;

$userName = $row->{‘userName’};
if ($userName == ”) {
$userName = $fc[$row->{‘fiscalcode’}];
}

$nickName = $row->{‘nickName’};

if (!empty($row->{‘gameLike’})) {
$vGameList = explode(“;”, $row->{‘gameLike’});
foreach($vGameList as $elem) {
if(!empty(trim($elem))) {
$game = str_replace(“\r\n”, “”, $elem);
//echo “

START: "; print_r($game); echo "

“;

//Controllo presenza gioco
$check = false;
foreach($games as $el) {
$title = str_replace(“\r\n”, “”, $el[‘title’]);
//echo “

Check: "; print_r($title); echo " - "; print_r($game); echo "

“;
if($title === $game)
$check = true;
}

if(!$check) continue;

$user = $userName;
if(!empty($nickName))
$user .= ‘ (‘ . $nickName . ‘)’;

if(count($games[$game][‘proprietari’]) > 0)
{
if(!in_array($user, $games[$game][‘proprietari’]) && !in_array($user, $games[$game][‘partecipanti’]))
{
array_push($games[$game][‘partecipanti’], $user);
//echo “

"; print_r($game .'-' . $user); echo "

“;
}
}
}
}
}
}

ksort($games);

//echo “

lista results

“;
//echo “

"; print_r($result); echo "

“;
//echo “

lista giochi

“;
//echo “

"; print_r($games); echo "

“;

echo “

De Bello Ludico edizione ” . $GLOBALS[‘YEAR’] . “

“;
echo “
“;
echo “

“;
echo “

“;

foreach ($games as $key => $game) {
echo “

“;
}
echo “

Gioco Proprietari Partecipanti Disponibilità
“. $key .” “. implode(“
“, $game[‘proprietari’]) . “
“. implode(“
“, $game[‘partecipanti’]) .”
“. implode(“
“, $game[‘availability’]) .”

“;
echo “
“;
echo “

Vuoi dare maggior risalto ai giochi che hai messo in griglia?

“;
echo “

Vai sulla geeklist De Bello Ludico Raduno 2021 – Games [played and] proposed creata per noi su BGG! Maggiori dettagli inseribili e il potenziale della sconfinata comunità BGG a seguire le tue proposte!

“;
?>