<!DOCTYPE html>
<html lang="en"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">

    <!-- CSRF Token -->
    <meta name="csrf-token" content="qdRk3vmM3FySwFLcoYYaMs7eozGBY34rhkqPnvNa">

    <title>Wedding Diary</title>

    <!-- Styles -->
    <link href="assets/css/public.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 cz-shortcut-listen="true">
    <div id="app"><nav class="navbar navbar-default navbar-static-top"><div class="container"><div class="navbar-header"><button type="button" data-toggle="collapse" data-target="#app-navbar-collapse" aria-expanded="false" class="navbar-toggle collapsed"><span class="sr-only">Toggle Navigation</span> <span class="icon-bar"></span> <span class="icon-bar"></span> <span class="icon-bar"></span></button> <a href="http://www.weddingdiary.com.bd/" class="navbar-brand">
                        Home
                    </a></div> <div id="app-navbar-collapse" class="collapse navbar-collapse">
					
					
					<ul class="nav navbar-nav">
                        &nbsp;
                    </ul> 
					
					<ul class="nav navbar-nav navbar-right"><li><a href="index.php">Login</a></li></ul>
					
					
					
					</div></div></nav> 
					
					
					<div class="container">
					<div class="row">
					<div class="panel panel-success m-t-15">
                                            <div class="panel-heading">New Booking</div>
                                            <div class="panel-body">
											
					<?php  
					ini_set('display_errors', 0);
					include 'inc/db_config.php';
					
					date_default_timezone_set('Asia/Dhaka');
                    $date_c = date('Y-m-d H:i:s', time());
					
					?>						
										
					<?php
					
					if (isset($_POST['submit'])) { 
				
					
					
					$client_name = mysqli_real_escape_string($connection, $_POST['name']);
					$email = mysqli_real_escape_string($connection, $_POST['email']);
					$address =  mysqli_real_escape_string($connection, $_POST['address']);
					$cell_1 =  mysqli_real_escape_string($connection, $_POST['cell_1']);
					$cell_2 =   mysqli_real_escape_string($connection, $_POST['cell_2']);
					$fb =  mysqli_real_escape_string($connection, $_POST['fb']);
					
					$ref =  mysqli_real_escape_string($connection, $_POST['ref']);
					$others =   mysqli_real_escape_string($connection, $_POST['others']);
					$event_type = $_POST['event_type'];
					$booking_name =  mysqli_real_escape_string($connection, $_POST['booking_name']);
					
					$sqlinsert = "INSERT INTO `bookings` (`id`, `booking_id`, `booking_name`, `name`, `email`, `cell_1`, `cell_2`, `address`, `fb`, `event_type`, `ref`, `groom_name`, `groom_fb`, `groom_email`, `groom_father`, `groom_mother`, `groom_brother`, `groom_sister`, `bride_name`, `bride_fb`, `bride_email`, `bride_father`, `bride_mother`, `bride_brother`, `bride_sister`, `additional_notes`, `vas`, `pkg_charge`, `discount`, `total_charge`, `advance`, `due`, `status`, `added_at`, `updated_at`) VALUES (NULL, '0', '$booking_name', '$client_name', '$email', '$cell_1', '$cell_2', '$address', '$fb', '$event_type', '$ref', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, '0', NULL, NULL, NULL, '0', '$date_c', NULL);";
											   
					 $sqlinsert = mysqli_query($connection, $sqlinsert); 
											  
					
					 
					$temp_id = mysqli_query($connection, "SELECT max(id) id FROM `bookings` ");
                    $temp_id = mysqli_fetch_object($temp_id);
									
                    $temp_id = $temp_id->id;
					
					if($others!=""){
						$sqlinsert = "INSERT INTO `ref_other` (`id`, `name`, `temp_id`, `updated_at`) VALUES (NULL, '$others', '$temp_id', NULL);";
											   
					 $sqlinsert = mysqli_query($connection, $sqlinsert); 
						
					}
					
					
					
					
					
					
					
					
					if (isset($_POST['marriage_div'])) {
					
					$groom_name =  mysqli_real_escape_string($connection, $_POST['groom_name']);
					$groom_father = $_POST['groom_father']; 
					$groom_mother = $_POST['groom_mother'];
					$groom_brother = $_POST['groom_brother'];
					$groom_sister = $_POST['groom_sister']; 
					$groom_fb = mysqli_real_escape_string($connection, $_POST['groom_fb']);
					$groom_email =  mysqli_real_escape_string($connection, $_POST['groom_email']);
					$groom_mobile =  mysqli_real_escape_string($connection, $_POST['groom_mobile']);
					
					$bride_name = mysqli_real_escape_string($connection, $_POST['bride_name']);
					$bride_father = $_POST['bride_father']; 
					$bride_mother = $_POST['bride_mother']; 
					$bride_brother = $_POST['bride_brother'];
					$bride_sister = $_POST['bride_sister'];
					$bride_fb =  mysqli_real_escape_string($connection, $_POST['bride_fb']);
					$bride_email = mysqli_real_escape_string($connection, $_POST['bride_email']);
                    $bride_mobile = mysqli_real_escape_string($connection, $_POST['bride_mobile']);
				    $sqlUpdate = "UPDATE bookings SET
 groom_name = '$groom_name',
 groom_father = '$groom_father',
 groom_mother = '$groom_mother',
 groom_brother = '$groom_brother',
 groom_sister = '$groom_sister',
 groom_fb = '$groom_fb',
 groom_mobile = '$groom_mobile',
 groom_email = '$groom_email',
 bride_name = '$bride_name',
 bride_father = '$bride_father',
 bride_mother = '$bride_mother',
 bride_brother = '$bride_brother',
 bride_sister = '$bride_sister',
 bride_fb = '$bride_fb',
 bride_mobile = '$bride_mobile',
 bride_email = '$bride_email',
 
 updated_at = '$date_c'
												  											  
 WHERE
 id = '$temp_id'           
";
$sqlUpdate = mysqli_query($connection, $sqlUpdate); 


          					
					}
					
					
					
					
					
					
					
					$numberOfEvents = $_POST['numberOfEvents'];
					
					$add_date=date("Y-m-d");
						
						
				
						for($i = 1; $i<=$numberOfEvents; $i++) {
                            ${eventdate.$i} = $_POST['event'.$i.'_date'];
					${eventname.$i} = mysqli_real_escape_string($connection, $_POST['event'.$i.'_event']);
					${eventtime.$i} = $_POST['event'.$i.'_time'];
					${eventvenue.$i} = mysqli_real_escape_string($connection, $_POST['event'.$i.'_venue']);
					${eventparlar.$i} =  mysqli_real_escape_string($connection, $_POST['event'.$i.'_parlar']);
					${eventdecor.$i} = mysqli_real_escape_string($connection, $_POST['event'.$i.'_decor']);
					${eventguest.$i} =  mysqli_real_escape_string($connection, $_POST['event'.$i.'_guest']);
					
					$sqlinsert = "INSERT INTO `events` (`id`, `temp_id`, `type`, `date`, `time`, `diary_of`, `venue`,`parlar`,`decor`, `guest`, `ph_package`, `vd_package`, `videoincluded`, `ev_notes`, `pr`, `photographers`, `videographers`, `asst`, `makeover`, `trailer_song`, `updated_at`, `state` ,`added_at`) VALUES (NULL, '$temp_id', NULL, '${eventdate.$i}', '${eventtime.$i}', '${eventname.$i}', '${eventvenue.$i}', '${eventparlar.$i}', '${eventdecor.$i}', '${eventguest.$i}', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, '0', '$add_date');";
											   
				    $sqlinsert = mysqli_query($connection, $sqlinsert); 
					
					$evn_id = mysqli_query($connection, "SELECT max(id) id FROM `events` ");
                    $evn_id = mysqli_fetch_object($evn_id);
									
                    $evn_id = $evn_id->id;
					
					$sqlinsert = "INSERT INTO `vd_edit` (`id`, `event_id`, `editor`, `date`, `hdd`, `remarks`, `status`, `updated_at`) VALUES (NULL, '$evn_id', NULL, NULL, NULL, NULL, '', CURRENT_TIMESTAMP);";
											   
				    $sqlinsert = mysqli_query($connection, $sqlinsert); 
					
					
					$sqlinsert = "INSERT INTO `photo_edit` (`id`, `event_id`, `editor`, `date`, `hdd`, `rg_edit`, `sp_edit`, `remarks`, `status`, `updated_at`) VALUES (NULL, '$evn_id', NULL, NULL, NULL, NULL, NULL, NULL, '', NULL);";
											   
				    $sqlinsert = mysqli_query($connection, $sqlinsert); 
					
					
				
					
					
                          }
				
					
					
					
			        
					
					
					print " <center>
					
					<b> Thank you for your submission !! We will contact with you as soon as possible </b> </br>
					<img src='assets/images/order_confirm_check_graphic.jpg' />
					</center>
					</br> </br>
					
					"
;

					}
					
