  <?php 
    $this->load->view('templates/header');
    $action                     = (isset($_GET['action'])) ? $_GET['action'] : "";
    $search_value_entry_no      = (isset($_GET['search_value_entry_no'])) ? $_GET['search_value_entry_no'] : 0;
    $search_value_entry_date    = (isset($_GET['search_value_entry_date'])) ? $_GET['search_value_entry_date'] : '';
    $search_value_cust_id       = (isset($_GET['search_value_cust_id'])) ? $_GET['search_value_cust_id'] : 0;
    $search_value_broker_id     = (isset($_GET['search_value_broker_id'])) ? $_GET['search_value_broker_id'] : 0;

  ?>
    <script>
        var link = "challan_return";
        var sub_link = "view";
    </script>
    <!-- Content Header (Page header) -->
    <section class="content-header">
      <h1>
        JANGAD
        <small>RETURN</small>
      </h1>
      <ol class="breadcrumb">
        <li><a href="#"><i class="fa fa-dashboard"></i> Home</a></li>
        <li><a href="#">Jangad Return</a></li>
        <li class="active">View</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('challan/challanctrl/challan_return_master/')?>" method="get">
                            <div class="panel panel-body remove-bottom">
                                <div class="form-group floating-form">
                                    
                                    <div class="col-md-1 col-sm-1 floating-label">
                                        <?php echo form_dropdown('', $data['entry_no_drop_down'], $search_value_entry_no,'id="search_value_entry_no" name="search_value_entry_no" class="form-control floating-select flexselect" ');?>
                                        <label>ENTRY NO</label>
                                    </div>

                                    <div class="col-md-1 col-sm-1 floating-label">
                                        <input type="text" class="form-control floating-input" name="search_value_entry_date" id="search_value_entry_date" value="<?php echo $search_value_entry_date ?>" placeholder=" " autocomplete="off"/>
                                        <label>Entry Date</label>
                                    </div>

                                    <div class="col-md-1 col-sm-1 floating-label">
                                        <?php echo form_dropdown('', $data['customer_drop_down'], $search_value_cust_id,'id="search_value_cust_id" name="search_value_cust_id" class="form-control floating-select flexselect" ');?>
                                        <label>CUSTOMER</label>
                                    </div>

                                    <div class="col-md-1 col-sm-1 floating-label">
                                        <?php echo form_dropdown('', $data['broker_drop_down'], $search_value_broker_id,'id="search_value_broker_id" name="search_value_broker_id" class="form-control floating-select flexselect" ');?>
                                        <label>BROKER</label>
                                    </div>
                                    
                                    <div class="col-md-1 col-sm-1 ">
                                        <button type="submit" class="btn btn-primary"><i class="fa fa-search" aria-hidden="true"></i>Search</button>                                   
                                        <input type="hidden" class="form-control" id="action" name="action" value="<?php echo $action ?>" />     
                                    </div>

                                    <div class="col-md-1 col-sm-1">
                                        <a href="<?php echo base_url('challan/challanctrl/challan_return_master?action=view'); ?>" class="btn btn-primary"><i class="fa fa-undo" aria-hidden="true"></i>
                                            Reset
                                        </a>
                                    </div>
                                    <div class="col-md-1 col-sm-1">
                                        <a href="<?php echo base_url('challan/challanctrl/challan_return_master?action=add'); ?>" class="btn btn-primary">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:90%;">
                                            Cnt :
                                            <span id="count_reload">                                                 
                                                <i id="total_rows"><?php echo $total_rows;?></i>
                                            </span>
                                        </label>                                        
                                    </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>#</th>
                                    <th>ENTRY NO</th>
                                    <th>ENTRY DATE</th>    
                                    <th>CUSTOMER</th>    
                                    <th>BROKER</th>    
                                    <th>THROUGH</th>                                        
                                    <!-- <th>QTY</th>                                         -->
                                    <!-- <th>AMT</th>                                         -->
                                    <th>EDIT</th>    
                                    <th>DELETE</th>    
                                </tr>
                            </thead>
                            <tbody>
                        <?php 
                                if(!empty($data['challan_return_data'])):
                                foreach ($data['challan_return_data'] as $key => $value): 
                                    $crm_id     = encrypt_decrypt("encrypt", $value['crm_id'], SECRET_KEY);
                                    $entry_no   = $value['crm_entry_no'];
                                    $entry_date = date('d-m-Y', strtotime($value['crm_entry_date']));
                                    $customer   = strtoupper($value['customer']);
                                    $broker     = strtoupper($value['broker']);
                                    $through    = strtoupper($value['crm_through']);
                                    $qty        = $value['crm_total_qty'];
                                    $amt        = number_format($value['crm_total_amt'],2);
                        ?>
                            <tr>
                                <td><?php echo $key+1?></td>                                
                                <td><?php echo $entry_no; ?></td>
                                <td><?php echo $entry_date; ?></td>
                                <td><?php echo $customer; ?></td>
                                <td><?php echo $broker; ?></td>
                                <td><?php echo $through; ?></td>
                                <!-- <td><?php echo $qty; ?></td> -->
                                <!-- <td><?php echo $amt; ?></td> -->
                                <td><a href="<?php echo base_url('challan/challanctrl/challan_return_master?action=edit&id='.$crm_id); ?>" class="glyphicon glyphicon-pencil"></a></td>                                
                                <td><span class="glyphicon glyphicon-trash" style="cursor: pointer;" onClick="delete_master_item(<?php echo $value['crm_id']?>,'challan_return_delete');"></span></td>
                            </tr> 
                        <?php
                            endforeach;
                            else:
                        ?>
                            <tr>
                                <td colspan="10" style="color:red;" align="center">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');
   ?>
    <script src="<?php echo assets('js/challan.js')?>"></script> 
  