mirror of
https://github.com/opensourcepos/opensourcepos.git
synced 2026-02-18 22:59:06 -05:00
fix error on new item (#429)
This commit is contained in:
@@ -172,30 +172,42 @@ class Items extends Secure_area implements iData_controller
|
||||
|
||||
function view($item_id=-1)
|
||||
{
|
||||
$data['item_info'] = $this->Item->get_info($item_id);
|
||||
$item_info = $this->Item->get_info($item_id);
|
||||
|
||||
$data['item_tax_info'] = $this->Item_taxes->get_info($item_id);
|
||||
$suppliers = array('' => $this->lang->line('items_none'));
|
||||
$data['default_tax_1_rate'] = '';
|
||||
$data['default_tax_2_rate'] = '';
|
||||
|
||||
if($item_id==-1)
|
||||
{
|
||||
$data['default_tax_1_rate'] = $this->Appconfig->get('default_tax_1_rate');
|
||||
$data['default_tax_2_rate'] = $this->Appconfig->get('default_tax_2_rate');
|
||||
|
||||
$item_info->receiving_quantity = 0;
|
||||
$item_info->reorder_level = 0;
|
||||
}
|
||||
|
||||
$data['item_info'] = $item_info;
|
||||
|
||||
$suppliers = array(''=>$this->lang->line('items_none'));
|
||||
foreach($this->Supplier->get_all()->result_array() as $row)
|
||||
{
|
||||
$suppliers[$row['person_id']] = $row['company_name'];
|
||||
}
|
||||
|
||||
$item_info = $this->Item->get_info($item_id);
|
||||
$data['suppliers'] = $suppliers;
|
||||
$data['selected_supplier'] = $item_info->supplier_id;
|
||||
$data['default_tax_1_rate'] = ($item_id==-1) ? $this->Appconfig->get('default_tax_1_rate') : '';
|
||||
$data['default_tax_2_rate'] = ($item_id==-1) ? $this->Appconfig->get('default_tax_2_rate') : '';
|
||||
|
||||
$data['logo_exists'] = $item_info->pic_id != '';
|
||||
$images = glob ("uploads/item_pics/" . $item_info->pic_id . ".*");
|
||||
$images = glob("uploads/item_pics/" . $item_info->pic_id . ".*");
|
||||
$data['image_path'] = sizeof($images) > 0 ? base_url($images[0]) : '';
|
||||
|
||||
$locations_data = $this->Stock_location->get_undeleted_all()->result_array();
|
||||
foreach($locations_data as $location)
|
||||
{
|
||||
$quantity = $this->Item_quantity->get_item_quantity($item_id,$location['location_id'])->quantity;
|
||||
$quantity = ($item_id == -1) ? 0 : $quantity;
|
||||
$location_array[$location['location_id']] = array('location_name'=>$location['location_name'], 'quantity'=>$quantity);
|
||||
$data['stock_locations'] = $location_array;
|
||||
$quantity = $this->Item_quantity->get_item_quantity($item_id,$location['location_id'])->quantity;
|
||||
$quantity = ($item_id == -1) ? 0 : $quantity;
|
||||
$location_array[$location['location_id']] = array('location_name'=>$location['location_name'], 'quantity'=>$quantity);
|
||||
$data['stock_locations'] = $location_array;
|
||||
}
|
||||
|
||||
$this->load->view("items/form", $data);
|
||||
|
||||
@@ -90,7 +90,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('default_tax_1_name'))
|
||||
'value'=>isset($item_tax_info[0]['name']) ? $item_tax_info[0]['name'] : $this->config->item('default_tax_1_name'))
|
||||
);?>
|
||||
</div>
|
||||
<div class="col-xs-3">
|
||||
@@ -99,7 +99,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'] : $default_tax_1_rate)
|
||||
'value'=>isset($item_tax_info[0]['percent']) ? $item_tax_info[0]['percent'] : $default_tax_1_rate)
|
||||
);?>
|
||||
<span class="input-group-addon input-sm"><b>%</b></span>
|
||||
</div>
|
||||
@@ -113,7 +113,7 @@
|
||||
'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('default_tax_2_name'))
|
||||
'value'=>isset($item_tax_info[1]['name']) ? $item_tax_info[1]['name'] : $this->config->item('default_tax_2_name'))
|
||||
);?>
|
||||
</div>
|
||||
<div class="col-xs-3">
|
||||
@@ -122,7 +122,7 @@
|
||||
'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'] : $default_tax_2_rate)
|
||||
'value'=>isset($item_tax_info[1]['percent']) ? $item_tax_info[1]['percent'] : $default_tax_2_rate)
|
||||
);?>
|
||||
<span class="input-group-addon input-sm"><b>%</b></span>
|
||||
</div>
|
||||
@@ -140,7 +140,7 @@
|
||||
'name'=>'quantity_' . $key,
|
||||
'id'=>'quantity_' . $key,
|
||||
'class'=>'required quantity form-control',
|
||||
'value'=>isset($item_info->item_id) ? to_quantity($location_detail['quantity']) : 0)
|
||||
'value'=>isset($item_info->item_id) ? to_quantity($location_detail['quantity']) : to_quantity(0))
|
||||
);?>
|
||||
</div>
|
||||
</div>
|
||||
@@ -155,7 +155,7 @@
|
||||
'name'=>'receiving_quantity',
|
||||
'id'=>'receiving_quantity',
|
||||
'class'=>'required form-control input-sm',
|
||||
'value'=>to_quantity($item_info->receiving_quantity))
|
||||
'value'=>isset($item_info->item_id) ? to_quantity($item_info->receiving_quantity) : to_quantity(0))
|
||||
);?>
|
||||
</div>
|
||||
</div>
|
||||
@@ -167,7 +167,7 @@
|
||||
'name'=>'reorder_level',
|
||||
'id'=>'reorder_level',
|
||||
'class'=>'form-control input-sm',
|
||||
'value'=>!isset($item_info->item_id) ? 0 : to_quantity($item_info->reorder_level))
|
||||
'value'=>isset($item_info->item_id) ? to_quantity($item_info->reorder_level) : to_quantity(0))
|
||||
);?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user