BBnepal-Accounts/account/application/views/inventory/items/list.php

184 lines
12 KiB
PHP
Raw Normal View History

2024-07-10 12:43:19 +00:00
<div class="content-wrapper">
<div class="content">
<div class="container-fluid">
<div class="row">
<div class="col-4">
<div class="card card-primary card-outline">
<div class="card-header">
<h5 class="m-0">
<?php echo isset($item) ? 'Edit' : 'Add'; ?>
<?php myLang('Inventory Item'); ?>
<!-- <?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="<?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_items">
<div class="row">
<!--COL START-->
<div class="col">
<div class="form-group">
<label for="title"><?php myLang('Name'); ?><span class="text-danger">*</span></label>
<input type="text" class="form-control" id="title" value="<?php echo isset($item) ? $item->title : ''; ?>" name="title" required>
</div>
</div>
<!--COL END-->
</div>
<div class="row">
<!--COL START-->
<div class="col-6">
<div class="form-group">
<label for="item_code"><?php myLang('Code'); ?></label>
<input type="text" class="form-control" id="item_code" value="<?php echo isset($item) ? $item->item_code : ''; ?>" name="item_code">
</div>
</div>
<!--COL END-->
<!--COL START-->
<div class="col-6">
<div class="form-group">
2024-08-12 10:36:46 +00:00
<?php fillComboWithValue("units_id", "Units <span class='text-danger'>*</span>", "units_id", "tbl_units", "title", "unit_id", isset($item) ? $item->units_id : '', "", false, "", true); ?>
2024-07-10 12:43:19 +00:00
</div>
</div>
<!--COL END-->
</div>
<div class="row">
<!--COL START-->
<div class="col">
<div class="form-group">
2024-08-12 10:36:46 +00:00
<?php fillComboWithValue("itemcategories_id", "Group <span class='text-danger'>*</span>", "itemcategories_id", "tbl_itemcategories", "title", "itemcategory_id", isset($item) ? $item->itemcategories_id : '', "", false, "", true); ?>
2024-07-10 12:43:19 +00:00
</div>
</div>
<!--COL END-->
</div>
<div class="row">
<!--COL START-->
<div class="col-4">
<div class="form-group">
<label for="opening_stock"><?php myLang('Opening Stock'); ?></label><input type="text" class="form-control" id="opening_stock" value="<?php echo isset($item) ? $item->Stock->opening_stock : ''; ?>" name="opening_stock">
</div>
</div>
<!--COL END-->
<!--COL START-->
<div class="col-4">
<div class="form-group">
<label for="opening_stock_rate"><?php myLang('Rate'); ?></label><input type="text" class="form-control" id="opening_stock_rate" value="<?php echo isset($item) ? $item->Stock->opening_stock_rate : ''; ?>" name="opening_stock_rate">
</div>
</div>
<!--COL END-->
<!--COL START-->
<div class="col-4">
<div class="form-group">
<label for="opening_stock_amount"><?php myLang('Amount'); ?></label><input type="text" class="form-control" id="opening_stock_amount" value="<?php echo isset($item) ? $item->Stock->opening_stock_amount : ''; ?>" name="opening_stock_amount">
</div>
</div>
<!--COL END-->
</div>
<div class="row">
<!--COL START-->
<div class="col">
<div class="form-group">
<label for="description"><?php myLang('Remarks'); ?></label>
2024-07-10 12:43:19 +00:00
<textarea class="form-control" id="description" name="description"><?php echo isset($item) ? $item->description : ''; ?></textarea>
</div>
</div>
<!--COL END-->
</div>
<div class="row">
<!--COL START-->
<!--COL END-->
</div>
<!-- <div class="row">
<div class="col">
<div class="form-group">
<label for="remarks"><?php //myLang('Remarks');
?></label>
<textarea class="form-control" id="remarks" name="remarks"><?php //echo isset($item) ? $item->remarks : '';
?></textarea>
</div>
</div>
</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>
</form>
</div>
</div>
</div>
<div class="col-8">
<div class="card card-primary card-outline">
<div class="card-header">
<h5 class="m-0">List <?php echo $pageTitle; ?>
<?php //showCreateButton($this->uri->segment(1) . "/" . $this->uri->segment(2) . "/add", "Create New " . $pageTitle);
?>
</h5>
</div>
<div class="card-body">
2024-07-12 12:12:29 +00:00
<table class="table table-bordered table-striped longdataTable">
2024-07-10 12:43:19 +00:00
<thead>
<tr>
2024-08-25 10:32:28 +00:00
<th width="5%" class="text-center"><?php myLang('S.N'); ?></th>
2024-07-10 12:43:19 +00:00
<th width="25%"><?php myLang('Name'); ?></th>
<th width="10%"><?php myLang('Code'); ?></th>
<th width="10%"><?php myLang('Units'); ?></th>
2024-07-22 12:16:09 +00:00
<th width="10%"><?php myLang('Group'); ?></th>
2024-07-10 12:43:19 +00:00
<th width="10%" class="text-right"><?php myLang('Qty'); ?></th>
<th width="10%" class="text-right"><?php myLang('Rate'); ?></th>
<th width="10%" class="text-right"><?php myLang('Total'); ?></th>
2024-08-08 12:56:24 +00:00
<td width="7%" class="col-1 text-bold text-center"><?php myLang("Action"); ?></th>
2024-07-10 12:43:19 +00:00
</tr>
</thead>
<tbody>
<?php $a = 0;
foreach ($TableData as $TableRow) : $a++; ?>
<?php foreach ($TableRow as $cols) : $id = $cols;
break;
endforeach; ?><tr>
2024-08-25 10:32:28 +00:00
<td class="text-center"><?php echo $a; ?></td>
2024-07-10 12:43:19 +00:00
<td><?php echo $TableRow->title; ?></td>
<td><?php echo $TableRow->item_code; ?></td>
2024-10-07 05:56:27 +00:00
<td><?php echo number_format((int)getFieldfromValue("tbl_units", "title", "unit_id", $TableRow->units_id),2); ?></td>
2024-07-10 12:43:19 +00:00
<td><?php echo getFieldfromValue("tbl_itemcategories", "title", "itemcategory_id", $TableRow->itemcategories_id); ?></td>
2024-10-07 05:56:27 +00:00
<td class="text-right"><?php echo number_format((int)$TableRow->Stock->qty,2); ?></td>
<td class="text-right"><?php echo number_format((int)$TableRow->Stock->rate,2); ?></td>
<td class="text-right"><?php echo number_format((int)$TableRow->Stock->amount,2); ?></td>
2024-08-08 12:56:24 +00:00
<td class="text-center">
2024-07-10 12:43:19 +00:00
<?php showEditButton($this->uri->segment(1) . "/" . $this->uri->segment(2) . "/edit/$id"); ?>
<?php showDeleteButton($id); ?>
</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;
}
}
</script>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<script>
// Function to calculate the amount
function calculateAmount() {
var opening_stock = parseFloat(document.getElementById('opening_stock').value);
var opening_stock_rate = parseFloat(document.getElementById('opening_stock_rate').value);
var opening_stock_amount = opening_stock * opening_stock_rate;
// Set the calculated amount in the amount field
document.getElementById('opening_stock_amount').value = opening_stock_amount.toFixed(2); // Adjust decimal places as needed
}
// Event listeners to trigger calculation on input change
document.getElementById('opening_stock').addEventListener('input', calculateAmount);
document.getElementById('opening_stock_rate').addEventListener('input', calculateAmount);
// Initial calculation on page load
calculateAmount();
</script>