<section class="border-top py-4">
   <div class="container">
      <div class="row">
         <div class="col-md-6">
            <div class="bottom-line">
               <h2 class="h5 mb-4">Deals of the Day</h2>
            </div>
         </div>
         <div class="col-md-6">
            <div class="view-all-details">
               <a href="deals-of-the-day" class="btn btn-outline-dark">
                  <span>
                     View All 
                     <i>
                        <svg style="transform:rotate(90deg)" width="8px" height="13px" viewBox="0 0 8 13" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
                           <g stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
                              <g transform="translate(-1228.000000, -4044.000000)" fill="#fff" fill-rule="nonzero">
                                 <path d="M1235.71217,4051.14357 L1229.6777,4056.73319 C1229.29383,4057.08894 1228.67146,4057.08894 1228.28778,4056.73319 C1227.90407,4056.37775 1227.90407,4055.80127 1228.28778,4055.44587 L1233.62736,4050.49991 L1228.28794,4045.55412 C1227.90423,4045.19854 1227.90423,4044.62212 1228.28794,4044.26668 C1228.67165,4043.91111 1229.29399,4043.91111 1229.67785,4044.26668 L1235.71233,4049.85639 C1235.90418,4050.03419 1236,4050.26698 1236,4050.49988 C1236,4050.73289 1235.90399,4050.96585 1235.71217,4051.14357 Z"></path>
                              </g>
                           </g>
                        </svg>
                     </i>
                  </span>
               </a>
            </div>
         </div>
      </div>
      <div class="row">
         <!--Deal of the Day-->
         <?php    $sqlcou="SELECT * FROM  product_master ORDER BY rand() LIMIT 4 ";
            $myquerycou=$conn->query($sqlcou);
            $mydaracou= $myquerycou->fetchAll()  ;
            
            $rows_foundcou = $myquerycou->rowCount();
            
            
            
            
            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('.$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('.$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 */
                            /*for fav 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('.$rowId .',1);" title="My Favourite"><i class="fas fa-heart"  ></i></a></li>';
                            }else{
                            $fav='  <li class="fav'.$rowId .'"><a onclick="return fav('.$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('.$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('.$rowId .', 0,'.$rowId .');" title="I Like This"><i class="fa fa-thumbs-up text-success" aria-hidden="true"></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('.$rowId .',1);" title="My Favourite"><i class="fas fa-heart" ></i></a></li>';
                            }else{
                            $fav='  <li class="fav'.$rowId .'"><a onclick="return fav('.$rowId .',0);" title="My Favourite"><i class="fa fa-heart fa-1x text-danger"></i></a></li>';
                            }
                            /*for fav master user */
                            
                            }else{
                            
                            $like='  <li data-bs-toggle="modal" data-bs-target="#like-product"><i title="I Like This" class="fas fa-thumbs-up"></i>'.$total_likes.'</li>';
                            $fav=' <li data-bs-toggle="modal" data-bs-target="#favorite-product"><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 alt="<?=$short_title?>" title="<?=$short_title?>" src="<?=$product_image?>"  class="img-fluid mx-auto d-block">
                     <div class="d-grid">
                        <small title="<?=$short_title?>" class="context-menu text-muted text-truncate"><?=$short_title?></small>
                        <p class="d-para">
                           <a class="context-menu" title="<?=$discription?>"><?=$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>
         <!--Popular-->
         <!-- share product start -->
         <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 alt="<?=$short_title?>" title="<?=$short_title?>" src="<?=$product_image?>" class="img-fluid mx-auto d-block context-menu">
                              </div>
                           </div>
                           <div class="col-md-7">
                              <div class="dm-price">
                                 <h3 title="<?=$short_title?>" class="fw-bold text-truncate context-menu"><?=$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>
                                 <!--Share 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 clipboarddealoftheday 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 clipboarddealoftheday End-->
                                    </div>
                                 </div>
                                 <!--Share Via Begin-->
                                 <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 end -->
         <?php } ?> 
      </div>
   </div>
</section>