<?php session_start();
include("./../config/config.php");  
include("./backend/validated_admin.php");  

?>
<!DOCTYPE html>
<html lang="en">
   <head>
      <meta charset="UTF-8">
      <title>Dashboard - iCouponWorld | Coupons | Discounts| Promo Codes</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="This is the dashboard of icouponworld with the help of which you can manage the whole website." />
      <link rel="canonical" href="dashboard.php"/>
      <meta name="keywords" content="Dashboard, Total Coupon, Total Affiliate Company, Total Brand, Total Store, Total Merchant">
      <!-- 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">
      <!-- DataTables Bootstrap CSS -->
      <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">
         <!-- Preloader Begin-->
       <!--   <div class="preloader">
            <div class="loading">
               <img src="../images/web-images/dashboard/loader.gif" class="mx-auto d-flex"> 
               <h4 class="text-center fw-bold pt-3">loading...</h4>
            </div>
         </div> -->
         <!-- Preloader End-->
         <!--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>
                              Dashboard
                           </h3>
                        </div>
                        <?php include("./includefiles/coupon_count.php"); ?>
                        <div class="row">
                           <!--Coupon uploaded  Begin-->
                           <div class="col-md-6">
                              <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">Total Coupon uploaded </h6>
                                 </div>
                                 <div class="card-body">
                                    <div class="table-responsive">
                                       <!--Table  Begin-->
                                   

                                       <table id="affiliatecompany" class="table table-striped table-hover">
                                          <thead class="table-light-success">
                                             <tr>
                                                <th>Company Name</th>
                                                <th>Coupon</th>
                                             </tr>
                                          </thead>
                                          <tbody class="text-capitalize">

                                             <?php  $data = affiliate_company();
                                             foreach($data as $row){ ?>
                                              <tr>
                                                <td><?php echo $row['from_site']?></td>
                                                <td><?php echo total_coupan($row['from_site']) ?></td>
                                             </tr>

                                          <?php   }   ?>
                                            
                                          </tbody>
                                          <tfoot>
                                             <tr>
                                                <th>Company Name</th>
                                                <th>Coupon</th>
                                             </tr>
                                          </tfoot>
                                       </table>
                                       <!--Table  End-->
                                    </div>
                                    
                                 </div>
                              </div>
                           </div>
                           <!--Coupon uploaded End-->
                           <!--Product uploaded Begin-->
                           <div class="col-md-6">
                              <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">Total Product uploaded</h6>
                                 </div>
                                 <div class="card-body">
                                    <div class="table-responsive">
                                       <!--Table  Begin-->
                                       <table class="table table-striped table-hover" id="company_wise">
                                          <thead class="table-light-success">
                                             <tr>
                                                <th>Company Name</th>
                                                <th>Product</th>
                                             </tr>
                                          </thead>
                                          <tbody class="text-capitalize">
                                             <?php  $data = affiliate_product();
                                             foreach($data as $row){ ?>
                                              <tr>
                                                <td><?php echo $row['company_name']?></td>
                                                <td><?php echo products_count(addslashes($row['company_name']))?></td>
                                             </tr>

                                          <?php   }   ?>
                                          </tbody>
                                          <tfoot>
                                             <tr>
                                                <th>Company Name</th>
                                                <th>Product</th>
                                             </tr>
                                          </tfoot>
                                       </table>
                                       <!--Table  End-->
                                    </div>
                                   
                                 </div>
                              </div>
                           </div>
                           <!---Product uploaded End-->
                           <!--Coupon and Product uploaded by merchant Begin-->
                           <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 text-inherit">Coupon and product uploaded by merchant</h6>
                                 </div>
                                 <div class="card-body">
                                    <div class="table-responsive">
                                       <!--Table  Begin-->
                                       <table class="table table-striped table-hover" id="merchant">
                                          <thead class="table-light-success">
                                             <tr>
                                                <th>Merchant Name</th>
                                                <th>Company Name</th>
                                                <th>Coupon</th>
                                                 <th>product</th>
                                             </tr>
                                          </thead>
                                          <tbody>
                                         <?php $sql = "SELECT * FROM vendor_master ";
   
    $myquery=$conn->query($sql);
  $mydara= $myquery->fetchAll()  ;
  
  $rows_found = $myquery->rowCount();

 foreach ($mydara as $key ) {
 	$rows_found_s=0;
     $rowId= $key['rowId'];
     $full_name= $key['full_name'];
    
     $company_name = $key['company_name'];

     $sql_s = "SELECT created_by FROM coupon WHERE created_by='$rowId' ";
     $myquery_s=$conn->query($sql_s);
  $mydara_s= $myquery->fetchAll()  ;
  
  $rows_found_s = $myquery->rowCount();

   $sql_p = "SELECT created_by FROM product_master WHERE created_by='$rowId' ";
     $myquery_p=$conn->query($sql_p);
  $mydara_p= $myquery_p->fetchAll()  ;
  
  $rows_found_p = $myquery_p->rowCount();
    
        
    
  
   ?>
                                             <tr>
                                                <td><?=$full_name?></td>
                                                <td><?=$company_name?></td>
                                                <td><?=$rows_found_s?></td>
                                                <td><?=$rows_found_p?></td>
                                             </tr>
                                            
                                            <?php } ?>
                                          </tbody>
                                          <tfoot>
                                             <tr>
                                                <th>Merchant Name</th>
                                                <th>Company Name</th>
                                                <th>Coupon</th>
                                                 <th>product</th>
                                             </tr>
                                          </tfoot>
                                       </table>
                                       <!--Table  End-->
                                    </div>
                                  
                                 </div>
                              </div>
                           </div>
                           <!---Coupon and Product uploaded by merchant End-->
                        </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-->
            <!-- Jquery Script Begin-->
            <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 Script Begin-->
            <script src="../js/dashboard-icouponworld.js"></script>
             <!-- dashboard-icouponworld Script End-->
            <!-- jQuery Datatable js Script Begin-->
            <script src="../js/jquery.dataTables.min.js"></script>
              <!-- jQuery Datatable js End -->
            <!-- dataTables.bootstrap5.min js Begin-->  
            <script src="../js/dataTables.bootstrap5.min.js"></script>
            <!-- dataTables.bootstrap5.min js End--> 
         </div>
         <!--scroll-top End-->
      </div>
      <!--unique id End -->
       <!-- Script for table footer filteration Begin--> 
      <script>
         $(document).ready(function () {
         $('#affiliatecompany tfoot th, #merchant tfoot th, #company_wise tfoot th').each(function () {
         var title = $(this).text();
         $(this).html('<input type="text" class="form-control" placeholder="Search ' + title + '" />');
         
         });
         
         // DataTable
         
         var table = $('#affiliatecompany, #merchant , #company_wise').DataTable({
         searchPanes: true,
         initComplete: function () {
          // Apply the search
          this.api()
             .columns()
             .every(function () {
         
                var that = this;
                $('input', this.footer()).on('keyup change clear', function () {
                   if (that.search() !== this.value) {
                      that.search(this.value).draw();
                   }
                });
             });
         },
         });
         })
          
      </script>
       <!-- Script for table footer filteration End--> 
   </body>
</html>
