<?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");
	$temp_id = $_GET["id"];
	
	
?>


						  
	<?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_id = $list->booking_id;
$booking_name = $list->booking_name;
$booking_type=$list->event_type;
$additional_notes = $list->additional_notes;
$vas = $list->vas;
$pkg_charge = $list->pkg_charge;
$discount = $list->discount;
$total_charge = $list->total_charge;		
$advance = $list->advance;								 
$due = $list->due;	
$added_at = $list->added_at;	
$updated_at = $list->updated_at;													  

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

$settingsSQL = mysqli_query($connection, "SELECT * FROM `settings` where name='mobile' ");
$settingsSQL = mysqli_fetch_object($settingsSQL);
									
$our_mobile = $settingsSQL->value;

$settingsSQL = mysqli_query($connection, "SELECT * FROM `settings` where name='email' ");
$settingsSQL = mysqli_fetch_object($settingsSQL);
									
$our_email = $settingsSQL->value;
								   
?>	

<html>

<style>
body {
  background: rgb(204,204,204); 
}
page {
  background: white;
  display: block;
  padding-top: 2cm;
  padding-left: 2cm;
  padding-right: 2cm;
  margin: auto;
  margin-bottom: 2.0cm;
}
page[size="A4"] {  
  width: 21cm;
  height: 29.7cm; 
}
page[size="A4"][layout="landscape"] {
  width: 29.7cm;
  height: 21cm;  
}

@media print {
  body, page {
    margin: 0;
    box-shadow: 0;
  }
}



</style>

  <head>
    <title>Booking Print</title>
	<meta http-equiv='content-type' content='text/html;charset=utf-8' />
  </head>
  
  <page size="A4">
  
  <body>
<center>
<table style="width:100%;border: 1px solid black;" cellpadding='0' height='' cellspacing='0'  >
 
  <tr align="center" >
    <td  style="width:30%; "  > <img src="assets/images/logo_wd.png" width="50%" /> </br>
<?php echo "$address"; ?> </br>
<?php echo "$our_email"; ?> </br>
<?php echo "$our_mobile"; ?> 

	</td>
    <td style="width:60%;;border-left: 1px solid black;">  
	
	<table style="width:100%" cellpadding='1' height='' cellspacing='0' >
	<tr align="center" >
	<td style="border-bottom: 1px solid black;">
	</br>
 </br>
    <img src='barcode.php?size=20&text=<?php echo $booking_id;  ?>&print=true' alt='Trolltunga Norway' width='' height=''>
  
	
	</td>
	</tr>
	
	<tr align="left" >
	<td style="border-bottom: 1px solid black;">
	
	&nbsp; Client Name:   <?php echo $name;  ?> 
	
	</td>
	</tr>
	<tr align="left" >
	<td style="border-bottom: 1px solid black;">
	
	&nbsp; Cell Number:  <?php echo $cell_1;  ?> 
	
	</td>
	</tr>
	<tr align="left" >
	<td style="border-bottom: 1px solid black;">
	
	&nbsp; Alternate Number:  <?php echo $cell_2;  ?>
	
	</td>
	</tr>
	
	<tr align="left" >
	<td style="border-bottom: 1px solid black;">
	
	&nbsp; Email:  <?php echo $email;  ?>   
	
	</td>
	</tr>
	
	<tr align="left" >
	<td>
	
	&nbsp; How did you find us:   <?php echo $ref;  ?> 
	
	</td>
	</tr>
	</table>
	
	</td> 
  </tr>
</table>

</br></br>

<table style="width:100%" cellpadding='1' height='' cellspacing='0' >
	<tr align="right" >
	   <td style="width:30%"> Diary of &nbsp;&nbsp;
       </td> 
	   <td style="width:70%;border: 1px solid black;" align="left">
	   <?php echo $booking_name;  ?>   
       </td> 
    </tr>
</table>
</br></br>



