<?php  session_start();
ini_set('display_errors', 1);
if(empty($_SESSION['LOGINID']) && empty($_SESSION['LOGINNM']) ){

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


date_default_timezone_set('Asia/Dhaka');
$date_t = date('Y-m-d', time());

 ?>





<?php  include 'header.php';

include("user.php");


$temp_id = $row->id;
$event_id = intval(mysqli_real_escape_string($connection, $_GET['id']));

$sqltab = "SELECT * FROM `events` where id='$event_id' AND temp_id='$temp_id' ";
$sqltab = mysqli_query($connection, $sqltab);
$rowcount_ev = mysqli_num_rows($sqltab);


if($rowcount_ev!=1)	{
	session_destroy();
	header("Location:index.php?logout=success");
}




?>








<!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> Wedding Diary</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/calendar2/semantic.ui.min.css" rel="stylesheet">
    <link href="assets/css/lib/calendar2/pignose.calendar.min.css" rel="stylesheet">
    <link href="assets/css/lib/chartist/chartist.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"); ?>
    
    <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>Welcome <span> <?php echo $row->name; ?> !!</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">
			
			  <?php 
                    if(!empty($msg)){
			 	 ?>


		<div class="alert alert-info alert-dismissable"> 
                                        <a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a>
                                        <strong> <?php echo $msg; ?> </strong> 
                                    </div>		 
				 
				 

            <?php 
			 	}
			 	  
				  
				  
$evdatas = mysqli_fetch_object($sqltab);


$max_ev = mysqli_query($connection, "SELECT max(date) max_date FROM `events` where temp_id=$temp_id;");
$max_ev = mysqli_fetch_object($max_ev);
									
$evndate = $max_ev->max_date;

$ddate_ph = $evdatas->d_date;
$ddate_vd = $evdatas->d_date_vd;

$settingsSQL = mysqli_query($connection, "SELECT * FROM `settings` where name='delivery_policy_day' ");
$settingsSQL = mysqli_fetch_object($settingsSQL);
									
$delivery_policy_day = $settingsSQL->value;			  
$change_need_vd='yes';
$change_need_ph='yes';


$new_d_date_vd=date('Y-m-d', strtotime($date_t. ' + '.$delivery_policy_day.' days'));
$new_d_date_ph=date('Y-m-d', strtotime($date_t. ' + '.$delivery_policy_day.' days'));

if(strtotime($ddate_vd) > strtotime($new_d_date_vd)) {
    $change_need_vd='no';
}

if(strtotime($evndate) > strtotime($date_t)) {
    $change_need_vd='no';
	$change_need_ph='no';
	
} 

if(strtotime($ddate_ph) > strtotime($new_d_date_ph)) {
    $change_need_ph='no';
}

//echo $ddate_ph.$new_d_date_ph;
//echo '</br>change need ph d date: '.$change_need_ph;			  
				  
				  
				  
				  
				  
				  
				  
				  
				  ?>


				




<?php

	
if (isset($_POST['submit_ph'])) {


$new_photo_selection =  mysqli_real_escape_string($connection, $_POST['photo_selection']);
	
	if($new_photo_selection!="") {
		$sqlUpdate = "UPDATE events SET
  ph_submit_date = '$date_t',
client_selection_date = '$date_t'  WHERE
 id = '$event_id'           
";
$sqlUpdate = mysqli_query($connection, $sqlUpdate);

if($change_need_ph=='yes'){
	$sqlUpdate = "UPDATE events SET
  d_date = '$new_d_date_ph',d_date_ph_set='1'  WHERE
 id = '$event_id'           
";
$sqlUpdate = mysqli_query($connection, $sqlUpdate);	
}



	$sqlUpdate = "UPDATE events SET
  photo_selection = '$new_photo_selection' WHERE
 id = '$event_id'           
";
$sqlUpdate = mysqli_query($connection, $sqlUpdate);

	}

	

  
}


if (isset($_POST['submit_song'])) {
	 $new_trailer_song =  mysqli_real_escape_string($connection, $_POST['trailer_song']);
	$sqlUpdate = "UPDATE events SET
  trailer_song = '$new_trailer_song' WHERE
 id = '$event_id'           
";
$sqlUpdate = mysqli_query($connection, $sqlUpdate);




$sqlUpdate = "UPDATE events SET
  song_submit_date = '$date_t'  WHERE
 id = '$event_id'           
";
$sqlUpdate = mysqli_query($connection, $sqlUpdate);	

if($change_need_vd=='yes'){
	$sqlUpdate = "UPDATE events SET
  d_date_vd = '$new_d_date_vd',d_date_set='1'  WHERE
 id = '$event_id'           
";
$sqlUpdate = mysqli_query($connection, $sqlUpdate);	
}

}

