photo remaining

This commit is contained in:
Sampanna Rimal
2024-07-16 12:43:55 +05:45
parent 7ffe31e260
commit de0b041520
18 changed files with 273 additions and 198 deletions

View File

@ -57,14 +57,14 @@
<tbody id="salesDetails">
<tr class="sales-detail-duplicator">
<td> <select name="item_id[]" class="form-control" required>
<td> <select name="item_id[]" class="form-control select_item" required>
<option value="">Select Item</option>
<?php foreach ($items as $item) : ?>
<option value="<?php echo $item->item_id; ?>" required><?php echo $item->title; ?></option>
<?php endforeach; ?>
</select></td>
<td> <input type="text" class="form-control input-group-sm" name="qty[]" required></td>
<td><input type="text" class="form-control" name="pcs/dozen/kgs" required> </td>
<td><input type="text" class="form-control item_unit" name="pcs/dozen/kgs" required> </td>
<td><input type="text" class="form-control" name="rate[]" required></td>
<td><input type="text" class="form-control" name="ltotal[]" required></td>
<td>
@ -87,7 +87,7 @@
</tr>
<tr>
<td class="text-right">
<input class="form-control1" type="text" name="discountpercentage" id="discountpercentage" value="5" width="2%"> <b>% Discount</b>
<input class="form-control1" type="text" name="discountpercentage" id="discountpercentage" value="0" width="2%"> <b>% Discount</b>
</td>
<td class="text-right"><b> <input type="text" class="form-control" id="discount"></b></td>
<td></td>
@ -175,30 +175,32 @@
// calculateTotals();
});
// $(document).on('change', '.select_item', function(){
$(document).on('change', '.select_item', function(){
// var selectedOption = $(this).find(':selected');
// var selectedValue = selectedOption.val();
// alert(selectedValue);
// var unitInput = $(this).closest('.sales-detail-duplicator').find('.item_unit');
// if (selectedValue) {
// $.ajax({
// url: '<?php //echo base_url(); ?>application/controllers/inventory/Sales/getUnitByItemId/' + selectedValue,
// method: 'POST',
// success: function(response) {
// console.log(response);
// unitInput.val(unitName);
// alert("Selected Item Value: " + selectedValue + "\nUnit: " + unitName);
// },
// error: function() {
// alert("Error retrieving unit data.");
// }
// });
// } else {
// unitInput.val('');
// alert("No item selected.");
// }
// });
var selectedOption = $(this).find(':selected');
var selectedValue = selectedOption.val();
var unitInput = $(this).closest('.sales-detail-duplicator').find('.item_unit');
if (selectedValue) {
$.ajax({
url: "<?php echo site_url("inventory/Sales/getunitbyitem/"); ?>" + selectedValue,
async: true,
dataType:"json",
method: 'POST',
success: function(response) {
console.log(response);
var unitName = response.title;
unitInput.val(unitName);
},
error: function() {
console.log(error);
alert("Error retrieving unit data.");
}
});
} else {
unitInput.val('');
alert("No item selected.");
}
});
// $(document).on("click", ".remove-sales-detail", function() {

View File

@ -63,19 +63,24 @@
</div>
</div>
<?php endif; endforeach; ?>
<?php $discount = $Sales->discount ?>
</div>
</div>
<div class="row bill-footer">
<div class="col text-right">
<p><strong>Subtotal:</strong> <?php echo myCurrency($total,true); ?></p>
<p><strong>Tax (13%):</strong> <?php echo myCurrency($tax=($total*13)/100,true); ?></p>
<p><strong>Total:</strong> <?php echo myCurrency(($total+$tax),true); ?></p>
<p><strong>Discount percent:</strong> <?php echo myCurrency($discount,true); ?></p>
<?php $discounted = ($total*$discount/100) ?>
<p><strong>Discount amount:</strong> <?php echo myCurrency($discounted,true); ?></p>
<?php $taxable = $total - $discounted ?>
<p><strong>Taxable amount:</strong> <?php echo myCurrency($taxable,true); ?></p>
<p><strong>Tax (13%):</strong> <?php echo myCurrency($tax=($taxable*13)/100,true); ?></p>
<p><strong>Total:</strong> <?php echo myCurrency(($taxable+$tax),true); ?></p>
</div>
</div>
</div>
</div>
</div>
</div>
</div>