
 <div class="container-fluid">
   <div class="row">
      <div class="col-sm-12 col-lg-12">
         <div class="iq-card">
            <div class="iq-card-header d-flex justify-content-between">
               <div class="iq-header-title">
                  <h4 class="card-title">Add Health Checkup</h4>
               </div>
               <span class="table-add float-right mb-3 mr-2">
                  <a href="<?php echo base_url(); ?>HealthCheckup/" class="btn btn-default pull-right"><i class="fa fa-arrow-left" aria-hidden="true"></i> Back</a>&emsp;
               </span>
            </div>
            <div class="iq-card-body">
               <div class="alert alert-success Add" style="display: none;">
                    <strong>Successfully Added Your Data!</strong>
                </div>
                <div class="alert alert-danger Adderror" style="display: none;">
                    <strong>Duplicate Entry!</strong>
                </div>
                <form role="form" method="post" id="addfrm">
                <div class="row">
                    <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
                        <div class="form-group">
                            <label>Health Checkup Name</label>
                            <input type="text" name="hc_name" id="hc_name" class="form-control" required="" placeholder="Enter Health Checkup Name"><br>
                        </div>
                    </div>
                    <div class="col-lg-6 col-md-6 col-sm-6 col-xs-12">
                        <div class="form-group">
                            <label>This test is for </label>
                            <input type="text" name="test_for" id="test_for" class="form-control" required="" placeholder="Example: Male,Female"><br>
                        </div>
                    </div>
                    <div class="col-lg-6 col-md-6 col-sm-6 col-xs-12">
                        <div class="form-group">
                            <label>Reports Time </label>
                            <input type="text" name="get_reports" id="get_reports" class="form-control" required="" placeholder="Example: 24 hours"><br>
                        </div>
                    </div>
                    
                    <div class="col-lg-6 col-md-6 col-sm-6 col-xs-12">
                        <div class="form-group">
                            <label>Total Price</label>
                            <input type="text" name="total_price" id="total_price" class="form-control" required="" placeholder="Enter Price"><br>
                        </div>
                    </div>
                    <div class="col-lg-6 col-md-6 col-sm-6 col-xs-12">
                        <div class="form-group">
                            <label>Amount Payble</label>
                            <input type="text" name="pay_amount" id="pay_amount" class="form-control" required="" placeholder="Enter Amount"><br>
                        </div>
                    </div>
                    
                    <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
                        <div class="form-group">
                            <label>Test Preparation</label>
                            <textarea  class="form-control summernote" name="test_preparation" required></textarea>
                            <br>
                        </div>
                    </div>
                    
                    <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
                        <div class="form-group">
                            <label>Test Includes List </label>
                            <div id="timingWrapper">
                                <!-- Timing rows go here -->
                            </div>
                            <button type="button" class="btn btn-success" id="addTiming">Add More</button><br>
                        </div>
                    </div>
                    <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
                        <div class="form-group">
                            <label>Smart Report Measure </label>
                            <div id="timingWrapper1">
                                <!-- Timing rows go here -->
                            </div>
                            <button type="button" class="btn btn-success" id="addTiming1">Add More</button><br>
                        </div>
                    </div>
                    
                    <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12" align="right">
                        <div class="form-group">
                            <button type="reset" class="btn btn-default"><i class="fa fa-repeat" aria-hidden="true"></i> Reset</button>
                            <button type="submit" class="btn btn-primary addbtn"><i class="fa fa-floppy-o" aria-hidden="true"></i> Save</button>
                            <button class="btn btn-primary addload buttonload" style="display: none;"><i class="fa fa-spinner fa-spin" style=" margin-left: -12px; margin-right: 8px;"></i>Please Wait</button>
                        </div>
                    </div>
                    
                </div>
                </form>
            </div>
         </div>
      </div>
   </div>
</div>
<script>
    let count = 0;

    function createTimingRow(index) {
        return `
            <div class="timing-row" id="row-${index}">
            <div class="row">
                <div class="col-lg-10 col-md-10 col-sm-10 col-xs-12">
                <input type="text" class="form-control" name="test_name[${index}][name]" required placeholder="Enter Test Name"/>
                </div>
                <div class="col-lg-2 col-md-2 col-sm-2 col-xs-12">
                <span class="remove-btn btn btn-danger btn-sm mt-1" onclick="removeRow(${index})">Remove</span>
                </div>
                </div><br>
            </div>
        `;
    }

    function removeRow(index) {
        $(`#row-${index}`).remove();
    }

    $("#addTiming").on("click", function() {
        $("#timingWrapper").append(createTimingRow(count++));
    });

    // Optional: Add initial one row
    $(document).ready(() => {
        $("#addTiming").click();
    });
</script>
<script>
    let count1 = 0;

    function createTimingRow1(indexs) {
        return `
            <div class="timing-row" id="row-${indexs}">
            <div class="row">
                <div class="col-lg-10 col-md-10 col-sm-10 col-xs-12">
                <input type="text" class="form-control" name="titles[${indexs}][title]" required placeholder="Enter Title"/></br>
                </div>
                <div class="col-lg-2 col-md-2 col-sm-2 col-xs-12">
                <span class="remove-btn btn btn-danger btn-sm mt-1" onclick="removeRow1(${indexs})">Remove</span>
                </div>
                <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
                <textarea class="form-control summernote1" name="titles[${indexs}][desc]" required placeholder="Enter Description"></textarea>
                </div>
                </div><br>
            </div>
        `;
    }

    function removeRow1(indexs) {
        $(`#row-${indexs}`).remove();
    }

    $("#addTiming1").on("click", function() {
        $("#timingWrapper1").append(createTimingRow1(count1++));
        $(`#row-${count1 - 1} .summernote1`).summernote({
            height: 100,
            placeholder: 'Description'
        });
    });

    // Optional: Add initial one row
    $(document).ready(() => {
        $("#addTiming1").click();
    });
</script>
<script>
// just for the demos, avoids form submit
jQuery.validator.setDefaults({
success: "valid"
});
$("#addfrm").validate({
rules: {
d_code: {
required: true
}
}
});
</script>
<script>
$(document).ready(function(e) {
$("#addfrm").on('submit', function(e) {
e.preventDefault();
var formStatus = $('#addfrm').validate().form();
if (true == formStatus) {
$.ajax({
type: 'POST',
url: '<?php echo base_url(); ?>HealthCheckup/save',
data: new FormData(this),
contentType: false,
cache: false,
processData: false,
beforeSend: function() {
$('.addbtn').hide();
$('.addload').show();
},
success: function(msg) {
if(msg=='Success')
{
$(".Add").show();
$('.Add').delay(3000).hide(200);
$('.addbtn').show();
$('.addload').hide();
setInterval(function() {
location.reload();
}, 3000);
}
else
{
$(".Adderror").show();
$('.Adderror').delay(3000).hide(200);
$('.addbtn').show();
$('.addload').hide();

}
}
});
}
});
});
</script>
                    