<link rel="stylesheet" href="<?php echo base_url();?>styles/css/table.css">
<?php
$fid=$this->session->userdata('fir_id');
$sid=$this->session->userdata('sec_id');
$find_curr=$this->db->query("select * from coin_info where coid='".$fid."'")->row();
$ex1=$find_curr->coin_symbol;
$find_curr1=$this->db->query("select * from coin_info where coid='".$sid."'")->row();
$ex2=$find_curr1->coin_symbol;

?>

      <h6 class="other-title theme-color"> My Open Orders</h6>
        
        <div class="table-responsive  main-table mb-10">
        <table>
          <thead>
            <tr>
                <th>Time</th>
                <th>Type</th>
                <th>Price (<?php echo $ex2;?>)</th>
                <th>Amount (<?php echo $ex1;?>)</th>
                <th>Total (<?php echo $ex2;?>)</th>
          </tr>
          </thead>
          <tbody>
          <?php
            $userid=$this->session->userdata('uusersid');
            $res=$this->db->query("select * from exchange where type in('3','4') and status='1' and pair='".$fid."' and market_type='".$sid."' and userid='$userid' order by date desc");
            $row=$res->result();
            if($row)
            {
              foreach($row as $row)
              {
                $type=$row->type;
                if($type=="3")
                  $type="BUY";
                else
                  $type="SELL";

                $first_dat=$this->db->query("select * from coin_info where coid='".$row->pair."'");
                $fir_d=$first_dat->result();
                $sec_dat=$this->db->query("select * from coin_info where coid='".$row->market_type."'");
                $sec_d=$sec_dat->result();
                $pair=strtoupper($fir_d[0]->coin_symbol).'/'.strtoupper($sec_d[0]->coin_symbol);


                if($row->type=='4')
                {
              ?>
                <tr>
                  <td style="color:purple;"><?php echo $row->date;?></td>
                  <td style="color:purple;"><?php echo $type;?></td>
                  <td style="color:purple;"><?php echo $row->price;?> <?php echo strtoupper($sec_d[0]->coin_symbol);?></td>
                  <td style="color:purple;"><?php echo $row->amount;?> <?php echo strtoupper($fir_d[0]->coin_symbol);?></td>
                  <td style="color:purple;"><?php echo $row->total;?> <?php echo strtoupper($sec_d[0]->coin_symbol);?></td>

                </tr>
                <?php
                }
                else
                {
                  ?>
                <tr>
                  <td style="color:green;"><?php echo $row->date;?></td>
                  <td style="color:green;"><?php echo $type;?></td>
                  <td style="color:green;"><?php echo $row->price;?> <?php echo strtoupper($sec_d[0]->coin_symbol);?></td>
                  <td style="color:green;"><?php echo $row->amount;?> <?php echo strtoupper($fir_d[0]->coin_symbol);?></td>
                  <td style="color:green;"><?php echo $row->total;?> <?php echo strtoupper($sec_d[0]->coin_symbol);?></td>
                </tr>

                  <?php

                }
              }

            }

          ?>          
		</tbody>
        </table>
      </div>



<script src="<?php echo base_url();?>styles/js/jquery-1.12.2.min.js"></script>
<script type="text/javascript" src="<?php echo base_url();?>styles/js/datatables.min.js"></script>

