mirror of
https://github.com/opensourcepos/opensourcepos.git
synced 2026-05-07 23:35:04 -04:00
Revert barcode rework
This commit is contained in:
@@ -90,7 +90,7 @@ class Receivings extends Secure_Controller
|
||||
|
||||
$mode = $this->receiving_lib->get_mode();
|
||||
$item_id_or_number_or_item_kit_or_receipt = $this->input->post('item');
|
||||
$this->barcode_lib->parse_barcode_fields($quantity, $price, $item_id_or_number_or_item_kit_or_receipt);
|
||||
$this->barcode_lib->parse_barcode_fields($quantity, $item_id_or_number_or_item_kit_or_receipt);
|
||||
$quantity = ($mode == 'receive' || $mode == 'requisition') ? $quantity : -$quantity;
|
||||
$item_location = $this->receiving_lib->get_stock_source();
|
||||
$discount = $this->config->item('default_receivings_discount');
|
||||
@@ -104,7 +104,7 @@ class Receivings extends Secure_Controller
|
||||
{
|
||||
$this->receiving_lib->add_item_kit($item_id_or_number_or_item_kit_or_receipt, $item_location, $discount, $discount_type);
|
||||
}
|
||||
elseif(!$this->receiving_lib->add_item($item_id_or_number_or_item_kit_or_receipt, $quantity, $item_location, $discount, $discount_type, $price))
|
||||
elseif(!$this->receiving_lib->add_item($item_id_or_number_or_item_kit_or_receipt, $quantity, $item_location, $discount, $discount_type))
|
||||
{
|
||||
$data['error'] = $this->lang->line('receivings_unable_to_add_item');
|
||||
}
|
||||
|
||||
@@ -398,7 +398,7 @@ class Sales extends Secure_Controller
|
||||
}
|
||||
|
||||
$item_id_or_number_or_item_kit_or_receipt = $this->input->post('item');
|
||||
$this->barcode_lib->parse_barcode_fields($quantity, $price, $item_id_or_number_or_item_kit_or_receipt);
|
||||
$this->barcode_lib->parse_barcode_fields($quantity, $item_id_or_number_or_item_kit_or_receipt);
|
||||
$mode = $this->sale_lib->get_mode();
|
||||
$quantity = ($mode == 'return') ? -$quantity : $quantity;
|
||||
$item_location = $this->sale_lib->get_sale_location();
|
||||
|
||||
@@ -49,23 +49,30 @@ class Barcode_lib
|
||||
return $data;
|
||||
}
|
||||
|
||||
public function parse_barcode_fields(&$quantity, &$price, &$item_id_or_number_or_item_kit_or_receipt)
|
||||
public function parse_barcode_fields(&$quantity, &$item_id_or_number_or_item_kit_or_receipt)
|
||||
{
|
||||
$barcode_formats = json_decode($this->CI->config->item('barcode_formats'));
|
||||
$barcode_tokens = Token::get_barcode_tokens();
|
||||
|
||||
if(!empty($barcode_formats))
|
||||
{
|
||||
foreach($barcode_formats as $barcode_format)
|
||||
{
|
||||
$parsed_results = $this->CI->Token_lib->parse($item_id_or_number_or_item_kit_or_receipt, $barcode_format, $barcode_tokens);
|
||||
$quantity = (isset($parsed_results['W'])) ? (int) $parsed_results['W'] / 1000 : 1;
|
||||
$item_id_or_number_or_item_kit_or_receipt = (isset($parsed_results['I'])) ?
|
||||
$parsed_results['I'] : $item_id_or_number_or_item_kit_or_receipt;
|
||||
$price = (isset($parsed_results['P'])) ? (int) $parsed_results['P'] : NULL;
|
||||
if(preg_match("/$barcode_format/", $item_id_or_number_or_item_kit_or_receipt, $matches) && sizeof($matches) > 1)
|
||||
{
|
||||
$qtyfirst = strpos('d', $barcode_format) - strpos('w', $barcode_format) < 0;
|
||||
$quantity = $matches[$qtyfirst ? 1 : 2];
|
||||
if(strstr($barcode_format, '02'))
|
||||
{
|
||||
$quantity = $quantity / 1000;
|
||||
}
|
||||
$item_id_or_number_or_item_kit_or_receipt = $matches[$qtyfirst ? 2 : 1];
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$quantity = 1;
|
||||
}
|
||||
|
||||
public function validate_barcode($barcode)
|
||||
|
||||
@@ -27,7 +27,7 @@ abstract class Token
|
||||
|
||||
static function get_barcode_tokens()
|
||||
{
|
||||
return array(new Token_barcode_price(), new Token_barcode_weight(), new Token_barcode_ean());
|
||||
return array();
|
||||
}
|
||||
|
||||
static function get_tokens()
|
||||
|
||||
Reference in New Issue
Block a user