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

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

<?php

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

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

date_default_timezone_set('Asia/Dhaka');
$date_c = date('Y-m-d H:i:s', time());
include("user.php");
$temp_id = $_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>Temporary Booking</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/calendar2/pignose.calendar.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 -->
				
					<?php if ($user_type==1){ ?>
				
				
                <section id="main-content">
				
				
			
				
				
				
				
				
				<div class="row">
				
				        <div class="col-lg-12">
						
						<div class="panel panel-info m-t-15">
                                            <div class="panel-heading">Provided Details</div>
                                            <div class="panel-body">
<?php						
 	
	
	
if (isset($_POST['submit'])) {
									  
 
 
								    $new_booking_id = $_POST['booking_id'];
								 
									//$new_event_type = $_POST['event_type'];
									$new_additional_notes =  mysqli_real_escape_string($connection, $_POST['additional_notes']);
									$new_vas =  mysqli_real_escape_string($connection, $_POST['vas']);
									$new_discount = $_POST['discount'];
									$new_discount = round($new_discount,4);
									$old_booking_status = $_POST['booking_status'];
									
									$new_advance = $_POST['advance'];
									$new_method = $_POST['method'];
									$new_description = $_POST['description'];
								
																		
//**												  
												  
$sqlUpdate = "UPDATE bookings SET
 additional_notes = '$new_additional_notes',
 vas = '$new_vas',
 discount = '$new_discount',
 status = '1',
 updated_at = '$date_c'
												  											  
 WHERE
 id = '$temp_id'           
";
$sqlUpdate = mysqli_query($connection, $sqlUpdate); 

date_default_timezone_set('Asia/Dhaka');
$date_c = date('Y-m-d H:i:s', time());
$sqlUpdate = "INSERT INTO `activity_log` (`id`, `user`, `activity`, `time`, `temp_id`) VALUES (NULL, '$ad_id', 'booking updated from temporary page', '$date_c','$temp_id')";
$sqlUpdate = mysqli_query($connection, $sqlUpdate); 


$advanceSQLRL = mysqli_query($connection, "SELECT * FROM `bookings` WHERE `booking_id` = '$new_booking_id' order by id limit 1 ");
$advanceSQL= mysqli_fetch_object($advanceSQLRL);
$rowcount = mysqli_num_rows($advanceSQLRL);

if($rowcount>0){ ?>
	
<script>

  alert("Booking ID Already Exist, Try Different ID if you want to update");

</script>
	
<?php }

if($rowcount<1){

$sqlUpdate = "UPDATE bookings SET
 booking_id = '$new_booking_id',
 updated_at = '$date_c'
												  											  
 WHERE
 id = '$temp_id'           
";
$sqlUpdate = mysqli_query($connection, $sqlUpdate); 

}








$advanceSQLRL = mysqli_query($connection, "SELECT * FROM `transactions` WHERE `temp_booking_id` = '$temp_id' order by id limit 1 ");
$advanceSQL= mysqli_fetch_object($advanceSQLRL);
$rowcount = mysqli_num_rows($advanceSQLRL);
if($rowcount==1){
	$advance_id = $advanceSQL->id;
	$sqlUpdate = "UPDATE transactions SET
 amount = '$new_advance',
 updated_at = '$date_c'
												  											  
 WHERE
 id = '$advance_id'           
";
$sqlUpdate = mysqli_query($connection, $sqlUpdate); 
}

if($rowcount!=1){
	  $date = date("Y/m/d");
	  $mr_no = mysqli_query($connection, "SELECT max(mr_no) mr FROM `transactions` limit 1");
			                           
	$mr_no = mysqli_fetch_object($mr_no);
	$mr_no = $mr_no->mr;
	$mr_no = $mr_no+1;
	$sqlinsert = "INSERT INTO `transactions` (`id`, `date`, `temp_booking_id`,`mr_no`, `method`,`details`,`amount`, `updated_by`, `added_at`, `updated_at`) VALUES (NULL, '$date', '$temp_id','$mr_no','$new_method','$new_description', '$new_advance', '$ad_id', '$date_c', NULL);           
";
$sqlinsert = mysqli_query($connection, $sqlinsert);
}


if($old_booking_status==0){
	
	$sqlinsert = "INSERT INTO `booking_log` (`id`, `temp_id`, `details`, `user`, `added_at`) VALUES (NULL, '$temp_id', 'Approved Booking', '$u_name', '$date_c' );          
";
$sqlinsert = mysqli_query($connection, $sqlinsert);

$sqlUpdate = "UPDATE bookings SET
 approved_at = '$date_c'
												  											  
 WHERE
 id = '$temp_id'           
";
$sqlUpdate = mysqli_query($connection, $sqlUpdate); 

		
}

if($old_booking_status!=0){
	
	$sqlinsert = "INSERT INTO `booking_log` (`id`, `temp_id`, `details`, `user`, `added_at`) VALUES (NULL, '$temp_id', 'Updated Booking', '$u_name', '$date_c' );          
";
$sqlinsert = mysqli_query($connection, $sqlinsert);
		
}
											 
 echo "<div>
 </br>
 </div>";
 include_once('updated.html');									  
}




if (isset($_POST['submit_ev'])) {
									  
                                   $edit_id = $_POST['event_id'];
 
								    $new_date = $_POST['date'];
								    $old_date = $_POST['old_date'];
									 $new_diary_of = mysqli_real_escape_string($connection, $_POST['diary_of']);
									 $new_ev_type = $_POST['ev_type'];
									  $new_ev_value = $_POST['ev_value'];
									 
									//$new_event_type = $_POST['event_type'];
									$new_venue =  mysqli_real_escape_string($connection, $_POST['venue']);
									$new_parlar =  mysqli_real_escape_string($connection, $_POST['parlar']);
									$new_decor = mysqli_real_escape_string($connection, $_POST['decor']);
									$new_guest = $_POST['guest'];
									$new_time = $_POST['time'];
									$new_ph_package =  mysqli_real_escape_string($connection, $_POST['ph_package']);
									if(isset($_POST['vd'])){
                                    $new_vd = $_POST['vd'];
                                    }else{
                                     $new_vd = NULL;#default value
                                    }
									
									if(isset($_POST['pr'])){
                                    $new_pr = $_POST['pr'];
                                    }else{
                                     $new_pr = NULL;#default value
                                    }
									
									if(isset($_POST['sp'])){
                                    $new_sp = $_POST['sp'];
                                    }else{
                                     $new_sp = NULL;#default value
                                    }
									
									
								    $new_pr_time = $_POST['pr_time'];
									$new_sp_time = $_POST['sp_time'];
									
									$new_no_of_ph = $_POST['no_of_ph'];
									$new_no_of_vd = $_POST['no_of_vd'];
									
									$new_vd_package = mysqli_real_escape_string($connection, $_POST['vd_package']);
								
									 $new_ev_notes = $_POST['ev_notes'];
										
										// $ph_namesArray = explode(',', $ph_names);
										//$photographersArray = explode(',', $photographers);
										//$vd_namesArray = explode(',', $vd_names);
										//$videographersArray = explode(',', $videographers);										
//**												  
												  
$sqlUpdate = "UPDATE events SET
  date = '$new_date',
  diary_of = '$new_diary_of',
 venue = '$new_venue',
  guest = '$new_guest',
   type = '$new_ev_type',
 time = '$new_time',
 ph_package = '$new_ph_package',
 videoincluded = '$new_vd',
 pr = '$new_pr',
 pr_time = '$new_pr_time',
 sp = '$new_sp',
 sp_time = '$new_sp_time',
 vd_package = '$new_vd_package',
 
 no_of_ph = '$new_no_of_ph',
 
 no_of_vd = '$new_no_of_vd',
 ev_notes = '$new_ev_notes',
 ev_value = '$new_ev_value',
 parlar = '$new_parlar',
 decor = '$new_decor',
 updated_at = '$date_c'
												  											  
 WHERE
 id = '$edit_id'           
";
$sqlUpdate = mysqli_query($connection, $sqlUpdate); 
$sqlUpdate = "INSERT INTO `events_log` (`id`, `ev_id`,`prev_date`, `new_date`, `details`, `user`, `added_at`) VALUES (NULL, '$edit_id','$old_date', '$new_date', 'Event Updated', '$u_name', '$date_c' );";
$sqlUpdate = mysqli_query($connection, $sqlUpdate); 

date_default_timezone_set('Asia/Dhaka');
$date_c = date('Y-m-d H:i:s', time());
$sqlUpdate = "INSERT INTO `activity_log` (`id`, `user`, `activity`, `time`, `temp_id`) VALUES (NULL, '$ad_id', 'event updated from temporary page', '$date_c','$temp_id')";
$sqlUpdate = mysqli_query($connection, $sqlUpdate); 
											 
 echo "<div>
 </br>
 </div>";
 include_once('updated.html');									  
}











?>                         
						  
						  
						  
						  
						  
						  
	<?php
$bookingtSQL = mysqli_query($connection, "SELECT v1.*,v2.title as ref_name from (SELECT t1.*,t2.name ev_type FROM `bookings` as t1 left join booking_types as t2 on t1.event_type=t2.id where t1.id='$temp_id') as v1 left join ref as v2 on v1.ref=v2.id ");
$list= mysqli_fetch_object($bookingtSQL);
									
                                    $idn = $list->id;
									 $name = $list->name;
									$cell_1 = $list->cell_1;
									$cell_2 = $list->cell_2;
									 $email = $list->email;
									 $ev_type = $list->ev_type;
									 
								    
									 
									 
									  $fb= $list->fb;  
									    $ref= $list->ref_name;  
										 $groom_name= $list->groom_name;  
										  $groom_fb= $list->groom_fb;  
										   $groom_email= $list->groom_email;  
										    $groom_mobile= $list->groom_mobile;  
										    $groom_father= $list->groom_father;  if($groom_father=="checked"){$groom_father="yes";}
											 $groom_mother= $list->groom_mother;  if($groom_mother=="checked"){$groom_mother="yes";}
											  $groom_brother= $list->groom_brother;  if($groom_brother=="checked"){$groom_brother="yes";}
											   $groom_sister= $list->groom_sister;  if($groom_sister=="checked"){$groom_sister="yes";}
											   
											   $bride_name= $list->bride_name;  
											    $bride_fb= $list->bride_fb;  
										   $bride_email= $list->bride_email;
										   $bride_mobile= $list->bride_mobile;
										    $bride_father= $list->bride_father;  if($bride_father=="checked"){$bride_father="yes";}
											 $bride_mother= $list->bride_mother;  if($bride_mother=="checked"){$bride_mother="yes";}
											  $bride_brother= $list->bride_brother;  if($bride_brother=="checked"){$bride_brother="yes";}
											  $bride_sister= $list->bride_sister; if($bride_sister=="checked"){$bride_sister="yes";}


            $booking_status=    $list->status;               
$booking_id = $list->booking_id;
$booking_name = $list->booking_name;
$additional_notes = $list->additional_notes;
$vas = $list->vas;
$pkg_charge1 = $list->pkg_charge;
$discount = $list->discount;
$total_charge1 = $list->total_charge;									 
$due1 = $list->due;	
$advance1 = $list->advance;	
$added_at = $list->added_at;	
$updated_at = $list->updated_at;	

$advanceSQL = mysqli_query($connection, "SELECT * FROM `transactions` WHERE `temp_booking_id` = '$temp_id' order by id limit 1 ");
$advanceSQL= mysqli_fetch_object($advanceSQL);
									
$advance = $advanceSQL->amount;
$method =  $advanceSQL->method;
												  
								   
?>	
						  
						  
						  
						  
<?php

	if (isset($_POST['submit_sms'])) {
		
		$fullNumber = '880' . substr(preg_replace('/\D/', '', $cell_1), -10);
		
		$sms=$_POST['sms'];
		$smsContent=urlencode($sms);
		   $settingsSQL = mysqli_query($connection, "SELECT * FROM `settings` where name='sms_api' ");
           $settingsSQL = mysqli_fetch_object($settingsSQL);
           $sms_api = $settingsSQL->value;
		   
		   
		   $orginal_text = ["%text%", "%number%"];
		   $replace_text = [$smsContent, $fullNumber];
            $curl_url = str_replace($orginal_text, $replace_text, $sms_api);
			
		  $curl = curl_init();
		  curl_setopt_array($curl, array(
   CURLOPT_CONNECTTIMEOUT => 20,
  CURLOPT_TIMEOUT => 520,
  CURLOPT_RETURNTRANSFER => 1,
  CURLOPT_URL =>$curl_url,
   CURLOPT_USERAGENT =>'jadukor IT Browser'
 ));
 
$resp = curl_exec($curl);
curl_close($curl);
		
		 echo "<div>
 </br>
 </div>";
 include_once('updated.html');
	
	date_default_timezone_set('Asia/Dhaka');
$date_c = date('Y-m-d H:i:s', time());
$sqlUpdate = "INSERT INTO `activity_log` (`id`, `user`, `activity`, `time`, `temp_id`) VALUES (NULL, '$ad_id', 'sms sent from temporary page', '$date_c','$temp_id')";
$sqlUpdate = mysqli_query($connection, $sqlUpdate);  

	
	}

?>						  
						  
						  
						  
						  
						  
						  
						  
						  
						  
						  
						  
						  
						  
						  
                                  <div class="row"> 

                                              <div class="col-lg-4"> <b> Client Name:   </b> &nbsp;    <?php echo $name;  ?>                   </br>
                                                                    <b> Email:    </b>  &nbsp;      <?php echo $email;  ?>                            </br>
                                                                     <b> How did you find us: </b> &nbsp;      <?php echo $ref;  ?> 
																	 </div>
											  <div class="col-lg-4">  <b> Primary Cell Number:   </b> &nbsp;      <?php echo $cell_1;  ?>                        </br>
                                                                    <b> Facebook:    </b>  &nbsp;       <?php echo $fb;  ?>                               </br>
																	 <b> Diary of:    </b>  &nbsp;       <?php echo $booking_name;  ?>                              
                                                                    
																	 </div>
											  <div class="col-lg-4">  <b> Alternative Number:   </b> &nbsp;      <?php echo $cell_2;  ?>                       </br>
                                                                    <b> Event Type:    </b>  &nbsp;       <?php echo $ev_type;  ?>                               </br>
                                                                    
																	 </div>
											
											 <div class="col-lg-12">
											<h4>Groom's Details</h4>
											 </div>
											
											 <div class="col-lg-6"> <b> Name:   </b> &nbsp;      <?php echo $groom_name;  ?>                       </br>
                                                                    <b> Father:    </b>  &nbsp;      <?php echo $groom_father;  ?>     &nbsp;   
                                                                       <b> Mother:    </b>  &nbsp;       <?php echo $groom_mother;  ?>     &nbsp; 
                                                                       <b> Brother:    </b>  &nbsp;      <?php echo $groom_brother;  ?>     &nbsp; 
                                                                       <b> Sister:    </b>  &nbsp;      <?php echo $groom_sister;  ?>     &nbsp;  																	
																	 </div>
											  <div class="col-lg-6"> <b> Facebook Link/Insta. ID:   </b> &nbsp;     <?php echo $groom_fb;  ?>                     </br>
                                                                    <b>  Email:    </b>  &nbsp;       <?php echo $groom_email;  ?>          </br>   
                                                                    <b>  Mobile:    </b>  &nbsp;       <?php echo $groom_mobile;  ?>  																	
																	 </div>
																	 
																	 
									         <div class="col-lg-12">
											<h4>Bride's Details</h4>
											 </div>
											
											 <div class="col-lg-6"> <b> Name:   </b> &nbsp;      <?php echo $bride_name;  ?>                       </br>
                                                                    <b> Father:    </b>  &nbsp;      <?php echo $bride_father;  ?>     &nbsp;   
                                                                       <b> Mother:    </b>  &nbsp;       <?php echo $bride_mother;  ?>     &nbsp; 
                                                                       <b> Brother:    </b>  &nbsp;      <?php echo $bride_brother;  ?>     &nbsp; 
                                                                       <b> Sister:    </b>  &nbsp;      <?php echo $bride_sister;  ?>     &nbsp;   																	
																	 </div>
											  <div class="col-lg-6"> <b> Facebook Link/Insta. ID:   </b> &nbsp;     <?php echo $bride_fb;  ?>                     </br>
                                                                    <b>  Email:    </b>  &nbsp;       <?php echo $bride_email;  ?>            </br>   
                                                                    <b>  Mobile:    </b>  &nbsp;       <?php echo $bride_mobile;  ?>                  
																	 </div>

											 
											</div>

                            
                                    

                                   


							 </div> </div>
							 
							 
							 
					  <div class="panel panel-info m-t-15">
                                            <div class="panel-heading">Events</div>
                                            <div class="panel-body">
						
                          
 
		<?php
                        $pkg_charge=0;
						$sqlSelectedLG = "SELECT t1.* , t2.name as ev_type FROM `events` as t1 left join event_types as t2 on t1.type=t2.id WHERE t1.temp_id = '$temp_id' ";

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

                                    
                                   
                                    $idn = $list->id;
                                    $diary_of = $list->diary_of;
									$event_type_name = $list->ev_type;
									$event_type = $list->type;
									$date = $list->date;
									$time = $list->time;
									$vd = $list->videoincluded;
									
									$venue = $list->venue;
									$parlar = $list->parlar;
									$decor = $list->decor;
									$guest = $list->guest;
									 $ph_package = $list->ph_package;
									   $vd_package = $list->vd_package;
									   $ev_notes = $list->ev_notes;
									   $ev_value = $list->ev_value;
									   $pkg_charge=$pkg_charge+$ev_value;
									   $pr = $list->pr;
									   $pr_time = $list->pr_time;
									   $sp = $list->sp;
									   $sp_time = $list->sp_time;
									     $no_of_ph = $list->no_of_ph;
										   $no_of_vd= $list->no_of_vd;
                                ?>

 
                                           <form class="form-valide" action="booking_tmp.php?id=<?php echo $temp_id;  ?>" method="post">
                                          

										   <div class="row">
											
											  
												<div class="col-lg-8">
                                                     <div class="form-group">
													    <label>Event Name</label>
                                                        <input type="text" class="form-control" placeholder="Event Name" value="<?php echo $diary_of;  ?>" name="diary_of">
                                                    </div>
                                                </div>
												<div class="col-lg-4">
                                                     <div class="form-group">
                                                        <label>Event</label>
                                                        <select name="ev_type" class="form-control">
															<option value="<?php echo $event_type;  ?>"><?php echo $event_type_name;  ?></option>
															
															<?php
									$sqlT = "SELECT * FROM `event_types` where status=1 ";
$sqlT = mysqli_query($connection, $sqlT);
while ($listQ = mysqli_fetch_object($sqlT)) {
                                    $type_id = $listQ->id;
									$type_name = $listQ->name;
									?>
															<option value="<?php echo $type_id; ?>" >  <?php echo $type_name; ?>  </option>
														
															
<?php } ?>
															
														</select>
                                                    </div>
                                                </div>
											 </div>
                                               <div class="row">
                                                <div class="col-lg-3">
                                                    <div class="form-group">
													   <label>Date</label>
                                                        <input type="date" class="form-control calendar bg-ash" placeholder="dd/mm/yyyy" id="text-calendar" value="<?php echo $date;  ?>" name="date">
                                                <span class="ti-calendar form-control-feedback booking-system-feedback m-t-30"></span>
                                                    </div>
                                                </div>
												
												<div class="col-lg-3">
                                                     <div class="form-group">
													    <label>Time</label>
                                                        <input type="time" class="form-control" placeholder="Time" value="<?php echo $time;  ?>" name="time">
                                                        <span class="form-control-feedback booking-system-feedback"></span>
                                                    </div>
                                                </div>
												
												<div class="col-lg-3">
                                                     <div class="form-group">
													    <label>Venue</label>
                                                        <input type="text" class="form-control" placeholder="Venue" value="<?php echo $venue;  ?>" name="venue">
                                                    </div>
                                                </div>
												
												<div class="col-lg-3">
                                                     <div class="form-group">
													    <label>Guest</label>
                                                        <input type="text" class="form-control" placeholder="Guest" value="<?php echo $guest;  ?>" name="guest">
                                                    </div>
                                                </div>
                                                
                                            </div>
                                           
                                             <div class="row">
                                                
                                                <div class="col-lg-3">
                                                     <div class="form-group">
													    <label>Photo Package</label>
                                                        <input type="text" class="form-control" placeholder="Package" value="<?php echo $ph_package;  ?>" name="ph_package">
                                                    </div>
                                                </div>
												<div class="col-lg-3">
                                                     <div class="form-group">
													    <label>Video Package</label>
                                                        <input type="text" class="form-control" placeholder="Package" value="<?php echo $vd_package;  ?>" name="vd_package">
                                                    </div>
                                                </div>
                                                <div class="col-lg-6">
                                                     <div class="form-group">
													    <label>Event Value</label>
                                                        <input type="number" class="form-control" placeholder="Event Value" value="<?php echo $ev_value;  ?>" name="ev_value">
                                                    </div>
                                                </div>
												
											
												
												
												
												 <div class="row">
                                                
                                                <div class="col-lg-3">
                                                     <div class="form-group">
													    <label>Parlour</label>
                                                        <input type="text" class="form-control" placeholder="Parlar" value="<?php echo $parlar;  ?>" name="parlar">
                                                    </div>
                                                </div>
												<div class="col-lg-3">
                                                     <div class="form-group">
													    <label>Decor By</label>
                                                        <input type="text" class="form-control" placeholder="Decor" value="<?php echo $decor;  ?>" name="decor">
                                                    </div>
                                                </div>
                                                <div class="col-lg-6">
                                                     <div class="form-group">
													    <label>Note</label>
                                                        <input type="text" class="form-control" placeholder="Note" value="<?php echo $ev_notes;  ?>" name="ev_notes">
                                                    </div>
                                                </div>
												
												<div class="col-lg-3">
                                                     <div class="form-group">
													    <label>PR</label>
                                                        <input type="checkbox" <?php echo $pr;  ?> value="checked" name="pr" > <input type="text" value="<?php echo $pr_time;  ?>" name="pr_time" placeholder="Hour">
                                                    </div>
                                                </div>
												<div class="col-lg-3">
                                                     <div class="form-group">
													    <label>SP</label>
                                                        <input type="checkbox" <?php echo $sp;  ?> value="checked" name="sp" > <input type="text" value="<?php echo $sp_time;  ?>" name="sp_time" placeholder="Hour">
                                                    </div>
                                                </div>
												<div class="col-lg-2">
                                                     <div class="form-group">
													    <label>Videoincluded</label>
                                                        <input type="checkbox" <?php echo $vd;  ?> value="checked" name="vd" > 
                                                    </div>
                                                </div>
												<div class="col-lg-3">
                                                     <div class="form-group">
													 
                                                        <input type="number" value="<?php echo $no_of_ph;  ?>" name="no_of_ph" placeholder="Num.of Photogrpaher">
														<input type="number" value="<?php echo $no_of_vd;  ?>" name="no_of_vd" placeholder="Num.of Videogrpaher">
                                                    </div>
                                                </div>
												
                                            </div>
                                            </div>

                                            <div class="row">
                                                <div class="col-lg-12">
                                                    <div class="form-group">
													    <input type="hidden"  value="<?php echo $idn;  ?>" name="event_id" >
														<input type="hidden"  value="<?php echo $date;  ?>" name="old_date" >
                                                        <button type="submit" name="submit_ev" class="btn btn-primary btn-rounded  m-l-5">Save</button>
                                                    </div>
                                                </div>
                                            </div>

                                        </form>

                                    
<?php } ?>
                                   


							 </div> </div>	

