102 lines
3.0 KiB
PHP
102 lines
3.0 KiB
PHP
<?= $this->extend('layouts/main.php') ?>
|
|
|
|
<?= $this->section('content') ?>
|
|
|
|
<main id="main" class="main">
|
|
<div class="pagetitle">
|
|
<h1>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();?>insts/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></th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
<?php
|
|
foreach($insts as $data) {
|
|
$instid = $data['instid'];
|
|
$instname= $data['instname'];
|
|
?>
|
|
<tr>
|
|
<td><?=$instid;?></td> <td><?=$instname;?></td>
|
|
<td>
|
|
<a href='<?=base_url()."insts/edit/".$instid;?>' class='btn btn-sm btn-warning'>edit</a>
|
|
<a href='<?=base_url()."flags/".$instid;?>' class='btn btn-sm btn-info'>Flag</a>
|
|
<a href='<?=base_url()."techs/".$instid;?>' class='btn btn-sm btn-info'>Tech.</a>
|
|
<!--
|
|
<button type="button" class="btn btn-sm btn-info openInstflag" data-bs-toggle="modal" data-bs-target="#instflag" data-instid="<?=$instid;?>">Flag</button>
|
|
<button type="button" class="btn btn-sm btn-info openInstTec" data-bs-toggle="modal" data-bs-target="#insttec" data-instid="<?=$instid;?>">Tec</button>
|
|
-->
|
|
</td>
|
|
</tr>
|
|
<?php
|
|
}
|
|
?>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
<form id='insttest_form'>
|
|
<div class="modal fade" id="insttest" tabindex="-1">
|
|
<div class="modal-dialog">
|
|
<div class="modal-content">
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</form>
|
|
|
|
</main>
|
|
<?= $this->endSection() ?>
|
|
|
|
<?= $this->section('script') ?>
|
|
<script>
|
|
$('.openInsttestEdit').on('click',function(){
|
|
const instid = $(this).data('instid');
|
|
$('.modal-content').load('insttest/edit/'+instid,function(){
|
|
$('#modal').modal('show');
|
|
});
|
|
});
|
|
|
|
$('#insttest_form').submit(function(event) {
|
|
event.preventDefault();
|
|
$('#insttest').modal('hide');
|
|
var formData = $(this).serialize();
|
|
|
|
$.ajax({
|
|
type: 'POST',
|
|
url: '<?=base_url()."insttest/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() ?>
|