Fix for adding/deleting stock locations (#242)

This commit is contained in:
jekkos
2015-12-04 08:33:39 +01:00
parent 16d5dfce77
commit 1bb9acdc37
2 changed files with 5 additions and 5 deletions

View File

@@ -1,10 +1,10 @@
<?php
class Stock_location extends CI_Model
{
function exists($location_id='')
function exists($location_name='')
{
$this->db->from('stock_locations');
$this->db->where('location_id',$location_id);
$this->db->where('location_name',$location_name);
$query = $this->db->get();
return ($query->num_rows()>=1);
@@ -84,9 +84,9 @@ class Stock_location extends CI_Model
function save(&$location_data,$location_id)
{
if (!$this->exists($location_id))
$location_name = $location_data['location_name'];
if (!$this->exists($location_name))
{
$location_name = $location_data['location_name'];
$this->db->trans_start();
$location_data = array('location_name'=>$location_name,'deleted'=>0);
$this->db->insert('stock_locations',$location_data);

View File

@@ -3,7 +3,7 @@
<?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;' ?>">
<?php echo form_label($this->lang->line('config_stock_location').' ' .++$i. ':', 'stock_location_'.$i ,array('class'=>'required wide')); ?>
<?php echo form_label($this->lang->line('config_stock_location').' ' .++$i. ':', 'stock_location_'.$i ,array('class'=>'required wide')); ?>
<div class='form_field'>
<?php $form_data = array(
'name'=>'stock_location_'.$location_id,