<?php
session_start();
include_once 'function.php';


$regid = $_GET['id'];

//`trans_id`, `cus_id`, `trans_date`, `trans_des`, `amt_credit`, `amt_debit`, `status`, `fromaccount`SELECT * FROM `transaction` WHERE 1

if ($_GET['action'] == 'delete') {
    
    $id  = $_GET['nwsevnt_id'];
     $eeid  = $_GET['id'];
    

    //`trans_id`, `cus_id`, `trans_date`, `trans_des`, `amt_credit`, `amt_debit`, `status`, `fromaccount`SELECT * FROM `transaction` WHERE 1
    $sql = "DELETE FROM transaction WHERE trans_id = $id;";
    $query = mysqli_query($connect,$sql) or die("There was a problem while deleting: " . mysqli_error());
    
    echo "<div style='width: 350px; text-align: center; margin: 20% auto 0px; font-family: arial; font-size: 14px; border: 1px solid #ddd; padding: 20px 40px;'>Please wait while we update the record loading...</div>";
    
    if ($query) {


        echo "<script type='text/javascript'>window.location = 'roitransactions.php?id=$eeid'</script>";
    }
    
}

// add Details
if ($_POST['add'] == 'submit') {
    
    //`trans_id`, `cus_id`, `trans_date`, `trans_des`, `amt_credit`, `amt_debit`, `status`, `fromaccount`SELECT * FROM `transaction` WHERE 1
    
$trans_date = date('Y-m-d');

$trans_des      = $_POST['trans_des'];
$amt_credit = $_POST['amt_credit'];
$amt_debit = $_POST['amt_debit'];

mysqli_query($connect,"INSERT into transaction (`cus_id`,`trans_date`,`trans_des`,`amt_credit`,`amt_debit`,`status`) values ('$regid','$trans_des','$trans_des','$amt_credit','$amt_debit','1')") or die(mysqli_error($connect));
  
echo "<div style='width: 350px; text-align: center; margin: 20% auto 0px; font-family: arial; font-size: 14px; border: 1px solid #ddd; padding: 20px 40px;'> 
        Please wait while we update loading...</div>";
    
    echo "<script type='text/javascript'>window.location = 'roitransactions.php?id=$regid'</script>";
}
// Edit


// Edit Details
if ($_POST['edit'] == 'submit') {
    
    //`trans_id`, `cus_id`, `trans_date`, `trans_des`, `amt_credit`, `amt_debit`, `status`, `fromaccount`SELECT * FROM `transaction` WHERE 1
    $trans_ID      = $_POST['trans_id'];

$trans_date      = $_POST['trans_date'];
$trans_des      = $_POST['trans_des'];
$amt_credit = $_POST['amt_credit'];
$amt_debit = $_POST['amt_debit'];

mysqli_query($connect,"UPDATE `transaction` SET `trans_date`='$trans_date',`trans_des`='$trans_des',`amt_credit`='$amt_credit',`amt_debit`='$amt_debit' WHERE trans_id = '$trans_ID'") or die(mysqli_error());

echo "<div style='width: 350px; text-align: center; margin: 20% auto 0px; font-family: arial; font-size: 14px; border: 1px solid #ddd; padding: 20px 40px;'> 
        Please wait while we update loading...</div>";
    
    echo "<script type='text/javascript'>window.location = 'roitransactions.php?id=$trans_ID'</script>";
}
// Edit


