  <?php 
    $this->load->view('templates/header');
    $action                     = (isset($_GET['action'])) ? $_GET['action'] : "";
    $search_value_stock_id      = (isset($_GET['search_value_stock_id'])) ? $_GET['search_value_stock_id'] : 0;
    $search_value_user          = (isset($_GET['search_value_user'])) ? $_GET['search_value_user'] : 0;
    $search_value_party         = (isset($_GET['search_value_party'])) ? $_GET['search_value_party'] : 0;
    $search_value_broker        = (isset($_GET['search_value_broker'])) ? $_GET['search_value_broker'] : 0;
    $search_value_status        = (isset($_GET['search_value_status'])) ? $_GET['search_value_status'] : 0;    
    $search_value_entry_date    = (isset($_GET['search_value_entry_date'])) ? $_GET['search_value_entry_date'] : '';    
    $search_value_entry_no      = (isset($_GET['search_value_entry_no'])) ? $_GET['search_value_entry_no'] : 0;    
  ?>
    <script>
        var link = "report";
        var sub_link = "certificate";
    </script>
    <!-- Content Header (Page header) -->
    <section class="content-header">
      <h1>
        PENDING CERTIFICATE
        <small>REPORT</small>
      </h1>
      <ol class="breadcrumb">
        <li><a href="#"><i class="fa fa-dashboard"></i> Home</a></li>
        <li class="active">Pending Certificate Report</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('report/Reportctrl/certificate_report')?>" 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['stock_id_drop_down'], $search_value_stock_id,'id="search_value_stock_id" name="search_value_stock_id" class="form-control floating-select" ');?>
                                        <label>STOCK ID</label>
                                    </div>

                                    <!-- <div class="col-md-1 col-sm-1 floating-label">
                                        <?php echo form_dropdown('', [0=>'ALL', 1=>'AVAILABLE', 2=>'ISSUE', 3=>'HOLD', 4=>'SOLD', 5=>'RETURN'], $search_value_status,'id="search_value_status" name="search_value_status" class="form-control floating-select flexselect" ');?>
                                        <label>STATUS</label>
                                    </div>
 -->
                                    <!-- <div class="col-md-1 col-sm-1 floating-label">
                                        <?php echo form_dropdown('', $data['user_drop_down'], $search_value_user,'id="search_value_user" name="search_value_user" class="form-control floating-select flexselect" ');?>
                                        <label>USER</label>
                                    </div> -->

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

                                    <div class="col-md-2 col-sm-2 floating-label">
                                        <?php echo form_dropdown('', $data['broker_drop_down'], $search_value_broker,'id="search_value_broker" name="search_value_broker" class="form-control floating-select flexselect" ');?>
                                        <label>BROKER</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-2 col-sm-2 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 ">
                                        <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('report/Reportctrl/certificate_report?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">
                                        <?php 
                                            $url = $_SERVER['QUERY_STRING'];
                                        ?>
                                        <a target="_blank" href="<?php echo base_url('report/Reportctrl/certificate_report_print?'.$url); ?>" class="btn btn-primary"><i class="fa fa-print" aria-hidden="true"></i>
                                            Print
                                        </a>
                                    </div> -->
                                    <div class="col-md-1 col-sm-1 ">
                                        <label for="inputEmail3" class="col-sm-1 control-label control-label_custom" style="width:100%;">
                                            Count :
                                            <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">
                        <div class="alert_msg"></div>
                        <table class="table table-bordered table-striped">
                            <thead>
                                <tr>
                                    <th width="3%">#</th>
                                    <th width="5%">STOCK ID</th>
                                    <th width="3%">SH</th>    
                                    <th width="3%">WT</th>    
                                    <th width="3%">COL</th>    
                                    <th width="3%">CLA</th>    
                                    <th width="3%">CUT</th>    
                                    <th width="3%">POL</th>    
                                    <th width="3%">SYM</th>    
                                    <th width="3%">FL</th>    
                                    <th width="3%">LAB</th>    
                                    <th width="5%">DISC</th>    
                                    <th width="5%">RAP</th>    
                                    <!-- <th width="5%">STATUS</th>     -->
                                    <!-- <th width="10%">USER</th>     -->
                                    <!-- <th width="10%">DATE AND TIME</th>     -->
                                    <th width="10%">PARTY</th>    
                                    <th width="10%">BROKER</th>                                        
                                    <th width="10%">ENTRY DATE</th>                                        
                                    <th width="10%">ENTRY NO</th>                                        
                                    <th width="10%">CERT GIVEN</th>                                        
                                </tr>
                            </thead>
                            <tbody>
                        <?php
                            if(!empty($data['diamond_data'])):
                            foreach ($data['diamond_data'] as $key => $value):
                                $crt_id = $value['crt_id'];
                                $code   = $value['crt_dm_code'];
                                $sh     = $value['crt_dm_sh'];
                                $wt     = $value['crt_dm_wt'];
                                $col    = $value['crt_dm_col'];
                                $cla    = $value['crt_dm_cla'];
                                $cut    = $value['crt_dm_cut'];
                                $pol    = $value['crt_dm_pol'];
                                $sym    = $value['crt_dm_sym'];
                                $fl     = $value['crt_dm_fl'];
                                $lab    = $value['crt_dm_lab'];
                                $disc   = $value['crt_dm_disc'];
                                $rap    = $value['crt_dm_rap'];
                                $party  =  $value['crm_customer'] == '' ? '-' : $value['crm_customer'];            
                                    $broker =  $value['crm_broker'] == '' ? '-' : $value['crm_broker'];       

                                $entry_date =  date('d-m-Y', strtotime($value['crm_entry_date']));            
                                $entry_no   =  $value['crm_entry_no'];            
                        ?>
                            <tr>
                                <td><?php echo $key+1 ?></td>                                
                                <td><?php echo $code; ?></td>
                                <td><?php echo $sh; ?></td>
                                <td><?php echo $wt; ?></td>
                                <td><?php echo $col; ?></td>
                                <td><?php echo $cla; ?></td>
                                <td><?php echo $cut; ?></td>
                                <td><?php echo $pol; ?></td>
                                <td><?php echo $sym; ?></td>
                                <td><?php echo $fl; ?></td>
                                <td><?php echo $lab; ?></td>
                                <td><?php echo $disc; ?></td>
                                <td><?php echo $rap; ?></td>
                                <td><?php echo $party; ?></td>
                                <td><?php echo $broker; ?></td>
                                <td><?php echo $entry_date; ?></td>
                                <td><?php echo $entry_no; ?></td>
                                <td><input type="checkbox" class="checkbox" id="cert_<?php echo $crt_id; ?>" onchange="receive_certificate(<?php echo $crt_id; ?>)" /></td>
                            </tr> 
                        <?php
                            endforeach;
                            else:
                        ?>
                            <tr>
                                <td colspan="18" 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');
   ?>
   <script src="<?php echo assets('js/report.js')?>"></script> 