<?php session_start();
include("./../config/config.php");  
include("./backend/validated_admin.php");  
$sql = "SELECT * FROM contact_master ";
   
    $myquery=$conn->query($sql);
  $mydara= $myquery->fetchAll()  ;
  
  $rows_found = $myquery->rowCount();
  foreach ($mydara as $key ) {
     $banner_image= $key['banner_image'];
     $hubspot= $key['email_hubspot'];
     
  }


?>
<!DOCTYPE html>
<html lang="en">
   <head>
      <meta charset="UTF-8">
      <title>Email Contact Form icouponworld.com</title>
      <meta http-equiv="X-UA-Compatible" content="IE=edge">
      <link id="favicon" rel="icon" type="image/x-icon" href="../images/web-images/home/favicon.png">
      <meta name="robots" content="index, follow" />
      <meta name="author" content="Design Collection">
      <meta name="description" content="Here's one more (easy-to-use) option to connect Contact Form by Icouponworld" />
      <link rel="canonical" href="email-hubspot-subscriber.php"/>
      <meta name="keywords" content="Contact Form, iCouponWorld stores, products, coupon, coupon code, promo code, cashback, offer, promotion, deal">
      <!-- Viewport configuration, scaling options -->
      <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
      <!-- Bootstrap CSS -->
      <link href="../css/icouponworld.css" rel="stylesheet">
      <!-- CSS Stylesheet -->
      <link href="../css/dashboard.css" rel="stylesheet">
      <link href="../css/dataTables.bootstrap5.min.css" rel="stylesheet">
      <!-- Font Awesome icon -->
      <link href="../fontawesome/css/fontawesome.css" rel="stylesheet" />
      <!-- Roboto font  -->
      <link rel="preconnect" href="https://fonts.googleapis.com">
      <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
      <link href="https://fonts.googleapis.com/css2?family=Roboto:ital,wght@0,100;0,300;0,400;0,500;0,700;1,100;1,300;1,400;1,500;1,700&display=swap" rel="stylesheet">
      <!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
      <!--[if lt IE 9]>
      <script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
      <script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script>
      <![endif]-->
   </head>
   <body>
      <!--unique id begin -->
      <div id="s_mm">
         <!--scroll-top Begin-->
         <div id="scroll-top">
            <!--sidebarwrapper Begin-->
            <div id="sidebarwrapper">
               <!--Sidebarmenu Begin-->
                <?php include("./includefiles/sidebar.php"); ?>
               <!--Sidebarmenu End-->
               <!--content-wrapper Begin-->
               <div id="content-wrapper" class="d-flex flex-column dashboard-navbar">
                  <div id="maincontent">
                     <!-- Navbar Topbar Begin-->
                     <?php include("./includefiles/header.php"); ?>
                     <!-- Navbar Topbar End-->
                     <!-- Container Begin-->
                     <div class="container-fluid px-4">
                        <div class="d-sm-flex align-items-center justify-content-between mb-4">
                           <h3>
                            Email Subscriber
                           </h3>
                        </div>
                        <?php include("./includefiles/coupon_count.php"); ?>
                        <div class="col-md-12">
                              <div class="card border-0  shadow mb-4">
                                 <div class="card-header bg-white border-bottom py-3">
                                    <h6 class="m-0 fw-bold text-inherit">Email Subscriber</h6>
                                 </div>
                        <div class="card-body">
               <div class="table-responsive m-3">
                  <!--Table  Begin-->
                  <table class="table table-striped table-hover" id="table">
                     <thead class="bg-blue fs-13">
                        <tr class= "user">

                           <th class= "user1">S.no</th>                          
                           <th class= "user1">Email</th>                           
                           <th class= "user1"> Date</th>
                          
                           
                        </tr>
                     </thead>
                     <tbody class="fs-13">
                        <?php
                        $sql = "SELECT * FROM email_subscriber";
                        $sql_query = $conn->query($sql);
                        $mydara_create=$sql_query->fetchAll();
                        $row_found = $sql_query->rowCount();
                           foreach($mydara_create as $row){
                               $s_no = $s_no+1; 
                              
                               $email_id = $row['user_email'];
                               $date = $row['datecreated'];
                              
                               
                            ?>
                        <tr class="data user">
                           <td class= "user2"><?=$s_no?></td>                          
                                                 
                           <td class= "user2"><?=$email_id?></td>
                           <td class= "user2"><?=$date?></td>
                           </tr>
                          
<?php } ?>
                           
                     </tbody>
                  </table>
                              </div>
                              </div>
                              <div class="paging-container d-flex justify-content-end" id="tablePaging">
		</div>
      <div class="download-buttons text-center p-1">
                           <button onClick="tableToCSV()" type="button" class="btn btn-primary bg-success fs-12"> Download
                           CSV</button>
                        </div>
                              </div>
                              </div>
                     </div>
                     <!-- Container End-->
                  </div>
                  <!--Copyright Begin-->
                  <?php include("./includefiles/footer.php"); ?>
                  <!--Copyright End-->
               </div>
               <!--content-wrapper End-->
            </div>
            <!--sidebarwrapper End-->
            <!--Scroll to top Begin-->
            <a class="scroll-to-top rounded" href="#scroll-top">
            <i class="fas fa-angle-up"></i>
            </a>
            <!--Scroll to top End-->
            <script src="../js/jquery-3.4.1.min.js"></script>
               <!-- Jquery Script End-->
               <!-- Bootstrap Script Begin-->
               <script src="../js/bootstrap.bundle.min.js"></script>
                <!-- Bootstrap Script End-->
               <!-- dashboard-icouponworld.js Begin -->
               <script src="../js/dashboard-icouponworld.js"></script>
                <!-- dashboard-icouponworld.js End -->
                 <!--dataTables.bootstrap5.min.js Begin -->
			   <script src="../js/dataTables.bootstrap5.min.js"></script>
             <!--dataTables.bootstrap5.min.js End -->
              <!--jquery.dataTables.min.js Begin -->
			   <script src="../js/jquery.dataTables.min.js"></script>
            <script src="../js/pagination.js"></script>
            <script src="../js/table2csv.js"></script>
            <script src="../js/pdfmake.min.js"></script>
            <script>
                function tableToCSV() {
 
 // Variable to store the final csv data
 var csv_data = [];

 // Get each row data
 var rows = document.getElementsByClassName('user');
 for (var i = 0; i < rows.length; i++) {

     // Get each column data
     var cols = rows[i].querySelectorAll('.user1,.user2');

     // Stores each csv row data
     var csvrow = [];
     for (var j = 0; j < cols.length; j++) {

         // Get the text data of each cell
         // of a row and push it to csvrow
         csvrow.push(cols[j].innerHTML);
     }

     // Combine each column value with comma
     csv_data.push(csvrow.join(","));
 }

 // Combine each row data with new line character
 csv_data = csv_data.join('\n');

 // Call this function to download csv file 
 downloadCSVFile(csv_data);

}