?>
<!DOCTYPE html>
<html lang="en">
  <meta http-equiv="content-type" content="text/html;charset=UTF-8" />   
  <head>
    <meta charset="utf-8" />
    <title>Transanction List | 
      <?php echo $site_title; ?>
    </title>
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta content="width=device-width, initial-scale=1" name="viewport" />
    <meta content="" name="description" />
    <meta content="" name="author" />
    <!-- BEGIN GLOBAL MANDATORY STYLES -->
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
    <link rel="stylesheet" href="assets/font-awesome/font-awesome.min.css">
    <link href="http://fonts.googleapis.com/css?family=Open+Sans:400,300,600,700&amp;subset=all" rel="stylesheet" type="text/css" />
    <link href="assets/global/plugins/font-awesome/css/font-awesome.min.css" rel="stylesheet" type="text/css" />
    <link href="assets/global/plugins/simple-line-icons/simple-line-icons.min.css" rel="stylesheet" type="text/css" />
    <link href="assets/global/plugins/bootstrap/css/bootstrap.min.css" rel="stylesheet" type="text/css" />
    <link href="assets/global/plugins/bootstrap-switch/css/bootstrap-switch.min.css" rel="stylesheet" type="text/css" />
    <script src="//cdn.ckeditor.com/4.5.7/standard/ckeditor.js">
    </script>
    <!-- END GLOBAL MANDATORY STYLES -->
    <!-- BEGIN PAGE LEVEL PLUGINS -->
    <link href="assets/global/plugins/datatables/datatables.min.css" rel="stylesheet" type="text/css" />
    <link href="assets/global/plugins/datatables/plugins/bootstrap/datatables.bootstrap.css" rel="stylesheet" type="text/css" />
    <!-- END PAGE LEVEL PLUGINS -->
    <!-- BEGIN THEME GLOBAL STYLES -->
    <link href="assets/global/css/components.min.css" rel="stylesheet" id="style_components" type="text/css" />
    <link href="assets/global/css/plugins.min.css" rel="stylesheet" type="text/css" />
    <!-- END THEME GLOBAL STYLES -->
    <!-- BEGIN THEME LAYOUT STYLES -->
    <link href="assets/layouts/layout/css/layout.min.css" rel="stylesheet" type="text/css" />
    <link href="assets/layouts/layout/css/themes/darkblue.min.css" rel="stylesheet" type="text/css" id="style_color" />
    <link href="assets/layouts/layout/css/custom.min.css" rel="stylesheet" type="text/css" />
    <link href="assets/global/plugins/select2/css/select2.min.css" rel="stylesheet" type="text/css" />
    <link href="assets/global/plugins/select2/css/select2-bootstrap.min.css" rel="stylesheet" type="text/css" />
    <link href="assets/global/plugins/bootstrap-fileinput/bootstrap-fileinput.css" rel="stylesheet" type="text/css" />
    <link href="assets/global/plugins/select2/css/select2.min.css" rel="stylesheet" type="text/css" />
    <link href="assets/global/plugins/select2/css/select2-bootstrap.min.css" rel="stylesheet" type="text/css" />
    <link href="assets/layouts/customer.css" rel="stylesheet" type="text/css" />
    <!-- END PAGE LEVEL PLUGINS -->
    <style type="text/css">
      .dt-buttons {
        display: none;
      }
    </style>
    <script type="text/javascript">
      function delete_menu(idurl)
      {
        go_on = confirm("Are you sure ? ");
        if(go_on)
        {
          document.location.href=idurl;
        }
      }
    </script>
  </head>
  <!-- END HEAD -->
  <body class="page-header-fixed page-sidebar-closed-hide-logo page-content-white">
    <div class="page-wrapper">
      <!-- BEGIN HEADER -->
      <?php include("header.php");?>
      <!-- END HEADER -->
      <!-- BEGIN HEADER & CONTENT DIVIDER -->
      <div class="clearfix"> 
      </div>
      <!-- END HEADER & CONTENT DIVIDER -->
      <!-- BEGIN CONTAINER -->
      <div class="page-container">
        <!-- BEGIN SIDEBAR -->
        <?php include("menu.php");?>
        <!-- END SIDEBAR -->
        <!-- BEGIN CONTENT -->
        <div class="page-content-wrapper">
          <!-- BEGIN CONTENT BODY -->
          <div class="page-content">
            <!-- END THEME PANEL -->
            <!-- BEGIN PAGE BAR -->
            <div class="page-bar">
              <ul class="page-breadcrumb">
                <li>
                  <a href="index.php">Home
                  </a>
                  <i class="fa fa-circle">
                  </i>
                </li>
                <li>
                  <span>Transaction List
                  </span>
                </li>
              </ul>
              <div class="page-toolbar">
                <div id="dashboard-report-range" class="pull-right tooltips btn btn-sm" data-container="body" data-placement="bottom" data-original-title="Change dashboard date range">
                  <i class="icon-calendar">
                  </i>&nbsp;
                  <span class="thin uppercase hidden-xs">
                  </span>&nbsp;
                  <i class="fa fa-angle-down">
                  </i>
                </div>
              </div>
            </div>
            <!-- END PAGE BAR -->
            <!-- BEGIN PAGE TITLE-->
            <br>
            <div class="row">
              <div class="col-md-12">
                <!-- BEGIN EXAMPLE TABLE PORTLET-->
                <div class="portlet box red">
                  <div class="portlet-title">
                    <div class="caption">
                      <i class="fa fa-globe">
                      </i>Transaction List - <?php echo regusersDB($regid); ?> - <?php echo 'ITC'.$regid; ?>
                    </div>
                    <div class="actions">
     <a class="btn btn-info btn-xs" data-toggle="modal" href="#addpayment<?php echo $reg_id; ?>">
                              <i class="fa fa-eye" aria-hidden="true">
                              </i> Add money 
                            </a>
                    </div>
                  </div>
                  <div class="portlet-body">
                    <?php pageStatus($status); 
                    //  id="sample_2"
                    ?>
                    <table class="table table-striped table-bordered table-hover">
                      <thead>
                        <tr class="">
                          <th> S.NO 
                          </th>
                          <th> Date
                          </th>
                          <th> DESC
                          </th>
                          <th> Amount credit
                          </th>
                          <th> Amount debit
                          </th>
                         
                          <th>Modify
                          </th>
                        </tr>
                      </thead>
                      <tbody>
                        <?php
