<?php
$res = $this->db->query("SELECT * FROM wps_categories WHERE status = '1' AND parent_id = '0' limit 0,4")->result_array();
?>
<body>
  <div id="header" class="header">
    <!--/.top-header -->
    <!-- MAIN HEADER -->
    <div class="header-bg">
      <div class="container main-header">
        <div class="row">
          <div class="col-xs-12 col-sm-3 logo">
            <a href="<?php echo site_url(); ?>"><img alt="Ajmera Fashion" src="<?php echo theme_url(); ?>images/logo.png" /></a>
          </div>
          <div class="col-xs-12 col-sm-9 ">
            <ul class="top-menu">

              <?php
              if ($this->session->userdata('user_id') > 0) {
                ?>
                <li><a href="<?php echo site_url('members'); ?>">Welcome <?php echo $this->session->userdata('first_name'); ?></a></li>
                <li><a href="<?php echo site_url('members'); ?>">My Account</a></li>
                <li><a href="<?php echo site_url('users/logout'); ?>">Logout</a></li>
                <?php
              } else {
                ?>
                <li><a href="<?php echo site_url('members'); ?>">Myaccount</a></li>
                <li><a href="<?php echo site_url('register'); ?>">Sign In/Register</a></li>
                <?php
              }
              ?>
            </ul>
            <div class="col-xs-7 col-sm-9 header-search-box">
              <form class="form-inline">
                <div class="form-group input-serach">
                  <input type="text" name="search_keyword" id="search_keyword" placeholder="Keyword here...">
                </div>
                <button type="submit" class="pull-right btn-search"></button>
                <div id="serach_listt"></div>
              </form>
            </div>
            <div id="shopping-cart" class="col-xs-12 col-sm-3 ">
              <ul>
                <li>
                  <a class="wishlist-link" href="<?php echo site_url('members/wishlist'); ?>">Wish List</a>
                </li>
                <li>
                  <div id="cart-block" class="shopping-cart-box">
                    <a class="cart-link" href="<?php echo site_url('cart'); ?>">My Bag (<?php echo count($this->cart->contents()); ?>)</a>
                    <?php
                    if (count($this->cart->contents()) > 0) {
                      ?>
                      <div class="cart-block">
                        <div class="cart-block-content">
                          <h5 class="cart-title"><?php echo count($this->cart->contents()); ?> Items in my cart</h5>
                          <div class="cart-block-list">
                            <ul>
                              <?php
                              $cart = $this->cart->contents();
                              $totalAmount = $pprice = 0;
                              foreach ($cart as $items) {
                                //trace($items);
                                $pprice = $items['price'] * $items['qty'];
                                $totalAmount += $pprice;
                                $img = get_db_field_value("wps_products_media", "media", "WHERE products_id='" . $items['pid'] . "'");
                                ?>
                                <li class="product-info">
                                  <div class="p-left">
                                    <a href="<?php echo site_url(); ?>cart/remove_item/<?php echo $items['rowid']; ?>" class="remove_link"></a>

                                    <img class="img-responsive" src="<?php echo get_image('product_images', $img, '100', '122', 'R'); ?>" alt="p10">

                                  </div>
                                  <div class="p-right">
                                    <p class="p-name"><?php echo $items['origname']; ?></p>
                                    <p class="p-rice"><?php echo display_price($pprice); ?></p>
                                    <p>Qty: <?php echo $items['qty']; ?></p>
                                  </div>
                                </li>
                                <?php
                              }
                              ?>
                            </ul>
                          </div>
                          <div class="toal-cart">
                            <span>Total</span>
                            <span class="toal-price pull-right"><?php echo display_price($totalAmount); ?> </span>
                          </div>
                          <div class="cart-buttons">
                            <a href="<?php echo site_url('cart/checkout'); ?>" class="btn-check-out">Checkout</a>
                          </div>
                        </div>
                      </div>
                      <?php
                    }
                    ?>
                  </div>
                </li>
              </ul>
            </div>
          </div>
        </div>
      </div>
    </div>
    <!-- END MANIN HEADER -->

    <div id="nav-top-menu" class="nav-top-menu">
      <div class="container">
        <div class="row">
          <div id="main-menu" class="col-sm-12 main-menu">
            <nav class="navbar navbar-default">
              <div class="container-fluid">
                <div class="navbar-header">
                  <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
                    <i class="fa fa-bars"></i>
                  </button>
                  <a class="navbar-brand" href="#">MENU</a>
                </div>
                <div id="navbar" class="navbar-collapse collapse">
                  <ul class="nav navbar-nav">
                    <li class="active "> <a  href="<?php echo site_url(); ?>">Home</a>   </li>
                    <li> <a  href="<?php echo site_url('aboutus'); ?>">About Us</a></li>
                    <?php
                    if (is_array($res) && !empty($res)) {
                      $slmenu = 1;
                      foreach ($res as $key => $val) {
                        if ($slmenu % 2 == 0) {
                          $catsRes = $this->db->query("SELECT category_id, category_name, friendly_url FROM wps_categories WHERE status = '1' AND parent_id = '" . $val['category_id'] . "' LIMIT 0,6")->result_array();
                          ?>
                          <li <?php echo (is_array($catsRes) && !empty($catsRes))?'class="dropdown"':''; ?>>
                            <a href="<?php echo site_url($val['friendly_url']); ?>" <?php echo (is_array($catsRes) && !empty($catsRes))?'class="dropdown-toggle" data-toggle="dropdown"':'';?>><?php echo $val['category_name']; ?></a>
                            <?php
                            if (is_array($catsRes) && !empty($catsRes)) {
                              ?>
                              <ul class="mega_dropdown dropdown-menu" style="max-width: 830px;">
                                <?php
                                foreach ($catsRes as $key1 => $pageVal) {
                                  $catsubRes = $this->db->query("SELECT category_id, category_name, friendly_url FROM wps_categories WHERE status = '1' AND parent_id = '" . $pageVal['category_id'] . "' LIMIT 0,5")->result_array();
                                  ?>
                                  <li class="block-container col-sm-3">
                                    <ul class="block">

                                      <li class="link_container group_header"><a href="<?php echo site_url($val['friendly_url']); ?>"><?php echo $pageVal['category_name']; ?></a></li>
                                      <?php
                                      if (is_array($catsubRes) && !empty($catsubRes)) {
                                        foreach ($catsubRes as $ks => $valSubCat) {
                                          ?>
                                          <li class="link_container"><a href="<?php echo site_url($valSubCat['friendly_url']); ?>"><?php echo $valSubCat['category_name']; ?></a></li>
                                          <?php
                                        }
                                      } else {
                                        $proRes = $this->db->query("SELECT product_name, friendly_url FROM wps_products WHERE status = '1' AND category_id = '" . $pageVal['category_id'] . "' LIMIT 0,5")->result_array();
                                        if (is_array($proRes) && !empty($proRes)) {
                                          foreach ($proRes as $ks => $valpro) {
                                            ?>
                                            <li class="link_container"><a href="<?php echo site_url($valpro['friendly_url']); ?>"><?php echo $valpro['product_name']; ?></a></li>
                                            <?php
                                          }
                                        }
                                      }
                                      ?>

                                    </ul>
                                  </li>
                                  <?php
                                }
                                ?>
                                <li class="block-container col-sm-3">
                                  <ul class="block">
                                    <li class="img_container">
                                      <img src="<?php echo get_image('category', $val['category_image'], '170', '320', 'R'); ?>" alt="Banner">
                                    </li>
                                  </ul>
                                </li>
                              </ul>
                              <?php
                            }
                            ?>
                          </li>
                          <?php
                        } else {
                          $catsRes = $this->db->query("SELECT category_id, category_name, category_image, friendly_url FROM wps_categories WHERE status = '1' AND parent_id = '" . $val['category_id'] . "' ORDER BY home_menu")->result_array();
                          ?>
                          <li <?php echo (is_array($catsRes) && !empty($catsRes))?'class="dropdown"':''; ?>>
                            <a href="<?php echo site_url($val['friendly_url']); ?>" <?php echo (is_array($catsRes) && !empty($catsRes))?'class="dropdown-toggle" data-toggle="dropdown"':'';?>><?php echo $val['category_name']; ?></a>
                            <?php
                            if (is_array($catsRes) && !empty($catsRes)) {
                              ?>
                              <ul class="dropdown-menu mega_dropdown" role="menu" style="width: 830px;">
                                <?php
                                $cnt=1;
                                foreach ($catsRes as $key1 => $pageVal) {
                                  ?>
                                  <li class="block-container col-sm-3">
                                    <ul class="block">
                                      <?php
                                      if($cnt == 1){
                                        ?>
                                      <li class="img_container">
                                        <a href="<?php echo site_url($pageVal['friendly_url']); ?>">
                                          <img class="img-responsive" src="<?php echo get_image('category', $pageVal['category_image'], '170', '207', 'R'); ?>" alt="sport">
                                        </a>
                                      </li>
                                      <li class="link_container group_header"><a href="<?php echo site_url($pageVal['friendly_url']); ?>"><?php echo $pageVal['category_name']; ?></a></li>
                                    <?php
                                      }
                                      else{
                                        ?>
                                        <li class="link_container"><a href="<?php echo site_url($pageVal['friendly_url']); ?>"><?php echo $pageVal['category_name']; ?></a></li>
                                        <?php
                                      }
                                      ?>
                                    </ul>
                                  </li>
                                  <?php
                                  $cnt++;
                                }
                                ?>
                              </ul>
                              <?php
                            }
                            ?>
                          </li>
                          <?php
                        }
                        $slmenu++;
                      }
                    }
                    ?>
                    <li><a href="<?php echo site_url('blog'); ?>">Blog</a></li>
                    <li><a href="<?php echo site_url('contactus'); ?>">Contact Us</a></li>
                  </ul>
                </div><!--/.nav-collapse -->
              </div>
            </nav>
          </div>
        </div>
        <!-- userinfo on top-->
        <div id="form-search-opntop">
        </div>
        <!-- userinfo on top-->
        <div id="user-info-opntop">
        </div>
        <!-- CART ICON ON MMENU -->
        <div id="shopping-cart-box-ontop">
          <i class="fa fa-shopping-cart"></i>
          <div class="shopping-cart-box-ontop-content"></div>
        </div>
      </div>
    </div>
  </div>
  
  <?php
  /*
   *<li class="block-container col-sm-3">
                                    <ul class="block">
                                      <li class="img_container">
                                        <a href="<?php echo site_url($pageVal['friendly_url']); ?>">
                                          <img class="img-responsive" src="<?php echo get_image('category', $pageVal['category_image'], '170', '207', 'R'); ?>" alt="sport">
                                        </a>
                                      </li>
                                      <li class="link_container group_header"><a href="<?php echo site_url($pageVal['friendly_url']); ?>"><?php echo $pageVal['category_name']; ?></a></li>

                                      <?php
                                      if (is_array($catsubRes) && !empty($catsubRes)) {
                                        foreach ($catsubRes as $ks => $valSubCat) {
                                          ?>
                                          <li class="link_container"><a href="<?php echo site_url($valSubCat['friendly_url']); ?>"><?php echo $valSubCat['category_name']; ?></a></li>
                                          <?php
                                        }
                                      } else {
                                        $proRes = $this->db->query("SELECT product_name, friendly_url FROM wps_products WHERE status = '1' AND category_id = '" . $pageVal['category_id'] . "' LIMIT 0,5")->result_array();
                                        if (is_array($proRes) && !empty($proRes)) {
                                          foreach ($proRes as $ks => $valpro) {
                                            ?>
                                            <li class="link_container"><a href="<?php echo site_url($valpro['friendly_url']); ?>"><?php echo $valpro['product_name']; ?></a></li>
                                            <?php
                                          }
                                        }
                                      }
                                      ?>
                                    </ul>
                                  </li>
   */
  ?>