mirror of
https://github.com/opensourcepos/opensourcepos.git
synced 2026-05-24 16:28:40 -04:00
#111 Change barcode types from numbers to strings for better code readability
This commit is contained in:
@@ -11,20 +11,17 @@ class Item_kits extends Secure_area implements iData_controller
|
||||
// add the total cost and retail price to a passed items kit retrieving the data from each singolar item part of the kit
|
||||
private function add_totals_to_item_kit($item_kit)
|
||||
{
|
||||
$total_cost_price = 0;
|
||||
$total_unit_price = 0;
|
||||
$item_kit->total_cost_price = 0;
|
||||
$item_kit->total_unit_price = 0;
|
||||
|
||||
foreach ($this->Item_kit_items->get_info($item_kit->item_kit_id) as $item_kit_item)
|
||||
{
|
||||
$item_info = $this->Item->get_info($item_kit_item['item_id']);
|
||||
|
||||
$total_cost_price += $item_info->cost_price;
|
||||
$total_unit_price += $item_info->unit_price;
|
||||
$item_kit->total_cost_price += $item_info->cost_price;
|
||||
$item_kit->total_unit_price += $item_info->unit_price;
|
||||
}
|
||||
|
||||
$item_kit->total_cost_price = $total_cost_price;
|
||||
$item_kit->total_unit_price = $total_unit_price;
|
||||
|
||||
return $item_kit;
|
||||
}
|
||||
|
||||
@@ -177,9 +174,9 @@ class Item_kits extends Secure_area implements iData_controller
|
||||
$barcode_config = $this->barcode_lib->get_barcode_config();
|
||||
// in case the selected barcode type is not Code39 or Code128 we set by default Code128
|
||||
// the rationale for this is that EAN codes cannot have strings as seed, so 'KIT ' is not allowed
|
||||
if($barcode_config['barcode_type'] != '1' && $barcode_config['barcode_type'] != '2')
|
||||
if($barcode_config['barcode_type'] != 'Code39' && $barcode_config['barcode_type'] != 'Code128')
|
||||
{
|
||||
$barcode_config['barcode_type'] = '2';
|
||||
$barcode_config['barcode_type'] = 'Code128';
|
||||
}
|
||||
$data['barcode_config'] = $barcode_config;
|
||||
$this->load->view("barcode_sheet", $data);
|
||||
|
||||
@@ -10,7 +10,7 @@ require APPPATH.'/views/barcodes/Ean8.php';
|
||||
class Barcode_lib
|
||||
{
|
||||
private $CI = null;
|
||||
private $supported_barcodes = array(1 => 'Code 39', 2 => 'Code 128', 3 => 'EAN 8', 4 => 'EAN 13');
|
||||
private $supported_barcodes = array('Code39' => 'Code 39', 'Code128' => 'Code 128', 'Ean8' => 'EAN 8', 'Ean13' => 'EAN 13');
|
||||
|
||||
function __construct()
|
||||
{
|
||||
@@ -42,24 +42,24 @@ class Barcode_lib
|
||||
return $data;
|
||||
}
|
||||
|
||||
private function get_barcode_instance($barcode_type)
|
||||
private function get_barcode_instance($barcode_type='Code128')
|
||||
{
|
||||
switch($barcode_type)
|
||||
{
|
||||
case '1':
|
||||
case 'Code39':
|
||||
return new emberlabs\Barcode\Code39();
|
||||
break;
|
||||
|
||||
case '2':
|
||||
case 'Code128':
|
||||
default:
|
||||
return new emberlabs\Barcode\Code128();
|
||||
break;
|
||||
|
||||
case '3':
|
||||
case 'Ean8':
|
||||
return new emberlabs\Barcode\Ean8();
|
||||
break;
|
||||
|
||||
case '4':
|
||||
case 'Ean13':
|
||||
return new emberlabs\Barcode\Ean13();
|
||||
break;
|
||||
}
|
||||
@@ -82,7 +82,7 @@ class Barcode_lib
|
||||
}
|
||||
catch(Exception $e)
|
||||
{
|
||||
echo 'Caught exception: ', $e->getMessage(), "\n";
|
||||
echo 'Caught exception: ', $e->getMessage(), "\n";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -90,8 +90,8 @@ class Barcode_lib
|
||||
{
|
||||
try
|
||||
{
|
||||
// Code128 is used for the receipts
|
||||
$barcode = $this->get_barcode_instance(2);
|
||||
// Code128 is the default and used in this case for the receipts
|
||||
$barcode = $this->get_barcode_instance();
|
||||
|
||||
// set the receipt number to generate the barcode for
|
||||
$barcode->setData($barcode_content);
|
||||
@@ -109,7 +109,7 @@ class Barcode_lib
|
||||
}
|
||||
catch(Exception $e)
|
||||
{
|
||||
echo 'Caught exception: ', $e->getMessage(), "\n";
|
||||
echo 'Caught exception: ', $e->getMessage(), "\n";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -134,7 +134,7 @@ class Barcode_lib
|
||||
}
|
||||
catch(Exception $e)
|
||||
{
|
||||
echo 'Caught exception: ', $e->getMessage(), "\n";
|
||||
echo 'Caught exception: ', $e->getMessage(), "\n";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ class Item_kit extends CI_Model
|
||||
/*
|
||||
Returns all the item kits
|
||||
*/
|
||||
function get_all($rows = 0, $limit_from = 0)
|
||||
function get_all($rows=0, $limit_from=0)
|
||||
{
|
||||
$this->db->from('item_kits');
|
||||
$this->db->order_by('name', 'asc');
|
||||
@@ -156,7 +156,7 @@ class Item_kit extends CI_Model
|
||||
foreach($by_name->result() as $row)
|
||||
{
|
||||
// do not touch the '|' otherwise the sale search will not fetch the kit
|
||||
$suggestions[]='KIT ' . $row->item_kit_id . '|' . $row->name;
|
||||
$suggestions[] = 'KIT ' . $row->item_kit_id . '|' . $row->name;
|
||||
}
|
||||
|
||||
//only return $limit suggestions
|
||||
@@ -169,7 +169,7 @@ class Item_kit extends CI_Model
|
||||
}
|
||||
|
||||
/*
|
||||
Preform a search on items
|
||||
Perform a search on items
|
||||
*/
|
||||
function search($search, $rows=0, $limit_from=0)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user