  <?php 
    $this->load->view('templates/header');
    $search_value_stock_id      = (isset($_REQUEST['search_value_stock_id'])) ? $_REQUEST['search_value_stock_id'] : 0;
    $search_value_sh            = (isset($_REQUEST['search_value_sh'])) ? $_REQUEST['search_value_sh'] : 0;
    $search_value_wt            = (isset($_REQUEST['search_value_wt'])) ? $_REQUEST['search_value_wt'] : 0;
    $search_value_col           = (isset($_REQUEST['search_value_col'])) ? $_REQUEST['search_value_col'] : 0;
    $search_value_cla           = (isset($_REQUEST['search_value_cla'])) ? $_REQUEST['search_value_cla'] : 0;
    $search_value_cut           = (isset($_REQUEST['search_value_cut'])) ? $_REQUEST['search_value_cut'] : 0;
    $search_value_pol           = (isset($_REQUEST['search_value_pol'])) ? $_REQUEST['search_value_pol'] : 0;
    $search_value_sym           = (isset($_REQUEST['search_value_sym'])) ? $_REQUEST['search_value_sym'] : 0;
    $search_value_fl            = (isset($_REQUEST['search_value_fl'])) ? $_REQUEST['search_value_fl'] : 0;
    $search_value_lab           = (isset($_REQUEST['search_value_lab'])) ? $_REQUEST['search_value_lab'] : 0;
    $search_value_status        = (isset($_REQUEST['search_value_status'])) ? $_REQUEST['search_value_status'] : 0;    
    $search_value_start_date    = (isset($_REQUEST['search_value_start_date'])) ? date('d-m-Y', strtotime($_REQUEST['search_value_start_date'])) : date('01-06-Y');    
    $search_value_end_date      = (isset($_REQUEST['search_value_end_date'])) ? date('d-m-Y', strtotime($_REQUEST['search_value_end_date'])) : date('d-m-Y');    
  ?>
    <script>
        var link = "report";
        var sub_link = "r2net";
    </script>
    <!-- Content Header (Page header) -->
    <section class="content-header">
      <h1>
        R2NET
        <small>REPORT</small>
      </h1>
      <ol class="breadcrumb">
        <li><a href="#"><i class="fa fa-dashboard"></i> Home</a></li>
        <li><a href="#">Report</a></li>
        <li class="active">R2Net 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/r2net_report/')?>" method="post">
                            <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" multiple ');?>
                                        <label>STOCK ID</label>
                                    </div>

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

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

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

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

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

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

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

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

                                    <div class="col-md-1 col-sm-1 floating-label">
                                        <?php echo form_dropdown('', $data['lab_drop_down'], $search_value_lab,'id="search_value_lab" name="search_value_lab[]" class="form-control floating-select" multiple ');?>
                                        <label>LAB</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>                                        
                                    </div>

                                    <div class="col-md-1 col-sm-1">
                                        <a href="<?php echo base_url('report/reportctrl/r2net_report'); ?>" class="btn btn-primary"><i class="fa fa-undo" aria-hidden="true"></i>
                                            Reset
                                        </a>
                                    </div>
                                </div>
                                <div class="form-group floating-form">
                                    <div class="col-md-offset-11 col-md-1 col-sm-offset-11 col-sm-1">
                                        <a href="<?php echo base_url('report/Reportctrl/r2net_report_excel'); ?>" target="_blank" class="btn btn-primary"><i class="fa fa-file-excel-o" aria-hidden="true"></i>
                                            Export
                                        </a>
                                    </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="2%">#</th>
                                    <th width="6%">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%">TD</th>    
                                    <th width="3%">TA</th>    
                                    <th width="3%">LEN</th>    
                                    <th width="3%">WID</th>    
                                    <th width="3%">HEI</th>    
                                    <th width="3%">LAB</th>    
                                    <th width="12%">CERT COMMENTS</th>    
                                    <th width="7%">REPORT NO</th>    
                                    <th width="4%">DISC</th>    
                                    <th width="4%">DISC</th>    
                                    <th width="3%">RAP</th>    
                                    <th width="5%">PER CRT</th>    
                                    <th width="4%">TOTAL</th>    
                                    <th width="5%">NR PPC</th>    
                                    <th width="6%">NR TOTAL</th>    
                                    
                                </tr>
                            </thead>
                            <tbody>
                        <?php
                            $sub_total      = 0;
                            $disc           = 0;
                            $disc_amt       = 0;
                            $total_dollar   = 0;
                            $price_per_crt  = 0;
                            if(!empty($data['diamond_data'])):
                            foreach ($data['diamond_data'] as $key => $value):
                                $disc1 = $value['dm_disc']-2;
                                $disc2 = $value['dm_disc']-3;

                                $disc_amt1 = ($value['dm_rap'] * $disc1) / 100;
                                $per_crt   = $value['dm_rap'] + $disc_amt1;
                                $total     = $per_crt * $value['dm_wt']; 

                                $disc_amt2 = ($value['dm_rap'] * $disc2) / 100;
                                $nr_ppc    = $value['dm_rap'] + $disc_amt2;
                                $nr_total  = $nr_ppc * $value['dm_wt']; 
                                
                        ?>
                            <tr>
                                <td><?php echo $key?></td>                                
                                <td><?php echo $value['dm_code']?></td>
                                <td><?php echo $value['dm_sh']?></td>
                                <td><?php echo $value['dm_wt']?></td>
                                <td><?php echo $value['dm_col']?></td>
                                <td><?php echo $value['dm_cla']?></td>
                                <td><?php echo $value['dm_cut']?></td>
                                <td><?php echo $value['dm_pol']?></td>
                                <td><?php echo $value['dm_sym']?></td>
                                <td><?php echo $value['dm_fl']?></td>
                                <td><?php echo $value['dm_td']?></td>
                                <td><?php echo $value['dm_ta']?></td>
                                <td><?php echo $value['dm_len']?></td>
                                <td><?php echo $value['dm_wid']?></td>
                                <td><?php echo $value['dm_hei']?></td>
                                <td><?php echo $value['dm_lab']?></td>
                                <td><?php echo $value['dm_cert_com']?></td>
                                <td><?php echo $value['dm_report_no']?></td>
                                <td><?php echo number_format($disc1, 2);?></td>
                                <td><?php echo number_format($disc2, 2);?></td>
                                <td><?php echo $value['dm_rap']?></td>
                                <td><?php echo number_format($per_crt, 2)?></td>
                                <td><?php echo number_format($total, 2) ?></td>
                                <td><?php echo number_format($nr_ppc, 2)?></td>
                                <td><?php echo number_format($nr_total, 2)?></td>
                            </tr> 
                        <?php
                            endforeach;
                            else:
                        ?>
                            <tr>
                                <td colspan="25" 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 type="text/javascript" src="<?php echo assets('js/report.js')?>"></script> 