<?php
$index_url =  $_SERVER["HTTP_REFERER"];
//echo $index_url;
$serach = strpos("$index_url","admin");
$cut_url = substr("$index_url",$serach);

$main_url = str_replace("$cut_url","",$index_url);
//echo $main_url;
?>

 <nav class="navbar navbar-expand navbar-light bg-white topbar mb-4 static-top shadow">

                        <button id="humbergersidebarToggleTop" class="btn btn-link rounded-circle mr-3">
                        <i class="fa fa-bars"></i>
                        </button>
                        <!-- Navbar Begin -->
                        <ul class="navbar-nav justify-content-center align-items-center ml-auto">
                        <li class="nav-item">
                        <form action="" method="POST">
                            
                            <button type="submit"  name="submit" class="btn btn-sm">Country Load</button>
                            </form>
                              </li>
                            <?php
                            
                            if ($_SERVER['REQUEST_METHOD'] === 'POST') {
                               // Check if the "runQuery" button was clicked
                               if (isset($_POST['submit'])) {
                                  //echo ("abc");
                                  $add_country = "UPDATE coupon INNER JOIN country_company_master ON coupon.company_name = country_company_master.company  SET coupon.coupon_country_name = country_company_master.country";
                                  $add_country =   $add_country." WHERE (coupon.company_name = country_company_master.company)";
                                 // $update_country =$conn->query($add_country);
                                 $stmts = $conn->prepare($add_country);
                                 if($stmts->execute()){

                                 }
                                  
                                  $add_country1 = "UPDATE product_master INNER JOIN country_company_master ON  product_master.company_name =  country_company_master.company SET product_master.country_name = country_company_master.country";
                                  $add_country1 =   $add_country1." WHERE (product_master.company_name = country_company_master.company)";
                                  $stmts = $conn->prepare($add_country1);
                              
                                    if($stmts->execute()){

                                                                       
                              
                                  
                              //var_dump($stmts->execute());
                                    ?>
                                        <script> swal("Successfully!", "Country Load Save!", "success");  </script>
                                        <?php 
                                    }
                                  else{
                                     echo("Something is Wrong");
                                  }
                               }
                                }
                               
                            ?>
                            <li class="nav-item ">
                            <form action="" method="POST">
                          
                          <button type="submit"  name="submitbrand" class="btn btn-sm">Brand Store</button>
                          </form>
                              </li>
                          <?php
                            
                            if ($_SERVER['REQUEST_METHOD'] === 'POST') {
                               // Check if the "runQuery" button was clicked
                               if (isset($_POST['submitbrand'])) {
                                  //echo ("abc");
                                  $add_country = "UPDATE coupon INNER JOIN brand_master ON coupon.company_name =  brand_master.brand_name  SET coupon.brand_store = 'B'";
                                  $add_country =   $add_country." WHERE (coupon.company_name =  brand_master.brand_name);";
                                 // $update_country =$conn->query($add_country);
                                 $stmts = $conn->prepare($add_country);
                                 if($stmts->execute()){

                                 }
                                  
                                  $add_country1 = "UPDATE coupon INNER JOIN store_master ON coupon.company_name =  store_master.store_name  SET coupon.brand_store = 'S'";
                                  $add_country1 =   $add_country1." WHERE (coupon.company_name =  store_master.store_name)";
                                  $stmts = $conn->prepare($add_country1);
                              
                                    if($stmts->execute()){                                                                        
                              
                                  
                              //var_dump($stmts->execute());
                                    ?>
                                        <script> swal("Successfully!", "Brand Name Save!", "success");  </script>
                                        <?php 
                                    }
                                  else{
                                     echo("Something is Wrong");
                                  }
                               }
                                }
                               
                            ?>
                           <li class="nav-item"> <a class="nav-link" target="_blank" href="./backend/load_store_brand_cat.php">
                              <span class="mr-2 text-dark"> 
                              Reload Data</span>
                              </a>
                           </li>
                           <li class="nav-item"> <a class="nav-link" target="_blank" href="<?=$main_url?>">
                              <span class="mr-2 text-dark"> 
                              View Website</span>
                              </a>
                           </li>
                           <li class="nav-item">
                              <a class="nav-link" href="#">
                              <span class="mr-2 d-none d-lg-inline text-dark"> 
                              Hi, <?=$full_name?></span>
                              </a>
                           </li>
                           <li class="nav-item">
                              <a class="nav-link" href="#">
                              <img class="img-profile rounded-circle border" alt="profile" title="profile" src="./backend/<?=$profile_pic?>">
                              </a>
                           </li>
                        </ul>
                        <!-- Navbar End -->
                     </nav>