clqms-server/app/Views/prodinst_index.php
2025-08-15 09:45:16 +07:00

98 lines
2.8 KiB
PHP

<?= $this->extend('layouts/main.php') ?>
<?= $this->section('content') ?>
<main id="main" class="main">
<div class="pagetitle">
<h1>Product - Instruments List</h1>
</div>
<?php
if(isset($validation)) {
?>
<div class='alert alert-danger alert-dismissible'>
<?= $validation->listErrors(); ?>
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"> <span aria-hidden="true"></span> </button>
</div>
<?php
}
?>
<div class="card" style="height:700px;">
<div class="card-body">
<div class='card-title d-flex'>
<h5><b>Instrument List</b></h5>
<a href='<?=base_url();?>prodinst/create' class='btn btn-sm btn-info ms-auto'> <i class='bi bi-plus-circle'></i> New Instrument</a>
</div>
<table class="table table-sm table-hover">
<thead>
<tr>
<th scope='col'>ID</th> <th scope="col">Instrument Name</th> <th scope="col">Instrument Code</th> <th></th>
</tr>
</thead>
<tbody>
<?php
foreach($prodinsts as $data) {
$prodinstid = $data['prodinstid'];
$prodinstname= $data['prodinstname'];
$prodinstcode= $data['prodinstcode'];
?>
<tr>
<td><?=$prodinstid;?></td> <td><?=$prodinstname;?></td> <td><?=$prodinstcode;?></td>
<td>
<a href='<?=base_url()."prodinst/edit/".$prodinstid;?>' class='btn btn-sm btn-warning'>edit</a>
<button type="button" class="btn btn-sm btn-info openProdinsttestEdit" data-bs-toggle="modal" data-bs-target="#prodinsttest" data-prodinstid="<?=$prodinstid;?>">tests</button>
</td>
</tr>
<?php
}
?>
</tbody>
</table>
</div>
</div>
<form id='prodinsttest_form'>
<div class="modal fade" id="prodinsttest" tabindex="-1">
<div class="modal-dialog">
<div class="modal-content">
</div>
</div>
</div>
</form>
</main>
<?= $this->endSection() ?>
<?= $this->section('script') ?>
<script>
$('.openProdinsttestEdit').on('click',function(){
const prodinstid = $(this).data('prodinstid');
$('.modal-content').load('prodinsttest/edit/'+prodinstid,function(){
$('#modal').modal('show');
});
});
$('#prodinsttest_form').submit(function(event) {
event.preventDefault();
$('#prodinsttest').modal('hide');
var formData = $(this).serialize();
$.ajax({
type: 'POST',
url: '<?=base_url()."prodinsttest/update";?>',
dataType: "json",
data: formData,
success: function(response) { console.log(response); },
error: function(xhr, status, error) {
if(xhr.status != '200') {
var alert = '<div class="alert alert-danger alert-dismissible fade show" role="alert">' +
'<strong>Error!</strong> An error occurred. Please try again later.<br>' +
'<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>' +
'</div>';
$('main').prepend(alert);
}
}
});
});
</script>
<?= $this->endSection() ?>