<?php if($booking_type==1) { ?>

<font size="3"> <b> BRIDE GROOM DETAILS</b> </font></br>
<table style="width:100%;border: 1px solid black;" cellpadding='1' height='' cellspacing='0'  >
	<tr align="left" >
	   <td style="width:50%"> 
	   
	   
	   <table style="width:100%" cellpadding='1' height='' cellspacing='0' border='0' >
	<tr align="left" >
	   <td style="width:100%;border-bottom: 1px solid black;"> 
	   Groom's Name:    <?php echo $groom_name;  ?>    
       </td> 
    </tr>
</table>
	   
	   
	   
	   
	  <table style="width:100%" cellpadding='1' height='' cellspacing='0' border='0' >
	<tr align="left"  >
	   <td style="width:25%;border-bottom: 1px solid black;"> 
	   Father:  <?php echo $groom_father;  ?> 
       </td> 
	    <td style="width:25%;border-bottom: 1px solid black;"> 
	   Mother:  <?php echo $groom_mother;  ?> 
       </td> 
	    <td style="width:25%;border-bottom: 1px solid black;"> 
	   Brother:  <?php echo $groom_brother;  ?>
       </td> 
	    <td style="width:25%;border-bottom: 1px solid black;"> 
	   Sister:   <?php echo $groom_sister;  ?> 
       </td> 
    </tr>
</table>
   
	   

 <table style="width:100%" cellpadding='1' height='' cellspacing='0' border='0' >
	<tr align="left" >
	  <td style="width:50%;border-bottom: 1px solid black;"> 
	   Instagram ID:   <?php echo $groom_fb;  ?> 
       </td> 
	 </tr> <tr align="left" >

	<td style="width:50%;;border-bottom: 1px solid black;"> 
	   Email:   <?php echo $groom_email;  ?>   
       </td> 
    </tr>
	<tr align="left" >

	<td style="width:50%;"> 
	   Mobile:  <?php echo $groom_mobile;  ?>  
       </td> 
    </tr>
</table>

   
	   
       </td> 
	   <td style="width:50%;border-left: 1px solid black;"> 
	    
	   <table style="width:100%" cellpadding='1' height='' cellspacing='0' border='0' >
	<tr align="left" >
	  <td style="width:100%;border-bottom: 1px solid black;"> 
	   Bride's Name:   <?php echo $bride_name;  ?>
       </td> 
    </tr>
</table>

 
	  <table style="width:100%" cellpadding='1' height='' cellspacing='0' border='0' >
	<tr align="left"  >
	   <td style="width:25%;border-bottom: 1px solid black;"> 
	   Father: <?php echo $bride_father;  ?> 
       </td> 
	    <td style="width:25%;border-bottom: 1px solid black;"> 
	   Mother:  <?php echo $bride_mother;  ?>
       </td> 
	    <td style="width:25%;border-bottom: 1px solid black;"> 
	   Brother:  <?php echo $bride_brother;  ?>
       </td> 
	    <td style="width:25%;border-bottom: 1px solid black;"> 
	   Sister:   <?php echo $bride_sister;  ?>
       </td> 
    </tr>
</table>


 <table style="width:100%" cellpadding='1' height='' cellspacing='0' border='0' >
	<tr align="left" >
	  <td style="width:50%;border-bottom: 1px solid black;"> 
	   Instagram ID:    <?php echo $bride_fb;  ?>   
       </td> 
	 </tr> <tr align="left" >

	<td style="width:50%;border-bottom: 1px solid black;"> 
	   Email:  <?php echo $bride_email;  ?>  
       </td> 
    </tr>
	
	<tr align="left" >

	<td style="width:50%;"> 
	   Mobile:  <?php echo $bride_mobile;  ?>  
       </td> 
    </tr>
</table>




       </td> 
    </tr>
</table>

</br></br>

<?php } ?>

<font size="3"> <b> EVENT DETAILS</b> </font></br>
 <table style="width:100%;border: 1px solid black;" cellpadding='3' height='' cellspacing='0'  >
	<tr align="left" >
	  <td style="border-bottom: 1px solid black;border-right: 1px solid black;"> 
	   Date
      </td> 
	  <td style="border-bottom: 1px solid black;border-right: 1px solid black;"> 
	   Event
      </td> 
	 <td style="border-bottom: 1px solid black;border-right: 1px solid black;"> 
	   Time
      </td> 
	  <td style="border-bottom: 1px solid black;border-right: 1px solid black;"> 
	   Venue
      </td> 
	  <td style="border-bottom: 1px solid black;border-right: 1px solid black;"> 
	   Parlour
      </td> 
	  <td style="border-bottom: 1px solid black;border-right: 1px solid black;"> 
	   Decor By
      </td> 
	  <td style="border-bottom: 1px solid black;border-right: 1px solid black;"> 
	   Guest
      </td> 
	  <td style="border-bottom: 1px solid black;border-right: 1px solid black;"> 
	   Package
      </td> 
	  <td style="border-bottom: 1px solid black;"> 
	   Amount
      </td> 
	</tr> 
	 
	 	<?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' ORDER BY TIMESTAMP(t1.date,t1.time) ";

