mirror of
https://github.com/opensourcepos/opensourcepos.git
synced 2026-03-05 23:58:02 -05:00
Merge pull request #2970 from opensourcepos/fix-location-crud
Fix stock location crud (#2965)
This commit is contained in:
@@ -578,15 +578,16 @@ class Config extends Secure_Controller
|
||||
{
|
||||
if(strstr($key, 'stock_location'))
|
||||
{
|
||||
$location_id = preg_replace("/.*?_(\d+)$/", "$1", $key);
|
||||
|
||||
// save or update
|
||||
$location_data = array('location_name' => $value);
|
||||
if($this->Stock_location->save($location_data, $location_id))
|
||||
foreach ($value as $location_id => $location_name)
|
||||
{
|
||||
$location_id = $this->Stock_location->get_location_id($value);
|
||||
$not_to_delete[] = $location_id;
|
||||
$this->_clear_session_state();
|
||||
$location_data = array('location_name' => $location_name);
|
||||
if($this->Stock_location->save($location_data, $location_id))
|
||||
{
|
||||
$location_id = $this->Stock_location->get_location_id($location_name);
|
||||
$not_to_delete[] = $location_id;
|
||||
$this->_clear_session_state();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -957,4 +958,4 @@ class Config extends Secure_Controller
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
?>
|
||||
|
||||
@@ -111,7 +111,7 @@ class Stock_location extends CI_Model
|
||||
$this->db->trans_start();
|
||||
|
||||
$this->db->insert('stock_locations', $location_data_to_save);
|
||||
$location_id = $this->db->insert_id();
|
||||
$location_id = $this->db->insert_id();
|
||||
|
||||
$this->_insert_new_permission('items', $location_id, $location_name);
|
||||
$this->_insert_new_permission('sales', $location_id, $location_name);
|
||||
|
||||
@@ -35,11 +35,9 @@ $(document).ready(function()
|
||||
};
|
||||
|
||||
var add_stock_location = function() {
|
||||
var id = $(this).parent().find('input').attr('id');
|
||||
id = id.replace(/.*?_(\d+)$/g, "$1");
|
||||
var block = $(this).parent().clone(true);
|
||||
var new_block = block.insertAfter($(this).parent());
|
||||
var new_block_id = 'stock_location_' + ++id;
|
||||
var new_block_id = 'stock_location[]';
|
||||
$(new_block).find('label').html("<?php echo $this->lang->line('config_stock_location'); ?> " + ++location_count).attr('for', new_block_id).attr('class', 'control-label col-xs-2');
|
||||
$(new_block).find('input').attr('id', new_block_id).removeAttr('disabled').attr('name', new_block_id).attr('class', 'form-control input-sm').val('');
|
||||
hide_show_remove();
|
||||
|
||||
@@ -11,8 +11,8 @@ foreach($stock_locations as $location => $location_data)
|
||||
<?php echo form_label($this->lang->line('config_stock_location') . ' ' . $i, 'stock_location_' . $i, array('class'=>'required control-label col-xs-2')); ?>
|
||||
<div class='col-xs-2'>
|
||||
<?php $form_data = array(
|
||||
'name'=>'stock_location_' . $location_id,
|
||||
'id'=>'stock_location_' . $location_id,
|
||||
'name'=>"stock_location[$location_id]",
|
||||
'id'=>"stock_location[$location_id]",
|
||||
'class'=>'stock_location valid_chars form-control input-sm required',
|
||||
'value'=>$location_name
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user