if (isset($_POST['video_songs'])) {
	 $new_video_songs =  mysqli_real_escape_string($connection, $_POST['video_songs']);
	$sqlUpdate = "UPDATE events SET
  video_songs = '$new_video_songs' WHERE
 id = '$event_id'           
";
$sqlUpdate = mysqli_query($connection, $sqlUpdate);
$sqlUpdate = "UPDATE events SET
  song_submit_date = '$date_t'  WHERE
 id = '$event_id'           
";
$sqlUpdate = mysqli_query($connection, $sqlUpdate);		
}



	
if (isset($_POST['submit_update'])) {
	  

$sql="INSERT INTO `notifications` (`id`, `details`, `ev_id`, `status`,`type`, `added_at`, `updated_at`) VALUES (NULL, 'Client Has Submitted New Information', '$event_id', '1', '1', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP);";									 
mysqli_query($connection, $sql); 


		
}	
	
	
	
	
















	
$sqltab = "SELECT * FROM `events` where id='$event_id' AND temp_id='$temp_id' ";

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

                                    
                                   
                                    $tab_id = $list->id;
								    $date = $list->date;
									$subid=$tab_id;
									$lock_input = $list->lock_input; if($lock_input==1){$lock_status="disabled";}
									$event_name = $list->diary_of;
									$trailer = $list->trailer_song;
									$photo_selection = $list->photo_selection;
									
									$video_songs = $list->video_songs;
									
								
									
								
									$venue = $list->venue;
									$time = $list->time;
									
									$ev_notes = $list->ev_notes;
									
									 $state=$list->state;
								
									     
									$videoincluded=$list->videoincluded;
									 
									 if($videoincluded=="checked") {$vdo_button="yes";
									 $state_img="vd".$state.".jpg";
									 } else {$vdo_button="no";
									$state_img="ph".$state.".jpg";
									 }
											   
                                  
}
?>





 <div class="panel panel-warning m-t-15">
                                            <div class="panel-heading">Event Details</div>
                                            <div class="panel-body"> 



   <div class="card-body">
											
											<div class="row">
							
				                               <div class="col-lg-4">
										
										
										
										<div class="row"> 

   
   <div class="col-lg-12">
   
  <div style="background-image: url(assets/images/loading.gif); background-repeat: repeat-y; height: 300px; width: 300px;" id="responseContainer<?php echo $tab_id;  ?>">
    <img src="assets/images/<?php echo $state_img;  ?>" width="300" height="auto"/>