$sqlSelectedLG = mysqli_query($connection, $sqlSelectedLG);
$rowcount = mysqli_num_rows($sqlSelectedLG);
$td_style="border-bottom: 1px solid black;border-right: 1px solid black;";
$sl=0;
while ($list = mysqli_fetch_object($sqlSelectedLG)) {

                                    
                                   $sl=$sl+1;
								   if($sl==$rowcount){$td_style="border-right: 1px solid black;";}
                                    $idn = $list->id;
                                    $diary_of = $list->diary_of;
									$event_type_name = $list->ev_type;
									$event_type = $list->type;
									$date = $list->date;
									$date=date("d-m-Y", strtotime($date));
									$time = $list->time;
									$vd = $list->videoincluded;
									
									$venue = $list->venue;
									$guest = $list->guest;
									 $ph_package = $list->ph_package;
									   $vd_package = $list->vd_package;
									   $ev_notes = $list->ev_notes;
									    $parlar = $list->parlar;
										 $decor = $list->decor;
										 $ev_value = $list->ev_value;
									    $pkg_charge=$pkg_charge+$ev_value;
                                ?>
	 
	 
	<tr align="left" >
	    <td style="<?php echo $td_style; ?>"> 
	   <?php echo $date;  ?>
      </td> 
	 <td style="<?php echo $td_style; ?>"> 
	   <?php echo $event_type_name;  ?>
      </td> 
	  <td style="<?php echo $td_style; ?>"> 
	   <?php echo $time;  ?>
      </td> 
	  <td style="<?php echo $td_style; ?>"> 
	   <?php echo $venue;  ?>
      </td> 
	  <td style="<?php echo $td_style; ?>"> 
	   <?php echo $parlar;  ?>
      </td> 
	  <td style="<?php echo $td_style; ?>"> 
	   <?php echo $decor;  ?>
      </td> 
	 <td style="<?php echo $td_style; ?>"> 
	   <?php echo $guest;  ?>
      </td> 
	 <td style="<?php echo $td_style; ?>"> 
	   <?php echo $ph_package;  ?>
      </td> 
	  <td style="<?php echo $td_style; ?>"> 
	   <?php echo $ev_value;  ?>
      </td> 
	  
	</tr> 
	<?php } ?>
</table>

</br>


<?php if($vas!="") {  ?>
<font size="3"> <b> Value Added Service</b> </font></br>
<table style="width:100%;border: 1px solid black;" cellpadding='2' height='80px' cellspacing='0'  >
	<tr align="left" >
	   <td> 
	   <?php echo $vas;  ?>
       </td> 
    </tr> 
	
</table>

<?php } ?>
<?php if($additional_notes!="") {  ?>

<font size="3"> <b> Notes</b> </font></br>
<table style="width:100%;border: 1px solid black;" cellpadding='2' height='80px' cellspacing='0' >
	<tr align="left" >
	   <td> 
	   <?php echo $additional_notes;  ?>
       </td> 
    </tr> 
	
</table>
<?php } ?>
</br>
<font size="3"> <b> Charges</b> </font></br>
 <table style="width:60%;border: 1px solid black;" cellpadding='3' height='' cellspacing='0' align='center' >
	<tr align="left" >
	  <td style="border-bottom: 1px solid black;;border-right: 1px solid black;"> 
	   Total
      </td> 
	  <td style="border-bottom: 1px solid black;"> 
	   <?php echo $pkg_charge;  ?>
      </td> 
	  
	<?php
	
$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;	
	
