  <?php
    $this->load->view('templates/header');
    $action = (isset($_GET['action'])) ? $_GET['action'] : "";
    $search_value_by_acc_id = (isset($_GET['search_value_by_acc_id'])) ? $_GET['search_value_by_acc_id'] : 0;
    $search_value_by_acc_kyc = (isset($_GET['search_value_by_acc_kyc'])) ? $_GET['search_value_by_acc_kyc'] : 0;
  ?>
    <script>
        var link     = "master";
        var sub_link =  "supplier_account" ;
    </script>
    <!-- Content Header (Page header) -->
    <section class="content-header">
      <h1>
       <?php echo $label ?>
        <small>Master</small>
      </h1>
      <ol class="breadcrumb">
        <li><a href="#"><i class="fa fa-dashboard"></i> Home</a></li>
        <li class="active">Broker Master</li>
      </ol>
    </section>

    <!-- Main content -->
    <section class="content">
        <div class="row">
            <div class="col-md-12 col-sm-12">
                <div class="box box-primary">
                    <!-- <div class="box-body"> -->
                        <form class="form-horizontal" id="search_form" action="<?php echo base_url('master/masterctrl/account_master/'.$type)?>" method="get">
                            <div class="panel panel-body remove-bottom">
                                <div class="form-group floating-form">
                                    <div class="col-md-2 col-sm-2 floating-label">
                                        <?php echo form_dropdown('', $data['acc_name_drop_down'], $search_value_by_acc_id,'id="search_value_by_acc_id" name="search_value_by_acc_id" class="form-control floating-select flexselect" placeholder=" " tabindex="1"');?>
                                        <label>Name</label>
                                    </div>
                                    <div class="col-md-2 col-sm-2 floating-label">
                                        <?php echo form_dropdown('', $data['acc_kyc_drop_down'], $search_value_by_acc_kyc,'id="search_value_by_acc_kyc" name="search_value_by_acc_kyc" class="form-control floating-select flexselect" placeholder=" " tabindex="2"');?>
                                        <label>KYC</label>
                                    </div>
                                    <div class="col-md-1  col-sm-1 ">
                                        <button type="submit" class="btn btn-primary" tabindex="3"><i class="fa fa-search" aria-hidden="true"></i>Search</button>
                                    </div>

                                    <div class="col-md-1 col-sm-1">
                                        <a href="<?php echo base_url('master/masterctrl/account_master/'.$type); ?>" class="btn btn-primary" tabindex="8"><i class="fa fa-undo" aria-hidden="true"></i>
                                            Reset
                                        </a>
                                    </div>
                                    <div class="col-md-1  col-sm-1">
                                        <a onClick="add_update_account_popup(0,<?php echo $type?>);" class="btn btn-primary" tabindex="9">Add New</a>
                                    </div>
                                    <div class="col-md-2 col-sm-2">
                                        <label for="inputEmail3" class="col-sm-1 control-label control-label_custom" style="width:100%;">
                                            Cnt :
                                            <span id="count_reload">
                                                <i id="total_rows"><?php echo $total_rows;?></i>
                                            </span>
                                        </label>
                                        <input type="hidden" class="form-control" id="action" name="action" value="<?php echo $action ?>" />
                                    </div>
                                </div>
                            </div>
                        </form>
                    <!-- </div> -->
                </div>
            </div>
        </div>
        <div class="row">
            <div class="col-md-12">
                <div class="box">
                    <div class="box-body" id="table_reload">
                        <table class="table table-bordered table-striped">
                            <thead>
                                <tr>
                                    <th width="4%">#</th>
                                    <!-- <th width="15%">Broker Name</th>
                                     <th width="12%">Broker Mobile</th> -->
                                   <!--  <th width="8%">Group</th> -->
                                    <th width="13%">Associate Name</th>
                                    <th width="11%">Associate Mobile</th>
                                    <th width="11%">Refrence 1 </th>
                                    <th width="11%">Refrence 2 </th>
                                    <th width="5%">KYC</th>
                                    <th width="5%">Edit</th>
                                    <th width="5%">Delete</th>

                                </tr>
                            </thead>
                            <tbody>
                            <?php
                                if(!empty($data['account_data'])):
                                foreach ($data['account_data'] as $key => $value):
                            ?>
                                <?php if($value['acc_status']=='GOOD')
                                {
                                   $tr ='<tr style="background-color:lightgreen;">';
                                }
                                elseif($value['acc_status'] =='LIMITED')
                                {
                                   $tr = '<tr style="background-color:#FFD580;">';
                                }
                                elseif($value['acc_status'] =='BLACKLISTED')
                                {
                                    $tr ='<tr style="background-color:#FF7F7F;">';
                                }
                                else
                                {
                                    $tr = '';
                                }
                                ?>
                                    <?php echo $tr;?>
                                    <td><?php echo $key+1 ?></td>
                                    <!-- <td><?php //echo strtoupper($value['acc_name']);?></td> -->
                                    <!-- <td><?php //echo $value['acc_mobile']?></td> -->
                                    <td><?php echo  strtoupper($value['acc_contact'])?></td>
                                    <td><?php echo $value['acc_aumobile']?></td>
                                    <td><?php echo $value['acc_ref']?></td>
                                    <td><?php echo $value['acc_ref2']?></td>
                                    <td><?php echo $value['acc_kyc'] == 1 ? 'Yes': 'No'; ?></td>


                                    <td><span class="glyphicon glyphicon-pencil" style="cursor:pointer;" onClick="add_update_account_popup(<?php echo $value['acc_id']?>,<?php echo $type?>)"></span></td>
                                    <td><span class="glyphicon glyphicon-trash" onClick="delete_master_item(<?php echo $value['acc_id']?>,'account_delete');"></span></td>
                                </tr>
                            <?php
                                endforeach;
                                else:
                            ?>
                                <tr>
                                    <td colspan="13" align="center" style="color: red;"> No Record Found! </td>
                                </tr>
                            <?php endif; ?>
                            </tbody>
                        </table>
                    </div>
                </div>
            </div>
        </div>
        <div class="row">
            <div class="text-right">
                <?= $this->pagination->create_links(); ?>
            </div>
        </div>
    </section>

<?php
    $this->load->view('templates/footer');
?>

    <!-- Master JS files -->
    <script src="<?php echo assets('js/master.js')?>"></script>

   </body>
</html>