<?php session_start(); ob_start(); ?>

<?php  include 'header.php'; ?>

<?php
ini_set('display_errors', 0);

if(empty($_SESSION['LOGINID']) && empty($_SESSION['LOGINNM']) ){

	header("Location:index.php");
}


include("user.php");


$action = $_GET['action'];

 $eid = mysqli_real_escape_string($connection, $_GET['id']);

?>



<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>Artist Management</title>
    <!-- ================= Favicon ================== -->
    <!-- Standard -->
    <link rel="shortcut icon" href="http://placehold.it/64.png/000/fff">
    <!-- Retina iPad Touch Icon-->
    <link rel="apple-touch-icon" sizes="144x144" href="http://placehold.it/144.png/000/fff">
    <!-- Retina iPhone Touch Icon-->
    <link rel="apple-touch-icon" sizes="114x114" href="http://placehold.it/114.png/000/fff">
    <!-- Standard iPad Touch Icon-->
    <link rel="apple-touch-icon" sizes="72x72" href="http://placehold.it/72.png/000/fff">
    <!-- Standard iPhone Touch Icon-->
    <link rel="apple-touch-icon" sizes="57x57" href="http://placehold.it/57.png/000/fff">
    <!-- Styles -->
     <link href="assets/css/lib/data-table/buttons.bootstrap.min.css" rel="stylesheet" />
    <link href="assets/css/lib/font-awesome.min.css" rel="stylesheet">
    <link href="assets/css/lib/themify-icons.css" rel="stylesheet">
    <link href="assets/css/lib/owl.carousel.min.css" rel="stylesheet" />
    <link href="assets/css/lib/owl.theme.default.min.css" rel="stylesheet" />
    <link href="assets/css/lib/weather-icons.css" rel="stylesheet" />
    <link href="assets/css/lib/menubar/sidebar.css" rel="stylesheet">
    <link href="assets/css/lib/bootstrap.min.css" rel="stylesheet">
    <link href="assets/css/lib/unix.css" rel="stylesheet">
    <link href="assets/css/style.css" rel="stylesheet">
</head>

