forked from configuroweb/gestion-pagos
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmanage_fee.php
87 lines (86 loc) · 2.98 KB
/
manage_fee.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
<?php include 'db_connect.php' ?>
<?php
if (isset($_GET['id'])) {
$qry = $conn->query("SELECT * FROM student_ef_list where id = {$_GET['id']} ");
foreach ($qry->fetch_array() as $k => $v) {
$$k = $v;
}
}
?>
<div class="container-fluid">
<form id="manage-fees">
<div id="msg"></div>
<input type="hidden" name="id" value="<?php echo isset($id) ? $id : '' ?>">
<div class="form-group">
<label for="" class="control-label">Nº Matrícula/ Nº Curso</label>
<input type="text" class="form-control" name="ef_no" value="<?php echo isset($ef_no) ? $ef_no : '' ?>" required>
</div>
<div class="form-group">
<label for="" class="control-label">Estudiante</label>
<select name="student_id" id="student_id" class="custom-select input-sm select2">
<option value=""></option>
<?php
$student = $conn->query("SELECT * FROM student order by name asc ");
while ($row = $student->fetch_assoc()) :
?>
<option value="<?php echo $row['id'] ?>" <?php echo isset($student_id) && $student_id == $row['id'] ? 'selected' : '' ?>><?php echo ucwords($row['name']) . ' | ' . $row['id_no'] ?></option>
<?php endwhile; ?>
</select>
</div>
<div class="form-group">
<label for="" class="control-label">Curso</label>
<select name="course_id" id="course_id" class="custom-select input-sm select2">
<option value=""></option>
<?php
$student = $conn->query("SELECT *,concat(course,'-',level) as class FROM courses order by course asc ");
while ($row = $student->fetch_assoc()) :
?>
<option value="<?php echo $row['id'] ?>" data-amount="<?php echo $row['total_amount'] ?>" <?php echo isset($course_id) && $course_id == $row['id'] ? 'selected' : '' ?>><?php echo $row['class'] ?></option>
<?php endwhile; ?>
</select>
</div>
<div class="form-group">
<label for="" class="control-label">Tarifa</label>
<input type="text" class="form-control text-right" name="total_fee" value="<?php echo isset($total_fee) ? number_format($total_fee) : '' ?>" required readonly>
</div>
</form>
</div>
<script>
$('.select2').select2({
placeholder: 'Por favor seleccione aquí',
width: '100%'
})
$('#course_id').change(function() {
var amount = $('#course_id option[value="' + $(this).val() + '"]').attr('data-amount')
$('[name="total_fee"]').val(parseFloat(amount).toLocaleString('en-US', {
style: 'decimal',
maximumFractionDigits: 2,
minimumFractionDigits: 2
}))
})
$('#manage-fees').submit(function(e) {
e.preventDefault()
start_load()
$.ajax({
url: 'ajax.php?action=save_fees',
method: 'POST',
data: $(this).serialize(),
error: err => {
console.log(err)
end_load()
},
success: function(resp) {
if (resp == 1) {
location.reload();
alert_toast("Datos guardados exitósamente", 'success')
setTimeout(function() {
location.reload()
}, 1000)
} else if (resp == 2) {
$('#msg').html('<div class="alert alert-danger">Número de Curso Existe Actualmente</div>')
end_load()
}
}
})
})
</script>