<?php
    include'../connection.php';
    include'../functions.php';
    
    $apiKey="d1db51a3a6a8ef6078fd8bf623dd0008";
	$operator=$_GET['op'];
	$mobile=$_GET['mobile'];
	
	$url="https://www.mplan.in/api/plans.php?";

	$ch = curl_init();

    if (!$ch)
    {
        die("Couldn't initialize a cURL handle");
    }
    curl_setopt($ch, CURLOPT_URL,$url); // Target URL
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
    curl_setopt($ch, CURLOPT_POST, 1);
    
	$apiUrl="apikey=$apiKey&offer=roffer&tel=$mobile&operator=$operator";
	
    curl_setopt($ch, CURLOPT_POSTFIELDS,$apiUrl);
    $result = curl_exec ($ch); 
    
    $result = json_decode($result,true);
    
    echo "<i class='fa fa-close' style='color:red' onclick='hideOfferDiv()'></i>
    <div Id='offerRecordDiv'>";
        $records=$result["records"];
        foreach($records as $key => $recordsVal) 
        {
            $rs=$recordsVal["rs"];
            $desc=$recordsVal["desc"];
            
            echo "<div id='planDetails'>
                        <div id='divAmt' onclick='useAmt($rs)'>
                            <i class='fa fa-inr'></i> <h4>".$rs."</h4><br><br><br>
                        </div>
                        <div id='desc'>
                            <p>".$desc."</p>
                        </div>
                </div><br><br><hr>";
        }
    echo "</div>";
    
?>