?>					
											
											
											
											
					<?php if (!isset($_POST['submit'])) { ?> 						
											
											
											
											
											
											
											
					<form method="POST" action="booking_new.php" class="form-horizontal" onsubmit="if(document.getElementById('agree').checked) { return true; } else { alert('Please mark that you have read and agree to the Terms and Conditions and Privacy Policy'); return false; }">
					
					<div class="form-group">
                                <label for="found" class="col-md-4 control-label">Event Type</label>
                                <div class="col-md-6">
                                    <select id="type" name="event_type" class="form-control">
															<option>Select one</option>
                                        									<?php
									$sqlSelectedLG = "SELECT * FROM `booking_types` where status=1 ";
$sqlSelectedLG = mysqli_query($connection, $sqlSelectedLG);
while ($list = mysqli_fetch_object($sqlSelectedLG)) {
                                    $type_id = $list->id;
									$type_name = $list->name;
									?>
															<option value="<?php echo $type_id; ?>" >  <?php echo $type_name; ?>  </option>
														
															
<?php } ?>
									</select>
                                </div>
                            </div>
					
					
					<input type="hidden" name="_token" value="qdRk3vmM3FySwFLcoYYaMs7eozGBY34rhkqPnvNa"> 
					<div class="form-group">
					<label for="clientName" class="col-md-2 control-label">Client Name</label>
					<div class="col-md-2">
					<input id="clientName" type="text" name="name" required="required" autofocus="autofocus" class="form-control">
					</div> 
					<label for="primaryCell" class="col-md-2 control-label">Cell Number</label> 
					<div class="col-md-2"><input id="primaryCell" type="text" name="cell_1" required="required" class="form-control"></div>
					
					<label for="alternateCell" class="col-md-2 control-label">Alternate Number</label> 
					<div class="col-md-2"><input id="alternateCell" type="text" name="cell_2" required="required" class="form-control"></div>
					</div> 
					
					<div class="form-group">
					<label for="email" class="col-md-2 control-label">Email</label>
					<div class="col-md-2"><input id="email" type="email" pattern="[a-z0-9._%+-]+@[a-z0-9.-]+\.[a-z]{2,}$" name="email" required="required" class="form-control"></div> 
					
				<label for="alternateCell" class="col-md-2 control-label">Current Address</label>
					
					<div class="col-md-2"><input id="alternateCell" type="text" name="address" required="required" class="form-control"></div>

					<label for="email" class="col-md-2 control-label">Facebook</label> 
					
					<div class="col-md-2"><input id="email" type="text" name="fb" class="form-control"></div></div> 
					
					 <div class="form-group">
                                <label for="found" class="col-md-4 control-label">How did you find us</label>
                                <div class="col-md-6">
                                    <select class="form-control" name="ref" id="ref">
									
									<?php
									$sqlSelectedLG = "SELECT * FROM `ref` where status=1 ";
$sqlSelectedLG = mysqli_query($connection, $sqlSelectedLG);
while ($list = mysqli_fetch_object($sqlSelectedLG)) {
                                    $ref_id = $list->id;
									$ref_title = $list->title;
									?>
															<option value="<?php echo $ref_id; ?>" >  <?php echo $ref_title; ?>  </option>
														
															
<?php } ?>
									</select>
                                </div>
                            </div>
							
							<div id="4" hidden="hidden">
								<div class="form-group"><label for="found" class="col-md-4 control-label">Reference Name</label> <div class="col-md-6"><input id="found" type="text" name="others" class="form-control"></div></div>
							</div>
							
							<div class="form-group"><label for="found" class="col-md-4 control-label">Diary of</label> <div class="col-md-6"><input id="found" type="text" name="booking_name" placeholder="Bride & Groom's Nick Name for Video Intro" class="form-control"></div></div>
					      
					
					
							
							<hr> 
							
							<div id="marriage" hidden="hidden">
							
							<input hidden="hidden" name="marriage_div">
							 <table class="table table-bordered" style="width: 100%;"><thead><tr><th><b>Groom's Details</b></th><th><b>Bride's Details</b></th></tr></thead> <tbody><tr><td><div class="form-group"><label for="groomName" class="col-md-4 control-label">Groom's Name</label> <div class="col-md-6"><input id="groomName" type="text" name="groom_name" class="form-control"></div></div></td> <td><div class="form-group"><label for="brideName" class="col-md-4 control-label">Bride's Name</label> <div class="col-md-6"><input id="brideName" type="text" name="bride_name" class="form-control"></div></div></td></tr> <tr><td>
                                            &nbsp;&nbsp;
                                            <input type="checkbox" name="groom_father" value="checked">Father &nbsp;&nbsp;
                                            <input type="checkbox" name="groom_mother" value="checked">Mother &nbsp;&nbsp;
                                            Sister &nbsp;&nbsp; <select name="groom_sister">
											<option value="0"> 0 </option> <option value="1"> 1 </option> <option value="2"> 2 </option> <option value="3"> 3 </option>
											<option value="4"> 4 </option>
											</select>
											 Brother &nbsp;&nbsp; <select name="groom_brother">
											<option value="0"> 0 </option> <option value="1"> 1 </option> <option value="2"> 2 </option> <option value="3"> 3 </option>
											<option value="4"> 4 </option>
											</select>
											
											
                                        </td> <td>
                                            &nbsp;&nbsp;
                                            <input type="checkbox" name="bride_father" value="checked">Father&nbsp;&nbsp;
                                            <input type="checkbox" name="bride_mother" value="checked">Mother&nbsp;&nbsp;
                                             Sister &nbsp;&nbsp; <select name="bride_sister">
											<option value="0"> 0 </option> <option value="1"> 1 </option> <option value="2"> 2 </option> <option value="3"> 3 </option>
											<option value="4"> 4 </option>
											</select>
											 Brother &nbsp;&nbsp; <select name="bride_brother">
											<option value="0"> 0 </option> <option value="1"> 1 </option> <option value="2"> 2 </option> <option value="3"> 3 </option>
											<option value="4"> 4 </option>
											</select>
                                        </td></tr>


										<tr>
										<td><div class="form-group"><label for="groomFb" class="col-md-4 control-label">Groom Instagram ID</label> <div class="col-md-6"><input id="groomFb" type="text" name="groom_fb" class="form-control"></div></div></td>
										<td><div class="form-group"><label for="brideFb" class="col-md-4 control-label">Bride Instagram ID</label> <div class="col-md-6"><input id="brideFb" type="text" name="bride_fb" class="form-control"></div></div></td>
										</tr> <tr>
										<td><div class="form-group"><label for="groomEmail" class="col-md-4 control-label">Groom's Email</label> <div class="col-md-6"><input id="groomEmail" type="text" name="groom_email" class="form-control"></div></div></td> 
										<td><div class="form-group"><label for="brideEmail" class="col-md-4 control-label">Bride's Email</label> <div class="col-md-6"><input id="brideEmail" type="text" name="bride_email" class="form-control"></div></div></td>
										</tr>
										<tr>
										<td><div class="form-group"><label for="groomMobile" class="col-md-4 control-label">Groom's Mobile</label> <div class="col-md-6"><input id="groomEmail" type="text" name="groom_mobile" class="form-control"></div></div></td> 
										<td><div class="form-group"><label for="brideMobile" class="col-md-4 control-label">Bride's Mobile</label> <div class="col-md-6"><input id="brideEmail" type="text" name="bride_mobile" class="form-control"></div></div></td>
										</tr>
										</tbody></table></div>


										<hr> 
										
										<h5>Event Details</h5> 
										
										<div id="event_details">
										<input hidden="hidden" name="numberOfEvents" id="numberOfEvents" value="1">
										<table id="eventTable" style="width: 100%;"><thead>
										
										<tr><td>Date</td><td>Event</td><td>Time</td><td>Venue</td><td>Parlour</td><td>Decor By</td> <td>Guest</td></tr></thead> 
										
										<tbody>
										<tr>
										<td><input name="event1_date" type="date"></td> 
										<td><input name="event1_event" type="text"></td> 
										<td><input name="event1_time" type="time"></td> 
										<td><input name="event1_venue" size="10" type="text"></td>
										
										<td><input name="event1_parlar" size="10" type="text"></td>
										<td><input name="event1_decor" size="10" type="text"></td>
										
										<td><input name="event1_guest" size="10" type="text"></td>
										</tr></tbody></table>
										
										
										<br> <button type="button" onclick="addEvent()" class="btn btn-success">Add Event</button> <button type="button" onclick="removeEvent()" class="btn btn-danger">Remove Event</button></div><hr><br>


                                      <input type="checkbox" name="checkbox" value="check" id="agree" /> I have read and agreed to the <a href="terms.php" target="popup" onclick="window.open('terms.php','popup','width=800,height=600');   
    return false;">  <font color="red"> <b>Terms and Conditions and Privacy Policy </b> </font>
</a>

<br><br>
										<input name="submit" type="submit" value="Submit" class="btn btn-primary"></form>
										
					<?php } ?>
					
					
					

										
										</div></div></div></div></div></div>
										
										
										

    <!-- Scripts -->
    <script src="assets/js/public.js"></script>
        <script type="text/javascript">
        $(document).on('change',"#type",function () {
            if($("#type").val() === "1") $("#marriage").show();
            else $("#marriage").hide();
        })
      </script>
	  
	   <script type="text/javascript">
        $(document).on('change',"#ref",function () {
            if($("#ref").val() === "4") $("#4").show();
            else $("#4").hide();
        })
      </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()+"_date\" type=\"date\"></td>\n" +
                "                                        <td><input name=\"event"+number_of_events.toString()+"_event\" type=\"text\"></td>\n" +
                "                                        <td><input name=\"event"+number_of_events.toString()+"_time\" type=\"time\"></td>\n" +
                "                                        <td><input name=\"event"+number_of_events.toString()+"_venue\" type=\"text\" size=\"10\" ></td>\n" +
                "                                        <td><input name=\"event"+number_of_events.toString()+"_parlar\" type=\"text\" size=\"10\" ></td>\n" +
                "                                        <td><input name=\"event"+number_of_events.toString()+"_decor\" type=\"text\" size=\"10\" ></td>\n" +				
                "                                        <td><input name=\"event"+number_of_events.toString()+"_guest\" type=\"text\" size=\"10\" ></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>