function downloadCSVFile(csv_data) {

 // Create CSV file object and feed
 // our csv_data into it
 CSVFile = new Blob([csv_data], {
     type: "text/csv"
 });

 // Create to temporary link to initiate
 // download process
 var temp_link = document.createElement('a');

 // Download csv file
 temp_link.download = "userdata.csv";
 var url = window.URL.createObjectURL(CSVFile);
 temp_link.href = url;

 // This link should not be displayed
 temp_link.style.display = "none";
 document.body.appendChild(temp_link);

 // Automatically click the link to
 // trigger download
 temp_link.click();
 document.body.removeChild(temp_link);
}
               $(function () {
  load = function() {
				window.tp = new Pagination('#tablePaging', {
					itemsCount: <?=$row_found?>,
					onPageSizeChange: function (ps) {
						console.log('changed to ' + ps);
					},
					onPageChange: function (paging) {
						//custom paging logic here
						console.log(paging);
						var start = paging.pageSize * (paging.currentPage - 1),
							end = start + paging.pageSize,
							$rows = $('#table').find('.data');

						$rows.hide();

						for (var i = start; i < end; i++) {
							$rows.eq(i).show();
						}
					}
				});
			}

		load();
	});

               </script>
         </div>
         <!--scroll-top End-->
      </div>
      <!--unique id End -->
   </body>
</html>
