refer
Fri Aug 11 2023 07:27:15 GMT+0000 (Coordinated Universal Time)
Saved by @NikhilArora #html #css #javascript #php
<?php // error_reporting(E_ALL); // ini_set('display_errors', 1); error_reporting(0); date_default_timezone_set('Asia/Kolkata'); function get($url) { // Initialize a CURL session. $ch = curl_init(); // Return Page contents. curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); //grab URL and pass it to the variable. curl_setopt($ch, CURLOPT_URL, $url); $result = curl_exec($ch); return $result; } $user = $_POST['user']; $offer = $_POST['offer']; $cname = $_POST['cname']; $event = $_POST['event']; $rp = get('https://nextpower.cashinmedia.in/api/v1/checkRefer/0a51d09c-f329-4436-89d5-bdbb52bea07c/' . $offer . '?number=' . $user . ''); // JSON response from the URL $response = $rp; // Decode the JSON response $response_data = json_decode($response, true); $totalClicks = $response_data['clicks']; $count = $response_data['count']; // Extract the 'data' section from the response $data = $response_data['data']; // Check if there's any data to display if (count($data) > 0) { // Echo the table header // echo '<table border="1"> // <tr> // <th>Click</th> // <th>User Amount</th> // <th>Refer Amount</th> // <th>User</th> // <th>Refer</th> // <th>Event</th> // <th>Status</th> // <th>Payment Status</th> // <th>Payment Message</th> // <th>Created At</th> // </tr>'; // // Loop through each data entry and display in table rows // foreach ($data as $entry) { // $userEncoded = preg_replace('/\d{5}(?=\d{4}$)/', 'xxxxx', $entry['user']); // echo '<tr>'; // echo '<td>' . $entry['click'] . '</td>'; // echo '<td>' . $entry['userAmount'] . '</td>'; // echo '<td>' . $entry['referAmount'] . '</td>'; // echo '<td>' . $userEncoded . '</td>'; // Display encoded user // echo '<td>' . $entry['refer'] . '</td>'; // echo '<td>' . $entry['event'] . '</td>'; // echo '<td>' . $entry['status'] . '</td>'; // echo '<td>' . $entry['referPaymentStatus'] . '</td>'; // echo '<td>' . $entry['payMessage'] . '</td>'; // echo '<td>' . $entry['createdAt'] . '</td>'; // echo '</tr>'; // } // // Close the table // echo '</table>'; // } else { // // If there's no data, show a JavaScript alert // echo '<script>alert("No data found.");</script>'; // } ?> <html lang="en" dir="ltr"> <head> <meta charset="utf-8"> <title>FokatCash</title> <link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Montserrat:wght@300;400;500;600&display=swap"> <link rel="stylesheet" href="report.css"> <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.4.1/jquery.min.js" charset="utf-8"></script> <meta name="viewport" content="width=device-width"> </head> <style> .data-table td, .data-table th { font-size: 17px; /* Adjust the value as needed */ } .credited { color: #FFA500; /* Orange color */ } </style> <body> <center> <div class="login-form"> <h1> <font color='#0f0f0f'>REPORT </h1> <center> </body> </html> <div class="statics"> <center><br> <fieldset>Refferer: <?php echo $user; ?> <hr>Camp: <?php echo $cname; ?> <hr>Total Clicks: <?php echo $totalClicks; ?> <hr>Total Conversions: <span id="totalLeads">Calculating...</span> <!-- Placeholder for total leads --> <hr> <font color="#008000"> Cashback Sent: Rs. <span id="totalAcceptedReferAmount">Calculating...</span> </font> <!-- Placeholder for total refer amount --> <hr> <font color="#FFA500">Pending Cashback : Rs.<span id="totalPendingReferAmount">Calculating...</span></font> <hr> </fieldset><br><br> <table class="data-table"> <tr> <th>Camp Name</th> <th>Refer Amount</th> <!--<th>Refer Status</th>--> <th>Cashback Status</th> <th>Time</th> </tr> <?php foreach ($data as $entry) { $userEncoded = preg_replace('/\d{5}(?=\d{4}$)/', 'xxxxx', $entry['user']); $dateTime = new DateTime($entry['createdAt']); // Convert to IST timezone $dateTime->setTimezone(new DateTimeZone('Asia/Kolkata')); // Format the time in desired format $istTimeFormatted = $dateTime->format('Y-m-d H:i:s'); if ($entry['referPaymentStatus'] === 'REJECTED' || $entry['referPaymentStatus'] === 'BLOCKED') { continue; } if ($entry['referPaymentStatus'] == 'ACCEPTED' || $entry['referPaymentStatus'] == 'UNKNOWN' || $entry['referPaymentStatus'] == 'FAILURE') { $cashbackStatus = '<b><span style="color: #198754;">Credited</span></b>'; } elseif ($entry['referPaymentStatus'] == 'PENDING') { $cashbackStatus = '<b><span style="color: #FFA500;">Processing</span></b>'; } else { // Handle other cases or set a default value for $cashbackStatus // For example: $cashbackStatus = 'Unknown Status'; $cashbackStatus = $entry['referPaymentStatus']; } if ($entry['referAmount'] > 0) { echo '<tr>'; // echo '<td>' . $entry['click'] . '</td>'; // echo '<td>' . $entry['userAmount'] . '</td>'; echo '<td>' . $cname . '</td>'; echo '<td>' . $entry['referAmount'] . '</td>'; // echo '<td>' . $userEncoded . '</td>'; // Display encoded user // echo '<td>' . $entry['refer'] . '</td>'; // echo '<td>' . $entry['event'] . '</td>'; // echo '<td>' . $entry['status'] . '</td>'; echo '<td>' . $cashbackStatus . '</td>'; // echo '<td>' . $entry['payMessage'] . '</td>'; echo '<td>' . $istTimeFormatted . '</td>'; echo '</tr>'; } } // Close the table echo '</table>'; } else { // If there's no data, show a JavaScript alert ?> <html lang="en" dir="ltr"> <head> <meta charset="utf-8"> <title>FokatCash</title> <link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Montserrat:wght@300;400;500;600&display=swap"> <link rel="stylesheet" href="report.css"> <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.4.1/jquery.min.js" charset="utf-8"></script> <meta name="viewport" content="width=device-width"> </head> <style> .data-table td, .data-table th { font-size: 17px; /* Adjust the value as needed */ } .credited { color: #FFA500; /* Orange color */ } </style> <body> <center> <div class="login-form"> <h1> <font color='#0f0f0f'>REPORT </h1> <center> </body> </html> <div class="statics"> <center><br> <fieldset>Refferer: <?php echo $user; ?> <hr>Camp: <?php echo $cname; ?> <hr>Total Clicks: <?php echo $totalClicks; ?> <hr>Total Conversions: <span id="totalLeads">Calculating...</span> <!-- Placeholder for total leads --> <hr> <font color="#008000"> Cashback Sent: Rs. <span id="totalAcceptedReferAmount">Calculating...</span> </font> <!-- Placeholder for total refer amount --> <hr> <font color="#FFA500">Pending Cashback : Rs.<span id="totalPendingReferAmount">Calculating...</span></font> <hr> </fieldset><br><br> <h5>No data Found</h5> <?php } ?> </table> <!-- ... Your existing code ... --> <script> // JavaScript to calculate and display the total leads count and total refer amounts document.addEventListener("DOMContentLoaded", function () { // Calculate the total leads count and total refer amounts based on the payment statuses and refer amount conditions var totalLeads = 0; var totalAcceptedReferAmount = 0; var totalPendingReferAmount = 0; var totalFailedReferAmount = 0; var totalUnknownReferAmount = 0; var event = "<?php echo $event; ?>"; <?php foreach ($data as $entry): ?> <?php if ($entry['referPaymentStatus'] !== 'REJECTED' && $entry['referPaymentStatus'] !== 'BLOCKED' && $entry['referAmount'] > 0): ?> totalLeads++; <?php if ($entry['referPaymentStatus'] === 'ACCEPTED'): ?> totalAcceptedReferAmount += parseFloat(<?php echo $entry['referAmount']; ?>); <?php elseif ($entry['referPaymentStatus'] === 'PENDING'): ?> totalPendingReferAmount += parseFloat(<?php echo $entry['referAmount']; ?>); <?php elseif ($entry['referPaymentStatus'] === 'FAILURE'): ?> totalFailedReferAmount += parseFloat(<?php echo $entry['referAmount']; ?>); <?php elseif ($entry['referPaymentStatus'] === 'UNKNOWN'): ?> totalUnknownReferAmount += parseFloat(<?php echo $entry['referAmount']; ?>); <?php endif; ?> <?php endif; ?> <?php endforeach; ?> // Update the HTML content to display the calculated totals var totalLeadsElement = document.getElementById("totalLeads"); totalLeadsElement.textContent = totalLeads; var totalAcceptedReferAmountElement = document.getElementById("totalAcceptedReferAmount"); totalAcceptedReferAmountElement.textContent = totalAcceptedReferAmount.toFixed(2); var totalPendingReferAmountElement = document.getElementById("totalPendingReferAmount"); totalPendingReferAmountElement.textContent = totalPendingReferAmount.toFixed(2); var totalFailedReferAmountElement = document.getElementById("totalFailedReferAmount"); totalFailedReferAmountElement.textContent = totalFailedReferAmount.toFixed(2); var totalUnknownReferAmountElement = document.getElementById("totalUnknownReferAmount"); totalUnknownReferAmountElement.textContent = totalUnknownReferAmount.toFixed(2); }); </script> <br><br><br> <footer id="footer"> <div class="copyright"> © Copyright <strong><span>FokatCash</span></strong> </div> </footer><!-- End Footer --> </div><!-- End statics div --> </center><!-- End center div --> </body><!-- End body tag --> </html><!-- End HTML document -->
Comments