<?php
session_start();
ob_start();
include('includes/config.php');
if($_SESSION['name'] == '')
 {
     header("location:index.php");
 }
    else{
        
        if(isset($_POST['submit'])!=''){
    
	
	$upi_id1=$_POST['upi_id1'];
	$upi_id2=$_POST['upi_id2'];


////////////

$imgfile1=$_FILES["qr_code1"]["name"];

$extension1 = substr($imgfile1,strlen($imgfile1)-4,strlen($imgfile1));

$allowed_extensions1 = array(".jpg","jpeg",".png");

if(!in_array($extension1,$allowed_extensions1))
{
 $a1=0;
}
else
{
	$uploads_dir1 = 'payment/';
    $pname1 = $uploads_dir1.rand(1000,10000)."-".$_FILES["qr_code1"]["name"];
     $tname1 = $_FILES["qr_code1"]["tmp_name"];
    move_uploaded_file($tname1, $pname1);
}


$imgfile2=$_FILES["qr_code2"]["name"];

$extension2 = substr($imgfile2,strlen($imgfile2)-4,strlen($imgfile2));

$allowed_extensions2 = array(".jpg","jpeg",".png");

if(!in_array($extension2,$allowed_extensions2))
{
 $a2=0;
}
else
{
	$uploads_dir2 = 'payment/';
    $pname2 = $uploads_dir2.rand(1000,10000)."-".$_FILES["qr_code2"]["name"];
     $tname2 = $_FILES["qr_code2"]["tmp_name"];
    move_uploaded_file($tname2, $pname2);
}

   if(!empty($_FILES["qr_code1"]["name"]) && empty($_FILES["qr_code2"]["name"]))
   {
    $sql= "UPDATE `payment` SET `upi_id1` = '$upi_id1',`upi_id2` = '$upi_id2',`qr_code1`='$pname1' WHERE `id`= '1'";
    
   }elseif(!empty($_FILES["qr_code2"]["name"]) && empty($_FILES["qr_code1"]["name"])){
       
   $sql= "UPDATE `payment` SET `upi_id1` = '$upi_id1',`upi_id2` = '$upi_id2',`qr_code2`='$pname2' WHERE `id`= '1'";
   }elseif(empty($_FILES["qr_code2"]["name"]) && empty($_FILES["qr_code1"]["name"]))
   {
      $sql= "UPDATE `payment` SET `upi_id1` = '$upi_id1',`upi_id2` = '$upi_id2' WHERE `id`= '1'";  
   }
   else{
        $sql= "UPDATE `payment` SET `upi_id1` = '$upi_id1',`upi_id2` = '$upi_id2',`qr_code1`='$pname1',`qr_code2`='$pname2' WHERE `id`= '1'";
   }
   
$query=mysqli_query($com,$sql);
if($query){
	
	$msg="Update successfully";
	}else 
{
$error="Something went wrong. Please try again";
}

	}
        ?>
<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="utf-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
    	<meta name="viewport" content="width=device-width, initial-scale=1">
        <title>Forcecrypto Admin </title>
        <link rel="stylesheet" href="css/bootstrap.min.css" media="screen" >
        <link rel="stylesheet" href="css/font-awesome.min.css" media="screen" >
        <link rel="stylesheet" href="css/animate-css/animate.min.css" media="screen" >
        <link rel="stylesheet" href="css/lobipanel/lobipanel.min.css" media="screen" >
        <link rel="stylesheet" href="css/prism/prism.css" media="screen" >
        <link rel="stylesheet" href="css/select2/select2.min.css" >
        <link rel="stylesheet" href="css/main.css" media="screen" >
        <script src="js/modernizr/modernizr.min.js"></script>
    </head>
    <body class="top-navbar-fixed">
        <div class="main-wrapper">

            <!-- ========== TOP NAVBAR ========== -->
  <?php include('includes/topbar.php');?> 
            <!-- ========== WRAPPER FOR BOTH SIDEBARS & MAIN CONTENT ========== -->
            <div class="content-wrapper">
                <div class="content-container">

                    <!-- ========== LEFT SIDEBAR ========== -->
                   <?php include('includes/leftbar.php');?>  
                    <!-- /.left-sidebar -->

                    <div class="main-page">

                     <div class="container-fluid">
                            <div class="row page-title-div">
                                <div class="col-md-6">
                                    <h2 class="title">Payment Details</h2>
                                
                                </div>
                                
                                <!-- /.col-md-6 text-right -->
                            </div>
                            <!-- /.row -->
                            <div class="row breadcrumb-div">
                                <div class="col-md-6">
                                    
                                </div>
                             
                            </div>
                            <!-- /.row -->
                        </div>
                        <div class="container-fluid">
                           
                        <div class="row">
                                    <div class="col-md-12">
                                        <div class="panel">
                                            <div class="panel-heading">
                                                <div class="panel-title">
                                                    <h5></h5>
                                                </div>
                                            </div>
                                            <div class="panel-body">
<?php if($msg){?>
<div class="alert alert-success left-icon-alert" role="alert">
 <strong>Well done!</strong><?php echo htmlentities($msg); ?>
 </div><?php } 
else if($error){?>
    <div class="alert alert-danger left-icon-alert" role="alert">
                                            <strong>Oh snap!</strong> <?php echo htmlentities($error); ?>
                                        </div>
                                        <?php } ?>
                                                 <form  method="post" action="<?php echo $_SERVER['PHP_SELF'];?>" enctype="multipart/form-data">
<?php
      
      $sql="select* FROM `payment` WHERE id='1'";
      $query=mysqli_query($com,$sql);
       $role=mysqli_fetch_array($query);
   ?>
<div class="form-group">
<label for="default" class="col-sm-2 control-label">QR Code 1</label>
<div class="col-sm-10">
<input type="file" name="qr_code1" class="form-control" id="qr_code1" value="<?php echo $role['qr_code1'];?>" autocomplete="off">
<img src="<?php echo $role['qr_code1'];?>" width="150" height="150">
</div>
</div>
<br><br><br><br><br>
<div class="form-group">
<label for="default" class="col-sm-2 control-label">QR Code 2</label>
<div class="col-sm-10">
<input type="file" name="qr_code2" class="form-control" id="qr_code2" value="<?php echo $role['qr_code2'];?>" autocomplete="off">
<img src="<?php echo $role['qr_code2'];?>" width="150" height="150">
</div>
</div>
<br><br><br><br><br>
<div class="form-group">
<label for="default" class="col-sm-2 control-label">UPI ID 1</label>
<div class="col-sm-10">
<input type="text" name="upi_id1" class="form-control" id="upi_id1" value="<?php echo $role['upi_id1'];?>" autocomplete="off">
</div>
</div>
<br><br><br><br><br>
<div class="form-group">
<label for="default" class="col-sm-2 control-label">UPI ID 2</label>
<div class="col-sm-10">
<input type="text" name="upi_id2" class="form-control" id="upi_id2" value="<?php echo $role['upi_id2'];?>" autocomplete="off">
</div>
</div>


                                                    
                                                    <div class="form-group">
                                                        <div class="col-sm-offset-2 col-sm-10">
                                                            <button type="submit" name="submit" class="btn btn-primary">Update</button>
                                                        </div>
                                                    </div>
                                                </form>

                                            </div>
                                        </div>
                                    </div>
                                    <!-- /.col-md-12 -->
                                </div>
                    </div>
                </div>
                <!-- /.content-container -->
            </div>
            <!-- /.content-wrapper -->
        </div>
        <!-- /.main-wrapper -->
        <script src="js/jquery/jquery-2.2.4.min.js"></script>
        <script src="js/bootstrap/bootstrap.min.js"></script>
        <script src="js/pace/pace.min.js"></script>
        <script src="js/lobipanel/lobipanel.min.js"></script>
        <script src="js/iscroll/iscroll.js"></script>
        <script src="js/prism/prism.js"></script>
        <script src="js/select2/select2.min.js"></script>
        <script src="js/main.js"></script>
        <script>
            $(function($) {
                $(".js-states").select2();
                $(".js-states-limit").select2({
                    maximumSelectionLength: 2
                });
                $(".js-states-hide").select2({
                    minimumResultsForSearch: Infinity
                });
            });
        </script>
    </body>
</html>
<?PHP } ?>
