BBnepal-Accounts/account/application/views/fiscalyear/list.php
Sampanna Rimal 78c76c2ef0 22july
2024-07-22 18:01:09 +05:45

214 lines
11 KiB
PHP

<div class="content-wrapper">
<div class="content">
<div class="container-fluid">
<div class="row">
<div class="col-3">
<!-- old code -->
<div class="card card-primary card-outline">
<div class="card-header">
<!-- <?php echo isset($item) ? 'Edit' : 'Create'; ?> -->
<h5 class="m-0">Create <?php echo $pageTitle; ?>
<?php //showListButton($this->uri->segment(1) . "/" . $this->uri->segment(2) . "/list","List ".$pageTitle);
?>
</h5>
</div>
<div class="card-body">
<!-- <form method=POST action="" enctype="multipart/form-data" name="tbl_fiscalyear"> -->
<form method="POST" action="<?php echo isset($item) ? site_url($this->uri->segment(1) . "/" . $this->uri->segment(2) . "/edit/" . $item->item_id) : site_url($this->uri->segment(1) . "/" . $this->uri->segment(2) . "/add"); ?>" enctype="multipart/form-data" name="tbl_fiscalyear">
<div class="row">
<!--COL START-->
<div class="col-6">
<div class="form-group">
<label for="fiscalyear_year">Fiscal Year <span style="color:#ff0000">*</span></label>
<input type="text" class="form-control" id="fiscalyear_year" value="<?php echo isset($item) ? $item->fiscalyear_year : ''; ?>" name="fiscalyear_year" required>
<!-- <input type="text" class="form-control" id="fiscalyear_year" value="" name="fiscalyear_year"> -->
</div>
</div>
<!--COL END-->
<!--COL START-->
<div class="col-6">
<div class="form-group">
<label for="fiscalyear_code"> Code</label>
<input type="text" class="form-control" id="fiscalyear_code" value="<?php echo isset($item) ? $item->fiscalyear_code : ''; ?>" name="fiscalyear_code">
<!-- <label for="fiscalyear_code"> Code</label><input type="text" class="form-control" id="fiscalyear_code" value="" name="fiscalyear_code"> -->
</div>
</div>
<!--COL END-->
</div>
<div class="row">
<!--COL START-->
<div class="col-6">
<div class="form-group">
<label for="fiscalyear_from"> From <span style="color:#ff0000">*</span></label>
<input type="text" class="form-control nepaliDatePicker" id="fiscalyear_from" value="<?php echo isset($item) ? $item->fiscalyear_from : ''; ?>" name="fiscalyear_from" required>
<!-- <input type="text" class="form-control nepaliDatePicker" id="fiscalyear_from" value="" name="fiscalyear_from"> -->
<!-- <input type="date" class="form-control" id="fiscalyear_from" value="" name="fiscalyear_from"> -->
</div>
</div>
<!--COL END-->
<!--COL START-->
<div class="col-6">
<div class="form-group">
<label for="fiscalyear_to"> To <span style="color:#ff0000">*</span></label>
<input type="text" class="form-control nepaliDatePicker" id="fiscalyear_to" value="<?php echo isset($item) ? $item->fiscalyear_to : ''; ?>" name="fiscalyear_to" required>
<!-- <input type="text" class="form-control nepaliDatePicker" id="fiscalyear_to" value="" name="fiscalyear_to"> -->
<!-- <input type="date" class="form-control" id="fiscalyear_to" value="" name="fiscalyear_to"> -->
</div>
</div>
<!--COL END-->
</div>
<div class="row">
<!--COL START-->
<div class="col">
<div class="form-group"> <label for="remarks">Remarks</label>
<textarea class="form-control" id="remarks" name="remarks"><?php echo isset($item) ? $item->remarks : ''; ?></textarea>
<!-- <textarea class="form-control" row="10" id="remarks" name="remarks" ></textarea> -->
</div>
</div>
<!--COL END-->
</div>
<!-- <button type="reset" class="btn btn-default btn-sm">Reset</button> -->
<button class="btn btn-primary btn-sm float-right" type="submit" name="submit"><?php echo isset($item) ? 'Update' : 'Save'; ?></button>
<!-- <button class="btn btn-primary btn-sm float-right" type="submit" name="submit">Save</button> -->
</form>
</div>
</div>
</div>
<div class="col-9">
<div class="card card-primary card-outline">
<div class="card-header">
<h5 class="m-0">
Current Fiscal Year :
<?php $currentFiscalYear = showFiscalYear(); ?>
<?php //showCreateButton($this->uri->segment(1) . "/" . $this->uri->segment(2) . "/add","Create New ".$pageTitle);
?>
</h5>
</div>
<div class="card-body">
<!-- <h3>Currently Selected Fiscal Year ID is: <?php //echo $this->session->userdata("FiscalYearID");
?></h3> -->
<?php $TableData = $this->db->query("select * from tbl_fiscalyear where status<>-1")->result(); ?>
<table class="table table-bordered table-striped dataTable">
<thead>
<tr>
<th>Fiscal Year </th>
<th> Code</th>
<th>From</th>
<th>To</th>
<!-- <th>Created By</th> -->
<th>Action</th>
</tr>
</thead>
<tbody>
<?php $a = 0;
foreach ($TableData as $TableRow) : $a++; ?>
<?php foreach ($TableRow as $cols) : $id = $cols;
break;
endforeach; ?><tr class="<?php echo ($TableRow->status == 1) ? "table-success" : "table-danger"; ?>">
<td><?php echo $TableRow->fiscalyear_year; ?></td>
<td><?php echo $TableRow->fiscalyear_code; ?></td>
<td><?php echo $TableRow->fiscalyear_from; ?></td>
<td><?php echo $TableRow->fiscalyear_to; ?></td>
<!-- <td><?php //echo $TableRow->created_by;
?></td> -->
<td>
<!-- <?php //showEditButton($this->uri->segment(1) . "/" . $this->uri->segment(2) . "/edit/$id"); ?> -->
<a href="<?php echo site_url($this->uri->segment(1) . "/" . $this->uri->segment(2) . "/edit/$id"); ?>" data-fiscalyear_id="<?php echo $id; ?>" class="btn btn-info btn-xs"><i class="fas fa-edit"></i> Edit</a>
<!-- <a href="<?php //echo site_url($this->uri->segment(1) . "/" . $this->uri->segment(2) . "/edit/$id"); ?>" data-fiscalyear_id="<?php //echo $id; ?>" class="editButton btn-info btn-xs"><i class="fas fa-edit"></i> Edit Modal</a> -->
<?php if ($TableRow->status == 0) : ?><a onClick="javascript:doSelect(<?php echo $id; ?>);" class="btn btn-success btn-xs"><i class="fas fa-check"></i> Select</a><?php endif; ?>
<a onClick="javascript:doDelete(<?php echo $id; ?>);" class="btn btn-danger btn-xs"><i class="fas fa-trash"></i> Delete</a>
</td>
</tr>
<?php endforeach; ?>
<tbody>
</table>
<script>
function doDelete(id) {
if (confirm('Are you sure to delete?')) {
window.location = '<?php echo site_url($this->uri->segment(1) . "/" . $this->uri->segment(2) . "/delete/"); ?>' + id;
}
}
function doSelect(id) {
if (confirm('Are you sure to switch current fiscal year? You will have to Log-In Again!')) {
window.location = '<?php echo site_url("master/fiscalyear/select/"); ?>' + id;
}
}
</script>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="modal fade" id="editModal" tabindex="-1" role="dialog" aria-labelledby="editModalLabel" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="editModalLabel">Edit Fiscal Year</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
<div class="modal-body" id="editModalBody">
<!-- Form for editing fiscal year data -->
<form id="editForm">
<!-- Form fields for editing -->
<input type="hidden" id="editId" name="editId">
<!-- Other form fields for editing fiscal year attributes -->
<div class="form-group">
<label for="editFiscalYearCode">Fiscal Year Code</label>
<input type="text" class="form-control" id="editFiscalYearCode" name="editFiscalYearCode">
</div>
<!-- Add more form fields as needed -->
<!-- Submit button -->
<button type="submit" class="btn btn-primary">Save Changes</button>
</form>
</div>
</div>
</div>
</div>
<?php function footerFunctions()
{ ?>
<script>
$(document).ready(function() {
// Handle Edit Button Click
$('.btn-info').click(function(e) {
e.preventDefault();
var id = $(this).data('fiscalyear_id');
$.ajax({
url: '<?php echo site_url("master/fiscalyear/edit/"); ?>' + id, // Change the URL to your server endpoint
type: 'GET',
data: {
id: id
},
success: function(response) {
$("#editModalBody").html(response);
$('#editModal').modal('show');
}
});
});
// Handle form submission for editing via AJAX
$('#editForm').submit(function(event) {
event.preventDefault();
// AJAX request to submit edited data
$.ajax({
url: 'edit_fiscal_year.php', // Change the URL to your server endpoint
type: 'POST',
data: $(this).serialize(),
success: function(response) {
// Handle success, e.g., update the corresponding row in the table
// Close the modal
$('#editModal').modal('hide');
}
});
});
});
</script>
<?php } ?> -->