$sno =0;
//`trans_id`, `cus_id`, `trans_date`, `trans_des`, `amt_credit`, `amt_debit`, `status`, `fromaccount`SELECT * FROM `transaction` WHERE 1

$get_customer = mysqli_query($connect,"SELECT * FROM transaction where cus_id = '$regid' and `trans_des` LIKE '%ROI%'") or die(mysqli_error());
while($get_value = mysqli_fetch_array($get_customer)) 
{
$sno++;    
$trans_id = $get_value['trans_id'];    
$cus_id=$get_value['cus_id']; 
$trans_date=$get_value['trans_date']; 
$trans_des=$get_value['trans_des']; 
$amt_credit=$get_value['amt_credit']; 


$amt_debit=$get_value['amt_debit']; 


?>
                        <tr>
                          <td>
                            <?php echo $sno;?> 
                          </td>
                          <td>
                            <?php echo date('d-m-Y',strtotime($trans_date)); ?>
                          </td>
                          <td>
                            <?php echo $trans_des; ?>
                          </td>
                          <td>
                            <?php echo $amt_credit;?> 
                          </td>
                          <td>
                            <?php echo $amt_debit; ?>
                          </td>
                          
                          
                          
                          <td>
                              
                             
                         
                              <a class="btn btn-xs btn-danger"  onClick="delete_menu('roitransactions.php?action=delete&nwsevnt_id=<?php echo $trans_id; ?>&id=<?php echo $cus_id; ?>')" href="javascript:;">
                                                            <i class="fa fa-trash"></i> Delete</a>
                                                            
     <a class="btn btn-info btn-xs" data-toggle="modal" href="#editpayment<?php echo $trans_id; ?>">
                              <i class="fa fa-eye" aria-hidden="true">
                              </i> Edit Transactions 
                            </a>
                                                            
                          </td>
         
         
          <div class="modal fade" id="addpayment<?php echo $reg_id; ?>" tabindex="-1" role="basic" aria-hidden="true">
                            <div class="modal-dialog">
                              <div class="modal-content">
                                <div class="modal-header">
                                  <button type="button" class="close" data-dismiss="modal" aria-hidden="true">
                                  </button>
                                  <h4 class="modal-title">
                                    <b>
                                      Add payment
                                    </b>
                                  </h4>
                                </div>
                                <div class="modal-body">
                                      <form class="auth-form p-0" action="" method="POST">
                                          
<!--//`trans_id`, `cus_id`, `trans_date`, `trans_des`, `amt_credit`, `amt_debit`, `status`, `fromaccount`SELECT * FROM `transaction` WHERE 1-->
<input type="hidden" value="<?php echo $reg_id; ?>" name="regid" />

   <div class="form-group">
          <label for="inputamount" class="form-label">Date</label>
          <input type="date" class="form-control" id="trans_date" name="trans_date" placeholder="Enter date" required/>
        </div>


   <div class="form-group">
          <label for="inputamount" class="form-label">trans_des</label>
    
          <input type="text" class="form-control" id="inputamount" name="trans_des" required/>
          <p>Referral Income</p>
             <p>Wallet withdraw</p>
             <p>Wallet payment</p>
              <p>ROI Income</p>
              <p>LEVEL INCOME</p>
               <p>product name</p>
        </div>

            
        <div class="form-group">
          <label for="inputamount" class="form-label">amt credit</label>
          <input type="text" class="form-control" id="amt_credit" name="amt_credit" placeholder="Enter amount" required/>
        </div>
        
           <div class="form-group">
          <label for="inputamount" class="form-label">amt debit</label>
          <input type="text" class="form-control" id="amt_debit" name="amt_debit" placeholder="Enter amount" required/>
        </div>

      

        <input type="submit" class="btn theme-btn w-100" name="add" value="submit" />  
        <!-- <a href="done.php" class="btn theme-btn w-100">Transfer</a> -->
      </form>
                                </div>
                                <div class="modal-footer">
                                  <button type="button" class="btn dark btn-outline" data-dismiss="modal">Close
                                  </button>
                                </div>
                              </div>
                              <!-- /.modal-content -->
                            </div>
                            <!-- /.modal-dialog -->
                          </div>
                        
                        
                               
          <div class="modal fade" id="editpayment<?php echo $trans_id; ?>" tabindex="-1" role="basic" aria-hidden="true">
                            <div class="modal-dialog">
                              <div class="modal-content">
                                <div class="modal-header">
                                  <button type="button" class="close" data-dismiss="modal" aria-hidden="true">
                                  </button>
                                  <h4 class="modal-title">
                                    <b>
                                      Edit payment
                                    </b>
                                  </h4>
                                </div>
                                <div class="modal-body">
                                      <form class="auth-form p-0" action="" method="POST">
                                          
<!--//`trans_id`, `cus_id`, `trans_date`, `trans_des`, `amt_credit`, `amt_debit`, `status`, `fromaccount`SELECT * FROM `transaction` WHERE 1-->
<input type="hidden" value="<?php echo $reg_id; ?>" name="regid" />

   <div class="form-group">
          <label for="inputamount" class="form-label">Date</label>
          <input type="text" class="form-control" id="trans_date" name="trans_date" value="<?php echo $trans_date; ?>" placeholder="Enter date" required/>
        </div>


   <div class="form-group">
          <label for="inputamount" class="form-label">trans_des</label>
    
          <input type="text" class="form-control" id="inputamount" name="trans_des" value="<?php echo $trans_des; ?>" required/>
          <p>Referral Income</p>
             <p>Wallet withdraw</p>
             <p>Wallet payment</p>
              <p>ROI Income</p>
              <p>LEVEL INCOME</p>
               <p>product name</p>
        </div>

            
        <div class="form-group">
          <label for="inputamount" class="form-label">amt credit</label>
          <input type="text" class="form-control" id="amt_credit" name="amt_credit" value="<?php echo $amt_credit; ?>"  placeholder="Enter amount" required/>
        </div>
        
           <div class="form-group">
          <label for="inputamount" class="form-label">amt debit</label>
          <input type="text" class="form-control" id="amt_debit" name="amt_debit" value="<?php echo $amt_debit; ?>" placeholder="Enter amount" required/>
        </div>

      

        <input type="submit" class="btn theme-btn w-100" name="edit" value="submit" />  
        <!-- <a href="done.php" class="btn theme-btn w-100">Transfer</a> -->
      </form>
                                </div>
                                <div class="modal-footer">
                                  <button type="button" class="btn dark btn-outline" data-dismiss="modal">Close
                                  </button>
                                </div>
                              </div>
                              <!-- /.modal-content -->
                            </div>
                            <!-- /.modal-dialog -->
                          </div>
           
                        </tr>
                        <?php
} 
?>
                      </tbody>
                    </table>
                  </div>
                </div>
              </div>
            </div>   
            <div class="clearfix">
            </div>
          </div>
          <!-- END CONTENT BODY -->
        </div>
        <!-- END CONTENT -->
        <!-- END QUICK SIDEBAR -->
      </div>
      <!-- END CONTAINER -->
      <!-- BEGIN FOOTER -->
      <?php include("footer.php");?>
      <!-- END FOOTER -->
    </div>
    <!-- BEGIN QUICK NAV -->
    <div class="quick-nav-overlay">
    </div>
    <!-- END QUICK NAV -->
    <!--[if lt IE 9]>
