From d88d9d9eed49101acebc9a73880817e839e08743 Mon Sep 17 00:00:00 2001 From: Svatos Coufal <29300135+scoufal@users.noreply.github.com> Date: Tue, 31 Mar 2026 10:48:25 +0200 Subject: [PATCH 1/2] Add mass race update from external system - Created `race_imports_update.php` and `race_imports_update_exc.php` for managing race updates from the ORIS system. - moved `gen_modify_flag_v2b` function for race modification logic. - Enhanced `RaceInfo` class to include `cancelled` property. - Updated forms in `race_edit.php` to handle `refresh_parent` parameter. - Improved error handling and user feedback in race update processes. --- common.inc.php | 27 +++ connectors.php | 33 ++-- race_edit.php | 7 +- race_edit_exc.php | 35 +--- race_imports.php | 2 +- race_imports_update.php | 116 +++++++++++++ race_imports_update_exc.php | 317 ++++++++++++++++++++++++++++++++++++ rg_ad_races_edit.inc.php | 5 +- 8 files changed, 494 insertions(+), 48 deletions(-) create mode 100644 race_imports_update.php create mode 100644 race_imports_update_exc.php diff --git a/common.inc.php b/common.inc.php index 5524c6c..9d6434f 100644 --- a/common.inc.php +++ b/common.inc.php @@ -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, diff --git a/connectors.php b/connectors.php index 69f2456..c0ffd9a 100644 --- a/connectors.php +++ b/connectors.php @@ -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) { @@ -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; @@ -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 } diff --git a/race_edit.php b/race_edit.php index 4fe2f4d..48f83b3 100644 --- a/race_edit.php +++ b/race_edit.php @@ -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 = ''; @@ -136,7 +137,7 @@ function checkDates() { // vicedenni ?> -