<?php
if($discount==""){$discount=0;}
if($advance==""){$advance=0;}
$total_charge=round($pkg_charge-(($pkg_charge*$discount)/100));
$due=$total_charge-$advance;
 ?>
		 
					  <div class="panel panel-info m-t-15">  <form class="form-valide" action="" method="post">
                                            <div class="panel-heading">Additional Details</div>
                                            <div class="panel-body">
											<div class="form-group">
											
											<?php
											$bk_id = mysqli_query($connection, "SELECT max(booking_id) bk_id FROM `bookings` where status=1 limit 1");
			                $bk_id = mysqli_fetch_object($bk_id);
							$bk_id = $bk_id->bk_id;
							$bk_id = $bk_id+1;
											?>
											
													    <label>Booking ID (suggested next booking ID: <font color='green'> <?php echo $bk_id;  ?> </font> )</label>
                                                        <input type="text" class="form-control" placeholder="Booking ID" name="booking_id" value="<?php echo $booking_id;  ?>">
                                            </div>
											
											
											<div class="form-group">
													    <label>Additional Notes</label>
                                                        <input type="text" class="form-control" placeholder="Additional Notes" name="additional_notes" value="<?php echo $additional_notes;  ?>">
                                            </div>
											
											<div class="form-group">
													    <label>Value Added Services</label>
                                                        <input type="text" class="form-control" placeholder="Value Added Services" name="vas" value="<?php echo $vas;  ?>">
                                            </div>
											
											<div class="form-group">
													    <label>Package Charge</label>
                                                        <input type="text" id ="charge" onkeyup="calculate()" class="form-control" placeholder="Package Charge" name="pkg_charge" value="<?php echo $pkg_charge;  ?>" readonly>
                                            </div>
											<div class="form-group">
													    <label>Discount %</label>
														<input type="hidden" id ="percent" onkeyup="calculate()"  value="100">
                                                        <input type="text" id ="discount" onkeyup="calculate()"  class="form-control" placeholder="Discount" name="discount" value="<?php echo $discount;  ?>"  readonly>
                                            </div>
                                            
                                            <div class="form-group">
													    <label>Discount Amount</label>
													
                                                        <input type="text" id ="discount_amt" onkeyup="calculate()"  class="form-control" placeholder="Discount Amount" name="discount_amt" value="<?php echo round(($pkg_charge*$discount)/100);  ?>">
                                            </div>
                                            
											<div class="form-group">
													    <label>Total Charge</label>
                                                        <input type="text" id ="total" onkeyup="calculate()" class="form-control" placeholder="Total Charge" name="total_charge" value="<?php echo $total_charge;  ?>" readonly>
                                            </div>
											
											<div class="form-group">
													    <label>Advance</label>
                                                        <input type="text" id ="advance" onkeyup="calculate()" class="form-control" placeholder="Advance" name="advance" value="<?php echo $advance;  ?>">
                                            </div>
											<?php if($advance==0) { ?>
											<div class="form-group">
													    <label>Method</label>
                                                        <select name="method" placeholder="payment method">
											    <option value="<?php echo $method;  ?>"><?php echo $method;  ?> </option>
											   <option value="cash"> cash </option>
											   <option value="bkash"> bkash </option>
											   <option value="cheque"> cheque </option>
											   <option value="bank"> bank </option>
											    <option value="card"> card </option>
											   </select>
                                            </div>
											<div class="form-group">
													    <label>Desciption</label>
                                                        <input type="text" class="form-control" placeholder="Payment Description" name="description" value="<?php echo $pay_description;  ?>">
                                            </div>
											<?php } ?>
											
											<div class="form-group">
													    <label>Due</label>
                                                        <input type="text" id ="due" onkeyup="calculate()" class="form-control" placeholder="Due" name="due" value="<?php echo $due;  ?>" readonly>
                                            </div>
											
											<div class="form-group">
											<input type="hidden"  value="<?php echo $booking_status;  ?>" name="booking_status" >
                                                        <button type="submit" name="submit" class="btn btn-primary btn-rounded  m-l-5">Save Change</button>
														 <a href="booking_print.php?id=<?php echo $temp_id;  ?>" target="_blank"> <button type="button" name="submit" class="btn btn-primary btn-rounded  m-l-5">Print</button> </a>
													
                                           </div>
											</form>
											  <form class="form-valide" action="booking_tmp.php?id=<?php echo $temp_id;  ?>" method="post">
											
											
											<div class="form-group">
													    <label>SMS Content</label>
                                                        <input type="text" class="form-control" placeholder="sms" name="sms" value="Dear Client, Your Booking Is Confirmed. Your Booking ID is: <?php echo $booking_id;  ?>  You May Login To Check Your Booking From www.weddingdiary.com.bd">
                                            </div>
											<div class="form-group">
                                                        <button type="submit" name="submit_sms" id="submit_sms"  class="btn btn-primary btn-rounded  m-l-5">Send SMS</button>
													
                                           </div>
										   </form>
										   
										   
										   
                                            
											<div class="form-group">
										
 <form>                                      <div class="form-group">
													    <label>Email Content</label>
                                                        <input type="text" class="form-control" placeholder="" id='email' value="Dear Client, Your Booking Is Confirmed. Your Booking ID is: <?php echo $booking_id;  ?>  You May Login To Check Your Booking From www.weddingdiary.com.bd ">
                                            </div>
                                              <input type='hidden' id='tmp_b_id' value='<?php echo $temp_id;  ?>'>
											  
											   <button class="btn btn-primary btn-rounded  m-l-5" id="sendmail" type="button">Send Email</button> 
											     </form>
												 
											
												 
												
                                           </div>
										   
										   
										    
										   
										   
										   
										   
											
					</div> </div>		 
							
                        </div>
				
				
                        <!-- /# column -->
                        
                    </div>
				
				
				
				
				
                    <!-- /# row -->
                     <?php include("footer.php"); ?>
					 
					 
                </section>
				
				
				<?php } ?>
            </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>
	    <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>
	  <!-- 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 type='text/javascript' src='https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js'></script>
	<script src=”http://code.jquery.com/jquery-3.1.1.min.js”></script>
<script>
$(function() {
    $("#charge, #discount_amt, #advance, #percent").on("keydown keyup", sum);
	function sum() {
	
	$("#total").val(Math.round((Number($("#discount_amt").val()))/(Number($("#charge").val()))));
	   
	$("#total").val(Math.round((Number($("#charge").val())-(Number($("#discount_amt").val()) ))));
	
	$("#due").val(Number($("#total").val()) - Number($("#advance").val()));
	$("#discount").val((Number($("#discount_amt").val()) / Number($("#charge").val()))*100);
	
	}
});



$(document).ready(function() {
$("#sendmail").click(function() {
var tmp_b_id = $("#tmp_b_id").val();
var email = $("#email").val();
if (tmp_b_id == '') {
alert("Insertion Failed Some Fields are Blank....!!");
} else {
// Returns successful data submission message when the entered information is stored in database.
$.post("welcome_mail.php", {
tmp_b_id:tmp_b_id,
email:email,
}, function(data) {
	$('#responseContainer').html(data);
alert("Email Sent");
});
}
});
});
</script>




</body>


</html>