<?php

include 'load.php';


?>

<!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>Receipt | Recharge and Billing System | ORMS | Dashbaord</title>
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" crossorigin="anonymous">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/Dropify/0.2.2/css/dropify.min.css" integrity="sha512-EZSUkJWTjzDlspOoPSpUFR0o0Xy7jdzW//6qhUkoZ9c4StFkVsp9fbbd0O06p9ELS3H486m4wmrCELjza4JEog==" crossorigin="anonymous" referrerpolicy="no-referrer" />

    <?php
	require_once 'headercss.php';
	?>

</head>

<body>

        <!--**********************************
        Main wrapper start
    ***********************************-->
    <div id="main-wrapper">
	
<?php
require_once 'header.php';
?>

        <!--**********************************
            Sidebar start
        ***********************************-->
        <div class="deznav">
            <div class="deznav-scroll">
<?php

require_once 'sidebarmenu.php';

?>
            </div>
        </div>
        <!--**********************************
            Sidebar end
        ***********************************-->
		
        <!--**********************************
            Content body start
        ***********************************-->
        <div class="content-body">
            <!-- row -->
            <div class="container-fluid">
			
				<div class="row">
				<div class="col-xl-12 col-xxl-12 col-sm-12">
				<div class="alert alert-danger bg-danger text-white" role="alert">
				<strong>Alert!</strong> ඔබගේ ගිනුම තහවුරු කිරීම අසම්පුර්නයි.<a href="identity_verify.php" class="btn btn-success float-right" style="padding: 0px 3px;">සම්පුර්න කරන්න</a>
				</div>
				</div>
				</div> 
				
                <div class="row page-titles mx-0">
                    <div class="col-sm-6 p-md-0">
                        <div class="welcome-text">
                            <h4>Payment Receipt</h4>
                        </div>
                    </div>
                    <div class="col-sm-6 p-md-0 justify-content-sm-end mt-2 mt-sm-0 d-flex">
                        <ol class="breadcrumb">
                            <li class="breadcrumb-item"><a href="home.php">Home</a></li>
							<li class="breadcrumb-item active"><a href="javascript:void(0);">Receipt</a></li>
                            <li class="breadcrumb-item active"><a href="javascript:void(0);">Payment Receipt</a></li>
                        </ol>
                    </div>
                </div>
				
			<div class="container" style="max-width: 33rem;">
				<div class="card">
				<div class="card-body">
					<?php 
	
					if (isset($_GET['reloadno']))	
					{
						
					$refnumber=$_GET['refnumber'];
					$reloadno=$_GET['reloadno'];

					$stmt = $DB_con->prepare('SELECT * FROM ormsreload WHERE refno="'.$refnumber.'" and number="'.$reloadno.'"');

					$stmt->execute();

					if($stmt->rowCount() > 0)

					{

					while($row=$stmt->fetch(PDO::FETCH_ASSOC))

					{

					extract($row);
				
					?>

					<h1 class="text-center"><i class="fa fa-check-circle-o" style="font-size:64px;color:#2ecc40;text-align:center;"></i></h1>
					<h1 class="text-center" style="font-weight;color:#2ecc40;">PAYMENT SUCCESSFUL!</h1>
					<h4 class="text-center">REF#<?php echo $row['refno']; ?></h4>
					<br>
					<h5 class="text-center">You Transferred</h5>
					<br>
					<h1 class="text-center" style="font-weight:bold;">LKR <?php echo number_format((float)$row['amount'],2); ?></h1>
					<br>
					<p class="text-center">To</p>
					<br>
					<h4 class="text-center" style="font-weight:bold;"><?php echo $row['number']; ?></h4>
					<br>
					<p class="text-center">On</p>
					<br>
					<p class="text-center"><?php echo date_format(date_create($row['add_date']),"M d, Y"); ?> <?php echo date_format(date_create($row['add_date']),"h:i:s A"); ?></p>

					<div class="row mt-4">
						<a class="btn btn-secondary col-md-4" href="pay_desk.php">BACK TO PAY DESK</a>
						<button class="btn btn-success col-md-8" onclick="printDiv('printableArea')">PRINT POS</button>
					</div>
					
					<div id="printableArea" style="display:none;">
					
					<h1 class="text-center" style="font-weight:bold;color:#000000;"><?php

												$id = $customer;  

												$query = $DB_con->prepare('SELECT shopname FROM ormsregister WHERE reid="'.$id.'"');

												$query->execute();

												$result = $query->fetch();

												echo $result['shopname'];

												?></h1>
					<h4 class="text-center" style="color:#000000;"><?php

												$id = $customer;  

												$query = $DB_con->prepare('SELECT mobilenumber FROM ormsregister WHERE reid="'.$id.'"');

												$query->execute();

												$result = $query->fetch();

												echo $result['mobilenumber'];

												?></h4>
					<h4 class="text-center" style="color:#000000;">Mobile : <?php

												$id = $customer;  

												$query = $DB_con->prepare('SELECT shopaddress FROM ormsregister WHERE reid="'.$id.'"');

												$query->execute();

												$result = $query->fetch();

												echo $result['shopaddress'];

												?></h4>
					<hr>
					<h3 class="text-center" style="font-weight:bold;">Bill Payment Information</h3>
					<hr>
					<h4 class="text-center" style="font-weight:bold;">Date : <?php echo date_format(date_create($row['add_date']),"M d, Y"); ?> <?php echo date_format(date_create($row['add_date']),"h:i:s A"); ?></h4>
					<h4 class="text-center" style="font-weight:bold;">Service Type : <?php

												$id = $row['provider'];  

												$query = $DB_con->prepare('SELECT sname FROM ormsservices WHERE scode="'.$id.'"');

												$query->execute();

												$result = $query->fetch();

												echo $result['sname'];

												?></h4>
					<h4 class="text-center" style="font-weight:bold;">Account No : <?php echo $row['number']; ?></h4>
					<h4 class="text-center" style="font-weight:bold;">LKR <?php echo number_format((float)$row['amount'],2); ?></h4>
					<h4 class="text-center" style="font-weight:bold;">Ref No : <?php echo $row['refno']; ?></h4>
					<hr>
					<h4 class="text-center">Thank You Come Again</h4>
					
					</div>
					
					<?php 
					} 
					}
					}
					?>
			</div>
			</div>	
        </div>
		
        </div>
        </div>
        <!--**********************************
            Content body end
        ***********************************-->

		<?php
		require_once 'footer.php';
		?>

		<!--**********************************
           Support ticket button start
        ***********************************-->

        <!--**********************************
           Support ticket button end
        ***********************************-->


    </div>
    <!--**********************************
        Main wrapper end
    ***********************************-->

    <?php
	require_once 'footerjs.php';
	?>
    
	        <script src="https://cdnjs.cloudflare.com/ajax/libs/Dropify/0.2.2/js/dropify.min.js" integrity="sha512-8QFTrG0oeOiyWo/VM9Y8kgxdlCryqhIxVeRpWSezdRRAvarxVtwLnGroJgnVW9/XBRduxO/z1GblzPrMQoeuew==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>

