updated profile with seasons
This commit is contained in:
@@ -54,6 +54,12 @@ class milestone
|
||||
$new_msr->set_msr_data_by_id($value);
|
||||
$this->set_ms_ranking_msr_id($new_msr);
|
||||
}
|
||||
|
||||
if ($field == 'ms_season' && $value != null) {
|
||||
$new_mss = new milestone_season();
|
||||
$new_mss->set_mss_data_by_id($value);
|
||||
$this->set_ms_season($new_mss);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -62,12 +68,12 @@ class milestone
|
||||
global $sql;
|
||||
return $sql->insert_into('milestone', array(
|
||||
'ms_type_mt_id' => $_mt,
|
||||
'ms_season' => $_season,
|
||||
'ms_user_kid_uk_id' => $_uk,
|
||||
'ms_training_mst_id' => $_mst,
|
||||
'ms_competition_msc_id' => $_msc,
|
||||
'ms_ranking_msr_id' => $_msr,
|
||||
'ms_camp_msca_id' => $_msca,
|
||||
'ms_user_kid_uk_id' => $_uk,
|
||||
'ms_season' => $_season,
|
||||
'ms_sums' => $_sums,
|
||||
), false);
|
||||
}
|
||||
@@ -283,153 +289,224 @@ class milestone
|
||||
$sql->execute_query('DELETE milestone_competition FROM milestone_competition JOIN milestone ON ms_competition_msc_id = msc_id WHERE ms_user_kid_uk_id = ' . $kid);
|
||||
$sql->execute_query('DELETE milestone_camp FROM milestone_camp JOIN milestone ON ms_camp_msca_id= msca_id WHERE ms_user_kid_uk_id = ' . $kid);
|
||||
$sql->execute_query('DELETE milestone_ranking FROM milestone_ranking JOIN milestone ON ms_ranking_msr_id= msr_id WHERE ms_user_kid_uk_id = ' . $kid);
|
||||
$sql->execute_query('DELETE milestone_season FROM milestone_season JOIN milestone ON ms_season = mss_id WHERE ms_user_kid_uk_id = ' . $kid);
|
||||
|
||||
|
||||
$content = file($_FILES['fileToUpload']['tmp_name']); //makes array
|
||||
|
||||
|
||||
for ($i=0; $i < count($content); $i++) {
|
||||
$line = $content[$i];
|
||||
//var_dump($content);
|
||||
|
||||
/*
|
||||
Szerkezet:
|
||||
|
||||
s 2018-2019 --> szezon: ez megy a fejlécbe, ami lenyílik
|
||||
x edzés *
|
||||
y verseny *
|
||||
|
||||
e 2018 10 --> edzés éééé-hh
|
||||
dátum F
|
||||
2 edzés F
|
||||
1 csoportos *
|
||||
1 külön *
|
||||
|
||||
v --> verseny
|
||||
Dátum F
|
||||
Diákolimpia F
|
||||
Kiskunfélegyháza F
|
||||
Korcsoport F
|
||||
Helyezés F
|
||||
Mérkőzések: *
|
||||
Egyéni 1. hely *
|
||||
Páros 2. hely *
|
||||
|
||||
t 2016-07 ---> tábor
|
||||
2018. július 17-24.
|
||||
Budapest, Hodos
|
||||
|
||||
r 2018-09 ---> ranglista
|
||||
2018. szeptember - 39. hét
|
||||
felnőtt női egyéni: 28. hely
|
||||
felnőtt női páros: 24. hely
|
||||
felnőtt női vegyes páros: 23. hely
|
||||
U19 lány egyéni: 32. hely
|
||||
U19 lány páros: 20. hely
|
||||
U19 lány vegyes páros: 23. hely
|
||||
U17 lány egyéni: 18. hely
|
||||
U17 lány páros: 17. hely
|
||||
U17 lány vegyes páros: 12. hely
|
||||
|
||||
A fájlt kötelező szezonnal kezdeni!
|
||||
|
||||
*/
|
||||
|
||||
$milestoneId = null;
|
||||
//var_dump($content);
|
||||
for ($lineNo = 0; $lineNo < count($content); ++$lineNo) {
|
||||
//var_dump($lineNo);
|
||||
$line = $content[$lineNo];
|
||||
//var_dump($line);
|
||||
|
||||
//1. sor lekezelése: ha nem szezon, akkor hiba!
|
||||
if (0 === $lineNo && 's' != substr($line, 0, 1)) {
|
||||
return 3;
|
||||
}
|
||||
|
||||
//ha nincs beállítva ms id, akkor új egység következik és beállítjuk
|
||||
if (null === $milestoneId) {
|
||||
$milestoneId = substr($line, 0, 1);
|
||||
//var_dump($line);
|
||||
if ($i === 0 || empty(trim($line))) { //ha üres sor volt
|
||||
if (empty(trim($line))) {
|
||||
++$i;
|
||||
}
|
||||
if (empty(trim($content[$i]))) {
|
||||
//a következő sor is üres, átugroható
|
||||
continue;
|
||||
}
|
||||
$firstLineParts = explode(' ', trim($content[$i]));
|
||||
|
||||
$typeLetter = $firstLineParts[0];
|
||||
//$month = $firstLineParts[1] . '-01';
|
||||
|
||||
//var_dump($milestoneId);
|
||||
//$ms = new milestone();
|
||||
//$mss_id = null;
|
||||
$mst_id = 'null';
|
||||
$msc_id = 'null';
|
||||
$msca_id = 'null';
|
||||
$msr_id = 'null';
|
||||
$actual_season = 'null';
|
||||
|
||||
if ('s' == $typeLetter) {
|
||||
$season = $firstLineParts[1];
|
||||
$sums = "";
|
||||
$j = $i + 1;
|
||||
while(isset($content[$j]) && !empty(trim($content[$j]))) {
|
||||
$sums .= trim($content[$j]) . '\n';
|
||||
++$i;
|
||||
$j = $i + 1;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
$type = $sql->single_variable('SELECT mt_id FROM milestone_type WHERE mt_short_name = "' . $typeLetter . '";');
|
||||
|
||||
if (null === $type) {
|
||||
//érvénytelen típus
|
||||
return 2;
|
||||
}
|
||||
|
||||
switch ($typeLetter) {
|
||||
case 'e':
|
||||
# training
|
||||
++$i;
|
||||
$mst_date = trim($content[$i]);
|
||||
|
||||
++$i;
|
||||
$mst_count = trim($content[$i]);
|
||||
|
||||
$j = $i + 1;
|
||||
$mst_trainings = "";
|
||||
while(isset($content[$j]) && !empty(trim($content[$j]))) {
|
||||
$mst_trainings .= trim($content[$j]) . '\n';
|
||||
++$i;
|
||||
$j = $i + 1;
|
||||
}
|
||||
|
||||
$mst_id = milestone_training::create_mst($mst_date, $mst_count, $mst_trainings);
|
||||
//var_dump($mst_trainings);
|
||||
|
||||
break;
|
||||
case 'v':
|
||||
# competition
|
||||
++$i;
|
||||
$msc_date = trim($content[$i]);
|
||||
|
||||
++$i;
|
||||
$msc_name = trim($content[$i]);
|
||||
|
||||
++$i;
|
||||
$msc_location = trim($content[$i]);
|
||||
|
||||
++$i;
|
||||
$msc_category = trim($content[$i]);
|
||||
|
||||
|
||||
++$i;
|
||||
$msc_place = trim($content[$i]);
|
||||
|
||||
++$i;
|
||||
if (isset($content[$i]) && !empty(trim($content[$i]))) {
|
||||
++$i; //mérkőzések szöveg
|
||||
$matches = '';
|
||||
do {
|
||||
$matches .= trim($content[$i]) . '\n';
|
||||
++$i;
|
||||
} while (isset($content[$i]) && !empty(trim($content[$i])));
|
||||
}
|
||||
else {
|
||||
$matches = 'null';
|
||||
}
|
||||
|
||||
$msc_id = milestone_competition::create_msc($msc_date, $msc_name, $msc_category, $msc_location, $msc_place, $matches);
|
||||
|
||||
break;
|
||||
case 't':
|
||||
# camp
|
||||
|
||||
++$i;
|
||||
$msca_date = trim($content[$i]);
|
||||
|
||||
++$i;
|
||||
$msca_place = trim($content[$i]);
|
||||
|
||||
$msca_id = milestone_camp::create_msca($msca_date, $msca_place);
|
||||
|
||||
break;
|
||||
|
||||
case 'r':
|
||||
# ranking
|
||||
|
||||
//get season after 'r'
|
||||
$msr_season = trim(substr($content[$i], 2));
|
||||
|
||||
++$i;
|
||||
$msr_date = trim($content[$i]);
|
||||
|
||||
++$i;
|
||||
$rankings = '';
|
||||
do {
|
||||
$rankings .= trim($content[$i]) . '\n';
|
||||
++$i;
|
||||
} while (isset($content[$i]) && !empty(trim($content[$i])));
|
||||
|
||||
$msr_id = milestone_ranking::create_msr($msr_date, $rankings, $msr_season);
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
# code...
|
||||
break;
|
||||
}
|
||||
|
||||
if (null !== $type) {
|
||||
self::create_ms($type, $season, $kid, $mst_id, $msc_id, $msca_id, $msr_id, $sums);
|
||||
}
|
||||
$sums = 'null';
|
||||
$type = 'null';
|
||||
}
|
||||
}
|
||||
//var_dump($milestoneId);
|
||||
switch ($milestoneId) {
|
||||
case 's':
|
||||
# SZEZON
|
||||
$mss_text = "";
|
||||
|
||||
$j = $lineNo;
|
||||
while(isset($content[$j]) && !empty(trim($content[$j]))) {
|
||||
//ha még csak a szezon első sorát olvassuk, akkor csak az "s" után rész kell
|
||||
if ($j == $lineNo) {
|
||||
//$content[$j] = substr($content[$j], 2);
|
||||
$j++;
|
||||
continue;
|
||||
}
|
||||
$mss_text .= trim($content[$j]) . '\n';
|
||||
//++$lineNo;
|
||||
$j++;
|
||||
}
|
||||
$lineNo = $j;
|
||||
//var_dump($lineNo);
|
||||
$mss_id = milestone_season::create_mss($mss_text);
|
||||
|
||||
break;
|
||||
case 'e':
|
||||
# EDZÉS
|
||||
$type = 1;
|
||||
|
||||
$mst = new milestone_training;
|
||||
|
||||
++$lineNo;
|
||||
$mst_date = trim($content[$lineNo]);
|
||||
//var_dump('date: ' . $mst_date);
|
||||
|
||||
++$lineNo;
|
||||
$mst_count = trim($content[$lineNo]);
|
||||
|
||||
$j = $lineNo + 1;
|
||||
$mst_trainings = "";
|
||||
while(isset($content[$j]) && !empty(trim($content[$j]))) {
|
||||
$mst_trainings .= trim($content[$j]) . '\n';
|
||||
++$j;
|
||||
}
|
||||
$lineNo = $j;
|
||||
//var_dump($mst_date, $mst_count, $mst_trainings);
|
||||
$mst_id = milestone_training::create_mst($mst_date, $mst_count, $mst_trainings);
|
||||
|
||||
break;
|
||||
|
||||
case 't':
|
||||
# TÁBOR
|
||||
$type = 3;
|
||||
|
||||
++$lineNo;
|
||||
$msca_date = trim($content[$lineNo]);
|
||||
|
||||
++$lineNo;
|
||||
$msca_place = trim($content[$lineNo]);
|
||||
|
||||
$msca_id = milestone_camp::create_msca($msca_date, $msca_place);
|
||||
|
||||
break;
|
||||
|
||||
case 'v':
|
||||
# VERSENY
|
||||
$type = 2;
|
||||
|
||||
++$lineNo;
|
||||
$msc_date = trim($content[$lineNo]);
|
||||
|
||||
++$lineNo;
|
||||
$msc_name = trim($content[$lineNo]);
|
||||
|
||||
++$lineNo;
|
||||
$msc_location = trim($content[$lineNo]);
|
||||
|
||||
++$lineNo;
|
||||
$msc_category = trim($content[$lineNo]);
|
||||
|
||||
|
||||
++$lineNo;
|
||||
$msc_place = trim($content[$lineNo]);
|
||||
|
||||
++$lineNo;
|
||||
if (isset($content[$lineNo]) && !empty(trim($content[$lineNo]))) {
|
||||
++$lineNo; //mérkőzések szöveg
|
||||
$matches = '';
|
||||
do {
|
||||
$matches .= trim($content[$lineNo]) . '\n';
|
||||
++$lineNo;
|
||||
} while (isset($content[$lineNo]) && !empty(trim($content[$lineNo])));
|
||||
}
|
||||
else {
|
||||
$matches = 'null';
|
||||
}
|
||||
|
||||
$msc_id = milestone_competition::create_msc($msc_date, $msc_name, $msc_category, $msc_location, $msc_place, $matches);
|
||||
|
||||
break;
|
||||
|
||||
case 'r':
|
||||
# RANGLISTA
|
||||
|
||||
$type = 4;
|
||||
|
||||
//get season after 'r'
|
||||
$msr_season = trim(substr($content[$lineNo], 2));
|
||||
|
||||
++$lineNo;
|
||||
$msr_date = trim($content[$lineNo]);
|
||||
|
||||
++$lineNo;
|
||||
$rankings = '';
|
||||
do {
|
||||
$rankings .= trim($content[$lineNo]) . '\n';
|
||||
++$lineNo;
|
||||
} while (isset($content[$lineNo]) && !empty(trim($content[$lineNo])));
|
||||
|
||||
$msr_id = milestone_ranking::create_msr($msr_date, $rankings, $msr_season);
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
# code...
|
||||
break;
|
||||
}
|
||||
|
||||
//todo: ezeket a változókat mindenképp be kell állítani h ne legyenek undefined-ok
|
||||
if ('null' != $type) {
|
||||
self::create_ms($type, $mss_id, $kid, $mst_id, $msc_id, $msca_id, $msr_id, $sums);
|
||||
}
|
||||
$milestoneId = null;
|
||||
//$lineNo++;
|
||||
|
||||
|
||||
//ha üres sor, akkor:
|
||||
//eddig adatok rögzítése az adatbázisban
|
||||
//ID nullozása
|
||||
|
||||
|
||||
|
||||
} //endfor
|
||||
|
||||
return 0;
|
||||
|
||||
|
||||
72
_class/class_milestone_season.php
Normal file
72
_class/class_milestone_season.php
Normal file
@@ -0,0 +1,72 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* MILESTONE SEASON
|
||||
*/
|
||||
class milestone_season
|
||||
{
|
||||
private $mss_id;
|
||||
private $mss_text;
|
||||
|
||||
public function set_mss_data_by_id($_mss_id) {
|
||||
global $sql;
|
||||
$mss_assoc_array = $sql->assoc_array("select * from milestone_season where mss_id = " . $_mss_id);
|
||||
$mss_array = $mss_assoc_array[0];
|
||||
//alapadatok
|
||||
foreach ($mss_array as $field => $value) {
|
||||
$function_name = "set_" . $field;
|
||||
$this->$function_name($value);
|
||||
}
|
||||
}
|
||||
|
||||
public static function create_mss($_text)
|
||||
{
|
||||
global $sql;
|
||||
return $sql->insert_into('milestone_season', array(
|
||||
'mss_text' => $_text,
|
||||
));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function get_mss_id()
|
||||
{
|
||||
return $this->mss_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $mss_id
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public function set_mss_id($mss_id)
|
||||
{
|
||||
$this->mss_id = $mss_id;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function get_mss_text()
|
||||
{
|
||||
return $this->mss_text;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $mss_text
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public function set_mss_text($mss_text)
|
||||
{
|
||||
$this->mss_text = $mss_text;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -1,88 +1,88 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
SQL osztály
|
||||
adatbázis műveletek
|
||||
SQLI osztályból származtatva
|
||||
SQL osztály
|
||||
adatbázis műveletek
|
||||
SQLI osztályból származtatva
|
||||
*/
|
||||
|
||||
|
||||
class sql extends mysqli {
|
||||
private $_query;
|
||||
private $_query;
|
||||
|
||||
function __construct($_host, $_username, $_password, $_dbname) {
|
||||
function __construct($_host, $_username, $_password, $_dbname) {
|
||||
parent::__construct($_host, $_username, $_password, $_dbname);
|
||||
self::set_charset("utf8");
|
||||
}
|
||||
|
||||
public function single_variable($_query) {
|
||||
$result = self::query($_query);
|
||||
$result = self::query($_query);
|
||||
//var_dump($_query);
|
||||
$assoc_array = $result->fetch_array(MYSQLI_NUM);
|
||||
return $assoc_array['0'];
|
||||
$assoc_array = $result->fetch_array(MYSQLI_NUM);
|
||||
return $assoc_array['0'];
|
||||
}
|
||||
|
||||
public function assoc_array($_query) {
|
||||
//var_dump($_query);
|
||||
$result = self::query($_query);
|
||||
$ret_array = array();
|
||||
while ($item = $result->fetch_assoc()) {
|
||||
$ret_array[] = $item;
|
||||
}
|
||||
return $ret_array;
|
||||
//var_dump($_query);
|
||||
$result = self::query($_query);
|
||||
$ret_array = array();
|
||||
while ($item = $result->fetch_assoc()) {
|
||||
$ret_array[] = $item;
|
||||
}
|
||||
return $ret_array;
|
||||
}
|
||||
|
||||
|
||||
public function insert_into($table, $value_array, $need_apostrophs = true) {
|
||||
//a beszúrt rekord id-ját adja vissza
|
||||
$fields = '';
|
||||
$values = '';
|
||||
$i = 0;
|
||||
$n = count($value_array);
|
||||
foreach ($value_array as $key => $value) {
|
||||
$fields .= $key;
|
||||
$need_apostrophs = $value!='null';
|
||||
$values .= ($need_apostrophs ? "'" : "") . $value . ($need_apostrophs ? "'" : "");
|
||||
if ($i!=($n-1)) {
|
||||
$fields .= ', ';
|
||||
$values .= ', ';
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
$this->_query = 'insert into ' . $table . ' (' . $fields . ') values (' . $values . ');';
|
||||
//var_dump($this->_query);
|
||||
self::query($this->_query);
|
||||
return $this->insert_id;
|
||||
//a beszúrt rekord id-ját adja vissza
|
||||
$fields = '';
|
||||
$values = '';
|
||||
$i = 0;
|
||||
$n = count($value_array);
|
||||
foreach ($value_array as $key => $value) {
|
||||
$fields .= $key;
|
||||
$need_apostrophs = $value!='null';
|
||||
$values .= ($need_apostrophs ? "'" : "") . $value . ($need_apostrophs ? "'" : "");
|
||||
if ($i!=($n-1)) {
|
||||
$fields .= ', ';
|
||||
$values .= ', ';
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
$this->_query = 'insert into ' . $table . ' (' . $fields . ') values (' . $values . ');';
|
||||
//var_dump($this->_query);
|
||||
self::query($this->_query);
|
||||
return $this->insert_id;
|
||||
}
|
||||
|
||||
public function update_table($table, $value_array, $conditions, $need_apostrophs = true) {
|
||||
$this->_query = "update " . $table . " set ";
|
||||
$n = count($value_array);
|
||||
$i=0;
|
||||
foreach ($value_array as $key => $val) {
|
||||
$need_apostrophs = $val!='null';
|
||||
$this->_query .= $key . "=" . ($need_apostrophs ? "'" : "") . $val . ($need_apostrophs ? "'" : "") . ($i!=$n-1 ? ", " : "");
|
||||
$i++;
|
||||
}
|
||||
$this->_query .= " where ";
|
||||
$n = count($conditions);
|
||||
$i=0;
|
||||
foreach ($conditions as $key_ => $val_) {
|
||||
$this->_query .= $key_ . "='" . $val_ . "'" . ($i!=$n-1 ? " and " : ";");
|
||||
$i++;
|
||||
}
|
||||
//var_dump($this->_query);
|
||||
self::query($this->_query);
|
||||
$this->_query = "update " . $table . " set ";
|
||||
$n = count($value_array);
|
||||
$i=0;
|
||||
foreach ($value_array as $key => $val) {
|
||||
$need_apostrophs = $val!='null';
|
||||
$this->_query .= $key . "=" . ($need_apostrophs ? "'" : "") . $val . ($need_apostrophs ? "'" : "") . ($i!=$n-1 ? ", " : "");
|
||||
$i++;
|
||||
}
|
||||
$this->_query .= " where ";
|
||||
$n = count($conditions);
|
||||
$i=0;
|
||||
foreach ($conditions as $key_ => $val_) {
|
||||
$this->_query .= $key_ . "='" . $val_ . "'" . ($i!=$n-1 ? " and " : ";");
|
||||
$i++;
|
||||
}
|
||||
//var_dump($this->_query);
|
||||
self::query($this->_query);
|
||||
}
|
||||
|
||||
|
||||
public function num_of_rows($_query) {
|
||||
$result = self::query($_query);
|
||||
return is_object($result)?$result->num_rows:0;
|
||||
$result = self::query($_query);
|
||||
return is_object($result)?$result->num_rows:0;
|
||||
}
|
||||
|
||||
public function execute_query($_query) {
|
||||
return self::query($_query);
|
||||
return self::query($_query);
|
||||
}
|
||||
|
||||
function export_database($tables=false, $backup_name=false )
|
||||
|
||||
Reference in New Issue
Block a user