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

<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <!-- Meta, title, CSS, favicons, etc. -->
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">

    <title></title>
	
	
	<style>
        
        h1,h2,h3,h4,h5,h6{
            margin: 0;
            padding: 0;
        }
        p{
            margin: 0;
            padding: 0;
        }
        .container7{
            width: 100%;
            margin-right: auto;
            margin-left: auto;
			background-color: #F6F6F6;
			page-break-after: always;
        }
        .brand-section{
           background-color: #0059aa;
           padding: 10px 40px;
		   border: 1px solid gray;
		   height:100px;
        }
		.brand-section1{
           background-color: #F6F6F6;
           padding: 10px 40px;
		   font-size:3px;
		   border: 1px solid gray;
        }
        .logo{
            width: 50%;
        }
		.tbl{
		background-color: #F6F6F6;	
		}

        .row{
            display: flex;
            flex-wrap: wrap;
        }
        .col-6{
            width: 60%;
            flex: 0 0 auto;
			/*background-color: #F6F6F6;*/
        }
        .text-white{
            color: #fff;
			font-size:10px;
        }
		
		.text-white1{
            color: #fff;
			font-size:10px;
        }
		
		
		.text-black{
			font-size:10px;
        }
        .company-details{
            float: right;
            text-align: right;
			/*font-size:10px;*/
        }
		.wrd{
             text-align: left;
			font-size:10px;
        }
        .body-section{
            padding: 16px;
            border: 1px solid gray;
			background-color: #F6F6F6;
        }
        .heading{
            font-size: 10px;
            margin-bottom: 08px;
        }
        .sub-heading{
            color: #262626;
            margin-bottom: 05px;
			padding-left:3px;
			font-size:8px;
			text-align:justify;
        }
		
		.sub-head{
            /*color: #3366ff;*/
            /*margin-bottom: 05px;*/
			padding-left:10px;
			font-size:10px;
			/*text-align:justify;*/
        }
		
        table{
            background-color: #fff;
            width: 100%;
            border-collapse: collapse;
        }
        table thead tr{
            border: 1px solid #111;
            background-color: #f2f2f2;
        }
        table td {
            vertical-align: middle !important;
            text-align: center;
        }
        table th, table td {
            padding-top: 08px;
            padding-bottom: 08px;
        }
        .table-bordered{
            box-shadow: 0px 0px 5px 0.5px gray;
        }
        .table-bordered td, .table-bordered th {
            border: 1px solid #dee2e6;
        }
        .text-right{
            text-align: end;
        }
		.text-left{
            text-align: left;
			font-size:10px;
        }
		.w-5{
            width: 5%;
        }
		.w-35{
            width: 35%;
        }
        .w-20{
            width: 20%;
        }
        .float-right{
            float: right;
        }
    </style>

   </head>
   
   <body>
   
   <?php
   
  $sql81 = "SELECT payment_mode.name,currency.currencyName,invoices.grand_total_amount,collected_payments.amount_paid,collected_payments.inv_id,collected_payments.payment_desc,collected_payments.rec_no,collected_payments.date,clients.client_fname,clients.client_lname,clients.client_email FROM clients,collected_payments,payment_mode,currency,invoices 	
					WHERE collected_payments.payment_id = {$payment_id} and clients.client_id=collected_payments.client_id and collected_payments.payment_mode_id=payment_mode.payment_mode_id and currency.currency_id=collected_payments.currency_id and collected_payments.inv_id=invoices.inv_id";

				$result81 = $conn->query($sql81);
   
 	
				
				while($data81 = mysqli_fetch_array($result81))
							{
							$recNo = $data81['rec_no'];
							$customer = $data81['client_fname']." ".$data81['client_lname'];
							$client_name = $data81['client_fname'];
							$client_email = $data81['client_email'];
							$payment_mode = $data81['name'];
							$paymentDesc = $data81['payment_desc'];
							$invId = $data81['inv_id'];
							$AMountPaid = $data81['amount_paid'];
							$InvAmount = $data81['grand_total_amount'];
							$Amount1 = number_format($data81['amount_paid'],2);
							$rec_date = $data81['date'];
							$currencyName = $data81['currencyName'];
				            }
							
							$sql818 = "SELECT sum(amount_paid) FROM collected_payments 	
					WHERE inv_id = {$invId}";

				$result818 = $conn->query($sql818);
				while($data818 = mysqli_fetch_array($result818))
							{
						$Amount = $data818['sum(amount_paid)'];		
							}
							
							$balanceDue = number_format(($InvAmount - $Amount),2);
							
							$recDate = date('d-m-Y', strtotime($rec_date));
							
				$num = $AMountPaid;	
				function numberTowords($num)
{ 
$ones = array( 
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" 
); 
$tens = array( 
1 => "ten",
2 => "twenty", 
3 => "thirty", 
4 => "forty", 
5 => "fifty", 
6 => "sixty", 
7 => "seventy", 
8 => "eighty", 
9 => "ninety" 
); 
$hundreds = array( 
"hundred", 
"thousand", 
"million", 
"billion", 
"trillion", 
"quadrillion" 
); //limit t quadrillion 
$num = number_format($num,2,".",","); 
$num_arr = explode(".",$num); 
$wholenum = $num_arr[0]; 
$decnum = $num_arr[1]; 
$whole_arr = array_reverse(explode(",",$wholenum)); 
krsort($whole_arr); 
$rettxt = ""; 
foreach($whole_arr as $key => $i){ 
if($i < 20){ 
$rettxt .= $ones[$i]; 
}elseif($i < 100){ 
$rettxt .= $tens[substr($i,0,1)]; 
$rettxt .= " ".$ones[substr($i,1,1)]; 
}else{ 
$rettxt .= $ones[substr($i,0,1)]." ".$hundreds[0]; 
$rettxt .= " ".$tens[substr($i,1,1)]; 
$rettxt .= " ".$ones[substr($i,2,1)]; 
} 
if($key > 0){ 
$rettxt .= " ".$hundreds[$key]." "; 
} 
} 
if($decnum > 0){ 
$rettxt .= " and "; 
if($decnum < 20){ 
$rettxt .= $ones[$decnum]; 
}elseif($decnum < 100){ 
$rettxt .= $tens[substr($decnum,0,1)]; 
$rettxt .= " ".$ones[substr($decnum,1,1)]; 
} 
} 
return $rettxt; 
}
		 
			
				
			
   ?>
   
 <div class="container7">
        <div class="brand-section">
            <div class="row">
                <div class="col-6">
                    <!--<h1 class="text-white">Kreen Logistics Co Ltd</h1>-->
				<?php
				$sql362a = "SELECT company_details.logo FROM company_details";
              $result362a = $conn->query($sql362a);
			  $num362a = mysqli_num_rows($result362a);
			          if($num362a>0){
              while ($row362a = mysqli_fetch_array($result362a)){
						$image_urla = substr($row362a['logo'], 3);
						echo "<img src = ".$image_urla." width='40%' height='50px'>";
			                }
                            }	
					?>	
					
                </div>
                <div class="col-6">
                    <div class="company-details">
                        <p class="text-white">+255764508508</p>
						<p class="text-white">info@brightvision.co.tz</p>
						<p class="text-white">Plot No. 314/322L</p>
						<p class="text-white">Mbagala Kibondemaji</p>
						<p class="text-white">P O Box 72539</p>
						<p class="text-white">Dar es Salaam</p>
						<p class="text-white">Tanzania</p>
						<p class="text-white">TIN: 108-382-228</p>
						<p class="text-white">VRN: 40023874L</p>
                    </div>
                </div>
            </div>
        </div>
		
		<div class="brand-section1">
            <div class="row">
                <div class="col-12">
					<h1 class="text-black"><center>Recept</center></h1>
                </div>
            </div>
        </div>

        <div class="body-section">
		
		
            <div class="row">
			   <table border="0" class="tbl" style="width:100%">
			   <tr>
			   
			   <td style="width:62%">
                <div class="col-6">
                    <p class="sub-heading"><b>Recept No:</b>  <?php print $recNo; ?></p>
                    <p class="sub-heading"><b>Received From:</b>  <?php print $customer; ?> </p>
					<p class="sub-heading"><b>Amount in Words:</b>  <?php print numberTowords($num); ?> <?php print $currencyName; ?> <?php print 'Only'; ?> </p>
					<p class="sub-heading"><b>Payment Of:</b> <?php print $paymentDesc; ?>  </p>
					<p class="sub-heading"><b>Amount Received By:</b> <?php print 'Kreen Logistics Co Ltd'; ?>  </p>
                </div>
				</td>
			   
			   <td style="width:38%">
                <div class="col-6">
                    <h2 class="sub-heading">Date: <?php print $recDate; ?></h2>
                    <p class="sub-heading"><b>Amount Of:</b> <?php print $currencyName; ?> <?php print $Amount1; ?> </p>
					<p class="sub-heading"><b>Payment Mode:</b> <?php print $payment_mode; ?>  </p>
                    <p class="sub-heading"><b>Balance Due:</b> <?php print $currencyName; ?> <?php print $balanceDue; ?> </p>
                </div>
				</td>
				
				</tr>
				</table>
            </div>
        </div>



              
    </div>
	
	<div style="page-break-inside: avoid;">
	
	
	</div>
   
   
 		  
</body>
</html>	
			  
		
		
 
  
		
			  
			  
			  
			  
			  
			  
			  
			  
			  
  
		
			  
  
		
			  
			  
			  
		
		
 
  
		
			  
			  
			  
		
		
 
  
		
			  
			  
			  
			  
		
		
 
  
		
			  
			  
			  
			  
			 
			  
			  
			  
			 
 
		
			  
			  
			  
			  
		
 
  	  
			  
			  
			 
			  
			  
			  
			  
				 
				 
   
   