photo remaining
This commit is contained in:
@ -142,9 +142,9 @@
|
||||
<tbody class="purchase-details-section">
|
||||
<tr class="purchase-detail">
|
||||
<td class="text-center bbsn">1</td>
|
||||
<td width=40%> <?php fillComboWithValue("item_id[]", "", "", "tbl_items", "title", "item_id"); ?></td>
|
||||
<td width=40%> <?php fillComboWithValue("item_id[]", "", "", "tbl_items", "title", "item_id", "", "select_item"); ?></td>
|
||||
<td width=10%> <input type="text" class="form-control input-group-sm" name="quantity[]"></td>
|
||||
<td width=5%><input type="text" class="form-control" name="pcs/dozen/kgs" required> </td>
|
||||
<td width=5%><input type="text" class="form-control item_unit" name="pcs/dozen/kgs" required> </td>
|
||||
<td width=15%><input type="text" class="form-control" name="rate[]"></td>
|
||||
<td width=15%><input type="text" class="form-control" name="total[]"></td>
|
||||
<td width="5%">
|
||||
@ -331,6 +331,33 @@
|
||||
var newPurchaseDetail = purchaseDetailClone.clone();
|
||||
$(".purchase-details-section").append(newPurchaseDetail);
|
||||
});
|
||||
|
||||
$(document).on('change', '.select_item', function(){
|
||||
|
||||
var selectedOption = $(this).find(':selected');
|
||||
var selectedValue = selectedOption.val();
|
||||
var unitInput = $(this).closest('.purchase-detail').find('.item_unit');
|
||||
if (selectedValue) {
|
||||
$.ajax({
|
||||
url: "<?php echo site_url("inventory/Purchases/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.");
|
||||
}
|
||||
});
|
||||
// Remove Purchase Detail
|
||||
$(document).on("click", ".remove-purchase-detail", function() {
|
||||
$(this).closest(".purchase-detail").remove();
|
||||
|
@ -65,12 +65,19 @@
|
||||
<?php endforeach; ?>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<?php $discount = $Purchase->discount ?>
|
||||
<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>
|
||||
|
||||
|
@ -147,10 +147,10 @@
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<!-- <tr>
|
||||
<td>1</td>
|
||||
<td>Education</td>
|
||||
<td>Pcs</td>
|
||||
<td>Example</td>
|
||||
<td>Example</td>
|
||||
<td class="text-center">1000</td>
|
||||
<td class="text-right">1000</td>
|
||||
<td class="text-right">200000</td>
|
||||
@ -165,43 +165,64 @@
|
||||
|
||||
|
||||
<td class="text-center">100%</td>
|
||||
</tr>
|
||||
</tr> -->
|
||||
<?php
|
||||
$spuramount = 0;
|
||||
$ssalamount = 0;
|
||||
$sclqty = 0;
|
||||
$sclamount = 0;
|
||||
$scogs = 0;
|
||||
?>
|
||||
<?php $a = 0;
|
||||
foreach ($StockRecords as $Stock) : $a++; ?>
|
||||
foreach ($StockItems as $Stock) : $a++; ?>
|
||||
<tr>
|
||||
<td><?php echo $a; ?></td>
|
||||
<td><?php echo $Stock->Item->title; ?></td>
|
||||
<td><?php echo $Stock->Item->Unit->title; ?></td>
|
||||
<td class="text-right"><?php echo $Stock->qty; ?></td>
|
||||
<td class="text-right"><?php echo $Stock->price; ?></td>
|
||||
<td class="text-right"><?php echo $Stock->qty * $Stock->price; ?></td>
|
||||
<td> </td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td><?php echo $Stock->Summary->Unit->title; ?></td>
|
||||
<td class="text-right"><?php echo $Stock->Summary->Purchase->qty; ?></td>
|
||||
<td class="text-right"><?php echo myCurrency($Stock->Summary->Purchase->rate); ?></td>
|
||||
<td class="text-right"><?php echo myCurrency($puramount=$Stock->Summary->Purchase->amount); ?></td>
|
||||
<td class="text-right"><?php echo $Stock->Summary->Sales->qty; ?></td>
|
||||
<td class="text-right"><?php echo myCurrency($Stock->Summary->Sales->rate); ?></td>
|
||||
<td class="text-right"><?php echo myCurrency($salamount = $Stock->Summary->Sales->amount); ?></td>
|
||||
<?php $soldinventory = ((($Stock->Summary->Opening->qty)-($Stock->Summary->Closing->qty))/($Stock->Summary->Opening->qty))*100; ?>
|
||||
<td class="text-center"><?php echo $soldinventory . "%"; ?></td>
|
||||
<?php $remaininventory = 100 - $soldinventory; ?>
|
||||
<td class="text-center"><?php echo $remaininventory . "%"; ?></td>
|
||||
<td class="text-right"><?php echo $clqty = $Stock->Summary->Closing->qty; ?></td>
|
||||
<td class="text-right"><?php echo myCurrency($clamount = $Stock->Summary->Closing->amount); ?></td>
|
||||
<?php $cogs = ($Stock->Summary->Sales->qty) * ($Stock->Summary->Purchase->rate); ?>
|
||||
<td class="text-right"><?php echo myCurrency($cogs); ?></td>
|
||||
<?php $gp=($Stock->Summary->Sales->qty) - $cogs; ?>
|
||||
<?php $gpm = ($Stock->Summary->Sales->amount > 0) ? (($Stock->Summary->Sales->amount - $cogs) / $Stock->Summary->Sales->amount) * 100 : 0; ?>
|
||||
<td class="text-center"><?php echo number_format($gpm, 2) . "%"; ?></td>
|
||||
<td></td>
|
||||
<?php
|
||||
|
||||
$spuramount += $puramount;
|
||||
$ssalamount += $salamount;
|
||||
$sclqty += $clqty;
|
||||
$sclamount += $clamount;
|
||||
$scogs += $cogs;
|
||||
|
||||
?>
|
||||
</tr>
|
||||
<?php //pre($Stock);
|
||||
endforeach; ?>
|
||||
</tbody>
|
||||
</tbody>
|
||||
<tfoot>
|
||||
<tr>
|
||||
<td colspan="5" class="text-right text-bold">Grand Total</td>
|
||||
<td class="text-right text-bold">5000</td>
|
||||
<td class="text-right text-bold">5000</td>
|
||||
<td class="text-right text-bold">ad</td>
|
||||
<td class="text-right text-bold">5000</td>
|
||||
<td class="text-right text-bold">5000</td>
|
||||
<td class="text-right text-bold">5000</td>
|
||||
<td class="text-right text-bold">5000</td>
|
||||
<td class="text-right text-bold">5000</td>
|
||||
<td class="text-right text-bold">5000</td>
|
||||
<td class="text-right text-bold">5000</td>
|
||||
<td class="text-right text-bold"><?php echo $spuramount ?></td>
|
||||
<td class="text-right text-bold"></td>
|
||||
<td class="text-right text-bold"></td>
|
||||
<td class="text-right text-bold"><?php echo $ssalamount ?></td>
|
||||
<td class="text-right text-bold"></td>
|
||||
<td class="text-right text-bold"></td>
|
||||
<td class="text-right text-bold"><?php echo $sclqty ?></td>
|
||||
<td class="text-right text-bold"><?php echo $sclamount ?></td>
|
||||
<td class="text-right text-bold"><?php echo $scogs ?></td>
|
||||
<td class="text-right text-bold"></td>
|
||||
|
||||
</tr>
|
||||
</tfoot>
|
||||
|
@ -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() {
|
||||
|
@ -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>
|
||||
|
Reference in New Issue
Block a user