<div class="form-group col-sm-12">  
    <?php echo validation_errors(); ?>
    <form id="formID4" action="<?php echo base_url(); ?>super_admin_student/save_student_payment_information" method="post" name="userForm" enctype="multipart/form-data" >
        <!--Some Required Hidden Value -->
        <input type="hidden" name="person_id" value="<?php echo $person_id; ?>">
        <input type="hidden" name="course_id" value="<?php echo $course_id; ?>">
        <input type="hidden" name="course_batch_id" value="<?php echo $course_batch_id; ?>">
        <input type="hidden" name="coupon_id" value="<?php echo $this->session->userdata('coupon_id'); ?>">

        <br>
        <br>
        <div class="form-group col-sm-12" id="">
            <div class="form-group col-sm-4">
                <label for="invoice_number">Invoice No:</label>
                <input data-errormessage-value-missing="Course Category is required!" 
                       class="form-control validate[required] text-input"
                       type="text" name="invoice_number" value="<?php echo rand(1000, 9999); ?>">
            </div>
        </div>

        <div class="form-group col-sm-12" id="">
            <div class="form-group col-sm-4">
                <label for="unit_price">Unit Price</label>
                <div class="controls">
                    <button class="btn btn-default col-sm-12" disabled> <?php
                        if (set_value('unit_price')) {
                            echo set_value('unit_price');
                        } else if ($course_info) {
                            echo $course_info->course_price;
                        } else {
                            echo 0;
                        }
                        ?>
                    </button>