<script>

function printDiv(printableArea){
	
var printContents = document.getElementById(printableArea).innerHTML;
var originalContents = document.body.innerHTML;

document.body.innerHTML = printContents;

window.print();

document.body.innerHTML = originalContents;

}

</script>

<script>

$('.dropify').dropify();

	function exportTableToExcel(tableID, filename = ''){
    var downloadLink;
    var dataType = 'application/vnd.ms-excel';
    var tableSelect = document.getElementById(tableID);
    var tableHTML = tableSelect.outerHTML.replace(/ /g, '%20');
    
    // Specify file name
    filename = filename?filename+'.xls':'excel_data.xls';
    
    // Create download link element
    downloadLink = document.createElement("a");
    
    document.body.appendChild(downloadLink);
    
    if(navigator.msSaveOrOpenBlob){
        var blob = new Blob(['\ufeff', tableHTML], {
            type: dataType
        });
        navigator.msSaveOrOpenBlob( blob, filename);
    }else{
        // Create a link to the file
        downloadLink.href = 'data:' + dataType + ', ' + tableHTML;
    
        // Setting the file name
        downloadLink.download = filename;
        
        //triggering the function
        downloadLink.click();
    }
}
</script>

<script>

$(document).ready(function(){

    loadGallery(true, 'a.thumbnail');

    //This function disables buttons when needed
    function disableButtons(counter_max, counter_current){
        $('#investow-previous-image, #investow-next-image').investow();
        if(counter_max == counter_current){
            $('#investow-next-image').hide();
        } else if (counter_current == 1){
            $('#investow-previous-image').hide();
        }
    }

    /**
     *
     * @param setIDs        Sets IDs when DOM is loaded. If using a PHP counter, set to false.
     * @param setClickAttr  Sets the attribute for the click handler.
     */

    function loadGallery(setIDs, setClickAttr){
        var current_image,
            selector,
            counter = 0;

        $('#investow-next-image, #investow-previous-image').click(function(){
            if($(this).attr('id') == 'investow-previous-image'){
                current_image--;
            } else {
                current_image++;
            }

            selector = $('[data-image-id="' + current_image + '"]');
            updateGallery(selector);
        });

        function updateGallery(selector) {
            var $sel = selector;
            current_image = $sel.data('image-id');
            $('#image-gallery-caption').text($sel.data('caption'));
            $('#image-gallery-title').text($sel.data('title'));
            $('#image-gallery-image').attr('src', $sel.data('image'));
            disableButtons(counter, $sel.data('image-id'));
        }

        if(setIDs == true){
            $('[data-image-id]').each(function(){
                counter++;
                $(this).attr('data-image-id',counter);
            });
        }
        $(setClickAttr).on('click',function(){
            updateGallery($(this));
        });
    }
});
</script>

<script>

		function Publiinvested_teainvestrs(id){
			
			$.ajax({
				url:'publiinvested_teainvestrs.php',
				method:'POST',
				data:{id:id},
				success:function(data){
					location.reload();

				}
			});

		}

		function Reject_ads(id){
				alert(id);
		$.ajax({
			url:'reject_teainvestrs.php',
			method:'POST',
			data:{id:id},
			success:function(data){
				location.reload();

			}
		});

	}
</script>
	
</body>
</html>