</div>



								 <table height="150"> <tr>
								  <td>
								  
								  </td> </tr>
								  </table>
											 		



											  </div>
											 
									    </div>
										
										
											   </div>
											   
											   
											   
											   
											   <div class="col-lg-8">
											   
											
											<div class="row"> 

                                              <div class="col-lg-3"> Event Name </div>
											  <div class="col-lg-6"> <input type="text" name="evname" class="form-control input-focus" placeholder="Event Name" value="<?php echo $event_name; ?>" readonly> </div>
											  <div class="col-lg-3">  </div>
											
											
											  
											</div>
											
											<div class="row"> 

                                              <div class="col-lg-3"> Location </div>
											  <div class="col-lg-6"> <input type="text" name="venue" class="form-control input-focus" placeholder="Venue" value="<?php echo $venue; ?>"readonly> </div>
											  <div class="col-lg-3">  </div>
											
											
											  
											</div>
											
											
											<div class="row"> 

                                              <div class="col-lg-3"> Date </div>
											  <div class="col-lg-6"> <input type="date" name="date" class="form-control input-focus" placeholder="Date" value="<?php echo $date; ?>"readonly> </div>
											  <div class="col-lg-3">  </div>
											
											
											  
											</div>
											
											
											<div class="row"> 

                                              <div class="col-lg-3"> Time </div>
											  <div class="col-lg-6"> <input type="time" name="time" class="form-control input-focus" placeholder="Event Name" value="<?php echo $time; ?>"readonly> </div>
											  <div class="col-lg-3">  </div>
											
											
											  
											</div>
											
											 <form action="event.php?id=<?php echo $tab_id; ?>" method="post">
											
										
											<div class="row"> 

                                              <div class="col-lg-3"> Photo No's By comma (,) </div>
											  <div class="col-lg-6"> <input type="text"  name="photo_selection" class="form-control input-focus" placeholder="1,2,3.." value="<?php echo $photo_selection; ?>"> </div>
											  <div class="col-lg-3">  </div>
											
											
											  
											</div>
											<div class="row"> 

                                              <div class="col-lg-3"> </div>
											  <div class="col-lg-6"> <a href="#" target="_blank"> <button   class="btn btn-primary" name="submit_ph" type="submit">Save</button>  </a>  </div>
											  <div class="col-lg-3">  </div>
											
								
											  
											</div>
											</form>
											
											
											<?php  if($videoincluded=="checked") { ?>
											<form action="event.php?id=<?php echo $tab_id; ?>" method="post">
											
											<div class="row"> 

                                              <div class="col-lg-3"> Trailer Song </div>
											  <div class="col-lg-6"> <input type="text" <?php echo $lock_status; ?>  name="trailer_song" class="form-control input-focus" placeholder="http://youtube.com/" value="<?php echo $trailer; ?>"> </div>
											  <div class="col-lg-3">  </div>
											
											
											  
											</div>
											<div class="row"> 

                                              <div class="col-lg-3"> Video Song List </div>
											  <div class="col-lg-6"> <textarea name="video_songs" <?php echo $lock_status; ?>  class="form-control input-focus" rows="10"><?php echo $video_songs; ?></textarea></div>
											  <div class="col-lg-3">  </div>
											
											
											  
											</div>
											
											<div class="row"> 

                                              <div class="col-lg-3"> </div>
											  <div class="col-lg-6"> <a href="#" target="_blank"> <button   class="btn btn-primary" name="submit_song" type="submit">Save</button>  </a>  </div>
											  <div class="col-lg-3">  </div>
											
											
											  
											</div>
											</form>
											<?php } ?>
											
												
											
											
											
											
											
											
											
										
											
											
											   </div>
											   
											  
													
										  </div>		
                                   
                                </div>
								
								<table height="100"> <tr>
								  <td>
								  
								  </td> </tr>
								  </table>
								
                                </div>
								</div>
                               



			
			
				
				
                    
                 
					
					
					 
					
					
					
					
					
					
					
                    <?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>
   
   
    <!-- 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 -->
    
    <!-- bootstrap -->

    <script src="assets/js/lib/calendar-2/moment.latest.min.js"></script>
    <!-- scripit init-->
    <script src="assets/js/lib/calendar-2/semantic.ui.min.js"></script>
    <!-- scripit init-->
    <script src="assets/js/lib/calendar-2/prism.min.js"></script>
    <!-- scripit init-->
    <script src="assets/js/lib/calendar-2/pignose.calendar.min.js"></script>
    <!-- scripit init-->
    <script src="assets/js/lib/calendar-2/pignose.init.js"></script>
    <!-- scripit init-->


    <script src="assets/js/lib/weather/jquery.simpleWeather.min.js"></script>
    <script src="assets/js/lib/weather/weather-init.js"></script>
    <script src="assets/js/lib/circle-progress/circle-progress.min.js"></script>
    <script src="assets/js/lib/circle-progress/circle-progress-init.js"></script>
    <script src="assets/js/lib/chartist/chartist.min.js"></script>
    <script src="assets/js/lib/chartist/chartist-init.js"></script>
    <script src="assets/js/lib/sparklinechart/jquery.sparkline.min.js"></script>
    <script src="assets/js/lib/sparklinechart/sparkline.init.js"></script>
    <script src="assets/js/lib/owl-carousel/owl.carousel.min.js"></script>
    <script src="assets/js/lib/owl-carousel/owl.carousel-init.js"></script>
    <script src="assets/js/scripts.js"></script>
    <!-- scripit init-->
	<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.5.0/Chart.min.js"></script>
 
	
	
	<script type="text/javascript">
        function addEvent() {
            var number_of_events = parseInt($("#numberOfEvents").val()) + 1;
            $("#numberOfEvents").val(number_of_events);
            $("#eventTable").append("<tr id=\"event"+number_of_events.toString()+"_row\">\n" +
                "                                        <td><input name=\"event"+number_of_events.toString()+"_link\" type=\"text\" size=\"55\"></td>\n" +
             
                "                                    </tr>");
        };

        function removeEvent() {
            var number_of_events_prev = parseInt($("#numberOfEvents").val()) ;
            var number_of_events = number_of_events_prev - 1;
            if (number_of_events === 0) return;
            $("#numberOfEvents").val(number_of_events);
            $("#event"+number_of_events_prev.toString()+"_row").remove();
        }
    </script>




	
	
</body>

</html>