<div class="wrapper">
    <div class="container">
        <!-- Page-Title -->
        <div class="row">
            <div class="col-sm-12">
                <div class="btn-group pull-right m-t-10">
                    <button onclick="openaddevent();" class="btn btn-primary waves-effect waves-light m-r-10"><i class="fa fa-plus"></i> Add Event</button>
                    
                </div>
                <h4 class="page-title">Account Mapping To Events:</h4>
               
            </div>
        </div>
        <div class="row" id="divselection">
            
          <?php  foreach($events as $event){?>
           
            <div class="col-md-12">
                <div class="card-box ">
                    <div class="row">
                        <div class="col-sm-12">
                            <div class="btn-group pull-right m-t-15">
                                <a id="btnEdit" href="<?php echo base_url();?>addmapping/<?php echo $event['id_account_events'];?>"  class="btn btn-primary waves-effect waves-light m-r-10"><i class="fa fa-plus"></i> Add</a>
                                <a id="btnEdit" href="<?php echo base_url();?>editmapping/<?php echo $event['id_account_events'];?>"  class="btn btn-warning waves-effect waves-light"><i class="fa fa-pencil"></i> Edit</a>
                                
                            </div>
                           <h4 class="header-title m-t-0 m-b-30"><?php echo $event['id_account_events']. " " .$event['account_event']; ?></h4>

                        </div>
                    </div>
                    
                    <div class="row">
                         <div class="col-md-4">
                            <h4>Description</h4>
                        </div>
                         <div class="col-md-2">
                            <h4>Debit/Credit</h4>
                        </div>
                        <div class="col-md-2">
                            <h4>Entity</h4>
                        </div>
                        <div class="col-md-4">
                            <h4>Mapped Account Head</h4>
                        </div>
                    </div>
                    <hr/>
                     <?php foreach($eventmapping as $eventmap){ 
                         $x=1; foreach ($eventmap as $e){
                            
                         if($event['id_account_events']== $e['id_account_events']){?>
                    <div class="row">
                        <div class="col-md-4">
                            <label><?php echo $x.' '. $e['description']; $x++;?></label>
                        </div>
                        <div class="col-md-2">
                            <h4><?php echo $e['transaction_type'];?></h4>
                        </div>
                        <div class="col-md-2">
                            <h5><?php echo $e['entity_name'];?></h5>
                        </div>
                        <div class="col-md-4">
                            <h4><?php echo $e['idbusiness'].' '. $e['account_head'];?></h4>
                        </div>
                    </div>
                         <?php }}} ?>
                </div>
            </div>
          <?php } ?>
        </div>
    </div>
    
    <div class="modal fade none-border" id="addevent" tabindex="-1" role="dialog" aria-labelledby="" aria-hidden="true">
        <div class="modal-dialog modal-lg">
        <form method="post" action="<?php echo base_url('superuser_controller/add_account_event');?>">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                    <h4 class="modal-title"><strong>Add Event</strong></h4>
                </div>
                <div class="modal-body">
                    <div class="row">
                        <div class="col-md-12">
                            <label for="txtnewevent">New Event Name:</label>
                            <input  class="form-control" name="account_event">
                        </div>
                    </div>
                </div>
                <div class="modal-footer">
                    
                    <button type="button" class="btn btn-default waves-effect" data-dismiss="modal">Close</button>
                    <button type="submit" class="btn btn-custom waves-effect waves-light">Add Event</button>
                </div>
            </div>
        </form>
        </div>
    </div>
    
    <div class="modal fade none-border" id="updateevent" tabindex="-1" role="dialog" aria-labelledby="" aria-hidden="true">
        <div class="modal-dialog modal-lg">
        <form method="post" action="<?php echo base_url('superuser_controller/update_account_event');?>">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                    <h4 class="modal-title"><strong>Update Event</strong></h4>
                </div>
                <div class="modal-body">
                    <div class="row">
                        <div class="col-md-12">
                            <label for="txtaccountevent">Account Event:</label>
                            <input  class="form-control" name="txtaccountevent">
                        </div>
                    </div>
                </div>
                <div class="modal-footer">
                    <input type="text" name="idevent" id="idevent"  />
                    <button type="button" class="btn btn-default waves-effect" data-dismiss="modal">Close</button>
                    <button type="submit" class="btn btn-custom waves-effect waves-light">Update Event</button>
                </div>
            </div>
        </form>
        </div>
    </div>
    
    <script>
        
        function openaddevent(){
           
            $("#addevent").modal('show');
        }
    
    </script>