<?php
header("Content-Type: application/json");

$maestro_id = $_POST["MaestroID"];
$player_id = $_POST["PlayerID"];
$subjectName = $_POST["SubjectName"];
$score = $_POST["Score"];
// echo $maestro_id." / ".$player_id." / ".$score;

include "./../lib/send_reply_json.php";
include "./../setup/connect_db.php";

insert_score($maestro_id, $player_id, $subjectName, $score);

send_result_success();
exit;



function insert_score($maestro_id, $player_id, $subject_name, $score) {
	global $db_conn;

	$query = "
		INSERT INTO license_score (MaestroID, PlayerID, SubjectName, Score, ScoreDateTime)
		VALUES (?, ?, ?, ?, NOW());
	";
	$stmt = $db_conn->prepare($query);
	$stmt->bind_param("iisi", $maestro_id, $player_id, $subject_name, $score);
	$stmt->execute();
}

/*
function get_score_list($maestro_id, $player_id) {
	global $db_conn;

	$query = "
		SELECT SubjectName, Score, ScoreDateTime
		FROM license_score
		WHERE MaestroID = ? AND PlayerID = ?
	";
	$stmt = $db_conn->prepare($query);
	$stmt->bind_param("ii", $maestro_id, $player_id);
	$stmt->execute();
	$stmt->bind_result($subject_name, $score, $score_date_time);

	$score_list = array();
	while($stmt->fetch()) {
		$score_data["SubjectName"] = $subject_name;
		$score_data["Score"] = $score;
		$score_data["ScoreDateTime"] = $score_date_time;
	    array_push($score_list, $score_data);
	}
	$stmt->close();

	return $score_list;
}
*/
?>