if($discount==""){$discount=0;}
if($advance==""){$advance=0;}
$total_charge=round($pkg_charge-(($pkg_charge*$discount)/100));
$due=$total_charge-$advance;
$number = $pkg_charge;
if($discount>0){
$number = $total_charge;	
}



   $no = round($number);
   $point = round($number - $no, 2) * 100;
   $hundred = null;
   $digits_1 = strlen($no);
   $i = 0;
   $str = array();
   $words = array('0' => '', '1' => 'One', '2' => 'Two',
    '3' => 'Three', '4' => 'Four', '5' => 'Five', '6' => 'Six',
    '7' => 'Seven', '8' => 'Eight', '9' => 'Nine',
    '10' => 'Ten', '11' => 'Eleven', '12' => 'Twelve',
    '13' => 'Thirteen', '14' => 'Fourteen',
    '15' => 'Fifteen', '16' => 'Sixteen', '17' => 'Seventeen',
    '18' => 'Eighteen', '19' =>'Nineteen', '20' => 'Twenty',
    '30' => 'Thirty', '40' => 'Forty', '50' => 'Fifty',
    '60' => 'sixty', '70' => 'seventy',
    '80' => 'Eighty', '90' => 'Ninety');
   $digits = array('', 'Hundred', 'Thousand', 'Lakh', 'Crore');
   while ($i < $digits_1) {
     $divider = ($i == 2) ? 10 : 100;
     $number = floor($no % $divider);
     $no = floor($no / $divider);
     $i += ($divider == 10) ? 1 : 2;
     if ($number) {
        $plural = (($counter = count($str)) && $number > 9) ? 's' : null;
        $hundred = ($counter == 1 && $str[0]) ? ' and ' : null;
        $str [] = ($number < 21) ? $words[$number] .
            " " . $digits[$counter] . $plural . " " . $hundred
            :
            $words[floor($number / 10) * 10]
            . " " . $words[$number % 10] . " "
            . $digits[$counter] . $plural . " " . $hundred;
     } else $str[] = null;
  }
  $str = array_reverse($str);
  $result = implode('', $str);
  $points = ($point) ?
    "." . $words[$point / 10] . " " . 
          $words[$point = $point % 10] : '';
  $in_words = $result . "Taka Only";

?>	
	</tr> 
	 <?php if($discount>0) { ?>
	<tr align="left" >
	  <td style="border-bottom: 1px solid black;;border-right: 1px solid black;"> 
	   Discount
      </td> 
	  <td style="border-bottom: 1px solid black;"> 
	   <?php echo $discount;  ?> %
      </td> 
	  
	  
	</tr>
	
	 <?php } 
	 if($discount>0){
	 
	 ?>
	<tr align="left" >
	  <td style="border-bottom: 1px solid black;;border-right: 1px solid black;"> 
	   Net Payable
      </td> 
	  <td style="border-bottom: 1px solid black;"> 
	   <?php echo $total_charge;  ?>
      </td> 
	  
	  
	</tr>
	
	 <?php
} 

	 if($advance>0) { ?>
	
	<tr align="left" >
	  <td style="border-bottom: 1px solid black;;border-right: 1px solid black;"> 
	   Advance
      </td> 
	  <td style="border-bottom: 1px solid black"> 
	   <?php echo $advance;  ?>
      </td> 
	  
	  
	</tr>
	 <?php } ?>
	<tr align="left" >
	 <td style="border-bottom: 1px solid black;;border-right: 1px solid black;"> 
	   Due
      </td> 
	 <td style="border-bottom: 1px solid black"> 
	   <?php echo $due;  ?>
      </td> 
	  
	  
	</tr>
	
	<tr align="left" >
	  <td style=";border-right: 1px solid black;"> 
	   In Words
      </td> 
	  <td> 
	   <?php echo $in_words;  ?> 
      </td> 
	  
	  
	</tr>
	
</table>
</br>


<font size="3"> <b> Delivery</b> </font></br>
 <table style="width:100%;height:100px;border: 1px solid black;" cellpadding='3' height='' cellspacing='0' align='center' >
	<tr align="center" >
	  <td style="border-right: 1px solid black;" valign="top"> 
	  Photo Delivery
      </td> 
	  <td style=";border-right: 1px solid black;" valign="top"> 
	   Video Delivery
      </td> 
<td valign="top"> 
	   All Delivery
      </td> 
	  
	  </tr>
 </table>
 
 
 
 
 </br>
  </br> </br> </br></br> </br>
 
  <table style="width:100%;height:100px;border-top: 1px solid black;" cellpadding='3' height='' cellspacing='0' align='center' >
	<tr align="center" >
	<td style="" valign="top"> 
	   
      </td>
	  <td style="" valign="top"> 
	  Client</br>
	  Signature & Date
      </td> 
	  <td style="" valign="top"> 
	   
      </td> 
<td valign="top"> 
	  Wedding Diary</br>
	  Signature & Date
      </td> 
	  <td style="" valign="top"> 
	   
      </td>
	  </tr>
 </table>
 
 
 
 
 
 
 
 
 </center> 
 
 
  </body>
  
  </page>
  
</html>