Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions common.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -623,6 +623,33 @@ function countRaceStats(array $zaznamy, bool $is_sdil_dopr_on): array
return $stats;
}

function gen_modify_flag_v2b($val_last,$val_new)
{ // varianta s ignorovanim zmeny terminu a zmeny v zavode pokud je zaroven vytvoren zavod
// povolene vysledne hodnoty 0,1,2,4,5
//
// puvodni
// 0 1 2 4 5
// n 0 | 0 | 1 | 2 | 4 | 5
// o 1 | 1 | 1 | 2 | 5 | 5
// v 4 | 4 | 5 | 2 | 4 | 5
// e 5 | 5 | 5 | 2 | 5 | 5

global $g_modify_flag;

if ($val_last == $val_new || $val_new == 0) // beze zmeny, nebo stejna zmena
$v1 = $val_last;
else if (($val_last & $g_modify_flag [1]['id'] ) != 0) // byl vytvoren (top level flag)
$v1 = $g_modify_flag [1]['id'] ;
else
{
if (($val_last & $g_modify_flag [0]['id'] ) != 0 || ($val_last & $g_modify_flag [2]['id'] ) != 0)
$v1 = $g_modify_flag [0]['id'] + $g_modify_flag [2]['id'];
else
$v1 = $val_new;
}
return $v1;
}

function RenderRaceStats(
array $stats,
bool $is_spol_dopr_on,
Expand Down
33 changes: 18 additions & 15 deletions connectors.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,11 @@ class RaceInfo {
public $etap;
public $poznamka;
public $vicedenni;
public $oddil;
public $modify_flag;
public $kategorie;
public $startovne;
public $oddil;
public $modify_flag;
public $kategorie;
public $startovne;
public $cancelled;

// Constructor to initialize the object with key-value pairs
public function __construct($data) {
Expand All @@ -56,11 +57,12 @@ public function __construct($data) {
$this->poznamka = $data['poznamka'] ?? null;
$this->vicedenni = $data['vicedenni'] ?? null;
$this->oddil = $data['oddil'] ?? null;
$this->modify_flag = $data['modify_flag'] ?? null;
$this->kategorie = $data['kategorie'] ?? null;
$this->startovne = $data['startovne'] ?? null;
}
}
$this->modify_flag = $data['modify_flag'] ?? null;
$this->kategorie = $data['kategorie'] ?? null;
$this->startovne = $data['startovne'] ?? null;
$this->cancelled = $data['cancelled'] ?? null;
}
}

class RacePayement {
public int $raceId;
Expand Down Expand Up @@ -271,12 +273,13 @@ public function getRaceInfo($raceId) : RaceInfo {
'koeficient2' => $raceData['EntryKoef3'],
'etap' => $raceData['Stages'],
// 'poznamka' => $poznamka,
'vicedenni' => ($raceData['Stages']>1?1:0),
'oddil' => $oddily,
'modify_flag' => 0,
'kategorie' => implode(';', array_keys ( $classFees ) ),
'startovne' => $classFees
]);
'vicedenni' => ($raceData['Stages']>1?1:0),
'oddil' => $oddily,
'modify_flag' => 0,
'kategorie' => implode(';', array_keys ( $classFees ) ),
'startovne' => $classFees,
'cancelled' => (!empty($raceData['Cancelled']) || !empty($raceData['Canceled']) || !empty($raceData['cancelled']) || !empty($raceData['canceled'])) ? 1 : 0
]);
} else {
return null; // Return null if race not found or error
}
Expand Down
7 changes: 4 additions & 3 deletions race_edit.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ function checkDates()
DrawPageTitle('Editace parametrů závodu');

$id = (IsSet($id) && is_numeric($id)) ? (int)$id : 0;
$refresh_parent = (IsSet($refresh_parent) && (int)$refresh_parent == 0) ? 0 : 1;
$ext_id = (IsSet($ext_id)) ? $ext_id : '';
$ext_id_info = '';