<body>

   
   
   
     <?php include("sidebar.php"); ?>
	
	
    <!-- /# sidebar -->
     <?php include("top.php"); ?>
	<!-- /# topebar --> 
	
	
	
    <div class="content-wrap">
        <div class="main">
            <div class="container-fluid">
                <div class="row">
                    <div class="col-lg-8 p-r-0 title-margin-right">
                        <div class="page-header">
                            <div class="page-title">
                                <h1>Hello, <span>Welcome Here</span></h1>
                            </div>
                        </div>
                    </div>
                    <!-- /# column -->
                    <div class="col-lg-4 p-l-0 title-margin-left">
                        <div class="page-header">
                            <div class="page-title">
                                <ol class="breadcrumb text-right">
                                    <li><a href="#">Dashboard</a></li>
                                    <li class="active">Home</li>
                                </ol>
                            </div>
                        </div>
                    </div>
                    <!-- /# column -->
                </div>
                <!-- /# row -->
                <section id="main-content">
				
				
			
				
				
				
				
				
				<div class="row">
				
				        <div class="col-lg-12">
						
						<div class="panel panel-info m-t-15">
                                            <div class="panel-heading">Artist Management</div>
                                            <div class="panel-body">
						
								    <a href="artists.php?action=add"> <button class="btn btn-success btn-md" type="submit"> Add Artist </button> </a>

								  
								  
								  
								  
								  <?php
								  
								  if (isset($_POST['submit'])) {
									  
									  $sub=$_POST['sub'];
									  
									   
									 
									  if($sub=='1')
										  
										  {
											    $new_name=$_POST['name'];
											  $new_email=$_POST['email'];
											  $new_type=$_POST['type'];
											  $new_mobile=$_POST['mobile'];
												  
												  
												  
											   $sqlUpdate = "UPDATE artists SET
                                                  name = '$new_name',
												  email = '$new_email',
												   mobile = '$new_mobile',
												  type = '$new_type'
												 
												  
												  
                                                

                                            WHERE
                                                  id = '$eid'           
                     ";
					 
					                           											   
               
                             /* echo $sqlUpdate;
              exit;*/

                                            $sqlUpdated = mysqli_query($connection, $sqlUpdate); 
											 
											 echo "<div>
											 </br>
											 </div>";
											 include_once('updated.html');
										  }
										  
										  
										  if($sub=='2') {
											  $new_name=$_POST['name'];
											  $new_email=$_POST['email'];
											  $new_type=$_POST['type'];
											  $new_mobile=$_POST['mobile'];
										
												  
												  
											   $sqlinsert = "INSERT INTO `artists` (`id`, `name`, `mobile`, `email`, `type`) VALUES (NULL, '$new_name', '$new_mobile', '$new_email', '$new_type');";
											   
											   $sqlinsert = mysqli_query($connection, $sqlinsert); 
											  
											 echo "<div>
											 </br>
											 </div>";
											 include_once('updated.html');
					                        }
											
											if($sub=='3') {
											  $del_id=$_POST['del_id'];
											
										
												  
												  
											   $sqlrmv = "DELETE FROM `artists` WHERE `artists`.`id` = '$del_id';";
											   
											   $sqlinsert = mysqli_query($connection, $sqlrmv); 
											  
											 echo "<div>
											 </br>
											 </div>";
											 include_once('updated.html');
					                        }
									  
								  }
								  
								  ?>
								  
								  
								  
								  
								  
								  
								  
								  
								  
                                    <div class="row">
                        <div class="col-lg-12">
                            <div class="card alert">
							
							
							
							
							
							
							
							
							
							
							
                               
								
								
								
								
								
								
								
								
								
						
								
								
								
								
									<?php 
							if ($action=="edit") { ?>
								
								 <div class="">
                                    <div class="table-responsive">
                                        <table id="" class="table table-striped table-bordered">
                                            <thead>
                                                <tr>
                                                    <th>Name</th>
													   <th>Mobile</th>
												  
													<th>Email</th>
													<th>Type</th>
													  
													<th>Save</th>
                                                </tr>
                                            </thead>
                                            <tbody>
											
											<?php
											
						
                        
		  						

						$sqlSelectedLG = "SELECT * FROM `artists` where id='$eid' ";

$sqlSelectedLG = mysqli_query($connection, $sqlSelectedLG);
while ($list = mysqli_fetch_object($sqlSelectedLG)) {

                                    
                                   
                                     $idn = $list->id;
								    
									
									
									
                                    $name = $list->name;
									   $email = $list->email;
									     $mobile = $list->mobile;
										 	
											    $type = $list->type;
								
                                    
                                   
                                ?>
											
											
											
											
                                                <tr> <form action="artists.php?action=edit&id=<?php echo $idn;  ?>" id='edit' method="post">
                                                 
                                                    <td><input type='text' name='name' value='<?php echo $name;  ?>'></td>
                                                     <td><input type='text' name='mobile' value='<?php echo $mobile;  ?>'></td>
													  <td><input type='text' name='email' value='<?php echo $email;  ?>'></td>
                                                  
													 <td> <select name='type'>
													 <option value='<?php echo $type;  ?>'>  <?php echo $type;  ?> </option>
													 
													  <option value='Photographer'> Photographer </option>
													     <option value='Videographer'> Videographer</option>
													 
													 
													 </select>
													 </td>
														 
															 	
													<td>     <input type='hidden' name='sub' value='1'>
													<button class="btn btn-success btn-md" type="submit" name="submit"><i class="ti-save"></i></button> 
													</td>
													
													</form>
                                                </tr>
                                                
												
<?php } ?>			
												
                                            </tbody>
                                        </table>
                                    </div>
                                </div>
								
								
								<?php } ?>	
								
								
								
								
								
								
								
								
								
								
								
								
								
								
								
								
								
								
								
								
								
								
								
								
								
								
								<?php 
							if ($action=="add") { ?>
								
								 <div class="">
                                    <div class="table-responsive">
                                        <table id="" class="table table-striped table-bordered">
                                            <thead>
                                                <tr>
                                                    <th>Name</th>
													<th>Email </th>
													<th>Mobile</th>
													<th>Type</th>
													<th>Add</th>
                                                </tr>
                                            </thead>
                                            <tbody>
								
											
						
                       
											
											
											
											
                                                <tr>
                                                    <form action="artists.php?action=add" method="post">
                                                    <td><input type='text' name='name'></td>
													  <td><input type='text' name='email'></td>
													 <td><input type='text' name='mobile'></td>
													 
                                                   
													  
													 <td> <select name='type'>
													
													   <option value='Photographer'> Photographer </option>
													     <option value='Videographer'> Videographer</option>
													 
													 
													 </select>
													 </td>
														 
														 <input type='hidden' name='sub' value='2'>	 	
													<td> <button class="btn btn-success btn-md" name='submit' type="submit"><i class="ti-plus"></i></button>  </td>
													
													
													</form>
                                                </tr>
                                                
												
	
												
                                            </tbody>
                                        </table>
                                    </div>
                                </div>
								
								
								<?php } ?>	
								
								
								
								
								
								
								
								
								</br>
								
								
								
								
								
								 <div class="bootstrap-data-table-panel">
                                    <div class="table-responsive">
                                        <table id="bootstrap-data-table-export" class="table table-striped table-bordered">
                                            <thead>
                                                <tr>
                                                    <th>Name</th>
													<th>Email</th>
														<th>Mobile</th>
													<th>Type</th>
                                                    
												
													  
													<th>Action</th>
                                                </tr>
                                            </thead>
                                            <tbody>
											
											<?php

						$sqlSelectedLG = "SELECT * FROM `artists`";

