BBnepal-Accounts/library/application/views/lms-admin/general-settings.php
Sampanna Rimal 9cd05ef3cb commitall
2024-07-10 18:28:19 +05:45

193 lines
8.1 KiB
PHP

<main class="common_margin" id="main">
<div class="main-wrap">
<div class="dashboard-cover">
<div class="subsec_sec">
<div class="subject_r">
<div class="subject_lsec">
<div class="common-heading">
<h2><?= $title; ?></h2>
</div>
<?php
$idVal = 0;
$cbifor = '';
$dfpd = '';
$nobpu = '';
$curr = '';
if (isset($gSData) && !empty($gSData)) {
$idVal = $gSData['id'];
$cbifor = $gSData['can_be_issued_for'];
$dfpd = $gSData['due_fee_per_day'];
$nobpu = $gSData['no_of_book_per_user'];
$curr = $gSData['currency'];
}
?>
<div class="alert alert-success" id="success" style="display:none;">
<?php if ($idVal == 0) { ?>
<strong>Success!</strong> The general settings data added successfully.
<?php } else { ?>
<strong>Success!</strong> The general settings data updated successfully.
<?php } ?>
</div>
<form id="generalSettingForm" method="POST">
<input type="hidden" name="id" id="id" value="<?= $idVal; ?>">
<div class="settings_wrap">
<div class="form-group">
<label>Default lending time :</label>
<input type="number" name="can_be_issued_for" id="can_be_issued_for" class="form-control txtData" step="1" min="0" placeholder="00" autocomplete="off" value="<?= $cbifor; ?>" />
<span>Days</span>
</div>
<p class="form_err" id="error-lending_days"></p>
<div class="form-group">
<label>Late Fee per day :</label>
<input type="number" name="due_fee_per_day" id="due_fee_per_day" class="form-control txtData" min="0" placeholder="0.00" autocomplete="off" value="<?= $dfpd; ?>" />
</div>
<p class="form_err" id="error-fee_per_day"></p>
<div class="form-group">
<label>Books per user :</label>
<input type="number" name="no_of_book_per_user" id="no_of_book_per_user" class="form-control txtData" min="0" step="1" placeholder="1" autocomplete="off" value="<?= $nobpu; ?>" />
</div>
<p class="form_err" id="error-no_of_book"></p>
<div class="form-group">
<label>Choose Currency :</label>
<select class="form-control txtData" name="currency" id="currency">
<?php if (isset($curr) && !empty($curr)) { ?>
<option value="<?= $curr; ?>"><?= $curr; ?></option>
<?php } else { ?>
<option value="">Choose Currency</option>
<?php } ?>
<option value="NRs">₹.NRs</option>
</select>
</div>
<p class="form_err" id="error-currency"></p>
</div>
<button type="submit" class="btn btn-success">Update</button>&nbsp;&nbsp;
<a href="javascript:history.back()"><button type="button" class="btn btn-dark btn-sm">Back</button></a>
</form>
</div>
</div>
</div>
</div>
</div>
</main>
<!--End right-top side-->
</div>
<!-- <script src="assets/js/jquery-3.2.1.slim.min.js"></script> -->
<script src="<?= base_url(); ?>assets-lms/js/jquery-3.4.1.min.js"></script>
<script src="<?= base_url(); ?>assets-lms/js/jquery.validate.js"></script>
<script src="<?= base_url(); ?>assets-lms/js/additional-methods.js"></script>
<script src="<?= base_url(); ?>assets-lms/js/bootstrap.min.js"></script>
<script src="<?= base_url(); ?>assets-lms/js/popper.min.js"></script>
<script defer src="<?= base_url(); ?>assets-lms/js/all.js"></script>
<script defer src="<?= base_url(); ?>assets-lms/js/main.js"></script>
<script src="<?= base_url(); ?>assets-lms/owl-carousel/js/owl.carousel.min.js"></script>
<script>
$(document).ready(function() {
$('.user-drpdown').click(function() {
$('.drpdown-items').toggle();
});
});
//table js
$('#tbl').DataTable({
"lengthMenu": [
[5, 10, 25, 50, -1],
[5, 10, 25, 50, "All"]
]
});
//table js end
//multiple select js start
$('select').selectpicker();
//multiple select js end
</script>
<script>
$("#generalSettingForm").validate({
errorClass: 'error',
rules: {
can_be_issued_for: {
required: true,
minlength: 1,
maxlength: 2,
min: 1
},
due_fee_per_day: {
required: true,
min: 1
},
no_of_book_per_user: {
required: true,
min: 1
},
currency: {
required: {
depends: function(element) {
return $("#currency").val() == '';
}
}
}
},
messages: {
can_be_issued_for: {
required: "Lending time is required",
minlength: "At least 1 characters long",
maxlength: "Should not exceed 2 characters",
min: "Value must be greater than 0"
},
due_fee_per_day: {
required: "Fee per day is required",
min: "Value must be greater than 0"
},
no_of_book_per_user: {
required: "Books per user is required",
min: "Value must be greater than 0"
},
currency: {
required: "Curreny is required"
}
},
errorPlacement: function(error, element) {
if (element.attr("name") == "can_be_issued_for") {
error.appendTo($("#error-lending_days"));
} else if (element.attr("name") == "due_fee_per_day") {
error.appendTo($("#error-fee_per_day"));
} else if (element.attr("name") == "no_of_book_per_user") {
error.appendTo($("#error-no_of_book"));
} else if (element.attr("name") == "currency") {
error.appendTo($("#error-currency"));
} else {
error.appendTo(element);
}
},
submitHandler: function(form) {
var formdata = new FormData(form);
$.ajax({
type: 'post',
url: '<?= base_url(); ?>LmsAdmin/generalSettings',
data: formdata,
cache: false,
contentType: false,
processData: false,
success: function(result) {
if (result == 1) {
//$('.txtData').val('');
$('#success').show();
setTimeout(function() {
location.reload();
}, 2000);
}
}
});
}
});
</script>
</body>
</html>