Expand Down Expand Up @@ -136,7 +137,7 @@ function checkDates()
{ // vicedenni
?>

<FORM METHOD=POST onsubmit="return checkDates();" ACTION="./race_edit_exc.php?rtype=1&id=<?echo $id?>" name="form2">
<FORM METHOD=POST onsubmit="return checkDates();" ACTION="./race_edit_exc.php?rtype=1&id=<?echo $id?>&refresh_parent=<?echo $refresh_parent?>" name="form2">

<TABLE width="90%">
<TR>
Expand All @@ -154,7 +155,7 @@ function checkDates()
else
{ // jednodenni
?>
<FORM METHOD=POST onsubmit="return checkDates();" ACTION="./race_edit_exc.php?rtype=0&id=<?echo $id?>" name="form2">
<FORM METHOD=POST onsubmit="return checkDates();" ACTION="./race_edit_exc.php?rtype=0&id=<?echo $id?>&refresh_parent=<?echo $refresh_parent?>" name="form2">

<TABLE width="90%">
<TR>
Expand Down Expand Up @@ -184,7 +185,7 @@ function toggleButtonState() {
</script>
<?
echo('<TD class="DataError"><INPUT TYPE="text" NAME="ext_id" id="ext_id" SIZE=8 value="'.$ext_id.'" onKeyup=\'toggleButtonState()\' placeholder=\'ID závodu\'>');
echo(' <button type="button" id="loadRaceByIdButton" disabled onclick="javascript:open_url(\'./race_edit.php?id='.$id.'&ext_id=\'+ext_id.value, \'\')">Náhrat informace</button><br>');
echo(' <button type="button" id="loadRaceByIdButton" disabled onclick="javascript:open_url(\'./race_edit.php?id='.$id.'&refresh_parent='.$refresh_parent.'&ext_id=\'+ext_id.value, \'\')">Náhrat informace</button><br>');
echo('</TD>');
} else {
echo('<TD class="DataError"><INPUT TYPE="text" NAME="ext_id" SIZE=8 value="'.$ext_id.'">'.$ext_id_info.'</TD>');
Expand Down
35 changes: 7 additions & 28 deletions race_edit_exc.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,34 +18,9 @@

$id = (IsSet($id) && is_numeric($id)) ? (int)$id : 0;
$rtype = (IsSet($rtype)&& is_numeric($rtype)) ? (int)$rtype : 0;
$refresh_parent = (IsSet($refresh_parent) && (int)$refresh_parent == 0) ? 0 : 1;

$datum = String2DateDMY($datum);
function gen_modify_flag_v2b($val_last,$val_new)
{ // varianta s ignorovanim zmeny terminu a zmeny v zavode pokud je zaroven vytvoren zavod
// povolene vysledne hodnoty 0,1,2,4,5
//
// puvodni
// 0 1 2 4 5
// n 0 | 0 | 1 | 2 | 4 | 5
// o 1 | 1 | 1 | 2 | 5 | 5
// v 4 | 4 | 5 | 2 | 4 | 5
// e 5 | 5 | 5 | 2 | 5 | 5

global $g_modify_flag;

if ($val_last == $val_new || $val_new == 0) // beze zmeny, nebo stejna zmena
$v1 = $val_last;
else if (($val_last & $g_modify_flag [1]['id'] ) != 0) // byl vytvoren (top level flag)
$v1 = $g_modify_flag [1]['id'] ;
else
{
if (($val_last & $g_modify_flag [0]['id'] ) != 0 || ($val_last & $g_modify_flag [2]['id'] ) != 0)
$v1 = $g_modify_flag [0]['id'] + $g_modify_flag [2]['id'];
else
$v1 = $val_new;
}
return $v1;
}

if( $rtype == 1)
{ // vicedenni
Expand Down Expand Up @@ -137,7 +112,11 @@ function gen_modify_flag_v2b($val_last,$val_new)
}
?>
<SCRIPT LANGUAGE="JavaScript">
window.opener.location.reload();
window.opener.focus();
<? if ($refresh_parent == 1) { ?>
if (window.opener) {
window.opener.location.reload();
window.opener.focus();
}
<? } ?>
window.close();
</SCRIPT>
2 changes: 1 addition & 1 deletion race_imports.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
require_once ("./header.inc.php"); // header obsahuje uvod html a konci <BODY>
require_once ("./common.inc.php");

DrawPageTitle('Import závodu ze systému Oris');
DrawPageTitle('Import závodu ze systému '.$connector->getSystemName());

DrawPageSubTitle('V rozmezí od '.$from.' do '.$to);
?>
Expand Down
116 changes: 116 additions & 0 deletions race_imports_update.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
<?php
define("__HIDE_TEST__", "_KeAr_PHP_WEB_");

@extract($_REQUEST, EXTR_SKIP);

require_once ("connect.inc.php");
require_once ("sess.inc.php");
require_once("cfg/_globals.php");

if (!IsLoggedRegistrator())
{
header("location: ".$g_baseadr."error.php?code=21");
exit;
}

require_once ("ctable.inc.php");
require_once ("./connectors.php");
require_once ("./common_race.inc.php");

$connector = ConnectorFactory::create();

if ($connector === null )
{
echo('Chyba v nastavení, nenalezen žádny connector, kontaktuje administrátora.<br>');
exit;
}

db_Connect();

require_once ("./header.inc.php"); // header obsahuje uvod html a konci <BODY>
require_once ("./common.inc.php");
require_once ('./url.inc.php');
require_once ("./ct_renderer_races.inc.php");

DrawPageTitle('Aktualizace závodů ze systému '.$connector->getSystemName());
DrawPageSubTitle('Budoucí závody uložené v přihláškovém systému');

$curr_date = GetCurrentDate();
$query = "SELECT id, datum, datum2, nazev, oddil, typ0, typ, vicedenni, odkaz, misto, cancelled, kapacita, kategorie, ext_id, prihlasenych FROM ".TBL_RACE
." WHERE ((datum >= '".$curr_date."') OR (datum2 >= '".$curr_date."'))"
." ORDER BY datum, datum2, id";
@$vysledek = query_db($query);
$zavody = ($vysledek !== FALSE) ? mysqli_fetch_all($vysledek, MYSQLI_ASSOC) : [];
?>
<script language="javascript">
<!--
javascript:set_default_size(800,600);

function toggleAllFutureRaces(source)
{
var checkboxes = document.querySelectorAll('.js-race-selector');
for (var i = 0; i < checkboxes.length; i++) {
if (!checkboxes[i].disabled) {
checkboxes[i].checked = source.checked;
}
}
}
//-->
</script>

<TABLE width="100%" cellpadding="0" cellspacing="0" border="0">
<TR>
<TD width="2%"></TD>
<TD width="90%" ALIGN=left>
<CENTER>
<?
if (empty($zavody)) {
echo('<BR />Žádné budoucí závody nebyly nalezeny.<BR /><BR />');
}
else {
?>
<FORM METHOD="POST" ACTION="./race_imports_update_exc.php">
<?

// define table
$tbl_renderer = RacesRendererFactory::createTable();
$tbl_renderer->addColumns([new DefaultHeaderRenderer('<input type="checkbox" checked onclick="toggleAllFutureRaces(this)">',ALIGN_CENTER),
new CallbackRenderer ( function ( RowData $row, array $options ) : string {
$has_ext_id = !empty($row->rec['ext_id']);
$checkbox_attrs = $has_ext_id ? ' checked' : ' disabled';
return '<input type="checkbox" class="js-race-selector" name="race_ids[]" value="'.$row->rec['id'].'"'.$checkbox_attrs.'>';
})]);

$tbl_renderer->addColumns('datum','nazev','misto','oddil');
$tbl_renderer->addColumns('ext_id');
$tbl_renderer->addColumns('typ0','typ','odkaz', ['kategorie', new FormatFieldRenderer ('kategorie', function ($kategorie) {
return (strlen($kategorie) > 0) ? 'A' :'<span class="TextAlertBold">N</span>';
})]);
if ($g_enable_race_capacity)
$tbl_renderer->addColumns('ucast');

echo $tbl_renderer->render( new html_table_mc(), $zavody, [] );
?>
<BR>
<INPUT TYPE="submit" VALUE="Aktualizovat">
</FORM>
<?
}
?>
<BR><hr><BR>
<A HREF="index.php?id=<? echo _REGISTRATOR_GROUP_ID_;?>&subid=4">Zpět</A><BR>
<BR><hr><BR>
</CENTER>
</TD>
<TD width="2%"></TD>
</TR>
<TR><TD COLSPAN=4 ALIGN=CENTER>
<!-- Footer Begin -->
<?require_once ("footer.inc.php");?>
<!-- Footer End -->
</TD></TR>
</TABLE>

<?
HTML_Footer();
?>
Loading