<?php
require("header.php")
?>




<div class="content-wrapper">
    <!-- Content Header (Page header) -->
    <section class="content-header">
        <div class="container-fluid">
            <div class="row mb-2">
                <div class="col-sm-6">
                    <h1></h1>
                </div>
                <div class="col-sm-6">

                </div>
            </div>
        </div><!-- /.container-fluid -->
    </section>

    <!-- Main content -->
    <section class="content">
        <div class="container-fluid">
            <div class="row">

                <div class="col-md-12">
                    <!-- general form elements -->
                    <div class="card card-secondary">
                        <div class="card-header" style="background-color: black;">
                            <h3 class="card-title">Add Credit</h3>
                            <ol class="breadcrumb float-sm-right" style="background-color: black;">
                                <li class="breadcrumb-item"><a href="dashboad.php">Home</a></li>
                                <li class="breadcrumb-item">Credit</li>
                                <li class="breadcrumb-item active">Add Credit</li>
                            </ol>
                        </div>
                        <!-- /.card-header -->
                        <!-- form start -->
                        <form action="add_credit_code.php" method="post"><br>

                            <div class="card-body">
                                <div class="col-sm-6">
                                    <div class="form-group">
                                        <label>User Type <span style="color:red; font-size:25px;">*<span></label>
                                        <select class="form-control" name="user_type" onchange="typ_select(this.value)">
                                            <option value=" ">---Select User---</option>
                                            <option value="reseller">Reseller</option>
                                            <option value="user">User</option>

                                        </select>
                                    </div>
                                </div>
                                <div class="col-sm-6">
                                    <div class="form-group">
                                        <label>User Id <span style="color:red; font-size:25px;">*<span></label>
                                        <select class="form-control user_id" name="user_id" id="user_id">
                                        <option value="">---Select user id---</option>
                                    </select>
                                    </div>
                                </div>

                                <div class="col-sm-6">
                                    <div class="form-group">
                                        <label for="exampleInputEmail1">Credit <span style="color:red; font-size:25px;">*<span></label>
                                        <input type="text" class="form-control" name="credit" id="exampleInputEmail1" placeholder="Enter credit">
                                    </div>
                                </div>
                                <div class="col-sm-6">
                                    <div class="form-group">
                                        <label>Credit Note <span style="color:red; font-size:25px;">*<span></label>
                                        <select class="form-control" required name="credit_note">
                                            <option value=" ">---Select note---</option>
                                            <option value="Cancel Order Refund">Cancel Order Refund</option>
                                            <option value="Withdrawal Credit">Withdrawal Credit</option>

                                        </select>
                                    </div>
                                </div>

                            </div>
                            <!-- /.card-body -->

                            <div class="card-footer">
                                <button type="submit" name="submit" class="btn btn-dark" style="background-color: black;">Add</button>
                                <button type="reset" class="btn btn-dark" style="font-size: 16px; background:black;">Clear</button>

                            </div>
                        </form>
                    </div>
                    <!-- /.card -->




                </div>

            </div>

            <!-- /.col -->
        </div>
        <!-- /.row -->

        <!-- /.container-fluid -->
    </section>
    <!-- /.content -->
</div>
<!-- for searching -->
<script type="text/javascript">
    function typ_select(value) {
        $.ajax({
            url: "get_select_value.php",
            type: 'post',
            data: {
                val: value
            },
            success: function(resp) {
                $('#user_id').html(resp);

            }
        });

    }
</script>
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@10"></script>
<script>
<?php
if (isset($_GET['success'])) {
    $successMessage = $_GET['success'];
    echo "Swal.fire({
        icon: 'success',
        title: 'Success',
        text: '$successMessage',
    });";
} elseif (isset($_GET['error'])) {
    $errorMessage = $_GET['error'];
    echo "Swal.fire({
        icon: 'error',
        title: 'Error',
        text: '$errorMessage',
    });";
}
?>
</script>
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.13/js/select2.min.js"></script>
    <script>
        $(document).ready(function() {
            $('.user_id').select2();
        });
    </script>
<?php
require("footer.php")
?>