<script src="assets/global/plugins/respond.min.js"></script>
<script src="assets/global/plugins/excanvas.min.js"></script> 
<script src="assets/global/plugins/ie8.fix.min.js"></script> 
<![endif]-->
    <!-- BEGIN CORE PLUGINS -->
    <script src="assets/global/plugins/jquery.min.js" type="text/javascript">
    </script>
    <script src="assets/global/plugins/bootstrap/js/bootstrap.min.js" type="text/javascript">
    </script>
    <script src="assets/global/plugins/js.cookie.min.js" type="text/javascript">
    </script>
    <script src="assets/global/plugins/jquery-slimscroll/jquery.slimscroll.min.js" type="text/javascript">
    </script>
    <script src="assets/global/plugins/jquery.blockui.min.js" type="text/javascript">
    </script>
    <script src="assets/global/plugins/bootstrap-switch/js/bootstrap-switch.min.js" type="text/javascript">
    </script>
    <!-- END CORE PLUGINS -->
    <!-- BEGIN PAGE LEVEL PLUGINS -->
    <script src="assets/global/scripts/datatable.js" type="text/javascript">
    </script>
    <script src="assets/global/plugins/datatables/datatables.min.js" type="text/javascript">
    </script>
    <script src="assets/global/plugins/datatables/plugins/bootstrap/datatables.bootstrap.js" type="text/javascript">
    </script>
    <!-- END PAGE LEVEL PLUGINS -->
    <!-- BEGIN THEME GLOBAL SCRIPTS -->
    <script src="assets/global/scripts/app.min.js" type="text/javascript">
    </script>
    <!-- END THEME GLOBAL SCRIPTS -->
    <!-- BEGIN PAGE LEVEL SCRIPTS -->
    <script src="assets/pages/scripts/table-datatables-colreorder.min.js" type="text/javascript">
    </script>
    <!-- END PAGE LEVEL SCRIPTS -->
    <!-- BEGIN THEME LAYOUT SCRIPTS -->
    <script src="assets/layouts/layout/scripts/layout.min.js" type="text/javascript">
    </script>
    <script src="assets/layouts/layout/scripts/demo.min.js" type="text/javascript">
    </script>
    <script src="assets/layouts/global/scripts/quick-sidebar.min.js" type="text/javascript">
    </script>
    <script src="assets/layouts/global/scripts/quick-nav.min.js" type="text/javascript">
    </script>
    <script src="assets/global/plugins/bootstrap-fileinput/bootstrap-fileinput.js" type="text/javascript">
    </script>
    <!-- BEGIN PAGE LEVEL PLUGINS -->
    <script src="assets/global/plugins/select2/js/select2.full.min.js" type="text/javascript">
    </script>
    <!-- END PAGE LEVEL PLUGINS -->
    <!-- BEGIN PAGE LEVEL SCRIPTS -->
    <script src="assets/pages/scripts/components-select2.min.js" type="text/javascript">
    </script>
    <!-- END PAGE LEVEL SCRIPTS -->
    <!-- SCRIPTS -->         
  </body>
</html>
re