$sqlSelectedLG = mysqli_query($connection, $sqlSelectedLG);
while ($list = mysqli_fetch_object($sqlSelectedLG)) {

                                    
                                   
                                    $idn = $list->id;
								    
									
									
									
                                    $name = $list->name;
									   $email = $list->email;
									     $mobile = $list->mobile;
										 	
											    $type = $list->type;
                                  
								
                                    
                                   
                                ?>
											
											
											
											
                                                <tr>
                                                 
                                                    <td><?php echo $name;  ?></td>
                                                    <td><?php echo $email;  ?></td>
													  <td><?php echo $mobile;  ?></td>
                                                    <td><?php echo $type;  ?></td>
													
													<td> <a href='artists.php?action=edit&id=<?php echo $idn;  ?>'><button class="btn btn-success btn-md" type="submit"><i class="ti-pencil-alt"></i></button>  </a> 
													<form action='artists.php' method='post'>
													<input type='hidden' name='sub' value='3'>
													<input type='hidden' name='del_id' value='<?php echo $idn;  ?>'>
													<button class="btn remove btn-danger btn-md" onclick="return confirm('Are you sure you want to Remove?');" type="submit" name='submit' ><i class="ti-close"></i></button> 
													
													
													
												   </form>
													
													</td>
													
													
                                                </tr>
                                                
												
<?php } ?>			
												
                                            </tbody>
                                        </table>
                                    </div>
                                </div>
								
								
								
								
								
								
								
                            </div>
                            <!-- /# card -->
                        </div>
                        <!-- /# column -->
                    </div>

                                   


							 </div> </div>
							
                        </div>
				
				
                        <!-- /# column -->
                        
                    </div>
				
				
				
				
				
                    <!-- /# row -->
                     <?php include("footer.php"); ?>
                </section>
            </div>
        </div>
    </div>

    <div id="search">
        <button type="button" class="close">×</button>
        <form>
            <input type="search" value="" placeholder="type keyword(s) here" />
            <button type="submit" class="btn btn-primary">Search</button>
        </form>
    </div>


    </div>
    <script src="assets/js/lib/jquery.min.js"></script>
    <!-- jquery vendor -->
    <script src="assets/js/lib/jquery.nanoscroller.min.js"></script>
    <!-- nano scroller -->
    <script src="assets/js/lib/menubar/sidebar.js"></script>
    <script src="assets/js/lib/preloader/pace.min.js"></script>
    <!-- sidebar -->
    <script src="assets/js/lib/bootstrap.min.js"></script>
    <!-- bootstrap -->
   
    <script src="assets/js/scripts.js"></script>
	
	 <script src="assets/js/lib/data-table/datatables.min.js"></script>
    <script src="assets/js/lib/data-table/buttons.dataTables.min.js"></script>
    <script src="assets/js/lib/data-table/dataTables.buttons.min.js"></script>
    <script src="assets/js/lib/data-table/buttons.flash.min.js"></script>
    <script src="assets/js/lib/data-table/jszip.min.js"></script>
    <script src="assets/js/lib/data-table/pdfmake.min.js"></script>
    <script src="assets/js/lib/data-table/vfs_fonts.js"></script>
    <script src="assets/js/lib/data-table/buttons.html5.min.js"></script>
    <script src="assets/js/lib/data-table/buttons.print.min.js"></script>
    <script src="assets/js/lib/data-table/datatables-init.js"></script>



</body>

</html>