<!--                            <input class="form-control" name="unit_price" id="unit_price" disabled value="<?php
//                            if (set_value('unit_price')) {
//                                echo set_value('unit_price');
//                            } else {
//                                echo $person_info->course_price;
//                            }
                    ?>" >-->
                </div>
            </div>

            <div class="form-group col-sm-4">
                <label for="total_price">Quantity</label>
                <div class="controls">
                    <button class="btn btn-default col-sm-12" disabled><?php echo '1'; ?></button>
                    <input type="hidden" class="form-control" name="total_price" id="total_price" value="<?php echo ($course_info->course_price * 1); ?>">
                </div>
            </div>

            <div class="form-group col-sm-4">
                <label for="total_price">Total Price</label>
                <div class="controls">
                    <button class="btn btn-default col-sm-12" disabled><?php echo ($course_info->course_price * 1); ?></button>
                    <input type="hidden" class="form-control" name="total_price" id="total_price" value="<?php echo ($course_info->course_price * 1); ?>" >
                </div>
            </div>

        </div>

        <div class="form-group col-sm-12" id="">
            <?php
            $discount = 10; //$coupon_information->coupon_discount_amount;
            $price = 0;
            if ($course_info) {
                $price = $course_info->course_price;
            }
            $quantity = 1;

            $price = $price * $quantity;

            $discount_price = ($price * $discount) / 100;

            $discount_price = $price - $discount_price;
            ?>

            <div class="form-group col-sm-4">
                <label for="total_price">Discount Price</label>
                <div class="controls">
                    <button class="btn btn-default col-sm-12" disabled><?php echo $discount_price; ?></button>
                    <input type="hidden" class="form-control" name="total_price" id="total_price" value="<?php echo $discount_price; ?>" >
                </div>
            </div>
        </div>
        <div class="form-group col-sm-12" id="">
            <div class="form-group col-sm-4">
                <label for="payment_name">Payment Name<span style="color: red">*</span></label>
                <div class="controls">
                    <input class="form-control" name="payment_name" id="payment_name" value="<?php
                    if ($person_info) {
                        echo $person_info->person_first_name;
                    }
                    ?>">
                </div>
            </div>
            <div class="required" id="payment_name_status"> <?php echo form_error('payment_name'); ?></div>
        </div>

        <div class="form-group col-sm-12" id="">
            <div class="form-group col-sm-4">
                <label for="payment_amount">Payment Amount<span style="color: red">*</span></label>
                <div class="controls">
                    <input data-errormessage-value-missing="Payment Amount is required!" 
                           class="form-control validate[required] text-input"
                           autofocus name="payment_amount" id="payment_amount" onblur="checkPaymentAmount();" value="<?php
                           if (set_value('payment_amount')) {
                               echo set_value('payment_amount');
                           } else {
                               echo $discount_price;
                           }
                           ?>" class="form-control">
                </div>
                <div class="required" id="payment_status"><?php echo form_error('payment_amount'); ?></div>
                <script>
                    function checkPaymentAmount() {

                        totalPrice = document.getElementById('total_price').value;
                        dueAmount = document.getElementById('due').value;
                        paymentAmount = document.getElementById('payment_amount').value;
//                                alert(dueAmount);
                        if (paymentAmount > dueAmount) {
                            document.getElementById('submit').disabled = true;
                            document.getElementById('payment_status').innerHTML = 'Your Payment OverFlow';
                        } else {
                            document.getElementById('payment_status').innerHTML = '';
                            document.getElementById('submit').disabled = false;
                        }
                    }
                </script>
            </div>
            <div class="form-group col-sm-4">
                <label for="payment_method">Payment Method<span style="color: red">*</span></label>
                <div class="controls">
                    <select data-errormessage-value-missing="Please Select A Payment Methode" 
                            class="form-control validate[required] text-input"
                            name="payment_method" id="payment_method" onchange="manupulatePaymentForm();">
                        <option value="">select Payment Method</option>
                        <!--<option value="1">Paypal</option>-->
                        <option value="2">Credit Card</option>
                        <option value="3">Account Pay</option>
                        <!--<option value="4">bKash</option>-->
                        <!--<option value="5">Hand Cash</option>-->
                    </select>
                </div>

                <div class="required" id="payment_method_status"><?php echo form_error('payment_method'); ?></div>
                <script>

                    function manupulatePaymentForm() {
                        paymentMethod = document.getElementById('payment_method').value;

                        serverPage = '<?php echo base_url(); ?>super_admin_student/manupulate_payment_form/' + paymentMethod;
                        xmlhttp.open("GET", serverPage);
                        xmlhttp.onreadystatechange = function ()
                        {
                            if (xmlhttp.readyState == 4 && xmlhttp.status == 200)
                            {
                                document.getElementById('payment_form').innerHTML = xmlhttp.responseText;
                            }
                        }
                        xmlhttp.send(null);
                    }
                </script>
            </div>
        </div>

        <div class="" id="payment_form"></div>

        <div class="form-group col-sm-12" id="">
            <div class="form-group col-sm-5">
                <label for="paid_on">Payment On<span style="color: red">*</span></label>
                <div class="controls">
                    <input data-errormessage-value-missing="Payment Date is required!" 
                           class="form-control validate[required] text-input"
                           type="date" name="paid_on" id="paid_on" value="<?php
                    if (set_value('paid_on')) {
                        echo set_value('paid_on');
                    } else {
                        echo date('Y-m-d');
                    }
                    ?>">
                </div>
                <div class="required" id="paid_on_status"><?php echo form_error('paid_on'); ?></div>
            </div>
            <div class="form-group col-sm-5">
                <label for="due_date">Due Payment Date<span style="color: red">*</span></label>
                <div class="controls">
                    <input class="form-control" type="date" name="due_date" id="due_date" value="<?php
                    if (set_value('due_date')) {
                        echo set_value('due_date');
                    } else {
                        echo date("Y-m-d", strtotime("+30 day"));
                        ;
                    }
                    ?>">
                </div>
            </div>
        </div>

        <div class="form-group col-sm-12" id="">
            <div class="form-group col-sm-6">
                <label for="payment_description">Payment Description </label>
                <textarea name="payment_description" class="form-control" ><?php echo set_value('payment_description'); ?></textarea>
            </div>
        </div>

        <div class="checkbox col-sm-6">
            <?php if ($person_info->person_id && $course_id) { ?>
                <button type="submit" id="submit" class="btn btn-default" onclick="checkAllField();">Submit</button>
                <button type="reset" class="btn btn-default">Reset</button>
            <?php } ?>

            <script>
                function checkAllField() {
//                                alert();
                    window.stop();
                }
            </script>
        </div>
    </form>
</div>
