  <?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;    
  ?>
    <script>
        var link = "report";
        var sub_link = "history";
    </script>
    <!-- Content Header (Page header) -->
    <section class="content-header">
      <h1>
        HISTORY
        <small>REPORT</small>
      </h1>
      <ol class="breadcrumb">
        <li><a href="#"><i class="fa fa-dashboard"></i> Home</a></li>
        <li class="active">History 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/history_report/')?>" 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['stock_id_drop_down'], $search_value_stock_id,'id="search_value_stock_id" name="search_value_stock_id" class="form-control floating-select flexselect" ');?>
                                        <label>STOCK ID</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/history_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/history_report_print?'.$url); ?>" class="btn btn-primary"><i class="fa fa-print" aria-hidden="true"></i>
                                            Print
                                        </a>
                                    </div>
                                    
                                </div>
                            </div>
                            <div class="panel panel-body remove-bottom">
                                <div class="form-group floating-form">                                    
                                    <div class="col-md-1 col-sm-1 floating-label">
                                        <input type="text" class="form-control floating-input" value="<?php echo empty($data['diamond_data']) ? '' : $data['diamond_data'][0]['dm_sh']; ?>" placeholder=" " autocomplete="off" readonly/>
                                        <label>SHAPE</label>
                                    </div>
                                    <div class="col-md-1 col-sm-1 floating-label">
                                        <input type="text" class="form-control floating-input" value="<?php echo empty($data['diamond_data']) ? '' : $data['diamond_data'][0]['dm_wt']; ?>" placeholder=" " autocomplete="off" readonly/>
                                        <label>WEIGHT</label>
                                    </div>
                                    <div class="col-md-1 col-sm-1 floating-label">
                                        <input type="text" class="form-control floating-input" value="<?php echo empty($data['diamond_data']) ? '' : $data['diamond_data'][0]['dm_col']; ?>" placeholder=" " autocomplete="off" readonly/>
                                        <label>COLOR</label>
                                    </div>
                                    <div class="col-md-1 col-sm-1 floating-label">
                                        <input type="text" class="form-control floating-input" value="<?php echo empty($data['diamond_data']) ? '' : $data['diamond_data'][0]['dm_cla']; ?>" placeholder=" " autocomplete="off" readonly/>
                                        <label>CLARITY</label>
                                    </div>
                                    <div class="col-md-1 col-sm-1 floating-label">
                                        <input type="text" class="form-control floating-input" value="<?php echo empty($data['diamond_data']) ? '' : $data['diamond_data'][0]['dm_cut']; ?>" placeholder=" " autocomplete="off" readonly/>
                                        <label>CUT</label>
                                    </div>
                                    <div class="col-md-1 col-sm-1 floating-label">
                                        <input type="text" class="form-control floating-input" value="<?php echo empty($data['diamond_data']) ? '' : $data['diamond_data'][0]['dm_pol']; ?>" placeholder=" " autocomplete="off" readonly/>
                                        <label>POLISH</label>
                                    </div>
                                    <div class="col-md-1 col-sm-1 floating-label">
                                        <input type="text" class="form-control floating-input" value="<?php echo empty($data['diamond_data']) ? '' : $data['diamond_data'][0]['dm_sym']; ?>" placeholder=" " autocomplete="off" readonly/>
                                        <label>SYMETRY</label>
                                    </div>
                                    <div class="col-md-1 col-sm-1 floating-label">
                                        <input type="text" class="form-control floating-input" value="<?php echo empty($data['diamond_data']) ? '' : $data['diamond_data'][0]['dm_fl']; ?>" placeholder=" " autocomplete="off" readonly/>
                                        <label>FLOUROSCENT</label>
                                    </div>
                                    <div class="col-md-1 col-sm-1 floating-label">
                                        <input type="text" class="form-control floating-input" value="<?php echo empty($data['diamond_data']) ? '' : $data['diamond_data'][0]['dm_lab']; ?>" placeholder=" " autocomplete="off" readonly/>
                                        <label>LAB</label>
                                    </div>
                                    <div class="col-md-1 col-sm-1 floating-label">
                                        <input type="text" class="form-control floating-input" value="<?php echo empty($data['diamond_data']) ? '' : $data['diamond_data'][0]['dm_disc']; ?>" placeholder=" " autocomplete="off" readonly/>
                                        <label>DISCOUNT</label>
                                    </div>
                                    <div class="col-md-1 col-sm-1 floating-label">
                                        <input type="text" class="form-control floating-input" value="<?php echo empty($data['diamond_data']) ? '' : $data['diamond_data'][0]['dm_rap']; ?>" placeholder=" " autocomplete="off" readonly/>
                                        <label>RAPNET</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>STATUS</th>
                                    <th>NO</th>
                                    <th>DATE</th>
                                    <th>PARTY</th>
                                    <th>BROKER</th>
                                    <th>USER</th>                                    
                                </tr>
                            </thead>
                            <tbody>
                        <?php
                            if(!empty($data['history_data'])):
                                foreach ($data['history_data'] as $key => $value):
                                    $status = '';
                                    if (!empty($value['crt_dm_status'])) 
                                    {
                                        if($value['crt_dm_status'] == 2)
                                        {
                                            $status = "Hold";
                                        }
                                        else if($value['crt_dm_status'] == 3)
                                        {
                                            $status = "Sold";
                                        }
                                        else
                                        {
                                            $status = "Return";
                                        }
                                    }
                        ?>
                                 <tr>
                                        <td><?php echo $status ; ?></td>
                                        <td><?php echo empty($value['crm_entry_no']) ? '' : $value['crm_entry_no'] ; ?></td>
                                        <td><?php echo empty($value['crm_entry_date']) ? '' : $value['crm_entry_date'] ; ?></td>
                                        <td><?php echo empty($value['crm_cust_id']) ? '' : $value['crm_customer'] ; ?></td>
                                        <td><?php echo empty($value['crm_broker_id']) ? '' : $value['crm_broker'] ; ?></td>
                                        <td><?php echo empty($value['crm_user']) ? '' : $value['crm_user'] ; ?></td>
                                </tr>
                                <tr>
                                        <td><?php echo empty($value['ct_status']) ? '' : 'Issue' ; ?></td>
                                        <td><?php echo empty($value['cm_entry_no']) ? '' : $value['cm_entry_no'] ; ?></td>
                                        <td><?php echo empty($value['cm_entry_date']) ? '' : $value['cm_entry_date'] ; ?></td>
                                        <td><?php echo empty($value['cm_cust_id']) ? '' : $value['cm_customer'] ; ?></td>
                                        <td><?php echo empty($value['cm_broker_id']) ? '' : $value['cm_broker'] ; ?></td>
                                        <td><?php echo empty($value['cm_user']) ? '' : $value['cm_user'] ; ?></td>
                                 </tr>
                        <?php
                                endforeach;
                            endif;
                        ?>
                            </tbody>
                        </table>
                    </div>
                </div>
            </div>
        </div>
    </section>
  <?php 
    $this->load->view('templates/footer');
   ?>
   <script type="text/javascript" >
       disable_enable_background(false)
   </script> 