<div class="tab-pane fade <?php  if (isset($_GET["page"])) { echo 'show active'; }else{ if (empty($_GET["page_coupon"])){ echo 'show active'; } } ?>" id="pills-product-dealoftheday" role="tabpanel" aria-labelledby="pills-product-dealoftheday-tab" tabindex="0">
   <div class="row">
      <div class="bottom-line">
         <h6 class="h5 mb-4">Deals Of The Day</h6>
      </div>
   </div>
   <div class="row">
      <!--Product Deal of the Day-->
      <?php  
         foreach( $mydaracou as $rowcou ){
         $rowId    = $rowcou["rowId"];
         $short_title   = $rowcou["title"];
         $discription   = $rowcou["discription"];
         $link = $rowcou["product_url"];
         $product_image   = $rowcou["product_image"];
         $type = $rowcou["exp_date"];
         $coupon_code   = $rowcou["country_name"];
         $company_name   = $rowcou["company_name"];
         $amount   = $rowcou["amount"];  
         $total_likes   = $rowcou["total_likes"];
         $currency    = $rowcou["currency"];
         
         
         if($_SESSION[ADD_TAG.'_UserId_vendor']!=''){
         
         $user_id=$_SESSION[ADD_TAG.'_UserId_vendor'];
         /*for like master vendor*/
         $sqlli = "SELECT * FROM like_master_product WHERE coupan_id='$rowId ' AND user_id='$user_id' AND user_type='vendor' ";
         $myqueryli=$conn->query($sqlli); 
         $mydarali= $myqueryli->fetchAll()  ;
         
         $rows_foundli = $myqueryli->rowCount();
         
         if($rows_foundli=='0'){
           $like='<li class="like'.$rowId.'" ><a onclick="return cwRating_product('.$rowId.', 1,'.$rowId.');" title="I Like This"><i title="I Like This" class="fas fa-thumbs-up"></i>&nbsp;'.$total_likes.'</a></li>';
         
         }else{
         $like=' <li  class="like'.$rowId.'"><a onclick="return cwRating_product('.$rowId.', 0,'.$rowId.');" title="I Like This"><i class="fa fa-thumbs-up" title="I Like This"></i>
         &nbsp;'.$total_likes.'</a></li>';
         }
         /*for like master vendor */
         
         $sqlfav = "SELECT * FROM fav_master_product WHERE coupan_id='$rowId ' AND user_id='$user_id' AND user_type='vendor' ";
         $myqueryfav=$conn->query($sqlfav); 
         $mydarafav= $myqueryfav->fetchAll()  ;
         
         $rows_foundfav = $myqueryfav->rowCount();
         
         if($rows_foundfav=='0'){
         $fav='<li class="fav'.$rowId.'"><a onclick="return fav_product('.$rowId.',1);" title="My Favourite"><i class="fas fa-heart"  ></i></a></li>';
         }else{
         $fav='  <li class="fav'.$rowId.'"><a onclick="return fav_product('.$rowId.',0);" title="My Favourite"><i class="fas fa-heart" ></i></a></li>';
         }
         /*for fav master vendor */
         
         }
         elseif($_SESSION[ADD_TAG.'_UserId_user']!=''){
         $user_id=$_SESSION[ADD_TAG.'_UserId_user'];
         /*for like master user*/
         $sqlli = "SELECT * FROM like_master_product WHERE coupan_id='$rowId ' AND user_id='$user_id' AND user_type='user'  ";
         $myqueryli=$conn->query($sqlli); 
         $mydarali= $myqueryli->fetchAll()  ;
         
         $rows_foundli = $myqueryli->rowCount();
         
         if($rows_foundli=='0'){
         $like='<li class="like'.$rowId.'"><a onclick="return cwRating_product('.$rowId.', 1,'.$rowId.');" title="I Like This"><i title="I Like This" class="fas fa-thumbs-up"></i>&nbsp;'.$total_likes.'</a></li>';
         // $like=' <li class="mr-0"  id="asd'.$rowId .'"><a onclick="return cwRating('.$rowId .', 1,'.$rowId .');" title="I Like This"><i class="fa fa-thumbs-o-up fa-1x text-success" aria-hidden="true" ></i>&nbsp;'.$total_likes.'</a></li>';
         }else{
         
         $like=' <li  class="like'.$rowId.'"><a onclick="return cwRating_product('.$rowId.', 0,'.$rowId.');" title="I Like This"><i class="fa fa-thumbs-up" title="I Like This"></i>
         &nbsp;'.$total_likes.'</a></li>';
         }
         /*for like master user*/  
          /*for fav master user*/
         $sqlfav = "SELECT * FROM fav_master_product WHERE coupan_id='$rowId ' AND user_id='$user_id' AND user_type='user' ";
         $myqueryfav=$conn->query($sqlfav); 
         $mydarafav= $myqueryfav->fetchAll()  ;
         
         $rows_foundfav = $myqueryfav->rowCount();
         
         if($rows_foundfav=='0'){
         $fav='<li class="fav'.$rowId.'"><a onclick="return fav_product('.$rowId.',1);" title="My Favourite"><i class="fas fa-heart" ></i></a></li>';
         }else{
         $fav='  <li class="fav'.$rowId.'"><a onclick="return fav_product('.$rowId.',0);" title="My Favourite"><i class="fas fa-heart"></i></a></li>';
         }
         /*for fav master user */
         
         }else{
         
         $like='  <li data-bs-toggle="modal" data-bs-target="#like-coupon"><i title="I Like This" class="fas fa-thumbs-up">&nbsp;'.$total_likes.'</i></li> ';
          $fav=' <li data-bs-toggle="modal" data-bs-target="#favorite-coupon"><i title="My Favourite" class="fas fa-heart"> </i></li>';
         }
         
         
         
         
         
         
         ?> 
      <div class="col-lg-3 col-6">
         <div class="deals">
            <div class="card border-0">
               <div class="card-body">
                  <img src="<?=$product_image?>" alt="<?=$short_title?>" title="<?=$short_title?>" class="img-fluid mx-auto d-block">
                  <div class="d-grid">
                     <small title="<?=$short_title?>" class="text-muted text-truncate"><?=$short_title?></small>
                     <p title="<?=$discription?>" class="d-para">
                        <a class="context-menu"><?=$discription?></a> 
                     </p>
                  </div>
                  <div class="row align-items-center">
                     <div class="col-md-7">
                     <?php
                              $currency_query = "SELECT * FROM country_currency_master WHERE code='$currency' limit 1";
                     $myquerycurr=$conn->query($currency_query); 
                     $mydaracurr= $myquerycurr->fetchAll()  ;
                     
                     $rows_foundcurr = $myquerycurr->rowCount();
                   
                     if( $rows_foundcurr !='0'){
                       // var_dump(  $mydaracurr);
                        foreach( $mydaracurr as $rowcous ){
                          $currency_symbol = $rowcous['symbol'];
                          
                        ?>
                                 <h3 class="mb-2 fw-bold text-truncate">
                                 <?=$currency_symbol?>   <?=$amount?>
                                 </h3>
                                 <?php }}?>
                        
                     </div>
                     <div class="col-md-5 text-end">
                        <h6 class="shop-now"><a target="_blank" href="<?=$link?>">Shop now</a></h6>
                     </div>
                  </div>
               </div>
               <div class="card-footer social-icons bg-white">
                  <ul class="list-unstyled mb-0">
                     <?=$fav?>
                     <?=$like?>
                     <li  data-bs-toggle="modal" data-bs-target="#share-product<?=$rowId?>"><i title="Share" class="fas fa-share pe-1"></i>Share</li>
                  </ul>
               </div>
            </div>
         </div>
      </div>
      <!--Share Product Modal Begin-->
      <div class="modal fade" id="share-product<?=$rowId?>" tabindex="-1"  aria-hidden="true">
         <div class="modal-dialog modal-dialog-centered modal-lg">
            <div class="modal-content">
               <div class="modal-header border-0">
                  <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
               </div>
               <div class="modal-body p-5">
                  <div id="removemodalproductdealoftheday">
                     <div class="row justify-content-center align-items-center">
                        <div class="col-md-5">
                           <div class="d-modal-left">
                              <img src="<?=$product_image?>" title="<?=$short_title?>" class="img-fluid mx-auto d-block">
                           </div>
                        </div>
                        <div class="col-md-7">
                           <div class="dm-price">
                              <h3 title="<?=$short_title?>" class="fw-bold text-truncate"><?=$short_title?></h3>
                              <a href="product-details-ref/<?=($rowId)?>" class="btn btn-view-deal w-100 d-block mt-2 mb-4">View Product Deal</a>
                              <!--Copy URL Begin-->
                              <div class="mb-3 row">
                                 <label class="col-sm-4 col-form-label">Copy URL</label>
                                 <div class="col-sm-8">
                                    <!--copy to copyclipboardproductdealoftheday Begin-->
                                    <div class="input-group clipboarddealoftheday">
                                    <input  class="form-control form-control-sm" value="<?php echo $link; ?>" id="<?=$rowId?>">
                                          <span class="input-group-text bg-secondary text-white" onclick="copy(<?=$rowId?>)"><i class="far fa-copy"></i></span>
                                    </div>
                                    <div id="copiedtextproductdealsday" class="copieddealoftheday">
                                       <span>Copied!</span>
                                    </div>
                                    <!--copy to copyclipboardproductdealoftheday End-->
                                 </div>
                              </div>
                              <div class="mb-3 row">
                                 <label class="col-sm-4 col-form-label">Share via</label>
                                 <div class="col-sm-8">
                                    <!--share Via Begin-->
                                    <div class="d-flex justify-content-start align-items-center">
                                       <a title="share via linkedin" href="https://www.linkedin.com/sharing/share-offsite/?url=<?=$link?>" class="share-linkedin ms-2"><i class="fab fa-linkedin-in"></i></a>
                                       <a title="share via facebook" href="https://www.facebook.com/sharer.php?u=<?=$link?>" class="share-facebook ms-2"><i class="fab fa-facebook-f"></i></a>
                                       <a title="share via twitter" href="https://twitter.com/intent/tweet?url=<?=$link?>" class="share-twitter ms-2"><i class="fab fa-twitter"></i></a>
                                       <a title="share via pinterest" href="https://www.pinterest.com/pin/create/button/?url=<?=$link?>" class="share-pinterest ms-2"><i class="fab fa-pinterest-p"></i></a>
                                       <a title="share via whatsapp" href="https://web.whatsapp.com/send?text=<?=$link?>" class="share-whatsapp ms-2"><i class="fab fa-whatsapp"></i></a>
                                       <a title="share via telegram" href="https://t.me/share/url?url=<?=$link?>&text=telegram" class="share-telegram ms-2"><i class="fab fa-telegram"></i></a>
                                       <a title="share via reddit" href="http://www.reddit.com/submit?url=<?=$link?>" class="share-reddit ms-2"><i class="fab fa-reddit"></i></a>
                                       <a title="share via tumblr" href="http://www.tumblr.com/share?v=3&u=<?=$link?>&t=tumblr" class="share-tumblr ms-2"><i class="fab fa-tumblr"></i></a>
                                    </div>
                                    <!--share Via End-->
                                 </div>
                              </div>
                           </div>
                        </div>
                     </div>
                  </div>
               </div>
            </div>
         </div>
      </div>
      <!--Share Product Modal End-->
      <?php } ?>
      <div class="col-lg-12">
         <!-- Paginations navbar Begin-->
         <nav aria-label="Page navigation example">
            <ul class="pagination justify-content-center pt-4 pb-4">
               <?php   
                  $sqlpa= "SELECT COUNT(*) FROM product_master  LIMIT $start_from, $limit"; 
                  
                  
                  
                  
                  $myquerypa=$conn->query($sqlpa);
                  $row = $myquerypa->fetch(PDO::FETCH_BOTH);
                  // do loop stuff
                  
                  
                  $rows_foundpa = $myquerypa->rowCount();   
                  $total_records = $row[0];  
                  
                  //echo $rows_foundpa;
                  if($total_records > 16){
                  $total_pages = ceil($total_records / $limit);
                  
                  $k = (($pn+1>$total_pages)?$total_pages-1:(($pn-1<1)?2:$pn));   
                  
                  $pagLink = "";
                  if($pn>=2){
                  echo "<li class='page-item'><a class='page-link' href='deals-product-page/1".$sr."'> << </a></li>";
                  echo "<li class='page-item'><a class='page-link' href='deals-product-page/".($pn-1).$sr." '> < </a></li>";
                  }
                  for ($i=-1; $i<=1; $i++) {
                  if($total_pages>=$k+$i && $k+$i!='0' ){
                  if($k+$i==$pn){
                  $pagLink .= "<li class='page-item active'><a class='page-link' href='deals-product-page/".($k+$i).$sr." ' >".($k+$i)."</a></li>";
                  }
                  else{
                  $pagLink .= "<li class='page-item'><a class='page-link' href='deals-product-page/".($k+$i).$sr." '>".($k+$i)."</a></li>";  
                  } }
                  };  
                  echo $pagLink;
                  if($pn<$total_pages){
                  echo "<li class='page-item'><a class='page-link' href='deals-product-page/".($pn+1).$sr." '> > </a></li>";
                  echo "<li class='page-item'><a class='page-link' href='deals-product-page/".$total_pages.$sr." '> >> </a></li>";
                  }  }  ?> 
            </ul>
         </nav>
         <!-- Paginations navbar End-->
      </div>
   </div>
</div>