milestone fix; maybe not perfect
This commit is contained in:
@@ -10,16 +10,20 @@ class milestone
|
||||
private $ms_training_mst_id = null;
|
||||
private $ms_competition_msc_id = null;
|
||||
private $ms_camp_msca_id = null;
|
||||
private $ms_ranking_msr_id = null;
|
||||
private $ms_user_kid_uk_id;
|
||||
private $ms_sums; //text
|
||||
|
||||
private $season;
|
||||
|
||||
public function set_ms_data_by_id($_ms_id) {
|
||||
global $sql;
|
||||
$cat_assoc_array = $sql->assoc_array("select * from milestone where ms_id = " . $_ms_id);
|
||||
$cat_array = $cat_assoc_array[0];
|
||||
global $sql;
|
||||
$cat_assoc_array = $sql->assoc_array("select * from milestone where ms_id = " . $_ms_id);
|
||||
$cat_array = $cat_assoc_array[0];
|
||||
//alapadatok
|
||||
foreach ($cat_array as $field => $value) {
|
||||
$function_name = "set_" . $field;
|
||||
$this->$function_name($value);
|
||||
foreach ($cat_array as $field => $value) {
|
||||
$function_name = "set_" . $field;
|
||||
$this->$function_name($value);
|
||||
|
||||
if ($field == 'ms_type_mt_id' && $value != null) {
|
||||
$new_mt = new milestone_type();
|
||||
@@ -44,18 +48,27 @@ class milestone
|
||||
$new_msca->set_msca_data_by_id($value);
|
||||
$this->set_ms_camp_msca_id($new_msca);
|
||||
}
|
||||
}
|
||||
|
||||
if ($field == 'ms_ranking_msr_id' && $value != null) {
|
||||
$new_msr = new milestone_ranking();
|
||||
$new_msr->set_msr_data_by_id($value);
|
||||
$this->set_ms_ranking_msr_id($new_msr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static function create_ms($_mt, $_uk, $_mst = null, $_msc = null, $_msca = null)
|
||||
public static function create_ms($_mt, $_season, $_uk, $_mst = null, $_msc = null, $_msca = null, $_msr = null, $_sums = null)
|
||||
{
|
||||
global $sql;
|
||||
return $sql->insert_into('milestone', array(
|
||||
'ms_type_mt_id' => $_mt,
|
||||
'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);
|
||||
}
|
||||
|
||||
@@ -93,6 +106,26 @@ class milestone
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function get_ms_season()
|
||||
{
|
||||
return $this->ms_season;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $ms_season
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public function set_ms_season($ms_season)
|
||||
{
|
||||
$this->ms_season = $ms_season;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
@@ -173,6 +206,26 @@ class milestone
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function get_ms_ranking_msr_id()
|
||||
{
|
||||
return $this->ms_ranking_msr_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $ms_ranking_msr_id
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public function set_ms_ranking_msr_id($ms_ranking_msr_id)
|
||||
{
|
||||
$this->ms_ranking_msr_id = $ms_ranking_msr_id;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
@@ -193,6 +246,26 @@ class milestone
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function get_ms_sums()
|
||||
{
|
||||
return $this->ms_sums;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $ms_sums
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public function set_ms_sums($ms_sums)
|
||||
{
|
||||
$this->ms_sums = $ms_sums;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public static function upload_file($file)
|
||||
{
|
||||
global $sql;
|
||||
@@ -209,27 +282,46 @@ class milestone
|
||||
$sql->execute_query('DELETE milestone_training FROM milestone_training JOIN milestone ON ms_training_mst_id = mst_id WHERE ms_user_kid_uk_id = ' . $kid);
|
||||
$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);
|
||||
|
||||
$content = file($_FILES['fileToUpload']['tmp_name']); //makes array
|
||||
|
||||
|
||||
for ($i=0; $i < count($content); $i++) {
|
||||
$line = $content[$i];
|
||||
|
||||
if (empty(trim($line))) { //ha üres sor volt
|
||||
if (empty(trim($content[$i+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+1]));
|
||||
$firstLineParts = explode(' ', trim($content[$i]));
|
||||
|
||||
$typeLetter = $firstLineParts[0];
|
||||
$month = $firstLineParts[1] . '-01';
|
||||
++$i;
|
||||
//$month = $firstLineParts[1] . '-01';
|
||||
|
||||
//$ms = new milestone();
|
||||
$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) {
|
||||
@@ -254,7 +346,7 @@ class milestone
|
||||
$j = $i + 1;
|
||||
}
|
||||
|
||||
$mst_id = milestone_training::create_mst($mst_date, $mst_count, $month, $mst_trainings);
|
||||
$mst_id = milestone_training::create_mst($mst_date, $mst_count, $mst_trainings);
|
||||
//var_dump($mst_trainings);
|
||||
|
||||
break;
|
||||
@@ -289,7 +381,7 @@ class milestone
|
||||
$matches = 'null';
|
||||
}
|
||||
|
||||
$msc_id = milestone_competition::create_msc($msc_date, $msc_name, $msc_category, $msc_location, $msc_place, $month, $matches);
|
||||
$msc_id = milestone_competition::create_msc($msc_date, $msc_name, $msc_category, $msc_location, $msc_place, $matches);
|
||||
|
||||
break;
|
||||
case 't':
|
||||
@@ -301,7 +393,27 @@ class milestone
|
||||
++$i;
|
||||
$msca_place = trim($content[$i]);
|
||||
|
||||
$msca_id = milestone_camp::create_msca($msca_date, $msca_place, $month);
|
||||
$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;
|
||||
|
||||
@@ -311,7 +423,7 @@ class milestone
|
||||
}
|
||||
|
||||
if (null !== $type) {
|
||||
self::create_ms($type, $kid, $mst_id, $msc_id, $msca_id);
|
||||
self::create_ms($type, $season, $kid, $mst_id, $msc_id, $msca_id, $msr_id, $sums);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,23 +12,22 @@ class milestone_camp
|
||||
|
||||
|
||||
public function set_msca_data_by_id($_msca_id) {
|
||||
global $sql;
|
||||
$cat_assoc_array = $sql->assoc_array("select * from milestone_camp where msca_id = " . $_msca_id);
|
||||
$cat_array = $cat_assoc_array[0];
|
||||
global $sql;
|
||||
$cat_assoc_array = $sql->assoc_array("select * from milestone_camp where msca_id = " . $_msca_id);
|
||||
$cat_array = $cat_assoc_array[0];
|
||||
//alapadatok
|
||||
foreach ($cat_array as $field => $value) {
|
||||
$function_name = "set_" . $field;
|
||||
$this->$function_name($value);
|
||||
}
|
||||
foreach ($cat_array as $field => $value) {
|
||||
$function_name = "set_" . $field;
|
||||
$this->$function_name($value);
|
||||
}
|
||||
}
|
||||
|
||||
public static function create_msca($_date, $_place, $_month)
|
||||
public static function create_msca($_date, $_place)
|
||||
{
|
||||
global $sql;
|
||||
return $sql->insert_into('milestone_camp', array(
|
||||
'msca_date' => $_date,
|
||||
'msca_place' => $_place,
|
||||
'msca_month' => $_month,
|
||||
));
|
||||
}
|
||||
|
||||
|
||||
@@ -17,17 +17,17 @@ class milestone_competition
|
||||
|
||||
|
||||
public function set_msc_data_by_id($_msc_id) {
|
||||
global $sql;
|
||||
$cat_assoc_array = $sql->assoc_array("select * from milestone_competition where msc_id = " . $_msc_id);
|
||||
$cat_array = $cat_assoc_array[0];
|
||||
global $sql;
|
||||
$cat_assoc_array = $sql->assoc_array("select * from milestone_competition where msc_id = " . $_msc_id);
|
||||
$cat_array = $cat_assoc_array[0];
|
||||
//alapadatok
|
||||
foreach ($cat_array as $field => $value) {
|
||||
$function_name = "set_" . $field;
|
||||
$this->$function_name($value);
|
||||
}
|
||||
foreach ($cat_array as $field => $value) {
|
||||
$function_name = "set_" . $field;
|
||||
$this->$function_name($value);
|
||||
}
|
||||
}
|
||||
|
||||
public static function create_msc($_date, $_name, $_category, $_location, $_place, $_month, $_matches = NULL)
|
||||
public static function create_msc($_date, $_name, $_category, $_location, $_place, $_matches = NULL)
|
||||
{
|
||||
global $sql;
|
||||
return $sql->insert_into('milestone_competition', array(
|
||||
@@ -36,7 +36,6 @@ class milestone_competition
|
||||
'msc_category' => $_category,
|
||||
'msc_location' => $_location,
|
||||
'msc_place' => $_place,
|
||||
'msc_month' => $_month,
|
||||
'msc_matches' => $_matches,
|
||||
));
|
||||
}
|
||||
|
||||
117
_class/class_milestone_ranking.php
Normal file
117
_class/class_milestone_ranking.php
Normal file
@@ -0,0 +1,117 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* MILESTONE RANKING
|
||||
*/
|
||||
class milestone_ranking
|
||||
{
|
||||
private $msr_id;
|
||||
private $msr_season;
|
||||
private $msr_date;
|
||||
private $msr_rankings;
|
||||
|
||||
|
||||
public function set_msr_data_by_id($_msr_id) {
|
||||
global $sql;
|
||||
$msr_assoc_array = $sql->assoc_array("select * from milestone_ranking where msr_id = " . $_msr_id);
|
||||
$msr_array = $msr_assoc_array[0];
|
||||
//alapadatok
|
||||
foreach ($msr_array as $field => $value) {
|
||||
$function_name = "set_" . $field;
|
||||
$this->$function_name($value);
|
||||
}
|
||||
}
|
||||
|
||||
public static function create_msr($_date, $_rankings, $_season = 'null')
|
||||
{
|
||||
global $sql;
|
||||
return $sql->insert_into('milestone_ranking', array(
|
||||
'msr_date' => $_date,
|
||||
'msr_rankings' => $_rankings,
|
||||
'msr_season' => $_season,
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function get_msr_id()
|
||||
{
|
||||
return $this->msr_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $msr_id
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public function set_msr_id($msr_id)
|
||||
{
|
||||
$this->msr_id = $msr_id;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function get_msr_season()
|
||||
{
|
||||
return $this->msr_season;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $msr_season
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public function set_msr_season($msr_season)
|
||||
{
|
||||
$this->msr_season = $msr_season;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function get_msr_date()
|
||||
{
|
||||
return $this->msr_date;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $msr_date
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public function set_msr_date($msr_date)
|
||||
{
|
||||
$this->msr_date = $msr_date;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function get_msr_rankings()
|
||||
{
|
||||
return $this->msr_rankings;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $msr_rankings
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public function set_msr_rankings($msr_rankings)
|
||||
{
|
||||
$this->msr_rankings = $msr_rankings;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
@@ -13,23 +13,22 @@ class milestone_training
|
||||
|
||||
|
||||
public function set_mst_data_by_id($_mst_id) {
|
||||
global $sql;
|
||||
$cat_assoc_array = $sql->assoc_array("select * from milestone_training where mst_id = " . $_mst_id);
|
||||
$cat_array = $cat_assoc_array[0];
|
||||
global $sql;
|
||||
$cat_assoc_array = $sql->assoc_array("select * from milestone_training where mst_id = " . $_mst_id);
|
||||
$cat_array = $cat_assoc_array[0];
|
||||
//alapadatok
|
||||
foreach ($cat_array as $field => $value) {
|
||||
$function_name = "set_" . $field;
|
||||
$this->$function_name($value);
|
||||
}
|
||||
foreach ($cat_array as $field => $value) {
|
||||
$function_name = "set_" . $field;
|
||||
$this->$function_name($value);
|
||||
}
|
||||
}
|
||||
|
||||
public static function create_mst($_date, $_count, $_month, $_trainings = NULL)
|
||||
public static function create_mst($_date, $_count, $_trainings = NULL)
|
||||
{
|
||||
global $sql;
|
||||
return $sql->insert_into('milestone_training', array(
|
||||
'mst_date' => $_date,
|
||||
'mst_count' => $_count,
|
||||
'mst_month' => $_month,
|
||||
'mst_trainings' => $_trainings,
|
||||
));
|
||||
}
|
||||
|
||||
@@ -1,235 +1,259 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
TRAINING osztály
|
||||
Edzések
|
||||
TRAINING osztály
|
||||
Edzések
|
||||
|
||||
|
||||
|
||||
*/
|
||||
|
||||
class training {
|
||||
private $tr_id;
|
||||
private $tr_date;
|
||||
private $tr_training_type_trt_id;
|
||||
private $tr_user_coach_uc_id;
|
||||
private $tr_duration;
|
||||
private $tr_note;
|
||||
private $tr_locked;
|
||||
private $tr_deleted;
|
||||
private $coaches = array();
|
||||
private $tr_id;
|
||||
private $tr_date;
|
||||
private $tr_training_type_trt_id;
|
||||
private $tr_user_coach_uc_id;
|
||||
private $tr_duration;
|
||||
private $tr_note;
|
||||
private $tr_locked;
|
||||
private $tr_deleted;
|
||||
private $coaches = array();
|
||||
|
||||
private $helpers = array();
|
||||
|
||||
|
||||
public function set_tr_id($_tr_id) {
|
||||
$this->tr_id = $_tr_id;
|
||||
}
|
||||
|
||||
public function set_tr_date($_tr_date) {
|
||||
$this->tr_date = $_tr_date;
|
||||
}
|
||||
public function set_tr_id($_tr_id) {
|
||||
$this->tr_id = $_tr_id;
|
||||
}
|
||||
|
||||
public function set_tr_training_type_trt_id($_tr_training_type_trt_id) {
|
||||
$this->tr_training_type_trt_id = $_tr_training_type_trt_id;
|
||||
}
|
||||
public function set_tr_date($_tr_date) {
|
||||
$this->tr_date = $_tr_date;
|
||||
}
|
||||
|
||||
public function set_tr_duration($_tr_duration) {
|
||||
$this->tr_duration = $_tr_duration;
|
||||
}
|
||||
public function set_tr_training_type_trt_id($_tr_training_type_trt_id) {
|
||||
$this->tr_training_type_trt_id = $_tr_training_type_trt_id;
|
||||
}
|
||||
|
||||
public function set_tr_note($_tr_note) {
|
||||
$this->tr_note = $_tr_note;
|
||||
}
|
||||
public function set_tr_duration($_tr_duration) {
|
||||
$this->tr_duration = $_tr_duration;
|
||||
}
|
||||
|
||||
public function set_tr_locked($_tr_locked) {
|
||||
$this->tr_locked = $_tr_locked;
|
||||
}
|
||||
public function set_tr_note($_tr_note) {
|
||||
$this->tr_note = $_tr_note;
|
||||
}
|
||||
|
||||
public function set_tr_deleted($_tr_deleted) {
|
||||
$this->tr_deleted = $_tr_deleted;
|
||||
}
|
||||
public function set_tr_locked($_tr_locked) {
|
||||
$this->tr_locked = $_tr_locked;
|
||||
}
|
||||
|
||||
public function get_tr_id() {
|
||||
return $this->tr_id;
|
||||
}
|
||||
public function set_tr_deleted($_tr_deleted) {
|
||||
$this->tr_deleted = $_tr_deleted;
|
||||
}
|
||||
|
||||
public function get_tr_date($_formatted = false) {
|
||||
return !$_formatted ? $this->tr_date : date("Y. F d. H:i", strtotime($this->tr_date));
|
||||
}
|
||||
public function get_tr_id() {
|
||||
return $this->tr_id;
|
||||
}
|
||||
|
||||
public function get_tr_date_day() {
|
||||
$day = date("d", strtotime($this->tr_date));
|
||||
if (substr($day, 0, 1) == '0') return substr($day, 1, 1);
|
||||
return date("d", strtotime($this->tr_date));
|
||||
}
|
||||
public function get_tr_date($_formatted = false) {
|
||||
return !$_formatted ? $this->tr_date : date("Y. F d. H:i", strtotime($this->tr_date));
|
||||
}
|
||||
|
||||
public function get_tr_date_day_of_week() {
|
||||
return date("w", strtotime($this->tr_date));
|
||||
}
|
||||
public function get_tr_date_day() {
|
||||
$day = date("d", strtotime($this->tr_date));
|
||||
if (substr($day, 0, 1) == '0') return substr($day, 1, 1);
|
||||
return date("d", strtotime($this->tr_date));
|
||||
}
|
||||
|
||||
public function get_tr_date_time() {
|
||||
return date("H:i", strtotime($this->tr_date));
|
||||
}
|
||||
public function get_tr_date_day_of_week() {
|
||||
return date("w", strtotime($this->tr_date));
|
||||
}
|
||||
|
||||
public function get_tr_training_type_trt_id() {
|
||||
return $this->tr_training_type_trt_id;
|
||||
}
|
||||
public function get_tr_date_time() {
|
||||
return date("H:i", strtotime($this->tr_date));
|
||||
}
|
||||
|
||||
public function get_tr_duration() {
|
||||
return $this->tr_duration;
|
||||
}
|
||||
public function get_tr_training_type_trt_id() {
|
||||
return $this->tr_training_type_trt_id;
|
||||
}
|
||||
|
||||
public function get_tr_note() {
|
||||
return $this->tr_note;
|
||||
}
|
||||
public function get_tr_duration() {
|
||||
return $this->tr_duration;
|
||||
}
|
||||
|
||||
public function get_tr_locked() {
|
||||
return $this->tr_locked;
|
||||
}
|
||||
public function get_tr_note() {
|
||||
return $this->tr_note;
|
||||
}
|
||||
|
||||
public function get_tr_deleted() {
|
||||
return $this->tr_deleted;
|
||||
}
|
||||
public function get_tr_locked() {
|
||||
return $this->tr_locked;
|
||||
}
|
||||
|
||||
public function get_tr_type_name_by_id() {
|
||||
global $sql;
|
||||
return $sql->single_variable("SELECT trt_name FROM training_type WHERE trt_id = " . $this->get_tr_training_type_trt_id());
|
||||
}
|
||||
public function get_tr_deleted() {
|
||||
return $this->tr_deleted;
|
||||
}
|
||||
|
||||
public function set_tr_coaches() {
|
||||
//beállítja a tr_coaches array-be a coach-okat
|
||||
//EZ CSAK AZ EDZŐKET ÁLLÍTJA BE, A SEGÉDEDZŐKET NEM
|
||||
global $sql;
|
||||
$coach_ids = $sql->assoc_array("SELECT trc_coach_uc_id FROM training_coach JOIN user_coach ON ua_id = trc_coach_uc_id WHERE ua_deleted = 0 AND trc_helper = 0 AND trc_training_tr_id = " . $this->get_tr_id());
|
||||
$this->tr_coaches = array();
|
||||
foreach ($coach_ids as $trc) {
|
||||
$this->tr_coaches[] = $trc['trc_coach_uc_id'];
|
||||
}
|
||||
}
|
||||
public function get_tr_type_name_by_id() {
|
||||
global $sql;
|
||||
return $sql->single_variable("SELECT trt_name FROM training_type WHERE trt_id = " . $this->get_tr_training_type_trt_id());
|
||||
}
|
||||
|
||||
public function set_training_data_by_id($_tr_id) {
|
||||
global $sql;
|
||||
$training_data_assoc_array = $sql->assoc_array("select * from training where tr_id = " . $_tr_id);
|
||||
$training_data_array = $training_data_assoc_array[0];
|
||||
foreach ($training_data_array as $field => $value) {
|
||||
$function_name = "set_" . $field;
|
||||
$this->$function_name($value);
|
||||
}
|
||||
$this->set_tr_coaches();
|
||||
}
|
||||
public function set_tr_coaches() {
|
||||
//beállítja a tr_coaches array-be a coach-okat
|
||||
global $sql;
|
||||
$coach_ids = $sql->assoc_array("SELECT trc_coach_uc_id FROM training_coach JOIN user_coach ON ua_id = trc_coach_uc_id WHERE ua_deleted = 0 AND trc_helper = 0 AND trc_training_tr_id = " . $this->get_tr_id());
|
||||
$this->tr_coaches = array();
|
||||
foreach ($coach_ids as $trc) {
|
||||
$this->tr_coaches[] = $trc['trc_coach_uc_id'];
|
||||
}
|
||||
|
||||
public function is_coach() {
|
||||
//megadja, hogy van-e beállítva edző az edzéshez
|
||||
//TRUE HA IGEN, FALSE EGYÉBKÉNT
|
||||
return !empty($this->tr_coaches);
|
||||
}
|
||||
$helper_ids = $sql->assoc_array("SELECT trc_coach_uc_id FROM training_coach JOIN user_coach ON ua_id = trc_coach_uc_id WHERE ua_deleted = 0 AND trc_helper = 1 AND trc_training_tr_id = " . $this->get_tr_id());
|
||||
$this->tr_helpers = array();
|
||||
foreach ($helper_ids as $trc) {
|
||||
$this->tr_helpers[] = $trc['trc_coach_uc_id'];
|
||||
}
|
||||
}
|
||||
|
||||
public function get_tr_coaches_name() {
|
||||
//tömböt ad vissza az edzők neveivel
|
||||
global $sql;
|
||||
$coach_names = array();
|
||||
foreach ($this->tr_coaches as $ua_id) {
|
||||
$coach_names[] = $sql->single_variable('SELECT ua_name FROM user_coach WHERE ua_id = ' . $ua_id);
|
||||
}
|
||||
return $coach_names;
|
||||
}
|
||||
public function set_training_data_by_id($_tr_id) {
|
||||
global $sql;
|
||||
$training_data_assoc_array = $sql->assoc_array("select * from training where tr_id = " . $_tr_id);
|
||||
$training_data_array = $training_data_assoc_array[0];
|
||||
foreach ($training_data_array as $field => $value) {
|
||||
$function_name = "set_" . $field;
|
||||
$this->$function_name($value);
|
||||
}
|
||||
$this->set_tr_coaches();
|
||||
}
|
||||
|
||||
public static function create_training($_training_value_array, $_every_week) {
|
||||
global $sql;
|
||||
//megnézzük, hogy minden hétre be kell-e rakni
|
||||
//ha igen, akkor az adott hónapban, a hét minden azonos napjára létrehozza
|
||||
if ($_every_week) {
|
||||
//megnézzük milyen nap van a megadott dátumon
|
||||
$day_of_week = date('N', strtotime($_training_value_array['tr_date']));
|
||||
//kigyűjtük a hónap további ilyen napjait
|
||||
$last_day = date("t", strtotime($_training_value_array['tr_date']));
|
||||
public function is_coach() {
|
||||
//megadja, hogy van-e beállítva edző az edzéshez
|
||||
//TRUE HA IGEN, FALSE EGYÉBKÉNT
|
||||
return !empty($this->tr_coaches);
|
||||
}
|
||||
|
||||
for ($actual_day=date('d', strtotime($_training_value_array['tr_date'])); $actual_day <= $last_day; $actual_day=$actual_day+7) {
|
||||
$new_tr_id = $sql->insert_into('training',
|
||||
array(
|
||||
'tr_date' => date('Y-m', strtotime($_training_value_array['tr_date'])) . '-' . $actual_day . ' ' . date('H:i', strtotime($_training_value_array['tr_date'])),
|
||||
'tr_training_type_trt_id' => $_training_value_array['tr_training_type_trt_id'],
|
||||
'tr_duration' => $_training_value_array['tr_duration'],
|
||||
'tr_note' => $_training_value_array['tr_note']
|
||||
)
|
||||
);
|
||||
log::register('new_training', $new_tr_id);
|
||||
//itt rakjuk be a coach-okat
|
||||
if (isset($_training_value_array['coaches'])) {
|
||||
foreach ($_training_value_array['coaches'] as $coach_id) {
|
||||
# beilleszt minden edzőt ehhez az edzéshez
|
||||
$sql->insert_into('training_coach', array('trc_training_tr_id' => $new_tr_id, 'trc_coach_uc_id' => $coach_id));
|
||||
}
|
||||
}
|
||||
//itt rakjuk be a segédedzőket
|
||||
if (isset($_training_value_array['helpets'])) {
|
||||
foreach ($_training_value_array['helpets'] as $coach_id) {
|
||||
# beilleszt minden edzőt ehhez az edzéshez
|
||||
$sql->insert_into('training_coach', array('trc_training_tr_id' => $new_tr_id, 'trc_coach_uc_id' => $coach_id, 'trc_helper' => 1));
|
||||
}
|
||||
}
|
||||
}
|
||||
//var_dump($day_array);
|
||||
}
|
||||
else {
|
||||
//coaches
|
||||
if (isset($_training_value_array['coaches'])) {
|
||||
$coaches = $_training_value_array['coaches'];
|
||||
unset($_training_value_array['coaches']);
|
||||
}
|
||||
//helpers
|
||||
if (isset($_training_value_array['helpers'])) {
|
||||
$helpers = $_training_value_array['helpers'];
|
||||
unset($_training_value_array['helpers']);
|
||||
}
|
||||
public function is_helper() {
|
||||
//megadja, hogy van-e beállítva segédedző az edzéshez
|
||||
//TRUE HA IGEN, FALSE EGYÉBKÉNT
|
||||
return !empty($this->tr_helpers);
|
||||
}
|
||||
|
||||
if ($_training_value_array['tr_note'] == "") {
|
||||
$_training_value_array['tr_note'] = null;
|
||||
}
|
||||
$new_tr_id = $sql->insert_into('training', $_training_value_array);
|
||||
log::register('new_training', $new_tr_id);
|
||||
if (isset($coaches)) {
|
||||
foreach ($coaches as $coach_id) {
|
||||
# beilleszt minden edzőt ehhez az edzéshez
|
||||
$new_trc_id = $sql->insert_into('training_coach', array('trc_training_tr_id' => $new_tr_id, 'trc_coach_uc_id' => $coach_id));
|
||||
}
|
||||
}
|
||||
if (isset($helpers)) {
|
||||
foreach ($helpers as $coach_id) {
|
||||
# beilleszt minden edzőt ehhez az edzéshez
|
||||
$sql->insert_into('training_coach', array('trc_training_tr_id' => $new_tr_id, 'trc_coach_uc_id' => $coach_id, 'trc_helper' => 1));
|
||||
}
|
||||
}
|
||||
}
|
||||
public function get_tr_coaches_name() {
|
||||
//tömböt ad vissza az edzők neveivel
|
||||
global $sql;
|
||||
$coach_names = array();
|
||||
foreach ($this->tr_coaches as $ua_id) {
|
||||
$coach_names[] = $sql->single_variable('SELECT ua_name FROM user_coach WHERE ua_id = ' . $ua_id);
|
||||
}
|
||||
return $coach_names;
|
||||
}
|
||||
|
||||
return $new_tr_id;
|
||||
public function get_tr_helpers_name() {
|
||||
//tömböt ad vissza a segédedzők neveivel
|
||||
global $sql;
|
||||
$helper_names = array();
|
||||
foreach ($this->tr_helpers as $ua_id) {
|
||||
$helper_names[] = $sql->single_variable('SELECT ua_name FROM user_coach WHERE ua_id = ' . $ua_id);
|
||||
}
|
||||
return $helper_names;
|
||||
}
|
||||
|
||||
}
|
||||
public static function create_training($_training_value_array, $_every_week) {
|
||||
global $sql;
|
||||
//megnézzük, hogy minden hétre be kell-e rakni
|
||||
//ha igen, akkor az adott hónapban, a hét minden azonos napjára létrehozza
|
||||
if ($_every_week) {
|
||||
//megnézzük milyen nap van a megadott dátumon
|
||||
$day_of_week = date('N', strtotime($_training_value_array['tr_date']));
|
||||
//kigyűjtük a hónap további ilyen napjait
|
||||
$last_day = date("t", strtotime($_training_value_array['tr_date']));
|
||||
|
||||
public static function update_training($_training_value_array, $_tr_id) {
|
||||
global $sql;
|
||||
for ($actual_day=date('d', strtotime($_training_value_array['tr_date'])); $actual_day <= $last_day; $actual_day=$actual_day+7) {
|
||||
$new_tr_id = $sql->insert_into('training',
|
||||
array(
|
||||
'tr_date' => date('Y-m', strtotime($_training_value_array['tr_date'])) . '-' . $actual_day . ' ' . date('H:i', strtotime($_training_value_array['tr_date'])),
|
||||
'tr_training_type_trt_id' => $_training_value_array['tr_training_type_trt_id'],
|
||||
'tr_duration' => $_training_value_array['tr_duration'],
|
||||
'tr_note' => $_training_value_array['tr_note']
|
||||
)
|
||||
);
|
||||
log::register('new_training', $new_tr_id);
|
||||
//itt rakjuk be a coach-okat
|
||||
if (isset($_training_value_array['coaches'])) {
|
||||
foreach ($_training_value_array['coaches'] as $coach_id) {
|
||||
# beilleszt minden edzőt ehhez az edzéshez
|
||||
$sql->insert_into('training_coach', array('trc_training_tr_id' => $new_tr_id, 'trc_coach_uc_id' => $coach_id));
|
||||
}
|
||||
}
|
||||
//itt rakjuk be a segédedzőket
|
||||
if (isset($_training_value_array['helpets'])) {
|
||||
foreach ($_training_value_array['helpets'] as $coach_id) {
|
||||
# beilleszt minden edzőt ehhez az edzéshez
|
||||
$sql->insert_into('training_coach', array('trc_training_tr_id' => $new_tr_id, 'trc_coach_uc_id' => $coach_id, 'trc_helper' => 1));
|
||||
}
|
||||
}
|
||||
}
|
||||
//var_dump($day_array);
|
||||
}
|
||||
else {
|
||||
//coaches
|
||||
if (isset($_training_value_array['coaches'])) {
|
||||
$coaches = $_training_value_array['coaches'];
|
||||
unset($_training_value_array['coaches']);
|
||||
}
|
||||
//helpers
|
||||
if (isset($_training_value_array['helpers'])) {
|
||||
$helpers = $_training_value_array['helpers'];
|
||||
unset($_training_value_array['helpers']);
|
||||
}
|
||||
|
||||
$sql->execute_query("DELETE FROM training_coach WHERE trc_training_tr_id = '" . $_tr_id ."';");
|
||||
if (isset($_training_value_array['coaches'])) {
|
||||
//coaches handler -> kitoroljuk mindet és újra insertaljuk
|
||||
foreach ($_training_value_array['coaches'] as $coach_id) {
|
||||
$sql->insert_into('training_coach', array('trc_training_tr_id' => $_tr_id, 'trc_coach_uc_id' => $coach_id));
|
||||
}
|
||||
if ($_training_value_array['tr_note'] == "") {
|
||||
$_training_value_array['tr_note'] = null;
|
||||
}
|
||||
$new_tr_id = $sql->insert_into('training', $_training_value_array);
|
||||
log::register('new_training', $new_tr_id);
|
||||
if (isset($coaches)) {
|
||||
foreach ($coaches as $coach_id) {
|
||||
# beilleszt minden edzőt ehhez az edzéshez
|
||||
$new_trc_id = $sql->insert_into('training_coach', array('trc_training_tr_id' => $new_tr_id, 'trc_coach_uc_id' => $coach_id));
|
||||
}
|
||||
}
|
||||
if (isset($helpers)) {
|
||||
foreach ($helpers as $coach_id) {
|
||||
# beilleszt minden edzőt ehhez az edzéshez
|
||||
$sql->insert_into('training_coach', array('trc_training_tr_id' => $new_tr_id, 'trc_coach_uc_id' => $coach_id, 'trc_helper' => 1));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
unset($_training_value_array['coaches']);
|
||||
}
|
||||
if (isset($_training_value_array['helpers'])) {
|
||||
//helper handler -> kitoroljuk mindet és újra insertaljuk
|
||||
foreach ($_training_value_array['helpers'] as $coach_id) {
|
||||
$sql->insert_into('training_coach', array('trc_training_tr_id' => $_tr_id, 'trc_coach_uc_id' => $coach_id, 'trc_helper' => 1));
|
||||
}
|
||||
return $new_tr_id;
|
||||
|
||||
unset($_training_value_array['helpers']);
|
||||
}
|
||||
if ($_training_value_array['tr_note'] == "") {
|
||||
$_training_value_array['tr_note'] = null;
|
||||
}
|
||||
$sql->update_table('training', $_training_value_array, array('tr_id' => $_tr_id));
|
||||
}
|
||||
}
|
||||
|
||||
public static function update_training($_training_value_array, $_tr_id) {
|
||||
global $sql;
|
||||
|
||||
$sql->execute_query("DELETE FROM training_coach WHERE trc_training_tr_id = '" . $_tr_id ."';");
|
||||
if (isset($_training_value_array['coaches'])) {
|
||||
//coaches handler -> kitoroljuk mindet és újra insertaljuk
|
||||
foreach ($_training_value_array['coaches'] as $coach_id) {
|
||||
$sql->insert_into('training_coach', array('trc_training_tr_id' => $_tr_id, 'trc_coach_uc_id' => $coach_id));
|
||||
}
|
||||
|
||||
unset($_training_value_array['coaches']);
|
||||
}
|
||||
if (isset($_training_value_array['helpers'])) {
|
||||
//helper handler -> kitoroljuk mindet és újra insertaljuk
|
||||
foreach ($_training_value_array['helpers'] as $coach_id) {
|
||||
$sql->insert_into('training_coach', array('trc_training_tr_id' => $_tr_id, 'trc_coach_uc_id' => $coach_id, 'trc_helper' => 1));
|
||||
}
|
||||
|
||||
unset($_training_value_array['helpers']);
|
||||
}
|
||||
if ($_training_value_array['tr_note'] == "") {
|
||||
$_training_value_array['tr_note'] = null;
|
||||
}
|
||||
$sql->update_table('training', $_training_value_array, array('tr_id' => $_tr_id));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user