119 lines
2.7 KiB
PHP
119 lines
2.7 KiB
PHP
<?php
|
|
|
|
class training_template {
|
|
private $tt_id;
|
|
private $tt_name;
|
|
private $tt_time;
|
|
private $tt_duration;
|
|
private $tt_training_type; //object
|
|
private $tt_deleted;
|
|
|
|
|
|
public function set_tt_id($_item) {
|
|
$this->tt_id = $_item;
|
|
}
|
|
|
|
public function set_tt_name($_item) {
|
|
$this->tt_name = $_item;
|
|
}
|
|
|
|
public function set_tt_time($_item) {
|
|
$this->tt_time = $_item;
|
|
}
|
|
|
|
public function set_tt_duration($_item) {
|
|
$this->tt_duration = $_item;
|
|
}
|
|
|
|
public function set_tt_training_type($_item) {
|
|
$this->tt_training_type = $_item;
|
|
}
|
|
|
|
public function set_tt_deleted($_item) {
|
|
$this->tt_deleted = $_item;
|
|
}
|
|
|
|
public function get_tt_id() {
|
|
return $this->tt_id;
|
|
}
|
|
|
|
public function get_tt_name() {
|
|
return $this->tt_name;
|
|
}
|
|
|
|
public function get_tt_time() {
|
|
return $this->tt_time;
|
|
}
|
|
|
|
public function get_tt_duration() {
|
|
return $this->tt_duration;
|
|
}
|
|
|
|
public function get_tt_training_type() {
|
|
return $this->tt_training_type;
|
|
}
|
|
|
|
public function get_tt_deleted() {
|
|
return $this->tt_deleted;
|
|
}
|
|
|
|
public function set_tt_data_by_id($_id) {
|
|
global $sql;
|
|
$tt_data_assoc_array = $sql->assoc_array("select * from training_template where tt_id = " . $_id);
|
|
$tt_data_array = $tt_data_assoc_array[0];
|
|
foreach ($tt_data_array as $field => $value) {
|
|
$function_name = "set_" . $field;
|
|
$this->$function_name($value); //alapadatok beállítása
|
|
|
|
if ($field == 'tt_training_type' && $value != null) {
|
|
$new_trt = new training_type();
|
|
$new_trt->set_trt_data_by_id($value);
|
|
$this->set_tt_training_type($new_trt);
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
public static function create_tt($_name, $_time, $_type, $_duration) {
|
|
global $sql;
|
|
|
|
if ($_time == '') {
|
|
$_time = 'null';
|
|
}
|
|
|
|
if ($_duration == '') {
|
|
$_duration = 'null';
|
|
}
|
|
|
|
return $sql->insert_into('training_template', array(
|
|
'tt_name' => $_name,
|
|
'tt_time' => $_time,
|
|
'tt_training_type' => $_type,
|
|
'tt_duration' => $_duration,
|
|
));
|
|
}
|
|
|
|
public static function update_tt($_name, $_time, $_type, $_duration, $_id) {
|
|
global $sql;
|
|
|
|
if ($_time == '') {
|
|
$_time = 'null';
|
|
}
|
|
|
|
if ($_duration == '') {
|
|
$_duration = 'null';
|
|
}
|
|
|
|
$sql->update_table('training_template', array(
|
|
'tt_name' => $_name,
|
|
'tt_time' => $_time,
|
|
'tt_training_type' => $_type,
|
|
'tt_duration' => $_duration,
|
|
), array('tt_id' => $_id));
|
|
}
|
|
|
|
}
|
|
|
|
|
|
?>
|