<div class="user-info">
    <?php $user_id=$this->session->userdata('user_id'); ?>
    <div class="gx-linebar"><i class="fa fa-outdent" aria-hidden="true"></i></div>
    <div class="site-logo">
 <?php  echo '<img src="'.base_url().'/uploads/site-logo.png" alt="Smiley face"   >'; ?>
    </div>
    <div class="edit_profile">
        <?php $logo='';
    $type=$this->db->query("select logo  from user 
      where user_id=$user_id");
    foreach ($type->result() as $key => $logo){
       $logo=$logo->logo; 
    $defult="logo.jpg";
    if($logo){
      echo '<img src='.base_url().'uploads/'.$logo.' alt="Smiley face" class="profile"  >';
    }
    else{
      echo '<img src='.base_url().'uploads/'.$defult.' alt="Smiley face" class="profile"  >'; 
    } 
    }
      
    ?>
         <?php  
  $type=$this->db->query("select * from buisness_type  
   where user_id='$user_id' ");
  $data='';
  foreach ($type->result() as $key => $type){ 
    $b_type=$type->type;
 $bid=$type->buisness_id;
  }
  ?>
    <div class="buisness">
        <p>
            <?php echo $b_type; ?>
        </p>
    </div>
    <div class="main_type">
        <?php  
    ?>
        <div class="link"><a data-toggle="collapse" data-parent="#accordion" href="#collapseFour">
      <i class=""></i>
    </a></div>
        <ul id="accordion" class="accordion">
            <li class="menu">
                <div class="link"><a id="ac-btn" href="javascript:void(0)"><i style="cursor:pointer;" class="fa fa-chevron-right"></i><i style="cursor:pointer;" class="fa fa-chevron-down"></i></a></div>
                <ul class="submenu">
                    <div class="you">
                        <li class="fild-title">you_________________</li>
                        <li><a id="logout" href="<?php echo site_url("user/profile ");?>"><i class="fa fa-user"></i>My Profile</a></li>
                        <li><!--<a id="logout" href="<?php //echo site_url("user/logout ");?>" onclick="window.location='<?php //echo site_url("user/logout ");?>'"><i class="icon-off"></i>Logout</a>--></li>

                    </div>
                    <div class="businesses">

                        <li class="fild-title">My Businesses________</li>

                        <?php  
          $buisnesstype=$this->db->query("select * from type  
          where user_id='$user_id'  ");
          $id='';
              $result=$buisnesstype->result();
          foreach ($buisnesstype->result() as $key => $buisnesstype){
            $type=$buisnesstype->type;
               $typeid=$buisnesstype->id;
              if($type==$b_type){
                  $class='fa fa-check';
              }
              else{
                 $class=''; 
              }
            echo '<li class="list'.$typeid.'"><a href="'.base_url().'user/buisness_type/'.$type.'/'.$typeid.'"><i class="fa fa-industry" aria-hidden="true"></i> '.$type.'<i style="cursor:pointer;" class="'.$class.'"></i></a></li>';
          }  
          ?>
                       
                    </div>
                     <li><a class="setingbuisness ac" href="#" data-toggle="modal" data-target="#sideModaltwo" onclick="buisnessadd()" style="font-size:13px;"><i class="fa fa-cogs" ></i> Manage Buisness</a></li>

                        <li><a class="addbuisness ac" href="#" data-toggle="modal" data-target="#sideModal" onclick="buisnessadd()" style="font-size:13px;"><i class="fa fa-plus" aria-hidden="true"></i> New Buisness</a></li>
                </ul>
            </li>
        </ul>
    </div>
        <!--<div class="edit"> <a href="#" class="btn btn-primary a-btn-slide-text"  >
      <span class="glyphicon glyphicon-edit" aria-hidden="true"></span>
     <span><strong>Edit</strong></span>           
    </a></div>-->
    </div>
  
    
     <div class="modal fade" id="AdminPanel" role="dialog" style="padding-right:93px;">
        <div class="modal-dialog">
            <!-- Modal content-->
            <div class="modal-content s_modal">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal">&times;</button>
                    <h4 class="modal-title">Admin Panel</h4>
                </div>
                         <div class="formsection">
                             <input type="password" class="form-control buisnessdelete" name="buisness_delete"  placeholder="Admin Password">
                            <input type="hidden" class="Deletebuisnessid">
                           
                         </div>
                            
                <div class="modal-footer">
                    <a class="btn btn-success btn-danger" onclick="buisnessdelete()">Delete</a>
                </div>
            </div>
        </div>
    </div>
    <div class="modal fade" id="sideModal" role="dialog">
        <div class="modal-dialog">
            <!-- Modal content-->
            <div class="modal-content s_modal">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal">&times;</button>
                    <h4 class="modal-title">Create a New Business</h4>
                </div>
                <form method="post" id="form" action="<?php echo site_url('user/do_upload');?>">
                    <div class="modal-body">
                        <div class="form-group">
                            <label for="pwd">Business Name:</label>
                            <input type="text" class="form-control buisnesstype" name="type" id="usr" placeholder="Enter a Business Name">
                        </div>
                        <div class="form-group buisnesspass">
                            <label for="pwd">Password:</label>
                            <input type="password" class="form-control buisnesstype buisnessnew" name="buis_pass" placeholder="Password">
                        </div>

                        <input type="hidden" class="bu_edit" name="bu_edit">
                        <input type="submit" class="btn btn-success update " value="Update My Business">
                        <input type="submit" class="btn btn-success pass" value="Create My Business">
                    </div>
                </form>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
                </div>
            </div>
        </div>
    </div>
    <div class="modal fade" id="setting" role="dialog" data-keyboard="false" data-backdrop="static">
        <div class="modal-dialog">
            <!-- Modal content-->
            <div class="modal-content s_modal " >
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal">&times;</button>
                    <h4 class="modal-title">Data List Setting</h4>
                </div>




                <form method="post" action="<?php echo site_url('user/page_set');?>">
                    <input type="hidden" name="seting" value="">

                    <div class="form-group type">
                        <label for="usr">Value:</label>
                        <input type="text" class="form-control" name="seting" id="pagevalue" value="">
                    </div>

                    <input type="submit" class="btn btn-primary" value="Save Change">
                    <input type="hidden" id="pagelimit" value="" name="page">
                </form>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
                </div>
            </div>
        </div>
    </div>


    <div class="modal fade" id="sideModaltwo" role="dialog">
        <div class="modal-dialog">
            <!-- Modal content-->
            <div class="modal-content s_modal">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal">&times;</button>
                    <h4 class="modal-title">Choose a Business</h4>
                </div>
                <form method="post" id="form" action="<?php echo site_url('user/do_upload');?>">
                    <div class="modal-body">

                        <table class="table table-bordered">

                            <?php  foreach ($result as $key=> $item)
               { 
                 $btype=$item->type;
               $beid=$item->id;
                if($btype==$b_type){
                  $activ='Active';
                    echo '<tr><td> '.$btype.' </td><td> '.$activ.' </td><td></td></tr>';
              }
              else{
                 $activ=''; 
             ?>
                            <tr class="delete_mem<?php echo $item->id; ?>">
                                <td>
                                    <?php echo $btype; ?>
                                </td>

                                <td style="cursor:pointer;"><a class="ac" onclick="buisnessedit(<?php echo $beid; ?>)" data-toggle="modal" data-target="#sideModal" data-toggle="modal" data-target="#sideModal"><i class="fa fa-edit"></i></a></td>
                                <td style="cursor:pointer;"><a class="ac" data-toggle="modal" data-target="#AdminPanel" data-toggle="modal" onclick="adminbuisnessdelete(<?php echo $beid; ?>)"><i class="fa fa-trash"></i></a></td>
                            </tr>
                            <?php } } ?>
                        </table>
                    </div>
                </form>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
                </div>
            </div>
        </div>
    </div>


</div>
<div class="main-nav">
    <nav class="navbar navbar-default">
        <div class="navbar-header">
          <button type="button" class="navbar-toggle collapsed" id="custom-toggle" data-toggle="collapse" data-target="#myNavbar">
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>                        
      </button>
        </div>
        <div class="collapse navbar-collapse" id="myNavbar">
            <ul class="nav navbar-nav navbar-left main-menu">
              
            
 
                <li><a class="btn-menu " id="link-link2"  href="<?php echo base_url('user/dash');?>"><i class="fa fa-home" aria-hidden="true"></i><span>Dashboard</span></a></li>
                <li class="active7"><a class="btn-menu " id="link-link2"  href="<?php echo base_url('user/alltrans');?>"><i class="fa fa-home" aria-hidden="true"></i><span>All Transaction</span></a></li>
                <li class="active2"><a class="btn-menu" href="<?php echo base_url('user/search');?>"><i class="fa fa-credit-card" aria-hidden="true"></i><span>Daily Sale</span></a></li>


                <li class="active3"><a class="btn-menu" href="<?php echo base_url('purchases/home');?>"><i class="fa fa-shopping-cart" aria-hidden="true"></i><span>Purchases</span></a></li>

                <li class="active4"><a class="btn-menu" href="<?php echo base_url('sale/wholesale');?>"><i class="fa fa-money" aria-hidden="true"></i><span>Whole Sale</span></a></li>

                <li class="active5"><a class="btn-menu" href="<?php echo base_url('worker/home');?>"><i class="fa fa-user-o" aria-hidden="true"></i><span>Employers</span></a></li>
                <li class="active6"><a class="btn-menu" href="<?php echo base_url('expense/search');?>"><i class="fa fa-dollar"></i><span>Expenses</span></a></li>
                <li><a class="btn-menu" href="<?php echo base_url('Balance/transfer');?>"><i class="fa fa-balance-scale" aria-hidden="true"></i><span>Bank Transfer</span></a></li>
              
        
                <li><a class="btn-menu" href="<?php echo base_url('invoice/details');?>"><i class="fa fa-files-o" aria-hidden="true"></i><span>Invoice</span></a></li>
                  <li class="menupanel panel-default" id="menudropdown">
<a class="dropdown_toggle" href="javascript:"  onclick="toggleclass('pagesubmenu')">
    <i class="fa fa-diamond"></i> Loan
<span class="caret"></span>
</a>


<ul class="dropdown-menu nav navbar-nav pagesubmenu submenu" >
    <li class="active66"><a class="btn-menu" href="<?php echo base_url('pay_loan/create');?>"><i class="fa fa-dollar"></i><span>Pay Loan</span></a></li>
    <li class="active67"><a class="btn-menu" href="<?php echo base_url('loan/create');?>"><i class="fa fa-credit-card"></i><span>Loan</span></a></li>

</ul>


</li>
            </ul>
        </div>
    </nav>
</div>

<script type="text/javascript" src="<?= base_url() ?>assets/admin/js/jquery-1.8.3.min.js" charset="UTF-8"></script>
<script type="text/javascript" src="<?= base_url() ?>assets/admin/js/bootstrap.min.js"></script>

<script type="text/javascript" src="<?= base_url() ?>assets/admin/js/bootstrap-datetimepicker.fr.js" charset="UTF-8"></script>

<script>
    $(function() {
        var Accordion = function(el, multiple) {
            this.el = el || {};
            this.multiple = multiple || false;
            // Variables privadas
            var links = this.el.find('.link');
            // Evento
            links.on('click', {
                el: this.el,
                multiple: this.multiple
            }, this.dropdown)
            $('.main-content').on('click', function(e) {
                $('.submenu').hide();
                // $(".menu,.link,.fa,.fa-chevron-right").css("display", "none");
                //  $(".menu.open,.link,.fa,.fa-chevron-right").css("display", "block");
                //   $(".menu,.link,.fa,.fa-chevron-down").css("display", "block");
                //  $(".menu.open,.link,.fa,.fa-chevron-down").css("display", "none");

            });
        }
        Accordion.prototype.dropdown = function(e) {
            var $el = e.data.el;
            $this = $(this),
                $next = $this.next();
            $next.slideToggle();
            $this.parent().toggleClass('open');
            if (!e.data.multiple) {
                $el.find('.submenu').not($next).slideUp().parent().removeClass('open');
            };
        }
        var accordion = new Accordion($('#accordion'), false);
    });
</script>
<script type="text/javascript">
    var _gaq = _gaq || [];
    _gaq.push(['_setAccount', 'UA-36251023-1']);
    _gaq.push(['_setDomainName', 'jqueryscript.net']);
    _gaq.push(['_trackPageview']);
    (function() {
        var ga = document.createElement('script');
        ga.type = 'text/javascript';
        ga.async = true;
        ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
        var s = document.getElementsByTagName('script')[0];
        s.parentNode.insertBefore(ga, s);
    })();
</script>
<script>
    function buisnessedit(id) {
        $('.bu_edit').val(id);
        $('.buisnesspass').hide();
        $('.update').show();
        $('.pass').hide();
        $.ajax({

            url: "<?php echo base_url();?>user/bu_edit",
            type: "POST",
            data: {
                'uristring': id
            },
            dataType: 'json',
            success: function(data) {

                $('.buisnesstype').val(data.type);


            }
        });
    }
</script>
<script>
    function buisnessdelete() {
        var buisnessid=$('.Deletebuisnessid').val();
        var access=$('.buisnessdelete').val();
        if(access=='M#jolmou@#'){
           
    $('#AdminPanel').hide();
$('.modal-backdrop').hide(); 
  
             swal({

                title: "Are you sure you want to delete the business ",
                text: "You will no longer have access to this account and this cannot be undone.",
                type: "warning",
                showCancelButton: true,
                confirmButtonClass: "btn-danger",
                confirmButtonText: "Delete",
                closeOnConfirm: false
            },
            function() {
                var datastr = buisnessid;

                //var datastr='ref='+ encodeURIComponent(ref)

                $.ajax({
                    url: "<?php echo base_url();?>user/bu_delete",
                    type: "POST",
                    data: {
                        'uristring': datastr
                    },
                    dataType: 'json',
                    success: function(data) {




                    }
                });
                swal("", "Your business has been removed.", "success");
                $(".delete_mem" + datastr).fadeOut('slow');
                $(".list" + datastr).fadeOut('slow');

            });
        }
        else{
           swal("Password not matched"); 
        }
       


    }
</script>
<script>
    function buisnessadd() {
        $('.submenu').hide();
        save_method = 'add';
        $('#form')[0].reset();
        $('.bu_edit').val('');
        $('.buisnesspass').show();
        $('.pass').show();
        $('.update').hide();
        $('#form').trigger("reset"); // reset form on modals
        $('.form-group').removeClass('has-error');
    }
</script>
<script>
    $('.pass').click(function() {

        if ($('.buisnessnew').val() !== 'M#jolmou@#') {
            swal("Password not matched!");
            return false;
        } else {
            swal("Buisness created");
            return true;
        }
    });
</script>



<script type="text/javascript">
    $(function() {
        // this will get the full URL at the address bar
        var url = window.location.href;

        // passes on every "a" tag
        $("#myNavbar a").each(function() {

            // checks if its the same on the address bar
            if (url == (this.href)) {
                $(this).closest("li").addClass("active");
                //for making parent of submenu active
                $(this).closest("li").parent().parent().addClass("active");
            }

        });
    });
</script>
<script>
    $(document).ready(function() {
        var url = (window.location);
        /*var afterDomain= url.substring(url.lastIndexOf('/') + 1);
        alert(afterDomain);*/
        /*var  niceURI = url.replace(/[^a-zA-Z0-9-_]/g, '');
         alert(niceURI);*/
        if (url == "<?php echo site_url('user/search'); ?>") {
            $(".active2").addClass('active');
        }

        if (url == "<?php echo site_url('purchases/home'); ?>") {
            $(".active3").addClass('active');
        }
        if (url == "<?php echo site_url('sale/wholesale'); ?>") {
            $(".active4").addClass('active');
        }
        if (url == "<?php echo site_url('worker/home'); ?>") {
            $(".active5").addClass('active');
        }
        if (url == "<?php echo site_url('expense/search'); ?>") {
            $(".active6").addClass('active');
        }
         if (url == "<?php echo site_url('user/alltrans'); ?>") {
            $(".active7").addClass('active');
        }
        if (url == "<?php echo site_url('pay_loan/create'); ?>") {
            $(".active66").addClass('active');
        }
        if (url == "<?php echo site_url('loan/create'); ?>") {
            $(".active67").addClass('active');
        }
    });
</script>
<script>
    function adminbuisnessdelete(id){
        $('.Deletebuisnessid').val(' ');
        $('.Deletebuisnessid').val(id);
        $('.buisnessdelete').val('');
    }
    $(".fa-outdent").on("click", function(event){
		event.preventDefault();
       $(this).toggleClass('content-minimize');
        $('.main-content').toggleClass('content-minimize');
        $('.admin-menu').toggleClass('content-minimize');
        $('#wrapper').toggleClass('content-minimize');
       
   });
     function toggleclass(divclass){
         $('.'+divclass+'').toggleClass('show');
         
     }
</script>
<script>
document.addEventListener("DOMContentLoaded", function () {
  const toggleBtn = document.getElementById("custom-toggle");
  const menu = document.getElementById("myNavbar");

  toggleBtn.addEventListener("click", function () {
    const isOpen = menu.classList.contains("mobilemenuactive");
    setTimeout(() => {
    if (isOpen) {
      // Close Menu
    menu.classList.remove("mobilemenuactive");
      menu.classList.remove("in");
        console.log('remove');
      menu.style.height = "0px";
      toggleBtn.classList.remove("open");
      toggleBtn.setAttribute("aria-expanded", "false");
    } else {
     menu.classList.add("mobilemenuactive");
           console.log('add');
      menu.classList.add("in");
      menu.style.height = "auto";
      toggleBtn.classList.add("open");
      toggleBtn.setAttribute("aria-expanded", "true");
    }
       }, 100); // short delay to allow transition
  });
});
    $('#myNavbar').on('hidden.bs.collapse shown.bs.collapse', function (e) {
  e.stopPropagation();
});
</script>

<style>
   
     .in.navbar-collapse{
        display: none!important;
    }
     .main-nav .navbar-collapse.mobilemenuactive.in{
        display: block!important;
    }
/* Overwrite collapse so no auto animation from Bootstrap */
#myNavbar {
  transition: height 0.3s ease;
}
#myNavbar.open-menu {
  height: auto !important;
}

/* Cross Animation */
.navbar-toggle.open .icon-bar:nth-child(1) {
  transform: rotate(45deg) translate(2px, 2px);
}
.navbar-toggle.open .icon-bar:nth-child(2) {
  opacity: 0;
}
.navbar-toggle.open .icon-bar:nth-child(3) {
  transform: rotate(-45deg) translate(6px, -6px);
}
.navbar-toggle .icon-bar {
  transition: all 0.3s ease;
}
</style>