mirror of
https://github.com/opensourcepos/opensourcepos.git
synced 2026-05-14 18:53:56 -04:00
Set tax rate name & % in bulk edit to be the config one, save only if not empty (#381)
This commit is contained in:
@@ -202,7 +202,7 @@ class Items extends Secure_area implements iData_controller
|
||||
|
||||
function inventory($item_id=-1)
|
||||
{
|
||||
$data['item_info']=$this->Item->get_info($item_id);
|
||||
$data['item_info'] = $this->Item->get_info($item_id);
|
||||
|
||||
$data['stock_locations'] = array();
|
||||
$stock_locations = $this->Stock_location->get_undeleted_all()->result_array();
|
||||
@@ -217,7 +217,7 @@ class Items extends Secure_area implements iData_controller
|
||||
|
||||
function count_details($item_id=-1)
|
||||
{
|
||||
$data['item_info']=$this->Item->get_info($item_id);
|
||||
$data['item_info'] = $this->Item->get_info($item_id);
|
||||
|
||||
$data['stock_locations'] = array();
|
||||
$stock_locations = $this->Stock_location->get_undeleted_all()->result_array();
|
||||
@@ -342,7 +342,7 @@ class Items extends Secure_area implements iData_controller
|
||||
$items_taxes_data = array();
|
||||
$tax_names = $this->input->post('tax_names');
|
||||
$tax_percents = $this->input->post('tax_percents');
|
||||
for($k=0;$k<count($tax_percents);$k++)
|
||||
for($k = 0; $k < count($tax_percents); $k++)
|
||||
{
|
||||
if (is_numeric($tax_percents[$k]))
|
||||
{
|
||||
@@ -376,7 +376,7 @@ class Items extends Secure_area implements iData_controller
|
||||
$success &= $this->Inventory->insert($inv_data);
|
||||
}
|
||||
}
|
||||
if ($success && $upload_success)
|
||||
if($success && $upload_success)
|
||||
{
|
||||
$success_message = $this->lang->line('items_successful_' . ($new_item ? 'adding' : 'updating')) .' '. $item_data['name'];
|
||||
|
||||
@@ -390,7 +390,6 @@ class Items extends Secure_area implements iData_controller
|
||||
|
||||
echo json_encode(array('success'=>false, 'message'=>$error_message, 'item_id'=>$item_id));
|
||||
}
|
||||
|
||||
}
|
||||
else//failure
|
||||
{
|
||||
@@ -426,7 +425,8 @@ class Items extends Secure_area implements iData_controller
|
||||
public function remove_logo($item_id)
|
||||
{
|
||||
$item_data = array('pic_id' => null);
|
||||
$result = $this->Item->save($item_data, $item_id);;
|
||||
$result = $this->Item->save($item_data, $item_id);
|
||||
|
||||
echo json_encode(array('success' => $result));
|
||||
}
|
||||
|
||||
@@ -474,30 +474,38 @@ class Items extends Secure_area implements iData_controller
|
||||
foreach($_POST as $key=>$value)
|
||||
{
|
||||
//This field is nullable, so treat it differently
|
||||
if ($key == 'supplier_id' and $value != '')
|
||||
if($key == 'supplier_id' && $value != '')
|
||||
{
|
||||
$item_data["$key"] = $value;
|
||||
}
|
||||
elseif($value != '' and !(in_array($key, array('item_ids', 'tax_names', 'tax_percents'))))
|
||||
elseif($value != '' && !(in_array($key, array('item_ids', 'tax_names', 'tax_percents'))))
|
||||
{
|
||||
$item_data["$key"] = $value;
|
||||
}
|
||||
}
|
||||
|
||||
//Item data could be empty if tax information is being updated
|
||||
if(empty($item_data) || $this->Item->update_multiple($item_data,$items_to_update))
|
||||
if(empty($item_data) || $this->Item->update_multiple($item_data, $items_to_update))
|
||||
{
|
||||
$items_taxes_data = array();
|
||||
$tax_names = $this->input->post('tax_names');
|
||||
$tax_percents = $this->input->post('tax_percents');
|
||||
for($k=0;$k<count($tax_percents);$k++)
|
||||
{
|
||||
if (is_numeric($tax_percents[$k]))
|
||||
$tax_updated = false;
|
||||
|
||||
for($k = 0; $k < count($tax_percents); $k++)
|
||||
{
|
||||
if( !empty($tax_names[$k]) && is_numeric($tax_percents[$k]))
|
||||
{
|
||||
$items_taxes_data[] = array('name'=>$tax_names[$k], 'percent'=>$tax_percents[$k] );
|
||||
$tax_updated = true;
|
||||
|
||||
$items_taxes_data[] = array('name'=>$tax_names[$k], 'percent'=>$tax_percents[$k]);
|
||||
}
|
||||
}
|
||||
$this->Item_taxes->save_multiple($items_taxes_data, $items_to_update);
|
||||
|
||||
if($tax_updated)
|
||||
{
|
||||
$this->Item_taxes->save_multiple($items_taxes_data, $items_to_update);
|
||||
}
|
||||
|
||||
echo json_encode(array('success'=>true,'message'=>$this->lang->line('items_successful_bulk_edit')));
|
||||
}
|
||||
@@ -509,7 +517,7 @@ class Items extends Secure_area implements iData_controller
|
||||
|
||||
function delete()
|
||||
{
|
||||
$items_to_delete=$this->input->post('ids');
|
||||
$items_to_delete = $this->input->post('ids');
|
||||
|
||||
if($this->Item->delete_list($items_to_delete))
|
||||
{
|
||||
|
||||
@@ -71,7 +71,7 @@
|
||||
'name'=>'tax_names[]',
|
||||
'id'=>'tax_name_1',
|
||||
'class'=>'form-control input-sm',
|
||||
'value'=> isset($item_tax_info[0]['name']) ? $item_tax_info[0]['name'] : $this->config->item('items_sales_tax_1'))
|
||||
'value'=>$this->config->item('default_tax_1_name'))
|
||||
);?>
|
||||
</div>
|
||||
<div class="col-sm-3">
|
||||
@@ -80,7 +80,7 @@
|
||||
'name'=>'tax_percents[]',
|
||||
'id'=>'tax_percent_name_1',
|
||||
'class'=>'form-control input-sm',
|
||||
'value'=> isset($item_tax_info[0]['percent']) ? $item_tax_info[0]['percent'] : '')
|
||||
'value'=>$this->config->item('default_tax_1_rate'))
|
||||
);?>
|
||||
<span class="input-group input-group-addon"><b>%</b></span>
|
||||
</div>
|
||||
@@ -94,16 +94,16 @@
|
||||
'name'=>'tax_names[]',
|
||||
'id'=>'tax_name_2',
|
||||
'class'=>'form-control input-sm',
|
||||
'value'=> isset($item_tax_info[1]['name']) ? $item_tax_info[1]['name'] : $this->config->item('items_sales_tax_2'))
|
||||
'value'=>$this->config->item('default_tax_2_name'))
|
||||
);?>
|
||||
</div>
|
||||
<div class="col-sm-3">
|
||||
<div class="input-group input-group-sm">
|
||||
<?php echo form_input(array(
|
||||
'name'=>'tax_percents[]',
|
||||
'class'=>'form-control input-sm',
|
||||
'id'=>'tax_percent_name_2',
|
||||
'value'=> isset($item_tax_info[1]['percent']) ? $item_tax_info[1]['percent'] : '')
|
||||
'class'=>'form-control input-sm',
|
||||
'value'=>$this->config->item('default_tax_2_rate'))
|
||||
);?>
|
||||
<span class="input-group input-group-addon"><b>%</b></span>
|
||||
</div>
|
||||
@@ -156,7 +156,7 @@ $(document).ready(function()
|
||||
|
||||
var confirm_message = false;
|
||||
$("#tax_percent_name_2, #tax_name_2").prop('disabled', true),
|
||||
$("#tax_percent_name_1, tax_name_1").blur(function() {
|
||||
$("#tax_percent_name_1, #tax_name_1").blur(function() {
|
||||
var disabled = !($("#tax_percent_name_1").val() + $("#tax_name_1").val());
|
||||
$("#tax_percent_name_2, #tax_name_2").prop('disabled', disabled);
|
||||
confirm_message = disabled ? "" : "<?php echo $this->lang->line('items_confirm_bulk_edit_wipe_taxes') ?>";
|
||||
|
||||
Reference in New Issue
Block a user