Fix stock location removal

This commit is contained in:
jekkos-t520
2015-02-02 16:55:26 +01:00
parent 215a2104a1
commit 7c24682584
4 changed files with 10 additions and 11 deletions

View File

@@ -133,7 +133,6 @@ class Stock_locations extends CI_Model
$this->db->where('location_id', $location_id);
$this->db->update('stock_locations', array('deleted' => 1));
// should delete permissions and grants as well?
$this->db->where('location_id', $location_id);
$this->db->delete('permissions');
$this->db->trans_complete();

View File

@@ -36,7 +36,7 @@ $(document).ready(function()
var hide_show_remove = function()
{
if ($("input[name*='stock_location']").length > 1)
if ($("input[name*='stock_location']:enabled").length > 1)
{
$(".remove_stock_location").show();
}
@@ -46,8 +46,6 @@ $(document).ready(function()
}
};
hide_show_remove();
var add_stock_location = function()
{
var id = $(this).parent().find('input').attr('id');
@@ -72,6 +70,7 @@ $(document).ready(function()
{
$('.add_stock_location').click(add_stock_location);
$('.remove_stock_location').click(remove_stock_location);
hide_show_remove();
};
init_add_remove_locations();
@@ -100,10 +99,7 @@ $(document).ready(function()
{
set_feedback(response.message,'error_message',true);
}
$("#stock_locations").load('<?php echo site_url("config/stock_locations");?>', function() {
init_add_remove_locations();
hide_show_remove();
});
$("#stock_locations").load('<?php echo site_url("config/stock_locations");?>', init_add_remove_locations);
},
dataType:'json'
});

View File

@@ -2,14 +2,17 @@
<?php foreach($stock_locations as $location => $location_data ) { ?>
<?php $location_id = $location_data['location_id']; ?>
<?php $location_name = $location_data['location_name']; ?>
<div class="field_row clearfix" style="<?php echo $location_data['deleted'] ? ';display:none;' : 'display:block;' ?>">
<div class="field_row clearfix" style="<?php echo $location_data['deleted'] ? 'display:none;' : 'display:block;' ?>">
<?php echo form_label($this->lang->line('config_stock_location').' ' .++$i. ':', 'stock_location_'.$i ,array('class'=>'required wide')); ?>
<div class='form_field'>
<?php echo form_input(array(
<?php $form_data = array(
'name'=>'stock_location_'.$location_id,
'id'=>'stock_location_'.$location_id,
'class'=>'stock_location required',
'value'=>$location_name)); ?>
'value'=>$location_name);
$location_data['deleted'] && $form_data['disabled'] = 'disabled';
echo form_input($form_data);
?>
</div>
<img class="add_stock_location" src="<?php echo base_url('images/plus.png'); ?>" />
<img class="remove_stock_location" src="<?php echo base_url('images/minus.png'); ?>" />

View File

@@ -66,4 +66,5 @@ div.tabcontents
border: 1px solid #B7B7B7; padding: 10px;
background-color:#FFF;
border-radius: 0 3px 3px 3px;
margin-bottom: 20px;
}