Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Use POST for delete supplier & customer (#3336)
  • Loading branch information
jekkos committed Oct 15, 2021
1 parent 2e33f32 commit 3ac43c2
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 7 deletions.
22 changes: 19 additions & 3 deletions application/views/receivings/receiving.php
Expand Up @@ -133,7 +133,7 @@
?>
<?php echo form_open($controller_name."/edit_item/$line", array('class'=>'form-horizontal', 'id'=>'cart_'.$line)); ?>
<tr>
<td><?php echo anchor($controller_name."/delete_item/$line", '<span class="glyphicon glyphicon-trash"></span>');?></td>
<td><span data-item-id="<?php echo $line;?>" class="delete_item_button"><span class="glyphicon glyphicon-trash"></span></span></td>
<td><?php echo $item['item_number']; ?></td>
<td style="align:center;">
<?php echo $item['name'] . ' '. implode(' ', array($item['attribute_values'], $item['attribute_dtvalues'])); ?><br /> <?php echo '[' . to_quantity_decimals($item['in_stock']) . ' in ' . $item['stock_name'] . ']'; ?>
Expand Down Expand Up @@ -276,8 +276,10 @@
?>
</table>

<?php echo anchor($controller_name."/remove_supplier", '<span class="glyphicon glyphicon-remove">&nbsp</span>' . $this->lang->line('common_remove').' '.$this->lang->line('suppliers_supplier'),
array('class'=>'btn btn-danger btn-sm', 'id'=>'remove_supplier_button', 'title'=>$this->lang->line('common_remove').' '.$this->lang->line('suppliers_supplier'))); ?>
<button class="btn btn-danger btn-sm" id="remove_supplier_button" title="<?php echo $this->lang->line('common_remove').' '.$this->lang->line('suppliers_supplier')?>">
<span class="glyphicon glyphicon-remove">&nbsp</span><?php echo $this->lang->line('common_remove').' '.$this->lang->line('suppliers_supplier') ?>
</button>

<?php
}
else
Expand Down Expand Up @@ -402,6 +404,20 @@
<script type="text/javascript">
$(document).ready(function()
{
const redirect = function() {
window.location.href = "<?php echo site_url('receivings'); ?>";
};

$("#remove_supplier_button").click(function()
{
$.post("<?php echo site_url('receivings/remove_supplier'); ?>", redirect);
});

$(".delete_item_button").click(function() {
const item_id = $(this).data('item-id');
$.post("<?php echo site_url('receivings/delete_item/'); ?>" + item_id, redirect);
});

$("#item").autocomplete(
{
source: '<?php echo site_url($controller_name."/stock_item_search"); ?>',
Expand Down
30 changes: 26 additions & 4 deletions application/views/sales/register.php
Expand Up @@ -136,8 +136,8 @@
<?php echo form_open($controller_name."/edit_item/$line", array('class'=>'form-horizontal', 'id'=>'cart_'.$line)); ?>
<tr>
<td>
<span data-item-id="<?php echo $line; ?>" class="delete_item_button"><span class="glyphicon glyphicon-trash"></span></span>
<?php
echo anchor($controller_name . "/delete_item/$line", '<span class="glyphicon glyphicon-trash"></span>');
echo form_hidden('location', $item['item_location']);
echo form_input(array('type'=>'hidden', 'name'=>'item_id', 'value'=>$item['item_id']));
?>
Expand Down Expand Up @@ -382,8 +382,10 @@
?>
</table>

<?php echo anchor($controller_name."/remove_customer", '<span class="glyphicon glyphicon-remove">&nbsp</span>' . $this->lang->line('common_remove').' '.$this->lang->line('customers_customer'),
array('class'=>'btn btn-danger btn-sm', 'id'=>'remove_customer_button', 'title'=>$this->lang->line('common_remove').' '.$this->lang->line('customers_customer'))); ?>
<button class="btn btn-danger btn-sm" id="remove_customer_button" title="<?php echo $this->lang->line('common_remove').' '.$this->lang->line('customers_customer')?>">
<span class="glyphicon glyphicon-remove">&nbsp</span><?php echo $this->lang->line('common_remove').' '.$this->lang->line('customers_customer') ?>
</button>

<?php
}
else
Expand Down Expand Up @@ -544,7 +546,7 @@
{
?>
<tr>
<td><?php echo anchor($controller_name."/delete_payment/$payment_id", '<span class="glyphicon glyphicon-trash"></span>'); ?></td>
<td><span data-payment-id="<?php echo $payment_id; ?>" class="delete_payment_button"><span class="glyphicon glyphicon-trash"></span></span></td>
<td><?php echo $payment['payment_type']; ?></td>
<td style="text-align: right;"><?php echo to_currency($payment['payment_amount']); ?></td>
</tr>
Expand Down Expand Up @@ -662,6 +664,26 @@
<script type="text/javascript">
$(document).ready(function()
{
const redirect = function() {
window.location.href = "<?php echo site_url('sales'); ?>";
};

$("#remove_customer_button").click(function()
{
$.post("<?php echo site_url('sales/remove_customer'); ?>", redirect);
});

$(".delete_item_button").click(function()
{
const item_id = $(this).data('item-id');
$.post("<?php echo site_url('sales/delete_item/'); ?>" + item_id, redirect);
});

$(".delete_payment_button").click(function() {
const item_id = $(this).data('payment-id');
$.post("<?php echo site_url('sales/delete_payment/'); ?>" + item_id, redirect);
});

$("input[name='item_number']").change(function() {
var item_id = $(this).parents('tr').find("input[name='item_id']").val();
var item_number = $(this).val();
Expand Down

0 comments on commit 3ac43c2

Please sign in to comment.