
<?php
require '../../connect.php';
session_start();
$type=$_SESSION['title'];

$id = $_REQUEST['id'];

$sql_query = "SELECT song_master.id AS song_id,
                song_master.music_director,
				song_master.title,
                song_master.language_id,
                song_master.file_location,
                song_master.lyrics_location,

                (SELECT lng.language_name
                  FROM languages AS lng
                  WHERE lng.id = song_master.language_id)
                  AS language_name

                FROM song_master
                WHERE song_master.id = $id";

$stmt = $con->prepare($sql_query); 
$stmt->execute(); 
$row = $stmt->fetch();

?>



<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <style>
           /* Style for the card */
    .card {
        border: 1px solid #dee2e6; /* Add border */
        border-radius: .25rem; /* Add border radius */
        margin: 20px auto; /* Center the card horizontally */
        max-width: 800px; /* Limit maximum width */
    }

    /* Style for the card header */
    .card-header {
        background-color: deepPink; /* Pink background color */
        color: white; /* White text color */
        padding: 10px; /* Add some padding */
        display: flex; /* Use flexbox for layout */
        justify-content: space-between; /* Space items evenly */
        align-items: center; /* Center items vertically */
		
    }

    /* Style for the back button */
    .btn-back {
        color: white; /* White text color */
        background-color: black; /* Black background color */
        padding: 5px 10px; /* Add padding */
        border: none; /* Remove border */
        cursor: pointer; /* Show pointer cursor */
        text-decoration: none; /* Remove default underline */
    }

    /* Style for the h3 inside card header */
    .card-header h3 {
        font-size: 24px; /* Set font size */
        margin: 0; /* Remove default margin */
    }

    /* Style for the form */
    .form-horizontal {
        margin-top: 20px; /* Add some top margin */
        padding: 20px; /* Add padding */
    }
	.btn.btn-success
	{
		border: none;
    background: pink;
    border-radius: 6px;
    height: 30px;
    width: 100px;
    font-size: 18px;
	}
	.btn.btn-success:hover
	{
		 background:deepPink;
		 color:white;
	}
	
	.backbtn
	{
		 color: white; /* White text color */
        background-color: gray; /* Gray background color */
        padding: 5px 10px; /* Add padding */
        border: none; /* Remove border */
        cursor: pointer; /* Show pointer cursor */
        text-decoration: none; /* Remove default underline */
	}
	.backbtn:hover {
        background-color: black; /* Black hover background color */
    }
	.form-control
	{
		width:100% !important;
	}
	
    </style>
</head>
<body>
    <div class="card card-pink" style="width: 140vh;">
        <div class="card-header">
            <h3 class="card-title"><b>SONGS EDIT</b></h3>
<div class="backbtn">
            <a onclick="return back()" style="float: right;color:white" data-toggle="modal" class="btn btn-dark"><b>Back</b></a>
			</div>        </div>
        <!-- /.card-header -->
        <!-- form start -->
        <form class="form-horizontal" action="mmusic/songs_update.php" method="POST" enctype="multipart/form-data">
            <div class="card-body">
                <div class="form-group row">
                    <label for="title" class="col-sm-2 col-form-label">Song Name</label>
                    <div class="col-sm-4">
                        <input type="hidden" class="form-control" id="get_id" name="get_id" value="<?php echo $row['song_id']; ?>">
                        <input type="text" class="form-control" name="title" id="title" value="<?php echo $row['title']; ?>">
                    </div>
                </div>
            </div>
            <br>
			 
            <div class="form-group row" style="">
               <label for="Languages" class="col-sm-2 col-form-label">Languages</label>
                <div class="col-sm-4">
                    <select class="form-control" name="language_id" id="language_name" required>
                        <option value="">---Select---</option>
                    <?php
                    $sql=$con->query("SELECT * FROM languages");
                    $i=1;
                    while($cmp = $sql->fetch(PDO::FETCH_ASSOC))
                    {
                    ?>
                    <option value="<?php echo $cmp['id'];?>"><?php echo $cmp['language_name'];?></option>
                    <?php
                    }
                    ?>
                    </select>
                </div>
            </div>
            <div class="card-body">
                <label for="file_location" class="col-sm-2 col-form-label">SONG :&nbsp;</label>
                <label for="file_location"><?php echo $row['file_location']; ?></label><br><br>
                <div class="form-group row">
                    <label for="songs" class="col-sm-2 col-form-label">UPLOAD SONG :&nbsp;&nbsp;</label><br><br>
                    <div class="col-sm-4">
                        <input type="file" name="song_file" id="song_file" placeholder="Enter the songs">
                    </div>
                </div>
            </div><br><br>
            <div class="card-body">
                <label for="lyrics_location" class="col-sm-2 col-form-label">TAMIL LYRICS :&nbsp;&nbsp;</label>
                <label for="lyrics_location" class="col-sm-6 col-form-label"><?php echo $row['lyrics_location']; ?></label><br><br>
                <div class="form-group row">
                    <label for="lyrics" class="col-sm-2 col-form-label">UPLOAD TAMIL LYRICS :&nbsp;&nbsp;</label><br><br>
                    <div class="col-sm-4">
                        <input type="file" name="lyrics_file" id="lyrics_file" placeholder="Enter the lyrics ">
                    </div>
                </div><br><br>
                <label for="lyrics_location" class="col-sm-2 col-form-label">Status :&nbsp;&nbsp;</label>
                <select id="status" name="status" style="width:25%" class="form-control">
                    <option value="nd">-- Status --</option>
                    <option value="active">Active</option>
                    <option value=" in active">In Active</option>
                </select>
            </div><br><br>
            <div class="card-footer">
                <button type="submit" name="Update" class="btn btn-success btn-md">Update</button>
                <button type="reset" class="btn btn-success btn-md" onclick="cancel()">Cancel</button>
            </div>
            <!-- /.card-footer -->
        </form>
    </div>

    <!-- Your footer content and scripts -->
</body>
</html>

<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script>
    function back() {
        var rightcontent = $("#rightcontent").hide();

        $.ajax({
            type: "POST",
            url: "professional_singer/music/music_view.php",
            success: function(data) {
                $("#centerconteid").css("marginLeft", "450px");
                $("#centerconteid").html(data);
            }
        })
    }

    function cancel() {
        var rightcontent = $("#rightcontent").hide();

        $.ajax({
            type: "POST",
            url: "professional_singer/music/music_view.php",
            success: function(data) {
                $("#centerconteid").css("marginLeft", "450px");
                $("#centerconteid").html(data);
            }
        })
    }
</script>
