I have a POS system which am trying to manually add a sale, and i need to add a quantity field similar to the one already on there to be labeled as bonus, so when you add the inputted values for both the initial qty field and the bonus qty field they will tally to the total of quantities supplied.
Here is the code (Partial part of it) :
`<?php defined('BASEPATH') or exit('No direct script access allowed'); ?>
<script type="text/javascript">
var count = 1, an = 1, product_variant = 0, DT = <?= $Settings->default_tax_rate ?>,
product_tax = 0, invoice_tax = 0, product_discount = 0, order_discount = 0, total_discount = 0, total = 0, allow_discount = <?= ($Owner || $Admin || $this->session->userdata('allow_discount')) ? 1 : 0; ?>,
tax_rates = <?php echo json_encode($tax_rates); ?>;
//var audio_success = new Audio('<?=$assets?>sounds/sound2.mp3');
//var audio_error = new Audio('<?=$assets?>sounds/sound3.mp3');
$(document).ready(function () {
if (localStorage.getItem('remove_slls')) {
if (localStorage.getItem('slitems')) {
localStorage.removeItem('slitems');
}
if (localStorage.getItem('sldiscount')) {
localStorage.removeItem('sldiscount');
}
if (localStorage.getItem('sltax2')) {
localStorage.removeItem('sltax2');
}
if (localStorage.getItem('slref')) {
localStorage.removeItem('slref');
}
if (localStorage.getItem('slshipping')) {
localStorage.removeItem('slshipping');
}
if (localStorage.getItem('slwarehouse')) {
localStorage.removeItem('slwarehouse');
}
if (localStorage.getItem('slnote')) {
localStorage.removeItem('slnote');
}
if (localStorage.getItem('slinnote')) {
localStorage.removeItem('slinnote');
}
if (localStorage.getItem('slcustomer')) {
localStorage.removeItem('slcustomer');
}
if (localStorage.getItem('slbiller')) {
localStorage.removeItem('slbiller');
}
if (localStorage.getItem('slcurrency')) {
localStorage.removeItem('slcurrency');
}
if (localStorage.getItem('sldate')) {
localStorage.removeItem('sldate');
}
if (localStorage.getItem('slsale_status')) {
localStorage.removeItem('slsale_status');
}
if (localStorage.getItem('slpayment_status')) {
localStorage.removeItem('slpayment_status');
}
if (localStorage.getItem('paid_by')) {
localStorage.removeItem('paid_by');
}
if (localStorage.getItem('amount_1')) {
localStorage.removeItem('amount_1');
}
if (localStorage.getItem('paid_by_1')) {
localStorage.removeItem('paid_by_1');
}
if (localStorage.getItem('pcc_holder_1')) {
localStorage.removeItem('pcc_holder_1');
}
if (localStorage.getItem('pcc_type_1')) {
localStorage.removeItem('pcc_type_1');
}
if (localStorage.getItem('pcc_month_1')) {
localStorage.removeItem('pcc_month_1');
}
if (localStorage.getItem('pcc_year_1')) {
localStorage.removeItem('pcc_year_1');
}
if (localStorage.getItem('pcc_no_1')) {
localStorage.removeItem('pcc_no_1');
}
if (localStorage.getItem('cheque_no_1')) {
localStorage.removeItem('cheque_no_1');
}
if (localStorage.getItem('payment_note_1')) {
localStorage.removeItem('payment_note_1');
}
if (localStorage.getItem('slpayment_term')) {
localStorage.removeItem('slpayment_term');
}
localStorage.removeItem('remove_slls');
}
<?php if ($quote_id) {
?>
// localStorage.setItem('sldate', '<?= $this->sma->hrld($quote->date) ?>');
localStorage.setItem('slcustomer', '<?= $quote->customer_id ?>');
localStorage.setItem('slbiller', '<?= $quote->biller_id ?>');
localStorage.setItem('slwarehouse', '<?= $quote->warehouse_id ?>');
localStorage.setItem('slnote', '<?= str_replace(["r", "n"], '', $this->sma->decode_html($quote->note)); ?>');
localStorage.setItem('sldiscount', '<?= $quote->order_discount_id ?>');
localStorage.setItem('sltax2', '<?= $quote->order_tax_id ?>');
localStorage.setItem('slshipping', '<?= $quote->shipping ?>');
localStorage.setItem('slitems', JSON.stringify(<?= $quote_items; ?>));
<?php
} ?>
<?php if ($this->input->get('customer')) {
?>
if (!localStorage.getItem('slitems')) {
localStorage.setItem('slcustomer', <?=$this->input->get('customer'); ?>);
}
<?php
} ?>
<?php if ($Owner || $Admin) {
?>
if (!localStorage.getItem('sldate')) {
$("#sldate").datetimepicker({
format: site.dateFormats.js_ldate,
fontAwesome: true,
language: 'sma',
weekStart: 1,
todayBtn: 1,
autoclose: 1,
todayHighlight: 1,
startView: 2,
forceParse: 0
}).datetimepicker('update', new Date());
}
$(document).on('change', '#sldate', function (e) {
localStorage.setItem('sldate', $(this).val());
});
if (sldate = localStorage.getItem('sldate')) {
$('#sldate').val(sldate);
}
<?php
} ?>
$(document).on('change', '#slbiller', function (e) {
localStorage.setItem('slbiller', $(this).val());
});
if (slbiller = localStorage.getItem('slbiller')) {
$('#slbiller').val(slbiller);
}
if (!localStorage.getItem('slref')) {
localStorage.setItem('slref', '<?=$slnumber?>');
}
if (!localStorage.getItem('sltax2')) {
localStorage.setItem('sltax2', <?=$Settings->default_tax_rate2;?>);
}
ItemnTotals();
$('.bootbox').on('hidden.bs.modal', function (e) {
$('#add_item').focus();
});
$("#add_item").autocomplete({
source: function (request, response) {
if (!$('#slcustomer').val()) {
$('#add_item').val('').removeClass('ui-autocomplete-loading');
bootbox.alert('<?=lang('select_above');?>');
$('#add_item').focus();
return false;
}
$.ajax({
type: 'get',
url: '<?= admin_url('sales/suggestions'); ?>',
dataType: "json",
data: {
term: request.term,
warehouse_id: $("#slwarehouse").val(),
customer_id: $("#slcustomer").val()
},
success: function (data) {
$(this).removeClass('ui-autocomplete-loading');
response(data);
}
});
},
minLength: 1,
autoFocus: false,
delay: 250,
response: function (event, ui) {
if ($(this).val().length >= 16 && ui.content[0].id == 0) {
bootbox.alert('<?= lang('no_match_found') ?>', function () {
$('#add_item').focus();
});
$(this).removeClass('ui-autocomplete-loading');
$(this).removeClass('ui-autocomplete-loading');
$(this).val('');
}
else if (ui.content.length == 1 && ui.content[0].id != 0) {
ui.item = ui.content[0];
$(this).data('ui-autocomplete')._trigger('select', 'autocompleteselect', ui);
$(this).autocomplete('close');
$(this).removeClass('ui-autocomplete-loading');
}
else if (ui.content.length == 1 && ui.content[0].id == 0) {
bootbox.alert('<?= lang('no_match_found') ?>', function () {
$('#add_item').focus();
});
$(this).removeClass('ui-autocomplete-loading');
$(this).val('');
}
},
select: function (event, ui) {
event.preventDefault();
if (ui.item.id !== 0) {
var row = add_invoice_item(ui.item);
if (row)
$(this).val('');
} else {
bootbox.alert('<?= lang('no_match_found') ?>');
}
}
});
$(document).on('change', '#gift_card_no', function () {
var cn = $(this).val() ? $(this).val() : '';
if (cn != '') {
$.ajax({
type: "get", async: false,
url: site.base_url + "sales/validate_gift_card/" + cn,
dataType: "json",
success: function (data) {
if (data === false) {
$('#gift_card_no').parent('.form-group').addClass('has-error');
bootbox.alert('<?=lang('incorrect_gift_card')?>');
} else if (data.customer_id !== null && data.customer_id !== $('#slcustomer').val()) {
$('#gift_card_no').parent('.form-group').addClass('has-error');
bootbox.alert('<?=lang('gift_card_not_for_customer')?>');
} else {
$('#gc_details').html('<small>Card No: ' + data.card_no + '<br>Value: ' + data.value + ' - Balance: ' + data.balance + '</small>');
$('#gift_card_no').parent('.form-group').removeClass('has-error');
}
}
});
}
});
});
</script>
<div class="col-md-12">
<div class="control-group table-group">
<label class="table-label"><?= lang('order_items'); ?> *</label>
<div class="controls table-controls">
<table id="slTable" class="table items table-striped table-bordered table-condensed table-hover sortable_table">
<thead>
<tr>
<th class="col-md-4"><?= lang('product') . ' (' . lang('code') . ' - ' . lang('name') . ')'; ?></th>
<?php
if ($Settings->product_serial) {
echo '<th class="col-md-2">' . lang('serial_no') . '</th>';
}
?>
<th class="col-md-1"><?= lang('net_unit_price'); ?></th>
<th class="col-md-1"><?= lang('quantity'); ?></th>
<?php
if ($Settings->product_discount && ($Owner || $Admin || $this->session->userdata('allow_discount'))) {
echo '<th class="col-md-1">' . lang('discount') . '</th>';
}
?>
<?php
if ($Settings->tax1) {
echo '<th class="col-md-1">' . lang('product_tax') . '</th>';
}
?>
<th>
<?= lang('subtotal'); ?>
(<span class="currency"><?= $default_currency->code ?></span>)
</th>
<th style="width: 30px !important; text-align: center;">
<i class="fa fa-trash-o" style="opacity:0.5; filter:alpha(opacity=50);"></i>
</th>
</tr>
</thead>
<tbody></tbody>
<tfoot></tfoot>
</table>
</div>
</div>
</div>
Recognized by PHP Collective
New contributor
NYCKIDD is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
2