diff --git a/application/config/config.php b/application/config/config.php index 4a0ff468a..8b86a1a9e 100644 --- a/application/config/config.php +++ b/application/config/config.php @@ -264,8 +264,8 @@ $config['sess_encrypt_cookie'] = FALSE; $config['sess_use_database'] = TRUE; $config['sess_table_name'] = 'sessions'; $config['sess_match_ip'] = FALSE; -$config['sess_match_useragent'] = FAlSE; -$config['sess_time_to_update'] = 0; +$config['sess_match_useragent'] = FALSE; +$config['sess_time_to_update'] = 120; /* |-------------------------------------------------------------------------- diff --git a/application/controllers/barcode.php b/application/controllers/barcode.php index 0d3d3b7b8..8d85ab974 100644 --- a/application/controllers/barcode.php +++ b/application/controllers/barcode.php @@ -1,5 +1,6 @@ load->library('barcode_lib'); } function index() { $location_names = array(); - $stock_locations = $this->Stock_locations->get_all()->result_array(); - $this->load->view("config", array('stock_locations' => $stock_locations)); + $data['stock_locations'] = $this->Stock_locations->get_all()->result_array(); + $data['support_barcode'] = $this->barcode_lib->get_list_barcodes(); + $this->load->view("configs/manage", $data); } function save() @@ -99,5 +101,31 @@ class Config extends Secure_area $this->receiving_lib->clear_stock_destination(); $this->receiving_lib->clear_all(); } + + function save_barcode() + { + $batch_save_data=array( + 'barcode_type'=>$this->input->post('barcode_type'), + 'barcode_dpi'=>$this->input->post('barcode_dpi'), + 'barcode_thickness'=>$this->input->post('barcode_thickness'), + 'barcode_scale'=>$this->input->post('barcode_scale'), + 'barcode_rotation'=>$this->input->post('barcode_rotation'), + 'barcode_font'=>$this->input->post('barcode_font'), + 'barcode_font_size'=>$this->input->post('barcode_font_size'), + 'barcode_checksum'=>$this->input->post('barcode_checksum'), + 'barcode_first_row'=>$this->input->post('barcode_first_row'), + 'barcode_second_row'=>$this->input->post('barcode_second_row'), + 'barcode_third_row'=>$this->input->post('barcode_third_row'), + 'barcode_num_in_row'=>$this->input->post('barcode_num_in_row'), + 'barcode_page_width'=>$this->input->post('barcode_page_width'), + 'barcode_page_cellspacing'=>$this->input->post('barcode_page_cellspacing') + ); + + if( $this->Appconfig->batch_save( $batch_save_data ) ) + { + echo json_encode(array('success'=>true,'message'=>$this->lang->line('config_saved_successfully'))); + } + + } } ?> \ No newline at end of file diff --git a/application/controllers/item_kits.php b/application/controllers/item_kits.php index 5d4986e99..86249bf80 100644 --- a/application/controllers/item_kits.php +++ b/application/controllers/item_kits.php @@ -123,6 +123,9 @@ class Item_kits extends Secure_area implements iData_controller } $data['items'] = $result; + $this->load->library('barcode_lib'); + $data['configs'] = $this->Appconfig->get_all(); + $data['barcode_config'] = $this->Barcode_lib->get_barcode_config(); $this->load->view("barcode_sheet", $data); } diff --git a/application/controllers/items.php b/application/controllers/items.php index 0aec46ebc..3c3b2345a 100644 --- a/application/controllers/items.php +++ b/application/controllers/items.php @@ -268,17 +268,14 @@ class Items extends Secure_area implements iData_controller function generate_barcodes($item_ids) { + $this->load->library('barcode_lib'); $result = array(); $item_ids = explode(':', $item_ids); - foreach ($item_ids as $item_id) - { - $item_info = $this->Item->get_info($item_id); - - $result[] = array('name' =>$item_info->name, 'id'=> $item_id, 'item_number'=> $item_info->item_number, 'unit_price'=>$item_info->unit_price); - } + $result = $this->Item->get_multiple_info($item_ids)->result_array(); $data['items'] = $result; + $data['barcode_config'] = $this->barcode_lib->get_barcode_config(); $this->load->view("barcode_sheet", $data); } diff --git a/application/controllers/sales.php b/application/controllers/sales.php index 897eede34..1e16f0849 100644 --- a/application/controllers/sales.php +++ b/application/controllers/sales.php @@ -5,7 +5,7 @@ class Sales extends Secure_area function __construct() { parent::__construct('sales'); - $this->load->library('sale_lib'); + $this->load->library('sale_lib'); } function index() diff --git a/application/language/en/config_lang.php b/application/language/en/config_lang.php index 8549e3b8d..6396ea6c8 100644 --- a/application/language/en/config_lang.php +++ b/application/language/en/config_lang.php @@ -2,6 +2,28 @@ $lang["config_address"] = "Company Address"; $lang["config_address_required"] = "Company address is a required field"; +$lang["config_barcode_checksum"] = "Checksum"; +$lang["config_barcode_company"] = "Company Name"; +$lang["config_barcode_content"] = "Barcode Content"; +$lang["config_barcode_dpi"] = "DPI"; +$lang["config_barcode_first_row"] = "Row 1"; +$lang["config_barcode_font"] = "Font"; +$lang["config_barcode_id"] = "Item Id/Name"; +$lang["config_barcode_info"] = "Barcode Configuration Information"; +$lang["config_barcode_labels"] = "Barcode Labels"; +$lang["config_barcode_layout"] = "Barcode layout"; +$lang["config_barcode_name"] = "Name"; +$lang["config_barcode_number"] = "UPC/EAN/ISBN"; +$lang["config_barcode_number_in_row"] = "Number in row"; +$lang["config_barcode_page_cellspacing"] = "Display page cellspacing"; +$lang["config_barcode_page_width"] = "Display page width"; +$lang["config_barcode_price"] = "Price"; +$lang["config_barcode_rotation"] = "Rotation"; +$lang["config_barcode_scale"] = "Scale"; +$lang["config_barcode_second_row"] = "Row 2"; +$lang["config_barcode_thickness"] = "Thickness"; +$lang["config_barcode_third_row"] = "Row 3"; +$lang["config_barcode_type"] = "Barcode Type"; $lang["config_company"] = "Company Name"; $lang["config_company_required"] = "Company name is a required field"; $lang["config_company_website_url"] = "Company website is not a valid URL (http://...)"; @@ -17,12 +39,27 @@ $lang["config_custom6"] = "Custom Field 6"; $lang["config_custom7"] = "Custom Field 7"; $lang["config_custom8"] = "Custom Field 8"; $lang["config_custom9"] = "Custom Field 9"; +$lang["config_default_barcode_dpi_number"] = "The default barcode dpi must be a number"; +$lang["config_default_barcode_dpi_required"] = "The default barcode dpi is a required field"; +$lang["config_default_barcode_font_size_number"] = "The default barcode font size must be a number"; +$lang["config_default_barcode_font_size_required"] = "The default barcode font size is a required field"; +$lang["config_default_barcode_num_in_row_number"] = "The default barcode num in row must be a number"; +$lang["config_default_barcode_num_in_row_required"] = "The default barcode num in row is a required field"; +$lang["config_default_barcode_page_cellspacing_number"] = "The default barcode page cellspacing must be a number"; +$lang["config_default_barcode_page_cellspacing_required"] = "The default barcode page cellspacing is a required field"; +$lang["config_default_barcode_page_width_number"] = "The default barcode page width must be a number"; +$lang["config_default_barcode_page_width_required"] = "The default barcode page width is a required field"; +$lang["config_default_barcode_scale_number"] = "The default barcode scale must be a number"; +$lang["config_default_barcode_scale_required"] = "The default barcode scale is a required field"; +$lang["config_default_barcode_thickness_number"] = "The default barcode thickness must be a number"; +$lang["config_default_barcode_thickness_required"] = "The default barcode thickness is a required field"; $lang["config_default_tax_rate"] = "Default Tax Rate %"; $lang["config_default_tax_rate_1"] = "Tax 1 Rate"; $lang["config_default_tax_rate_2"] = "Tax 2 Rate"; $lang["config_default_tax_rate_number"] = "The default tax rate must be a number"; $lang["config_default_tax_rate_required"] = "The default tax rate is a required field"; $lang["config_fax"] = "Fax"; +$lang["config_general_config"] = "General Configuration"; $lang["config_info"] = "Store Configuration Information"; $lang["config_language"] = "Language"; $lang["config_phone"] = "Company Phone"; @@ -41,6 +78,7 @@ $lang["config_stock_location_required"] = "Stock location number is a required f $lang["config_tax_included"] = "Tax Included"; $lang["config_timezone"] = "Timezone"; $lang["config_website"] = "Website"; +$lang["config_barcode_configuration"] = "Barcode Configuration"; $lang["config_barcode_number"] = "UPC/EAN/ISBN"; $lang["config_barcode_id"] = "Item Id/Name"; $lang["config_barcode_content"] = "Barcode Content"; diff --git a/application/language/es/config_lang.php b/application/language/es/config_lang.php index 11d27728a..47bf23ccd 100644 --- a/application/language/es/config_lang.php +++ b/application/language/es/config_lang.php @@ -2,6 +2,28 @@ $lang["config_address"] = "Dirección del Comercio"; $lang["config_address_required"] = "Dirección del Comercio es requerida"; +$lang["config_barcode_checksum"] = ""; +$lang["config_barcode_company"] = "Nombre del Comercio"; +$lang["config_barcode_content"] = "Barcode Content"; +$lang["config_barcode_dpi"] = ""; +$lang["config_barcode_first_row"] = ""; +$lang["config_barcode_font"] = ""; +$lang["config_barcode_id"] = "Item Id/Name"; +$lang["config_barcode_info"] = ""; +$lang["config_barcode_labels"] = "Barcode Labels"; +$lang["config_barcode_layout"] = ""; +$lang["config_barcode_name"] = "Name"; +$lang["config_barcode_number"] = "UPC/EAN/ISBN"; +$lang["config_barcode_number_in_row"] = ""; +$lang["config_barcode_page_cellspacing"] = ""; +$lang["config_barcode_page_width"] = ""; +$lang["config_barcode_price"] = "Price"; +$lang["config_barcode_rotation"] = ""; +$lang["config_barcode_scale"] = ""; +$lang["config_barcode_second_row"] = ""; +$lang["config_barcode_thickness"] = ""; +$lang["config_barcode_third_row"] = ""; +$lang["config_barcode_type"] = ""; $lang["config_company"] = "Nombre del Comercio"; $lang["config_company_required"] = "Nombre del Comercio es requerido"; $lang["config_company_website_url"] = "Sitio Web no es una URL estándard (http://...)"; @@ -17,12 +39,27 @@ $lang["config_custom6"] = "Campo Libre 6"; $lang["config_custom7"] = "Campo Libre 7"; $lang["config_custom8"] = "Campo Libre 8"; $lang["config_custom9"] = "Campo Libre 9"; +$lang["config_default_barcode_dpi_number"] = ""; +$lang["config_default_barcode_dpi_required"] = ""; +$lang["config_default_barcode_font_size_number"] = ""; +$lang["config_default_barcode_font_size_required"] = ""; +$lang["config_default_barcode_num_in_row_number"] = ""; +$lang["config_default_barcode_num_in_row_required"] = ""; +$lang["config_default_barcode_page_cellspacing_number"] = ""; +$lang["config_default_barcode_page_cellspacing_required"] = ""; +$lang["config_default_barcode_page_width_number"] = ""; +$lang["config_default_barcode_page_width_required"] = ""; +$lang["config_default_barcode_scale_number"] = ""; +$lang["config_default_barcode_scale_required"] = ""; +$lang["config_default_barcode_thickness_number"] = ""; +$lang["config_default_barcode_thickness_required"] = ""; $lang["config_default_tax_rate"] = "% de Impuestos Predeterminada"; $lang["config_default_tax_rate_1"] = "Impuesto 1"; $lang["config_default_tax_rate_2"] = "Impuesto 2"; $lang["config_default_tax_rate_number"] = "El Impuesto Predeterminado debe ser un número"; $lang["config_default_tax_rate_required"] = "El Impuesto Predeterminado es requerido"; $lang["config_fax"] = "Fax"; +$lang["config_general_config"] = ""; $lang["config_info"] = "Información del Comercio"; $lang["config_language"] = "Idioma"; $lang["config_phone"] = "Teléfono del Comercio"; @@ -41,6 +78,7 @@ $lang["config_stock_location_required"] = ""; $lang["config_tax_included"] = "Impuestos incluidos"; $lang["config_timezone"] = "Zona Horaria"; $lang["config_website"] = "Sitio Web"; +$lang["config_barcode_configuration"] = ""; $lang["config_barcode_number"] = "UPC/EAN/ISBN"; $lang["config_barcode_id"] = "Item Id/Name"; $lang["config_barcode_content"] = "Barcode Content"; diff --git a/application/language/fr/config_lang.php b/application/language/fr/config_lang.php index 0e8999538..90092cf11 100644 --- a/application/language/fr/config_lang.php +++ b/application/language/fr/config_lang.php @@ -2,6 +2,28 @@ $lang["config_address"] = "Addresse"; $lang["config_address_required"] = "L\'adresse est requise"; +$lang["config_barcode_checksum"] = ""; +$lang["config_barcode_company"] = "Nome de l\'Entreprise"; +$lang["config_barcode_content"] = "Barcode Content"; +$lang["config_barcode_dpi"] = ""; +$lang["config_barcode_first_row"] = ""; +$lang["config_barcode_font"] = ""; +$lang["config_barcode_id"] = "Item Id/Name"; +$lang["config_barcode_info"] = ""; +$lang["config_barcode_labels"] = "Barcode Labels"; +$lang["config_barcode_layout"] = ""; +$lang["config_barcode_name"] = "Name"; +$lang["config_barcode_number"] = "UPC/EAN/ISBN"; +$lang["config_barcode_number_in_row"] = ""; +$lang["config_barcode_page_cellspacing"] = ""; +$lang["config_barcode_page_width"] = ""; +$lang["config_barcode_price"] = "Price"; +$lang["config_barcode_rotation"] = ""; +$lang["config_barcode_scale"] = ""; +$lang["config_barcode_second_row"] = ""; +$lang["config_barcode_thickness"] = ""; +$lang["config_barcode_third_row"] = ""; +$lang["config_barcode_type"] = ""; $lang["config_company"] = "Nome de l\'Entreprise"; $lang["config_company_required"] = "Le nom d\'entreprise est requis"; $lang["config_company_website_url"] = "Le site web de l\'entreprise n\'est pas une URL valide (http://...)"; @@ -17,12 +39,27 @@ $lang["config_custom6"] = "Champ Personnalisé 6"; $lang["config_custom7"] = "Champ Personnalisé 7"; $lang["config_custom8"] = "Champ Personnalisé 8"; $lang["config_custom9"] = "Champ Personnalisé 9"; +$lang["config_default_barcode_dpi_number"] = ""; +$lang["config_default_barcode_dpi_required"] = ""; +$lang["config_default_barcode_font_size_number"] = ""; +$lang["config_default_barcode_font_size_required"] = ""; +$lang["config_default_barcode_num_in_row_number"] = ""; +$lang["config_default_barcode_num_in_row_required"] = ""; +$lang["config_default_barcode_page_cellspacing_number"] = ""; +$lang["config_default_barcode_page_cellspacing_required"] = ""; +$lang["config_default_barcode_page_width_number"] = ""; +$lang["config_default_barcode_page_width_required"] = ""; +$lang["config_default_barcode_scale_number"] = ""; +$lang["config_default_barcode_scale_required"] = ""; +$lang["config_default_barcode_thickness_number"] = ""; +$lang["config_default_barcode_thickness_required"] = ""; $lang["config_default_tax_rate"] = "Taux d\'Imposition par Défaut"; $lang["config_default_tax_rate_1"] = "Taux d\'Imposition 1"; $lang["config_default_tax_rate_2"] = "Taux d\'Imposition 2"; $lang["config_default_tax_rate_number"] = "Le taux d\'imposition doit etre un nombre"; $lang["config_default_tax_rate_required"] = "Le taux d\'imposition par défaut est requis"; $lang["config_fax"] = "Fax"; +$lang["config_general_config"] = ""; $lang["config_info"] = "Çonfiguration de l\'Entreprise"; $lang["config_language"] = "Langue"; $lang["config_phone"] = "Téléphone"; @@ -41,6 +78,7 @@ $lang["config_stock_location_required"] = ""; $lang["config_tax_included"] = ""; $lang["config_timezone"] = "Fuseau Horaire"; $lang["config_website"] = "Site-web"; +$lang["config_barcode_configuration"] = ""; $lang["config_barcode_number"] = "UPC/EAN/ISBN"; $lang["config_barcode_id"] = "Item Id/Name"; $lang["config_barcode_content"] = "Barcode Content"; diff --git a/application/language/id/config_lang.php b/application/language/id/config_lang.php index d05225725..e63736b09 100644 --- a/application/language/id/config_lang.php +++ b/application/language/id/config_lang.php @@ -2,6 +2,28 @@ $lang["config_address"] = "Alamat Perusahaan"; $lang["config_address_required"] = "Alamat Perusahaan wajib diisi"; +$lang["config_barcode_checksum"] = ""; +$lang["config_barcode_company"] = "Nama Perusahaan"; +$lang["config_barcode_content"] = "Barcode Content"; +$lang["config_barcode_dpi"] = ""; +$lang["config_barcode_first_row"] = ""; +$lang["config_barcode_font"] = ""; +$lang["config_barcode_id"] = "Item Id/Name"; +$lang["config_barcode_info"] = ""; +$lang["config_barcode_labels"] = "Barcode Labels"; +$lang["config_barcode_layout"] = ""; +$lang["config_barcode_name"] = "Name"; +$lang["config_barcode_number"] = "UPC/EAN/ISBN"; +$lang["config_barcode_number_in_row"] = ""; +$lang["config_barcode_page_cellspacing"] = ""; +$lang["config_barcode_page_width"] = ""; +$lang["config_barcode_price"] = "Price"; +$lang["config_barcode_rotation"] = ""; +$lang["config_barcode_scale"] = ""; +$lang["config_barcode_second_row"] = ""; +$lang["config_barcode_thickness"] = ""; +$lang["config_barcode_third_row"] = ""; +$lang["config_barcode_type"] = ""; $lang["config_company"] = "Nama Perusahaan"; $lang["config_company_required"] = "Nama Perusahaan wajib diisi"; $lang["config_company_website_url"] = "Situs Perusahaan bukan URL yang benar(http://...)"; @@ -17,12 +39,27 @@ $lang["config_custom6"] = "Custom Field 6"; $lang["config_custom7"] = "Custom Field 7"; $lang["config_custom8"] = "Custom Field 8"; $lang["config_custom9"] = "Custom Field 9"; +$lang["config_default_barcode_dpi_number"] = ""; +$lang["config_default_barcode_dpi_required"] = ""; +$lang["config_default_barcode_font_size_number"] = ""; +$lang["config_default_barcode_font_size_required"] = ""; +$lang["config_default_barcode_num_in_row_number"] = ""; +$lang["config_default_barcode_num_in_row_required"] = ""; +$lang["config_default_barcode_page_cellspacing_number"] = ""; +$lang["config_default_barcode_page_cellspacing_required"] = ""; +$lang["config_default_barcode_page_width_number"] = ""; +$lang["config_default_barcode_page_width_required"] = ""; +$lang["config_default_barcode_scale_number"] = ""; +$lang["config_default_barcode_scale_required"] = ""; +$lang["config_default_barcode_thickness_number"] = ""; +$lang["config_default_barcode_thickness_required"] = ""; $lang["config_default_tax_rate"] = "Tarif Pajak Biasa%"; $lang["config_default_tax_rate_1"] = "Tarif Pajak 1"; $lang["config_default_tax_rate_2"] = "Tarif Pajak 2"; $lang["config_default_tax_rate_number"] = "Tarif Pajak Biasa harus angka"; $lang["config_default_tax_rate_required"] = "Tarif Pajak Biasa wajib diisi"; $lang["config_fax"] = "Fax"; +$lang["config_general_config"] = ""; $lang["config_info"] = "Informasi Konfigurasi Toko"; $lang["config_language"] = "Bahasa"; $lang["config_phone"] = "Telepon Perusahaan"; @@ -41,6 +78,7 @@ $lang["config_stock_location_required"] = ""; $lang["config_tax_included"] = "Dikenakan Pajak"; $lang["config_timezone"] = "Zona Waktu"; $lang["config_website"] = "Situs Perusahaan"; +$lang["config_barcode_configuration"] = ""; $lang["config_barcode_number"] = "UPC/EAN/ISBN"; $lang["config_barcode_id"] = "Item Id/Name"; $lang["config_barcode_content"] = "Barcode Content"; diff --git a/application/language/nl-BE/config_lang.php b/application/language/nl-BE/config_lang.php index ae8bd7f6a..2d686feba 100755 --- a/application/language/nl-BE/config_lang.php +++ b/application/language/nl-BE/config_lang.php @@ -2,6 +2,28 @@ $lang["config_address"] = "Adres"; $lang["config_address_required"] = "Het adres van het bedrijf moet ingevuld worden"; +$lang["config_barcode_checksum"] = ""; +$lang["config_barcode_company"] = "Bedrijfsnaam"; +$lang["config_barcode_content"] = "Inhoud Barcode"; +$lang["config_barcode_dpi"] = ""; +$lang["config_barcode_first_row"] = ""; +$lang["config_barcode_font"] = ""; +$lang["config_barcode_id"] = "Product id/naam"; +$lang["config_barcode_info"] = ""; +$lang["config_barcode_labels"] = "Barcode Labels"; +$lang["config_barcode_layout"] = ""; +$lang["config_barcode_name"] = "Productnaam"; +$lang["config_barcode_number"] = "UPC/EAN/ISBN"; +$lang["config_barcode_number_in_row"] = ""; +$lang["config_barcode_page_cellspacing"] = ""; +$lang["config_barcode_page_width"] = ""; +$lang["config_barcode_price"] = "Prijs"; +$lang["config_barcode_rotation"] = ""; +$lang["config_barcode_scale"] = ""; +$lang["config_barcode_second_row"] = ""; +$lang["config_barcode_thickness"] = ""; +$lang["config_barcode_third_row"] = ""; +$lang["config_barcode_type"] = ""; $lang["config_company"] = "Bedrijfsnaam"; $lang["config_company_required"] = "De bedrijfsnaam moet ingevuld worden"; $lang["config_company_website_url"] = "De website van het bedrijf is geen geldige URL (http://...)"; @@ -17,12 +39,27 @@ $lang["config_custom6"] = "Custom Veld 6"; $lang["config_custom7"] = "Custom Veld 7"; $lang["config_custom8"] = "Custom Veld 8"; $lang["config_custom9"] = "Custom Veld 9"; +$lang["config_default_barcode_dpi_number"] = ""; +$lang["config_default_barcode_dpi_required"] = ""; +$lang["config_default_barcode_font_size_number"] = ""; +$lang["config_default_barcode_font_size_required"] = ""; +$lang["config_default_barcode_num_in_row_number"] = ""; +$lang["config_default_barcode_num_in_row_required"] = ""; +$lang["config_default_barcode_page_cellspacing_number"] = ""; +$lang["config_default_barcode_page_cellspacing_required"] = ""; +$lang["config_default_barcode_page_width_number"] = ""; +$lang["config_default_barcode_page_width_required"] = ""; +$lang["config_default_barcode_scale_number"] = ""; +$lang["config_default_barcode_scale_required"] = ""; +$lang["config_default_barcode_thickness_number"] = ""; +$lang["config_default_barcode_thickness_required"] = ""; $lang["config_default_tax_rate"] = "Standaard VAT %"; $lang["config_default_tax_rate_1"] = "VAT 1 %"; $lang["config_default_tax_rate_2"] = "VAT 2 %"; $lang["config_default_tax_rate_number"] = "Het percentage VAT moet een nummer zijn"; $lang["config_default_tax_rate_required"] = "Het percentage VAT moet ingevuld worden"; $lang["config_fax"] = "Fax"; +$lang["config_general_config"] = ""; $lang["config_info"] = "Configuratie Informatie"; $lang["config_language"] = "Taal"; $lang["config_phone"] = "Telefoon"; @@ -41,6 +78,7 @@ $lang["config_stock_location_required"] = "Naam van de stock locatie is een verp $lang["config_tax_included"] = "VAT Ingebgrepen"; $lang["config_timezone"] = "Tijdzone"; $lang["config_website"] = "Website"; +$lang["config_barcode_configuration"] = "Barcode Configuratie"; $lang["config_barcode_number"] = "UPC/EAN/ISBN"; $lang["config_barcode_id"] = "Product id/naam"; $lang["config_barcode_content"] = "Inhoud Barcode"; diff --git a/application/language/nl-BE/form_validation_lang.php b/application/language/nl-BE/form_validation_lang.php index 2b41ae549..e66250b4a 100644 --- a/application/language/nl-BE/form_validation_lang.php +++ b/application/language/nl-BE/form_validation_lang.php @@ -1,18 +1,18 @@ 'Codabar', + 'BCGcode11' => 'Code 11', + 'BCGcode39' => 'Code 39', + 'BCGcode39extended' => 'Code 39 Extended', + 'BCGcode93' => 'Code 93', + 'BCGcode128' => 'Code 128', + 'BCGean8' => 'EAN-8', + 'BCGean13' => 'EAN-13', + 'BCGgs1128' => 'GS1-128 (EAN-128)', + 'BCGisbn' => 'ISBN', + 'BCGi25' => 'Interleaved 2 of 5', + 'BCGs25' => 'Standard 2 of 5', + 'BCGmsi' => 'MSI Plessey', + 'BCGupca' => 'UPC-A', + 'BCGupce' => 'UPC-E', + 'BCGupcext2' => 'UPC Extenstion 2 Digits', + 'BCGupcext5' => 'UPC Extenstion 5 Digits', + 'BCGpostnet' => 'Postnet', + 'BCGintelligentmail' => 'Intelligent Mail', + 'BCGothercode' => 'Other Barcode'); + + function __construct() + { + $this->CI =& get_instance(); + } + + function get_list_barcodes() + { + return $this->supported_barcodes; + } + + function get_barcode_config() + { + $data['barcode_dpi'] = $this->CI->Appconfig->get('barcode_dpi'); + $data['barcode_scale'] = $this->CI->Appconfig->get('barcode_scale'); + $data['barcode_rotation'] = $this->CI->Appconfig->get('barcode_rotation'); + $data['barcode_font'] = $this->CI->Appconfig->get('barcode_font'); + $data['barcode_font_size'] = $this->CI->Appconfig->get('barcode_font_size'); + $data['barcode_thickness'] = $this->CI->Appconfig->get('barcode_thickness'); + $data['barcode_checksum'] = $this->CI->Appconfig->get('barcode_checksum'); + $data['barcode_first_row'] = $this->CI->Appconfig->get('barcode_first_row'); + $data['barcode_second_row'] = $this->CI->Appconfig->get('barcode_second_row'); + $data['barcode_third_row'] = $this->CI->Appconfig->get('barcode_third_row'); + $data['barcode_num_in_row'] = $this->CI->Appconfig->get('barcode_num_in_row'); + $data['barcode_page_width'] = $this->CI->Appconfig->get('barcode_page_width'); + $data['barcode_page_cellspacing'] = $this->CI->Appconfig->get('barcode_page_cellspacing'); + return $data; + } + + function create_display_barcode($item, $barcode_config) + { + $display_table = ""; + $display_table .= ""; + $display_table .= ""; + $display_table .= ""; + $display_table .= "
". $this->manage_display_layout($barcode_config['barcode_first_row'], $item, $barcode_config)."
". $this->manage_display_layout($barcode_config['barcode_second_row'], $item, $barcode_config)."
". $this->manage_display_layout($barcode_config['barcode_third_row'], $item, $barcode_config)."
"; + return $display_table; + } + + private function manage_display_layout($layout_type, $item, $barcode_config) + { + $result; + if($layout_type == 'item_code') + { + $result = ""; + } + else if($layout_type == 'name'){ + $result = $this->CI->lang->line('items_name') . " " . $item['name']; + } + else if($layout_type == 'category'){ + $result = $this->CI->lang->line('items_category') . " " . $item['category']; + } + else if($layout_type == 'cost_price'){ + $result = $this->CI->lang->line('items_cost_price') . " " . to_currency($item['cost_price']); + } + else if($layout_type == 'unit_price'){ + $result = $this->CI->lang->line('items_unit_price') . " " . to_currency($item['unit_price']); + } + return $result; + } + + function get_font_name($font_file_name) + { + return substr($font_file_name, 0, -4); + } +} +?> \ No newline at end of file diff --git a/application/libraries/barcodegen/README_1D.txt b/application/libraries/barcodegen/README_1D.txt new file mode 100644 index 000000000..78e653e74 --- /dev/null +++ b/application/libraries/barcodegen/README_1D.txt @@ -0,0 +1,48 @@ +This script is free for personal use. The program is provide "AS IS" +without warranty of any kind. If you want to use it as +commercial use, you have to purchase it on +http://www.barcodephp.com +You must let the copyright intact. + +Ce script est gratuit pour usage personnel. Le programme est +fourni "TEL QUEL" sans aucune garantie que ce soit. +Si vous voulez l'utiliser pour un usage commercial, +vous devez l'acheter sur +http://www.barcodephp.com +Vous devez laisser les droits d'auteur intacts. +This script is free for personal use. The program is provide "AS IS" +without warranty of any kind. If you want to use it as +commercial use, you have to purchase it on +http://www.barcodephp.com +You must let the copyright intact. + +Ce script est gratuit pour usage personnel. Le programme est +fourni "TEL QUEL" sans aucune garantie que ce soit. +Si vous voulez l'utiliser pour un usage commercial, +vous devez l'acheter sur +http://www.barcodephp.com +Vous devez laisser les droits d'auteur intacts. +This script is free for personal use. The program is provide "AS IS" +without warranty of any kind. If you want to use it as +commercial use, you have to purchase it on +http://www.barcodephp.com +You must let the copyright intact. + +Ce script est gratuit pour usage personnel. Le programme est +fourni "TEL QUEL" sans aucune garantie que ce soit. +Si vous voulez l'utiliser pour un usage commercial, +vous devez l'acheter sur +http://www.barcodephp.com +Vous devez laisser les droits d'auteur intacts. +This script is free for personal use. The program is provide "AS IS" +without warranty of any kind. If you want to use it as +commercial use, you have to purchase it on +http://www.barcodephp.com +You must let the copyright intact. + +Ce script est gratuit pour usage personnel. Le programme est +fourni "TEL QUEL" sans aucune garantie que ce soit. +Si vous voulez l'utiliser pour un usage commercial, +vous devez l'acheter sur +http://www.barcodephp.com +Vous devez laisser les droits d'auteur intacts. \ No newline at end of file diff --git a/application/libraries/barcodegen/VERSION_1D b/application/libraries/barcodegen/VERSION_1D new file mode 100644 index 000000000..4f6b77e0b --- /dev/null +++ b/application/libraries/barcodegen/VERSION_1D @@ -0,0 +1,412 @@ +v5.2.0 26 may 2014 Fix potential break in PNG writter. + Fix BCGColor. Deprecated usage of string character reference. + Rotation of text or barcode is now CLOCKWISE. + Fix Code11. Incorrect size when using a scale bigger than 1. + Fix Code128. Potential incorrect table lookup. + Fix IntelligentMail user interface not accepting correct serial number. + Improve speed by setting some methods static. + Fix OtherCode. It now checks for incorrect input. + Use ISO-8859-1 when generating a barcode with the user interface. + Usage of quotes and double quotes was not working properly with the user interface. +v5.1.0 4 oct 2012 Files moved to support 1D and 2D barcodes together + Whiskers has been removed from writing a small line in scale 1 (bug in PHP) + Add alignDefaultLabel for EAN-13 and UPC-A + Versioning is now per file + BoxFix can now be overriden + Fix some references +v5.0.1 18 apr 2012 Fix Navigation support +v5.0.0 18 apr 2012 HTML5 support. Fix some exception file inclusion bugs. + Using space instead of tabs! Added support to change the boxfix. + Added support to Intelligent Mail. Better support for Postnet. Following standard for printing. + Added getters in GS1-128. +v4.1.0 3 aug 2011 Support for transparent background +v4.0.0 15 apr 2011 Brand new version which includes some breaking changes. + Now supports the possibility to add labels around the barcode really easily thanks to the method addLabel() + You can also specify the alignment of the label, rotation, etc. + If the label is bigger than the barcode itself, the image will get bigger to avoid text clipping. + Add the setRatio method for I25 barcodes + Fix EAN-13 and ISBN +v3.0.2 4 apr 2011 Fixing the test.php +v3.0.1 26 mar 2011 Minor fixes for IE9 +v3.0.0 21 mar 2011 Better support for failure instead of writing the error on the UI, an exception is being thrown. +v2.2.0 13 feb 2010 Added the support for GS1-128 (EAN-128). + Fix ISBN text support to be the right font. + Make sure the /html files are formatted. +v2.1.0 8 nov 2009 Added a way to change the DPI before saving (BCGDrawing::setDPI()). Set the value to null if you want to improve the performance and still have 72dpi. + But you can set it to 300 if you wish to print it. + You do not need an additional DLL for this. + Added a way to rotate in degree the barcode before saving (BCGDrawing::setRotationAngle()). + Added a verification if you have GD installed... So that way you know it before contacting support :) + Fix HTML display for Code 93 and Code 39 Extended buttons + You can now specify a specific table for Code 128. For instance, if you want to force to use the table B, you would write the following to parse + array(CODE128_B, 'The Text To Encode') + The default table selection for Code 128 is automatically chosen. + Fix many PHP4 errors. +v2.0.1Fix 28 jul 2009 Change UPC-E encoding from UTF-8 to ANSI +v2.0.1 21 may 2009 Fix the Code 128C, Fix EAN-8, EAN-13, UPC-A, UPC-E and Postnet padding, MSI checksum can be 1 or 2 + Fix JoinDraw class + Added GIF and WBMP support + Fix the Checksum Text displayed for ISBN + Fix padding for ISBN with setOffsetY + Fix Button in /html for IE8 +v2.0.0 23 apr 2008 The new version has been released... All the codes have been revamped to fit with + common file for 2D barcodes. Instead of using "setText()" method, the method + parse() is used. + Thickness is modified by the scale. + Code 128: it has been modified completely, no need to specify which encoding you want to + use, it will select it for you automatically and try to get the shortest barcode. + Codabar: you can't only put one letter as a barcode. + Code 93: supports now the extended full ASCII 0 to 127 + Code 39 extended has been added in a separate file since the extended + version of Code 39 is totally optional. + Codabar has been fixed for B and C letter + We got our real nice domain: http://www.barcodephp.com +v1.3.0 13 apr 2007 Remove ISBN from EAN-13 and a new file has been created to handle + ISBN-10 and ISBN-13. +v1.2.4 1 feb 2007 Fix Code128. There were some errors dealing with C table +v1.2.3pl1 11 mar 2006 Correct the EAN-13/ISBN file. There was a problem with displaying correctly an ISBN. +v1.2.3 8 feb 2006 Int for font is no longer deprecated and can be used. + Correct many labels' positions : ean8, ean13, upca, upce + Correct getWidth of Font. +v1.2.3b 5 jan 2006 Add separate checksum method to calculate and get this special number created and a way to display it with the label. + Correct code for PHP5.1 compatibility. Selecting a char by { } is now deprecated. Using of [ ] is used instead. + Correct checksum for Code11. In some case, the checksum was bad. + Correct problem displaying label with text under the baseline (letters such as p, g...). + SIZE_SPACING_FONT_END has been suppressed since the previous bug has been fixed. + Correct label if two barcode were generated with the same font. The font is now cloned immediately before using. + The FDrawing has new methods now, use setBarcode and draw instead of add_barcode and draw_all. Only one barcode per FDrawing is possible now. + Correct errors of othercode if no text font has been selected. + othercode was not working for PHP4 due to the lack of the str_split function. Now the function is emulated. + New file : JoinDraw allows you to join 2 graphic and align each of them. (Useful for UCPExt). PHP5 only + Currently Working on UPC-A label +v1.2.2 23 jul 2005 Correct checksum for i25 and s25 barcode (thanks to Gerald Pienkowski (Germany)) + Enhance rapidity for some barcode + Change almost all comment in files : the update 1.2.1 was in 2005, not in 2004 ;) +v1.2.1 27 jun 2005 The php code is now cleaner :) + Increase rapidity of execution + Type verifications in conditions + NEW support of exterior font (Arial, Courier, etc.) with a size that you can specify + Use PHP fonts is deprecated and they will be deleted in further versions. + Remove the "alt" text on the image (IE displays it as a tooltip) + Color class has been enhanced and accept new parameter for constructor + Now you don't have to provide a specific size of the image, it will be calculated automatically for barcodes and errors + Added the version number at the bottom of the script html. + Correcting code 128 to output code correctly when passing from code C to another code +v1.05 27 jun 2005 UPCext2 has been corrected. It could display a wrong barcode. + Correcting UPC-A, bad output when writting text +v1.04 2 apr 2005 Correcting some bugs and makes available for commercial usage : purchase it on http://www.barcodephp.com +v1.03 28 mar 2005 Correcting DrawChar +v1.02 8 mar 2005 Transforming PHPDOC and converting to XHTML1.0 Transitionnal + And adding a special option that check if you have PHP5 installed + Because to many people are writing to me that saying the script doesn't work (because they have PHP4). +v1.01 7 jul 2004 Correcting code39.barcode.php +v1.00 17 jun 2004 New :) +v5.2.0 26 may 2014 Fix potential break in PNG writter. + Fix BCGColor. Deprecated usage of string character reference. + Rotation of text or barcode is now CLOCKWISE. + Fix Code11. Incorrect size when using a scale bigger than 1. + Fix Code128. Potential incorrect table lookup. + Fix IntelligentMail user interface not accepting correct serial number. + Improve speed by setting some methods static. + Fix OtherCode. It now checks for incorrect input. + Use ISO-8859-1 when generating a barcode with the user interface. + Usage of quotes and double quotes was not working properly with the user interface. +v5.1.0 4 oct 2012 Files moved to support 1D and 2D barcodes together + Whiskers has been removed from writing a small line in scale 1 (bug in PHP) + Add alignDefaultLabel for EAN-13 and UPC-A + Versioning is now per file + BoxFix can now be overriden + Fix some references +v5.0.1 18 apr 2012 Fix Navigation support +v5.0.0 18 apr 2012 HTML5 support. Fix some exception file inclusion bugs. + Using space instead of tabs! Added support to change the boxfix. + Added support to Intelligent Mail. Better support for Postnet. Following standard for printing. + Added getters in GS1-128. +v4.1.0 3 aug 2011 Support for transparent background +v4.0.0 15 apr 2011 Brand new version which includes some breaking changes. + Now supports the possibility to add labels around the barcode really easily thanks to the method addLabel() + You can also specify the alignment of the label, rotation, etc. + If the label is bigger than the barcode itself, the image will get bigger to avoid text clipping. + Add the setRatio method for I25 barcodes + Fix EAN-13 and ISBN +v3.0.2 4 apr 2011 Fixing the test.php +v3.0.1 26 mar 2011 Minor fixes for IE9 +v3.0.0 21 mar 2011 Better support for failure instead of writing the error on the UI, an exception is being thrown. +v2.2.0 13 feb 2010 Added the support for GS1-128 (EAN-128). + Fix ISBN text support to be the right font. + Make sure the /html files are formatted. +v2.1.0 8 nov 2009 Added a way to change the DPI before saving (BCGDrawing::setDPI()). Set the value to null if you want to improve the performance and still have 72dpi. + But you can set it to 300 if you wish to print it. + You do not need an additional DLL for this. + Added a way to rotate in degree the barcode before saving (BCGDrawing::setRotationAngle()). + Added a verification if you have GD installed... So that way you know it before contacting support :) + Fix HTML display for Code 93 and Code 39 Extended buttons + You can now specify a specific table for Code 128. For instance, if you want to force to use the table B, you would write the following to parse + array(CODE128_B, 'The Text To Encode') + The default table selection for Code 128 is automatically chosen. + Fix many PHP4 errors. +v2.0.1Fix 28 jul 2009 Change UPC-E encoding from UTF-8 to ANSI +v2.0.1 21 may 2009 Fix the Code 128C, Fix EAN-8, EAN-13, UPC-A, UPC-E and Postnet padding, MSI checksum can be 1 or 2 + Fix JoinDraw class + Added GIF and WBMP support + Fix the Checksum Text displayed for ISBN + Fix padding for ISBN with setOffsetY + Fix Button in /html for IE8 +v2.0.0 23 apr 2008 The new version has been released... All the codes have been revamped to fit with + common file for 2D barcodes. Instead of using "setText()" method, the method + parse() is used. + Thickness is modified by the scale. + Code 128: it has been modified completely, no need to specify which encoding you want to + use, it will select it for you automatically and try to get the shortest barcode. + Codabar: you can't only put one letter as a barcode. + Code 93: supports now the extended full ASCII 0 to 127 + Code 39 extended has been added in a separate file since the extended + version of Code 39 is totally optional. + Codabar has been fixed for B and C letter + We got our real nice domain: http://www.barcodephp.com +v1.3.0 13 apr 2007 Remove ISBN from EAN-13 and a new file has been created to handle + ISBN-10 and ISBN-13. +v1.2.4 1 feb 2007 Fix Code128. There were some errors dealing with C table +v1.2.3pl1 11 mar 2006 Correct the EAN-13/ISBN file. There was a problem with displaying correctly an ISBN. +v1.2.3 8 feb 2006 Int for font is no longer deprecated and can be used. + Correct many labels' positions : ean8, ean13, upca, upce + Correct getWidth of Font. +v1.2.3b 5 jan 2006 Add separate checksum method to calculate and get this special number created and a way to display it with the label. + Correct code for PHP5.1 compatibility. Selecting a char by { } is now deprecated. Using of [ ] is used instead. + Correct checksum for Code11. In some case, the checksum was bad. + Correct problem displaying label with text under the baseline (letters such as p, g...). + SIZE_SPACING_FONT_END has been suppressed since the previous bug has been fixed. + Correct label if two barcode were generated with the same font. The font is now cloned immediately before using. + The FDrawing has new methods now, use setBarcode and draw instead of add_barcode and draw_all. Only one barcode per FDrawing is possible now. + Correct errors of othercode if no text font has been selected. + othercode was not working for PHP4 due to the lack of the str_split function. Now the function is emulated. + New file : JoinDraw allows you to join 2 graphic and align each of them. (Useful for UCPExt). PHP5 only + Currently Working on UPC-A label +v1.2.2 23 jul 2005 Correct checksum for i25 and s25 barcode (thanks to Gerald Pienkowski (Germany)) + Enhance rapidity for some barcode + Change almost all comment in files : the update 1.2.1 was in 2005, not in 2004 ;) +v1.2.1 27 jun 2005 The php code is now cleaner :) + Increase rapidity of execution + Type verifications in conditions + NEW support of exterior font (Arial, Courier, etc.) with a size that you can specify + Use PHP fonts is deprecated and they will be deleted in further versions. + Remove the "alt" text on the image (IE displays it as a tooltip) + Color class has been enhanced and accept new parameter for constructor + Now you don't have to provide a specific size of the image, it will be calculated automatically for barcodes and errors + Added the version number at the bottom of the script html. + Correcting code 128 to output code correctly when passing from code C to another code +v1.05 27 jun 2005 UPCext2 has been corrected. It could display a wrong barcode. + Correcting UPC-A, bad output when writting text +v1.04 2 apr 2005 Correcting some bugs and makes available for commercial usage : purchase it on http://www.barcodephp.com +v1.03 28 mar 2005 Correcting DrawChar +v1.02 8 mar 2005 Transforming PHPDOC and converting to XHTML1.0 Transitionnal + And adding a special option that check if you have PHP5 installed + Because to many people are writing to me that saying the script doesn't work (because they have PHP4). +v1.01 7 jul 2004 Correcting code39.barcode.php +v1.00 17 jun 2004 New :) +v5.2.0 26 may 2014 Fix potential break in PNG writter. + Fix BCGColor. Deprecated usage of string character reference. + Rotation of text or barcode is now CLOCKWISE. + Fix Code11. Incorrect size when using a scale bigger than 1. + Fix Code128. Potential incorrect table lookup. + Fix IntelligentMail user interface not accepting correct serial number. + Improve speed by setting some methods static. + Fix OtherCode. It now checks for incorrect input. + Use ISO-8859-1 when generating a barcode with the user interface. + Usage of quotes and double quotes was not working properly with the user interface. +v5.1.0 4 oct 2012 Files moved to support 1D and 2D barcodes together + Whiskers has been removed from writing a small line in scale 1 (bug in PHP) + Add alignDefaultLabel for EAN-13 and UPC-A + Versioning is now per file + BoxFix can now be overriden + Fix some references +v5.0.1 18 apr 2012 Fix Navigation support +v5.0.0 18 apr 2012 HTML5 support. Fix some exception file inclusion bugs. + Using space instead of tabs! Added support to change the boxfix. + Added support to Intelligent Mail. Better support for Postnet. Following standard for printing. + Added getters in GS1-128. +v4.1.0 3 aug 2011 Support for transparent background +v4.0.0 15 apr 2011 Brand new version which includes some breaking changes. + Now supports the possibility to add labels around the barcode really easily thanks to the method addLabel() + You can also specify the alignment of the label, rotation, etc. + If the label is bigger than the barcode itself, the image will get bigger to avoid text clipping. + Add the setRatio method for I25 barcodes + Fix EAN-13 and ISBN +v3.0.2 4 apr 2011 Fixing the test.php +v3.0.1 26 mar 2011 Minor fixes for IE9 +v3.0.0 21 mar 2011 Better support for failure instead of writing the error on the UI, an exception is being thrown. +v2.2.0 13 feb 2010 Added the support for GS1-128 (EAN-128). + Fix ISBN text support to be the right font. + Make sure the /html files are formatted. +v2.1.0 8 nov 2009 Added a way to change the DPI before saving (BCGDrawing::setDPI()). Set the value to null if you want to improve the performance and still have 72dpi. + But you can set it to 300 if you wish to print it. + You do not need an additional DLL for this. + Added a way to rotate in degree the barcode before saving (BCGDrawing::setRotationAngle()). + Added a verification if you have GD installed... So that way you know it before contacting support :) + Fix HTML display for Code 93 and Code 39 Extended buttons + You can now specify a specific table for Code 128. For instance, if you want to force to use the table B, you would write the following to parse + array(CODE128_B, 'The Text To Encode') + The default table selection for Code 128 is automatically chosen. + Fix many PHP4 errors. +v2.0.1Fix 28 jul 2009 Change UPC-E encoding from UTF-8 to ANSI +v2.0.1 21 may 2009 Fix the Code 128C, Fix EAN-8, EAN-13, UPC-A, UPC-E and Postnet padding, MSI checksum can be 1 or 2 + Fix JoinDraw class + Added GIF and WBMP support + Fix the Checksum Text displayed for ISBN + Fix padding for ISBN with setOffsetY + Fix Button in /html for IE8 +v2.0.0 23 apr 2008 The new version has been released... All the codes have been revamped to fit with + common file for 2D barcodes. Instead of using "setText()" method, the method + parse() is used. + Thickness is modified by the scale. + Code 128: it has been modified completely, no need to specify which encoding you want to + use, it will select it for you automatically and try to get the shortest barcode. + Codabar: you can't only put one letter as a barcode. + Code 93: supports now the extended full ASCII 0 to 127 + Code 39 extended has been added in a separate file since the extended + version of Code 39 is totally optional. + Codabar has been fixed for B and C letter + We got our real nice domain: http://www.barcodephp.com +v1.3.0 13 apr 2007 Remove ISBN from EAN-13 and a new file has been created to handle + ISBN-10 and ISBN-13. +v1.2.4 1 feb 2007 Fix Code128. There were some errors dealing with C table +v1.2.3pl1 11 mar 2006 Correct the EAN-13/ISBN file. There was a problem with displaying correctly an ISBN. +v1.2.3 8 feb 2006 Int for font is no longer deprecated and can be used. + Correct many labels' positions : ean8, ean13, upca, upce + Correct getWidth of Font. +v1.2.3b 5 jan 2006 Add separate checksum method to calculate and get this special number created and a way to display it with the label. + Correct code for PHP5.1 compatibility. Selecting a char by { } is now deprecated. Using of [ ] is used instead. + Correct checksum for Code11. In some case, the checksum was bad. + Correct problem displaying label with text under the baseline (letters such as p, g...). + SIZE_SPACING_FONT_END has been suppressed since the previous bug has been fixed. + Correct label if two barcode were generated with the same font. The font is now cloned immediately before using. + The FDrawing has new methods now, use setBarcode and draw instead of add_barcode and draw_all. Only one barcode per FDrawing is possible now. + Correct errors of othercode if no text font has been selected. + othercode was not working for PHP4 due to the lack of the str_split function. Now the function is emulated. + New file : JoinDraw allows you to join 2 graphic and align each of them. (Useful for UCPExt). PHP5 only + Currently Working on UPC-A label +v1.2.2 23 jul 2005 Correct checksum for i25 and s25 barcode (thanks to Gerald Pienkowski (Germany)) + Enhance rapidity for some barcode + Change almost all comment in files : the update 1.2.1 was in 2005, not in 2004 ;) +v1.2.1 27 jun 2005 The php code is now cleaner :) + Increase rapidity of execution + Type verifications in conditions + NEW support of exterior font (Arial, Courier, etc.) with a size that you can specify + Use PHP fonts is deprecated and they will be deleted in further versions. + Remove the "alt" text on the image (IE displays it as a tooltip) + Color class has been enhanced and accept new parameter for constructor + Now you don't have to provide a specific size of the image, it will be calculated automatically for barcodes and errors + Added the version number at the bottom of the script html. + Correcting code 128 to output code correctly when passing from code C to another code +v1.05 27 jun 2005 UPCext2 has been corrected. It could display a wrong barcode. + Correcting UPC-A, bad output when writting text +v1.04 2 apr 2005 Correcting some bugs and makes available for commercial usage : purchase it on http://www.barcodephp.com +v1.03 28 mar 2005 Correcting DrawChar +v1.02 8 mar 2005 Transforming PHPDOC and converting to XHTML1.0 Transitionnal + And adding a special option that check if you have PHP5 installed + Because to many people are writing to me that saying the script doesn't work (because they have PHP4). +v1.01 7 jul 2004 Correcting code39.barcode.php +v1.00 17 jun 2004 New :) +v5.2.0 26 may 2014 Fix potential break in PNG writter. + Fix BCGColor. Deprecated usage of string character reference. + Rotation of text or barcode is now CLOCKWISE. + Fix Code11. Incorrect size when using a scale bigger than 1. + Fix Code128. Potential incorrect table lookup. + Fix IntelligentMail user interface not accepting correct serial number. + Improve speed by setting some methods static. + Fix OtherCode. It now checks for incorrect input. + Use ISO-8859-1 when generating a barcode with the user interface. + Usage of quotes and double quotes was not working properly with the user interface. +v5.1.0 4 oct 2012 Files moved to support 1D and 2D barcodes together + Whiskers has been removed from writing a small line in scale 1 (bug in PHP) + Add alignDefaultLabel for EAN-13 and UPC-A + Versioning is now per file + BoxFix can now be overriden + Fix some references +v5.0.1 18 apr 2012 Fix Navigation support +v5.0.0 18 apr 2012 HTML5 support. Fix some exception file inclusion bugs. + Using space instead of tabs! Added support to change the boxfix. + Added support to Intelligent Mail. Better support for Postnet. Following standard for printing. + Added getters in GS1-128. +v4.1.0 3 aug 2011 Support for transparent background +v4.0.0 15 apr 2011 Brand new version which includes some breaking changes. + Now supports the possibility to add labels around the barcode really easily thanks to the method addLabel() + You can also specify the alignment of the label, rotation, etc. + If the label is bigger than the barcode itself, the image will get bigger to avoid text clipping. + Add the setRatio method for I25 barcodes + Fix EAN-13 and ISBN +v3.0.2 4 apr 2011 Fixing the test.php +v3.0.1 26 mar 2011 Minor fixes for IE9 +v3.0.0 21 mar 2011 Better support for failure instead of writing the error on the UI, an exception is being thrown. +v2.2.0 13 feb 2010 Added the support for GS1-128 (EAN-128). + Fix ISBN text support to be the right font. + Make sure the /html files are formatted. +v2.1.0 8 nov 2009 Added a way to change the DPI before saving (BCGDrawing::setDPI()). Set the value to null if you want to improve the performance and still have 72dpi. + But you can set it to 300 if you wish to print it. + You do not need an additional DLL for this. + Added a way to rotate in degree the barcode before saving (BCGDrawing::setRotationAngle()). + Added a verification if you have GD installed... So that way you know it before contacting support :) + Fix HTML display for Code 93 and Code 39 Extended buttons + You can now specify a specific table for Code 128. For instance, if you want to force to use the table B, you would write the following to parse + array(CODE128_B, 'The Text To Encode') + The default table selection for Code 128 is automatically chosen. + Fix many PHP4 errors. +v2.0.1Fix 28 jul 2009 Change UPC-E encoding from UTF-8 to ANSI +v2.0.1 21 may 2009 Fix the Code 128C, Fix EAN-8, EAN-13, UPC-A, UPC-E and Postnet padding, MSI checksum can be 1 or 2 + Fix JoinDraw class + Added GIF and WBMP support + Fix the Checksum Text displayed for ISBN + Fix padding for ISBN with setOffsetY + Fix Button in /html for IE8 +v2.0.0 23 apr 2008 The new version has been released... All the codes have been revamped to fit with + common file for 2D barcodes. Instead of using "setText()" method, the method + parse() is used. + Thickness is modified by the scale. + Code 128: it has been modified completely, no need to specify which encoding you want to + use, it will select it for you automatically and try to get the shortest barcode. + Codabar: you can't only put one letter as a barcode. + Code 93: supports now the extended full ASCII 0 to 127 + Code 39 extended has been added in a separate file since the extended + version of Code 39 is totally optional. + Codabar has been fixed for B and C letter + We got our real nice domain: http://www.barcodephp.com +v1.3.0 13 apr 2007 Remove ISBN from EAN-13 and a new file has been created to handle + ISBN-10 and ISBN-13. +v1.2.4 1 feb 2007 Fix Code128. There were some errors dealing with C table +v1.2.3pl1 11 mar 2006 Correct the EAN-13/ISBN file. There was a problem with displaying correctly an ISBN. +v1.2.3 8 feb 2006 Int for font is no longer deprecated and can be used. + Correct many labels' positions : ean8, ean13, upca, upce + Correct getWidth of Font. +v1.2.3b 5 jan 2006 Add separate checksum method to calculate and get this special number created and a way to display it with the label. + Correct code for PHP5.1 compatibility. Selecting a char by { } is now deprecated. Using of [ ] is used instead. + Correct checksum for Code11. In some case, the checksum was bad. + Correct problem displaying label with text under the baseline (letters such as p, g...). + SIZE_SPACING_FONT_END has been suppressed since the previous bug has been fixed. + Correct label if two barcode were generated with the same font. The font is now cloned immediately before using. + The FDrawing has new methods now, use setBarcode and draw instead of add_barcode and draw_all. Only one barcode per FDrawing is possible now. + Correct errors of othercode if no text font has been selected. + othercode was not working for PHP4 due to the lack of the str_split function. Now the function is emulated. + New file : JoinDraw allows you to join 2 graphic and align each of them. (Useful for UCPExt). PHP5 only + Currently Working on UPC-A label +v1.2.2 23 jul 2005 Correct checksum for i25 and s25 barcode (thanks to Gerald Pienkowski (Germany)) + Enhance rapidity for some barcode + Change almost all comment in files : the update 1.2.1 was in 2005, not in 2004 ;) +v1.2.1 27 jun 2005 The php code is now cleaner :) + Increase rapidity of execution + Type verifications in conditions + NEW support of exterior font (Arial, Courier, etc.) with a size that you can specify + Use PHP fonts is deprecated and they will be deleted in further versions. + Remove the "alt" text on the image (IE displays it as a tooltip) + Color class has been enhanced and accept new parameter for constructor + Now you don't have to provide a specific size of the image, it will be calculated automatically for barcodes and errors + Added the version number at the bottom of the script html. + Correcting code 128 to output code correctly when passing from code C to another code +v1.05 27 jun 2005 UPCext2 has been corrected. It could display a wrong barcode. + Correcting UPC-A, bad output when writting text +v1.04 2 apr 2005 Correcting some bugs and makes available for commercial usage : purchase it on http://www.barcodephp.com +v1.03 28 mar 2005 Correcting DrawChar +v1.02 8 mar 2005 Transforming PHPDOC and converting to XHTML1.0 Transitionnal + And adding a special option that check if you have PHP5 installed + Because to many people are writing to me that saying the script doesn't work (because they have PHP4). +v1.01 7 jul 2004 Correcting code39.barcode.php +v1.00 17 jun 2004 New :) \ No newline at end of file diff --git a/application/libraries/barcodegen/class/BCGArgumentException.php b/application/libraries/barcodegen/class/BCGArgumentException.php new file mode 100755 index 000000000..a0e98e795 --- /dev/null +++ b/application/libraries/barcodegen/class/BCGArgumentException.php @@ -0,0 +1,25 @@ +param = $param; + parent::__construct($message, 20000); + } +} +?> \ No newline at end of file diff --git a/application/libraries/barcodegen/class/BCGBarcode.php b/application/libraries/barcodegen/class/BCGBarcode.php new file mode 100755 index 000000000..66ea3e281 --- /dev/null +++ b/application/libraries/barcodegen/class/BCGBarcode.php @@ -0,0 +1,436 @@ +setOffsetX(0); + $this->setOffsetY(0); + $this->setForegroundColor(0x000000); + $this->setBackgroundColor(0xffffff); + $this->setScale(1); + } + + /** + * Parses the text before displaying it. + * + * @param mixed $text + */ + public function parse($text) { + } + + /** + * Gets the foreground color of the barcode. + * + * @return BCGColor + */ + public function getForegroundColor() { + return $this->colorFg; + } + + /** + * Sets the foreground color of the barcode. It could be a BCGColor + * value or simply a language code (white, black, yellow...) or hex value. + * + * @param mixed $code + */ + public function setForegroundColor($code) { + if ($code instanceof BCGColor) { + $this->colorFg = $code; + } else { + $this->colorFg = new BCGColor($code); + } + } + + /** + * Gets the background color of the barcode. + * + * @return BCGColor + */ + public function getBackgroundColor() { + return $this->colorBg; + } + + /** + * Sets the background color of the barcode. It could be a BCGColor + * value or simply a language code (white, black, yellow...) or hex value. + * + * @param mixed $code + */ + public function setBackgroundColor($code) { + if ($code instanceof BCGColor) { + $this->colorBg = $code; + } else { + $this->colorBg = new BCGColor($code); + } + + foreach ($this->labels as $label) { + $label->setBackgroundColor($this->colorBg); + } + } + + /** + * Sets the color. + * + * @param mixed $fg + * @param mixed $bg + */ + public function setColor($fg, $bg) { + $this->setForegroundColor($fg); + $this->setBackgroundColor($bg); + } + + /** + * Gets the scale of the barcode. + * + * @return int + */ + public function getScale() { + return $this->scale; + } + + /** + * Sets the scale of the barcode in pixel. + * If the scale is lower than 1, an exception is raised. + * + * @param int $scale + */ + public function setScale($scale) { + $scale = intval($scale); + if ($scale <= 0) { + throw new BCGArgumentException('The scale must be larger than 0.', 'scale'); + } + + $this->scale = $scale; + } + + /** + * Abstract method that draws the barcode on the resource. + * + * @param resource $im + */ + public abstract function draw($im); + + /** + * Returns the maximal size of a barcode. + * [0]->width + * [1]->height + * + * @param int $w + * @param int $h + * @return int[] + */ + public function getDimension($w, $h) { + $labels = $this->getBiggestLabels(false); + $pixelsAround = array(0, 0, 0, 0); // TRBL + if (isset($labels[BCGLabel::POSITION_TOP])) { + $dimension = $labels[BCGLabel::POSITION_TOP]->getDimension(); + $pixelsAround[0] += $dimension[1]; + } + + if (isset($labels[BCGLabel::POSITION_RIGHT])) { + $dimension = $labels[BCGLabel::POSITION_RIGHT]->getDimension(); + $pixelsAround[1] += $dimension[0]; + } + + if (isset($labels[BCGLabel::POSITION_BOTTOM])) { + $dimension = $labels[BCGLabel::POSITION_BOTTOM]->getDimension(); + $pixelsAround[2] += $dimension[1]; + } + + if (isset($labels[BCGLabel::POSITION_LEFT])) { + $dimension = $labels[BCGLabel::POSITION_LEFT]->getDimension(); + $pixelsAround[3] += $dimension[0]; + } + + $finalW = ($w + $this->offsetX) * $this->scale; + $finalH = ($h + $this->offsetY) * $this->scale; + + // This section will check if a top/bottom label is too big for its width and left/right too big for its height + $reversedLabels = $this->getBiggestLabels(true); + foreach ($reversedLabels as $label) { + $dimension = $label->getDimension(); + $alignment = $label->getAlignment(); + if ($label->getPosition() === BCGLabel::POSITION_LEFT || $label->getPosition() === BCGLabel::POSITION_RIGHT) { + if ($alignment === BCGLabel::ALIGN_TOP) { + $pixelsAround[2] = max($pixelsAround[2], $dimension[1] - $finalH); + } elseif ($alignment === BCGLabel::ALIGN_CENTER) { + $temp = ceil(($dimension[1] - $finalH) / 2); + $pixelsAround[0] = max($pixelsAround[0], $temp); + $pixelsAround[2] = max($pixelsAround[2], $temp); + } elseif ($alignment === BCGLabel::ALIGN_BOTTOM) { + $pixelsAround[0] = max($pixelsAround[0], $dimension[1] - $finalH); + } + } else { + if ($alignment === BCGLabel::ALIGN_LEFT) { + $pixelsAround[1] = max($pixelsAround[1], $dimension[0] - $finalW); + } elseif ($alignment === BCGLabel::ALIGN_CENTER) { + $temp = ceil(($dimension[0] - $finalW) / 2); + $pixelsAround[1] = max($pixelsAround[1], $temp); + $pixelsAround[3] = max($pixelsAround[3], $temp); + } elseif ($alignment === BCGLabel::ALIGN_RIGHT) { + $pixelsAround[3] = max($pixelsAround[3], $dimension[0] - $finalW); + } + } + } + + $this->pushLabel[0] = $pixelsAround[3]; + $this->pushLabel[1] = $pixelsAround[0]; + + $finalW = ($w + $this->offsetX) * $this->scale + $pixelsAround[1] + $pixelsAround[3]; + $finalH = ($h + $this->offsetY) * $this->scale + $pixelsAround[0] + $pixelsAround[2]; + + return array($finalW, $finalH); + } + + /** + * Gets the X offset. + * + * @return int + */ + public function getOffsetX() { + return $this->offsetX; + } + + /** + * Sets the X offset. + * + * @param int $offsetX + */ + public function setOffsetX($offsetX) { + $offsetX = intval($offsetX); + if ($offsetX < 0) { + throw new BCGArgumentException('The offset X must be 0 or larger.', 'offsetX'); + } + + $this->offsetX = $offsetX; + } + + /** + * Gets the Y offset. + * + * @return int + */ + public function getOffsetY() { + return $this->offsetY; + } + + /** + * Sets the Y offset. + * + * @param int $offsetY + */ + public function setOffsetY($offsetY) { + $offsetY = intval($offsetY); + if ($offsetY < 0) { + throw new BCGArgumentException('The offset Y must be 0 or larger.', 'offsetY'); + } + + $this->offsetY = $offsetY; + } + + /** + * Adds the label to the drawing. + * + * @param BCGLabel $label + */ + public function addLabel(BCGLabel $label) { + $label->setBackgroundColor($this->colorBg); + $this->labels[] = $label; + } + + /** + * Removes the label from the drawing. + * + * @param BCGLabel $label + */ + public function removeLabel(BCGLabel $label) { + $remove = -1; + $c = count($this->labels); + for ($i = 0; $i < $c; $i++) { + if ($this->labels[$i] === $label) { + $remove = $i; + break; + } + } + + if ($remove > -1) { + array_splice($this->labels, $remove, 1); + } + } + + /** + * Clears the labels. + */ + public function clearLabels() { + $this->labels = array(); + } + + /** + * Draws the text. + * The coordinate passed are the positions of the barcode. + * $x1 and $y1 represent the top left corner. + * $x2 and $y2 represent the bottom right corner. + * + * @param resource $im + * @param int $x1 + * @param int $y1 + * @param int $x2 + * @param int $y2 + */ + protected function drawText($im, $x1, $y1, $x2, $y2) { + foreach ($this->labels as $label) { + $label->draw($im, + ($x1 + $this->offsetX) * $this->scale + $this->pushLabel[0], + ($y1 + $this->offsetY) * $this->scale + $this->pushLabel[1], + ($x2 + $this->offsetX) * $this->scale + $this->pushLabel[0], + ($y2 + $this->offsetY) * $this->scale + $this->pushLabel[1]); + } + } + + /** + * Draws 1 pixel on the resource at a specific position with a determined color. + * + * @param resource $im + * @param int $x + * @param int $y + * @param int $color + */ + protected function drawPixel($im, $x, $y, $color = self::COLOR_FG) { + $xR = ($x + $this->offsetX) * $this->scale + $this->pushLabel[0]; + $yR = ($y + $this->offsetY) * $this->scale + $this->pushLabel[1]; + + // We always draw a rectangle + imagefilledrectangle($im, + $xR, + $yR, + $xR + $this->scale - 1, + $yR + $this->scale - 1, + $this->getColor($im, $color)); + } + + /** + * Draws an empty rectangle on the resource at a specific position with a determined color. + * + * @param resource $im + * @param int $x1 + * @param int $y1 + * @param int $x2 + * @param int $y2 + * @param int $color + */ + protected function drawRectangle($im, $x1, $y1, $x2, $y2, $color = self::COLOR_FG) { + if ($this->scale === 1) { + imagefilledrectangle($im, + ($x1 + $this->offsetX) + $this->pushLabel[0], + ($y1 + $this->offsetY) + $this->pushLabel[1], + ($x2 + $this->offsetX) + $this->pushLabel[0], + ($y2 + $this->offsetY) + $this->pushLabel[1], + $this->getColor($im, $color)); + } else { + imagefilledrectangle($im, ($x1 + $this->offsetX) * $this->scale + $this->pushLabel[0], ($y1 + $this->offsetY) * $this->scale + $this->pushLabel[1], ($x2 + $this->offsetX) * $this->scale + $this->pushLabel[0] + $this->scale - 1, ($y1 + $this->offsetY) * $this->scale + $this->pushLabel[1] + $this->scale - 1, $this->getColor($im, $color)); + imagefilledrectangle($im, ($x1 + $this->offsetX) * $this->scale + $this->pushLabel[0], ($y1 + $this->offsetY) * $this->scale + $this->pushLabel[1], ($x1 + $this->offsetX) * $this->scale + $this->pushLabel[0] + $this->scale - 1, ($y2 + $this->offsetY) * $this->scale + $this->pushLabel[1] + $this->scale - 1, $this->getColor($im, $color)); + imagefilledrectangle($im, ($x2 + $this->offsetX) * $this->scale + $this->pushLabel[0], ($y1 + $this->offsetY) * $this->scale + $this->pushLabel[1], ($x2 + $this->offsetX) * $this->scale + $this->pushLabel[0] + $this->scale - 1, ($y2 + $this->offsetY) * $this->scale + $this->pushLabel[1] + $this->scale - 1, $this->getColor($im, $color)); + imagefilledrectangle($im, ($x1 + $this->offsetX) * $this->scale + $this->pushLabel[0], ($y2 + $this->offsetY) * $this->scale + $this->pushLabel[1], ($x2 + $this->offsetX) * $this->scale + $this->pushLabel[0] + $this->scale - 1, ($y2 + $this->offsetY) * $this->scale + $this->pushLabel[1] + $this->scale - 1, $this->getColor($im, $color)); + } + } + + /** + * Draws a filled rectangle on the resource at a specific position with a determined color. + * + * @param resource $im + * @param int $x1 + * @param int $y1 + * @param int $x2 + * @param int $y2 + * @param int $color + */ + protected function drawFilledRectangle($im, $x1, $y1, $x2, $y2, $color = self::COLOR_FG) { + if ($x1 > $x2) { // Swap + $x1 ^= $x2 ^= $x1 ^= $x2; + } + + if ($y1 > $y2) { // Swap + $y1 ^= $y2 ^= $y1 ^= $y2; + } + + imagefilledrectangle($im, + ($x1 + $this->offsetX) * $this->scale + $this->pushLabel[0], + ($y1 + $this->offsetY) * $this->scale + $this->pushLabel[1], + ($x2 + $this->offsetX) * $this->scale + $this->pushLabel[0] + $this->scale - 1, + ($y2 + $this->offsetY) * $this->scale + $this->pushLabel[1] + $this->scale - 1, + $this->getColor($im, $color)); + } + + /** + * Allocates the color based on the integer. + * + * @param resource $im + * @param int $color + * @return resource + */ + protected function getColor($im, $color) { + if ($color === self::COLOR_BG) { + return $this->colorBg->allocate($im); + } else { + return $this->colorFg->allocate($im); + } + } + + /** + * Returning the biggest label widths for LEFT/RIGHT and heights for TOP/BOTTOM. + * + * @param bool $reversed + * @return BCGLabel[] + */ + private function getBiggestLabels($reversed = false) { + $searchLR = $reversed ? 1 : 0; + $searchTB = $reversed ? 0 : 1; + + $labels = array(); + foreach ($this->labels as $label) { + $position = $label->getPosition(); + if (isset($labels[$position])) { + $savedDimension = $labels[$position]->getDimension(); + $dimension = $label->getDimension(); + if ($position === BCGLabel::POSITION_LEFT || $position === BCGLabel::POSITION_RIGHT) { + if ($dimension[$searchLR] > $savedDimension[$searchLR]) { + $labels[$position] = $label; + } + } else { + if ($dimension[$searchTB] > $savedDimension[$searchTB]) { + $labels[$position] = $label; + } + } + } else { + $labels[$position] = $label; + } + } + + return $labels; + } +} +?> \ No newline at end of file diff --git a/application/libraries/barcodegen/class/BCGBarcode1D.php b/application/libraries/barcodegen/class/BCGBarcode1D.php new file mode 100755 index 000000000..a4f5c50e3 --- /dev/null +++ b/application/libraries/barcodegen/class/BCGBarcode1D.php @@ -0,0 +1,259 @@ +setThickness(30); + + $this->defaultLabel = new BCGLabel(); + $this->defaultLabel->setPosition(BCGLabel::POSITION_BOTTOM); + $this->setLabel(self::AUTO_LABEL); + $this->setFont(new BCGFontPhp(5)); + + $this->text = ''; + $this->checksumValue = false; + $this->positionX = 0; + } + + /** + * Gets the thickness. + * + * @return int + */ + public function getThickness() { + return $this->thickness; + } + + /** + * Sets the thickness. + * + * @param int $thickness + */ + public function setThickness($thickness) { + $thickness = intval($thickness); + if ($thickness <= 0) { + throw new BCGArgumentException('The thickness must be larger than 0.', 'thickness'); + } + + $this->thickness = $thickness; + } + + /** + * Gets the label. + * If the label was set to BCGBarcode1D::AUTO_LABEL, the label will display the value from the text parsed. + * + * @return string + */ + public function getLabel() { + $label = $this->label; + if ($this->label === self::AUTO_LABEL) { + $label = $this->text; + if ($this->displayChecksum === true && ($checksum = $this->processChecksum()) !== false) { + $label .= $checksum; + } + } + + return $label; + } + + /** + * Sets the label. + * You can use BCGBarcode::AUTO_LABEL to have the label automatically written based on the parsed text. + * + * @param string $label + */ + public function setLabel($label) { + $this->label = $label; + } + + /** + * Gets the font. + * + * @return BCGFont + */ + public function getFont() { + return $this->font; + } + + /** + * Sets the font. + * + * @param mixed $font BCGFont or int + */ + public function setFont($font) { + if (is_int($font)) { + if ($font === 0) { + $font = null; + } else { + $font = new BCGFontPhp($font); + } + } + + $this->font = $font; + } + + /** + * Parses the text before displaying it. + * + * @param mixed $text + */ + public function parse($text) { + $this->text = $text; + $this->checksumValue = false; // Reset checksumValue + $this->validate(); + + parent::parse($text); + + $this->addDefaultLabel(); + } + + /** + * Gets the checksum of a Barcode. + * If no checksum is available, return FALSE. + * + * @return string + */ + public function getChecksum() { + return $this->processChecksum(); + } + + /** + * Sets if the checksum is displayed with the label or not. + * The checksum must be activated in some case to make this variable effective. + * + * @param boolean $displayChecksum + */ + public function setDisplayChecksum($displayChecksum) { + $this->displayChecksum = (bool)$displayChecksum; + } + + /** + * Adds the default label. + */ + protected function addDefaultLabel() { + $label = $this->getLabel(); + $font = $this->font; + if ($label !== null && $label !== '' && $font !== null && $this->defaultLabel !== null) { + $this->defaultLabel->setText($label); + $this->defaultLabel->setFont($font); + $this->addLabel($this->defaultLabel); + } + } + + /** + * Validates the input + */ + protected function validate() { + // No validation in the abstract class. + } + + /** + * Returns the index in $keys (useful for checksum). + * + * @param mixed $var + * @return mixed + */ + protected function findIndex($var) { + return array_search($var, $this->keys); + } + + /** + * Returns the code of the char (useful for drawing bars). + * + * @param mixed $var + * @return string + */ + protected function findCode($var) { + return $this->code[$this->findIndex($var)]; + } + + /** + * Draws all chars thanks to $code. If $startBar is true, the line begins by a space. + * If $startBar is false, the line begins by a bar. + * + * @param resource $im + * @param string $code + * @param boolean $startBar + */ + protected function drawChar($im, $code, $startBar = true) { + $colors = array(BCGBarcode::COLOR_FG, BCGBarcode::COLOR_BG); + $currentColor = $startBar ? 0 : 1; + $c = strlen($code); + for ($i = 0; $i < $c; $i++) { + for ($j = 0; $j < intval($code[$i]) + 1; $j++) { + $this->drawSingleBar($im, $colors[$currentColor]); + $this->nextX(); + } + + $currentColor = ($currentColor + 1) % 2; + } + } + + /** + * Draws a Bar of $color depending of the resolution. + * + * @param resource $img + * @param int $color + */ + protected function drawSingleBar($im, $color) { + $this->drawFilledRectangle($im, $this->positionX, 0, $this->positionX, $this->thickness - 1, $color); + } + + /** + * Moving the pointer right to write a bar. + */ + protected function nextX() { + $this->positionX++; + } + + /** + * Method that saves FALSE into the checksumValue. This means no checksum + * but this method should be overriden when needed. + */ + protected function calculateChecksum() { + $this->checksumValue = false; + } + + /** + * Returns FALSE because there is no checksum. This method should be + * overriden to return correctly the checksum in string with checksumValue. + * + * @return string + */ + protected function processChecksum() { + return false; + } +} +?> \ No newline at end of file diff --git a/application/libraries/barcodegen/class/BCGColor.php b/application/libraries/barcodegen/class/BCGColor.php new file mode 100755 index 000000000..5ece68db7 --- /dev/null +++ b/application/libraries/barcodegen/class/BCGColor.php @@ -0,0 +1,154 @@ +r = intval($args[0]); + $this->g = intval($args[1]); + $this->b = intval($args[2]); + } elseif ($c === 1) { + if (is_string($args[0]) && strlen($args[0]) === 7 && $args[0][0] === '#') { // Hex Value in String + $this->r = intval(substr($args[0], 1, 2), 16); + $this->g = intval(substr($args[0], 3, 2), 16); + $this->b = intval(substr($args[0], 5, 2), 16); + } else { + if (is_string($args[0])) { + $args[0] = self::getColor($args[0]); + } + + $args[0] = intval($args[0]); + $this->r = ($args[0] & 0xff0000) >> 16; + $this->g = ($args[0] & 0x00ff00) >> 8; + $this->b = ($args[0] & 0x0000ff); + } + } else { + $this->r = $this->g = $this->b = 0; + } + } + + /** + * Sets the color transparent. + * + * @param bool $transparent + */ + public function setTransparent($transparent) { + $this->transparent = $transparent; + } + + /** + * Returns Red Color. + * + * @return int + */ + public function r() { + return $this->r; + } + + /** + * Returns Green Color. + * + * @return int + */ + public function g() { + return $this->g; + } + + /** + * Returns Blue Color. + * + * @return int + */ + public function b() { + return $this->b; + } + + /** + * Returns the int value for PHP color. + * + * @param resource $im + * @return int + */ + public function allocate(&$im) { + $allocated = imagecolorallocate($im, $this->r, $this->g, $this->b); + if ($this->transparent) { + return imagecolortransparent($im, $allocated); + } else { + return $allocated; + } + } + + /** + * Returns class of BCGColor depending of the string color. + * + * If the color doens't exist, it takes the default one. + * + * @param string $code + * @param string $default + */ + public static function getColor($code, $default = 'white') { + switch(strtolower($code)) { + case '': + case 'white': + return 0xffffff; + case 'black': + return 0x000000; + case 'maroon': + return 0x800000; + case 'red': + return 0xff0000; + case 'orange': + return 0xffa500; + case 'yellow': + return 0xffff00; + case 'olive': + return 0x808000; + case 'purple': + return 0x800080; + case 'fuchsia': + return 0xff00ff; + case 'lime': + return 0x00ff00; + case 'green': + return 0x008000; + case 'navy': + return 0x000080; + case 'blue': + return 0x0000ff; + case 'aqua': + return 0x00ffff; + case 'teal': + return 0x008080; + case 'silver': + return 0xc0c0c0; + case 'gray': + return 0x808080; + default: + return self::getColor($default, 'white'); + } + } +} +?> \ No newline at end of file diff --git a/application/libraries/barcodegen/class/BCGDrawException.php b/application/libraries/barcodegen/class/BCGDrawException.php new file mode 100755 index 000000000..8c85f8c2b --- /dev/null +++ b/application/libraries/barcodegen/class/BCGDrawException.php @@ -0,0 +1,21 @@ + \ No newline at end of file diff --git a/application/libraries/barcodegen/class/BCGDrawing.php b/application/libraries/barcodegen/class/BCGDrawing.php new file mode 100755 index 000000000..6766c1e41 --- /dev/null +++ b/application/libraries/barcodegen/class/BCGDrawing.php @@ -0,0 +1,248 @@ +im = null; + $this->setFilename($filename); + $this->color = $color; + $this->dpi = null; + $this->rotateDegree = 0.0; + } + + /** + * Destructor. + */ + public function __destruct() { + $this->destroy(); + } + + /** + * Gets the filename. + * + * @return string + */ + public function getFilename() { + return $this->filename; + } + + /** + * Sets the filename. + * + * @param string $filaneme + */ + public function setFilename($filename) { + $this->filename = $filename; + } + + /** + * @return resource. + */ + public function get_im() { + return $this->im; + } + + /** + * Sets the image. + * + * @param resource $im + */ + public function set_im($im) { + $this->im = $im; + } + + /** + * Gets barcode for drawing. + * + * @return BCGBarcode + */ + public function getBarcode() { + return $this->barcode; + } + + /** + * Sets barcode for drawing. + * + * @param BCGBarcode $barcode + */ + public function setBarcode(BCGBarcode $barcode) { + $this->barcode = $barcode; + } + + /** + * Gets the DPI for supported filetype. + * + * @return float + */ + public function getDPI() { + return $this->dpi; + } + + /** + * Sets the DPI for supported filetype. + * + * @param float $dpi + */ + public function setDPI($dpi) { + $this->dpi = $dpi; + } + + /** + * Gets the rotation angle in degree clockwise. + * + * @return float + */ + public function getRotationAngle() { + return $this->rotateDegree; + } + + /** + * Sets the rotation angle in degree clockwise. + * + * @param float $degree + */ + public function setRotationAngle($degree) { + $this->rotateDegree = (float)$degree; + } + + /** + * Draws the barcode on the image $im. + */ + public function draw() { + $size = $this->barcode->getDimension(0, 0); + $this->w = max(1, $size[0]); + $this->h = max(1, $size[1]); + $this->init(); + $this->barcode->draw($this->im); + } + + /** + * Saves $im into the file (many format available). + * + * @param int $image_style + * @param int $quality + */ + public function finish($image_style = self::IMG_FORMAT_PNG, $quality = 100) { + $drawer = null; + + $im = $this->im; + if ($this->rotateDegree > 0.0) { + if (function_exists('imagerotate')) { + $im = imagerotate($this->im, 360 - $this->rotateDegree, $this->color->allocate($this->im)); + } else { + throw new BCGDrawException('The method imagerotate doesn\'t exist on your server. Do not use any rotation.'); + } + } + + if ($image_style === self::IMG_FORMAT_PNG) { + $drawer = new BCGDrawPNG($im); + $drawer->setFilename($this->filename); + $drawer->setDPI($this->dpi); + } elseif ($image_style === self::IMG_FORMAT_JPEG) { + $drawer = new BCGDrawJPG($im); + $drawer->setFilename($this->filename); + $drawer->setDPI($this->dpi); + $drawer->setQuality($quality); + } elseif ($image_style === self::IMG_FORMAT_GIF) { + // Some PHP versions have a bug if passing 2nd argument as null. + if ($this->filename === null || $this->filename === '') { + imagegif($im); + } else { + imagegif($im, $this->filename); + } + } elseif ($image_style === self::IMG_FORMAT_WBMP) { + imagewbmp($im, $this->filename); + } + + if ($drawer !== null) { + $drawer->draw(); + } + } + + /** + * Writes the Error on the picture. + * + * @param Exception $exception + */ + public function drawException($exception) { + $this->w = 1; + $this->h = 1; + $this->init(); + + // Is the image big enough? + $w = imagesx($this->im); + $h = imagesy($this->im); + + $text = 'Error: ' . $exception->getMessage(); + + $width = imagefontwidth(2) * strlen($text); + $height = imagefontheight(2); + if ($width > $w || $height > $h) { + $width = max($w, $width); + $height = max($h, $height); + + // We change the size of the image + $newimg = imagecreatetruecolor($width, $height); + imagefill($newimg, 0, 0, imagecolorat($this->im, 0, 0)); + imagecopy($newimg, $this->im, 0, 0, 0, 0, $w, $h); + $this->im = $newimg; + } + + $black = new BCGColor('black'); + imagestring($this->im, 2, 0, 0, $text, $black->allocate($this->im)); + } + + /** + * Free the memory of PHP (called also by destructor). + */ + public function destroy() { + @imagedestroy($this->im); + } + + /** + * Init Image and color background. + */ + private function init() { + if ($this->im === null) { + $this->im = imagecreatetruecolor($this->w, $this->h) + or die('Can\'t Initialize the GD Libraty'); + imagefilledrectangle($this->im, 0, 0, $this->w - 1, $this->h - 1, $this->color->allocate($this->im)); + } + } +} +?> \ No newline at end of file diff --git a/application/libraries/barcodegen/class/BCGFont.php b/application/libraries/barcodegen/class/BCGFont.php new file mode 100755 index 000000000..a2a8f2f19 --- /dev/null +++ b/application/libraries/barcodegen/class/BCGFont.php @@ -0,0 +1,23 @@ + \ No newline at end of file diff --git a/application/libraries/barcodegen/class/BCGFontFile.php b/application/libraries/barcodegen/class/BCGFontFile.php new file mode 100755 index 000000000..756046686 --- /dev/null +++ b/application/libraries/barcodegen/class/BCGFontFile.php @@ -0,0 +1,209 @@ +path = $fontPath; + $this->size = $size; + $this->foregroundColor = new BCGColor('black'); + $this->setRotationAngle(0); + $this->setBoxFix(self::PHP_BOX_FIX); + } + + /** + * Gets the text associated to the font. + * + * @return string + */ + public function getText() { + return $this->text; + } + + /** + * Sets the text associated to the font. + * + * @param string text + */ + public function setText($text) { + $this->text = $text; + $this->box = null; + } + + /** + * Gets the rotation in degree. + * + * @return int + */ + public function getRotationAngle() { + return (360 - $this->rotationAngle) % 360; + } + + /** + * Sets the rotation in degree. + * + * @param int + */ + public function setRotationAngle($rotationAngle) { + $this->rotationAngle = (int)$rotationAngle; + if ($this->rotationAngle !== 90 && $this->rotationAngle !== 180 && $this->rotationAngle !== 270) { + $this->rotationAngle = 0; + } + + $this->rotationAngle = (360 - $this->rotationAngle) % 360; + + $this->box = null; + } + + /** + * Gets the background color. + * + * @return BCGColor + */ + public function getBackgroundColor() { + } + + /** + * Sets the background color. + * + * @param BCGColor $backgroundColor + */ + public function setBackgroundColor($backgroundColor) { + } + + /** + * Gets the foreground color. + * + * @return BCGColor + */ + public function getForegroundColor() { + return $this->foregroundColor; + } + + /** + * Sets the foreground color. + * + * @param BCGColor $foregroundColor + */ + public function setForegroundColor($foregroundColor) { + $this->foregroundColor = $foregroundColor; + } + + /** + * Gets the box fix information. + * + * @return int + */ + public function getBoxFix() { + return $this->boxFix; + } + + /** + * Sets the box fix information. + * + * @param int $value + */ + public function setBoxFix($value) { + $this->boxFix = intval($value); + } + + /** + * Returns the width and height that the text takes to be written. + * + * @return int[] + */ + public function getDimension() { + $w = 0.0; + $h = 0.0; + $box = $this->getBox(); + + if ($box !== null) { + $minX = min(array($box[0], $box[2], $box[4], $box[6])); + $maxX = max(array($box[0], $box[2], $box[4], $box[6])); + $minY = min(array($box[1], $box[3], $box[5], $box[7])); + $maxY = max(array($box[1], $box[3], $box[5], $box[7])); + + $w = $maxX - $minX; + $h = $maxY - $minY; + } + + $rotationAngle = $this->getRotationAngle(); + if ($rotationAngle === 90 || $rotationAngle === 270) { + return array($h + self::PHP_BOX_FIX, $w); + } else { + return array($w + self::PHP_BOX_FIX, $h); + } + } + + /** + * Draws the text on the image at a specific position. + * $x and $y represent the left bottom corner. + * + * @param resource $im + * @param int $x + * @param int $y + */ + public function draw($im, $x, $y) { + $drawingPosition = $this->getDrawingPosition($x, $y); + imagettftext($im, $this->size, $this->rotationAngle, $drawingPosition[0], $drawingPosition[1], $this->foregroundColor->allocate($im), $this->path, $this->text); + } + + private function getDrawingPosition($x, $y) { + $dimension = $this->getDimension(); + $box = $this->getBox(); + $rotationAngle = $this->getRotationAngle(); + if ($rotationAngle === 0) { + $y += abs(min($box[5], $box[7])); + } elseif ($rotationAngle === 90) { + $x += abs(min($box[5], $box[7])); + $y += $dimension[1]; + } elseif ($rotationAngle === 180) { + $x += $dimension[0]; + $y += abs(max($box[1], $box[3])); + } elseif ($rotationAngle === 270) { + $x += abs(max($box[1], $box[3])); + } + + return array($x, $y); + } + + private function getBox() { + if ($this->box === null) { + $gd = imagecreate(1, 1); + $this->box = imagettftext($gd, $this->size, 0, 0, 0, 0, $this->path, $this->text); + } + + return $this->box; + } +} +?> \ No newline at end of file diff --git a/application/libraries/barcodegen/class/BCGFontPhp.php b/application/libraries/barcodegen/class/BCGFontPhp.php new file mode 100755 index 000000000..e556e49aa --- /dev/null +++ b/application/libraries/barcodegen/class/BCGFontPhp.php @@ -0,0 +1,153 @@ +font = max(0, intval($font)); + $this->backgroundColor = new BCGColor('white'); + $this->foregroundColor = new BCGColor('black'); + $this->setRotationAngle(0); + } + + /** + * Gets the text associated to the font. + * + * @return string + */ + public function getText() { + return $this->text; + } + + /** + * Sets the text associated to the font. + * + * @param string text + */ + public function setText($text) { + $this->text = $text; + } + + /** + * Gets the rotation in degree. + * + * @return int + */ + public function getRotationAngle() { + return (360 - $this->rotationAngle) % 360; + } + + /** + * Sets the rotation in degree. + * + * @param int + */ + public function setRotationAngle($rotationAngle) { + $this->rotationAngle = (int)$rotationAngle; + if ($this->rotationAngle !== 90 && $this->rotationAngle !== 180 && $this->rotationAngle !== 270) { + $this->rotationAngle = 0; + } + + $this->rotationAngle = (360 - $this->rotationAngle) % 360; + } + + /** + * Gets the background color. + * + * @return BCGColor + */ + public function getBackgroundColor() { + return $this->backgroundColor; + } + + /** + * Sets the background color. + * + * @param BCGColor $backgroundColor + */ + public function setBackgroundColor($backgroundColor) { + $this->backgroundColor = $backgroundColor; + } + + /** + * Gets the foreground color. + * + * @return BCGColor + */ + public function getForegroundColor() { + return $this->foregroundColor; + } + + /** + * Sets the foreground color. + * + * @param BCGColor $foregroundColor + */ + public function setForegroundColor($foregroundColor) { + $this->foregroundColor = $foregroundColor; + } + + /** + * Returns the width and height that the text takes to be written. + * + * @return int[] + */ + public function getDimension() { + $w = imagefontwidth($this->font) * strlen($this->text); + $h = imagefontheight($this->font); + + $rotationAngle = $this->getRotationAngle(); + if ($rotationAngle === 90 || $rotationAngle === 270) { + return array($h, $w); + } else { + return array($w, $h); + } + } + + /** + * Draws the text on the image at a specific position. + * $x and $y represent the left bottom corner. + * + * @param resource $im + * @param int $x + * @param int $y + */ + public function draw($im, $x, $y) { + if ($this->getRotationAngle() !== 0) { + if (!function_exists('imagerotate')) { + throw new BCGDrawException('The method imagerotate doesn\'t exist on your server. Do not use any rotation.'); + } + + $w = imagefontwidth($this->font) * strlen($this->text); + $h = imagefontheight($this->font); + $gd = imagecreatetruecolor($w, $h); + imagefilledrectangle($gd, 0, 0, $w - 1, $h - 1, $this->backgroundColor->allocate($gd)); + imagestring($gd, $this->font, 0, 0, $this->text, $this->foregroundColor->allocate($gd)); + $gd = imagerotate($gd, $this->rotationAngle, 0); + imagecopy($im, $gd, $x, $y, 0, 0, imagesx($gd), imagesy($gd)); + } else { + imagestring($im, $this->font, $x, $y, $this->text, $this->foregroundColor->allocate($im)); + } + } +} +?> \ No newline at end of file diff --git a/application/libraries/barcodegen/class/BCGLabel.php b/application/libraries/barcodegen/class/BCGLabel.php new file mode 100755 index 000000000..1a378001e --- /dev/null +++ b/application/libraries/barcodegen/class/BCGLabel.php @@ -0,0 +1,320 @@ +setFont($font); + $this->setText($text); + $this->setPosition($position); + $this->setAlignment($alignment); + $this->setSpacing(4); + $this->setOffset(0); + $this->setRotationAngle(0); + $this->setBackgroundColor(new BCGColor('white')); + $this->setForegroundColor(new BCGColor('black')); + } + + /** + * Gets the text. + * + * @return string + */ + public function getText() { + return $this->font->getText(); + } + + /** + * Sets the text. + * + * @param string $text + */ + public function setText($text) { + $this->text = $text; + $this->font->setText($this->text); + } + + /** + * Gets the font. + * + * @return BCGFont + */ + public function getFont() { + return $this->font; + } + + /** + * Sets the font. + * + * @param BCGFont $font + */ + public function setFont($font) { + if ($font === null) { + throw new BCGArgumentException('Font cannot be null.', 'font'); + } + + $this->font = clone $font; + $this->font->setText($this->text); + $this->font->setRotationAngle($this->rotationAngle); + $this->font->setBackgroundColor($this->backgroundColor); + $this->font->setForegroundColor($this->foregroundColor); + } + + /** + * Gets the text position for drawing. + * + * @return int + */ + public function getPosition() { + return $this->position; + } + + /** + * Sets the text position for drawing. + * + * @param int $position + */ + public function setPosition($position) { + $position = intval($position); + if ($position !== self::POSITION_TOP && $position !== self::POSITION_RIGHT && $position !== self::POSITION_BOTTOM && $position !== self::POSITION_LEFT) { + throw new BCGArgumentException('The text position must be one of a valid constant.', 'position'); + } + + $this->position = $position; + } + + /** + * Gets the text alignment for drawing. + * + * @return int + */ + public function getAlignment() { + return $this->alignment; + } + + /** + * Sets the text alignment for drawing. + * + * @param int $alignment + */ + public function setAlignment($alignment) { + $alignment = intval($alignment); + if ($alignment !== self::ALIGN_LEFT && $alignment !== self::ALIGN_TOP && $alignment !== self::ALIGN_CENTER && $alignment !== self::ALIGN_RIGHT && $alignment !== self::ALIGN_BOTTOM) { + throw new BCGArgumentException('The text alignment must be one of a valid constant.', 'alignment'); + } + + $this->alignment = $alignment; + } + + /** + * Gets the offset. + * + * @return int + */ + public function getOffset() { + return $this->offset; + } + + /** + * Sets the offset. + * + * @param int $offset + */ + public function setOffset($offset) { + $this->offset = intval($offset); + } + + /** + * Gets the spacing. + * + * @return int + */ + public function getSpacing() { + return $this->spacing; + } + + /** + * Sets the spacing. + * + * @param int $spacing + */ + public function setSpacing($spacing) { + $this->spacing = max(0, intval($spacing)); + } + + /** + * Gets the rotation angle in degree. + * + * @return int + */ + public function getRotationAngle() { + return $this->font->getRotationAngle(); + } + + /** + * Sets the rotation angle in degree. + * + * @param int $rotationAngle + */ + public function setRotationAngle($rotationAngle) { + $this->rotationAngle = intval($rotationAngle); + $this->font->setRotationAngle($this->rotationAngle); + } + + /** + * Gets the background color in case of rotation. + * + * @return BCGColor + */ + public function getBackgroundColor() { + return $this->backgroundColor; + } + + /** + * Sets the background color in case of rotation. + * + * @param BCGColor $backgroundColor + */ + public /*internal*/ function setBackgroundColor($backgroundColor) { + $this->backgroundColor = $backgroundColor; + $this->font->setBackgroundColor($this->backgroundColor); + } + + /** + * Gets the foreground color. + * + * @return BCGColor + */ + public function getForegroundColor() { + return $this->font->getForegroundColor(); + } + + /** + * Sets the foreground color. + * + * @param BCGColor $foregroundColor + */ + public function setForegroundColor($foregroundColor) { + $this->foregroundColor = $foregroundColor; + $this->font->setForegroundColor($this->foregroundColor); + } + + /** + * Gets the dimension taken by the label, including the spacing and offset. + * [0]: width + * [1]: height + * + * @return int[] + */ + public function getDimension() { + $w = 0; + $h = 0; + + $dimension = $this->font->getDimension(); + $w = $dimension[0]; + $h = $dimension[1]; + + if ($this->position === self::POSITION_TOP || $this->position === self::POSITION_BOTTOM) { + $h += $this->spacing; + $w += max(0, $this->offset); + } else { + $w += $this->spacing; + $h += max(0, $this->offset); + } + + return array($w, $h); + } + + /** + * Draws the text. + * The coordinate passed are the positions of the barcode. + * $x1 and $y1 represent the top left corner. + * $x2 and $y2 represent the bottom right corner. + * + * @param resource $im + * @param int $x1 + * @param int $y1 + * @param int $x2 + * @param int $y2 + */ + public /*internal*/ function draw($im, $x1, $y1, $x2, $y2) { + $x = 0; + $y = 0; + + $fontDimension = $this->font->getDimension(); + + if ($this->position === self::POSITION_TOP || $this->position === self::POSITION_BOTTOM) { + if ($this->position === self::POSITION_TOP) { + $y = $y1 - $this->spacing - $fontDimension[1]; + } elseif ($this->position === self::POSITION_BOTTOM) { + $y = $y2 + $this->spacing; + } + + if ($this->alignment === self::ALIGN_CENTER) { + $x = ($x2 - $x1) / 2 + $x1 - $fontDimension[0] / 2 + $this->offset; + } elseif ($this->alignment === self::ALIGN_LEFT) { + $x = $x1 + $this->offset; + } else { + $x = $x2 + $this->offset - $fontDimension[0]; + } + } else { + if ($this->position === self::POSITION_LEFT) { + $x = $x1 - $this->spacing - $fontDimension[0]; + } elseif ($this->position === self::POSITION_RIGHT) { + $x = $x2 + $this->spacing; + } + + if ($this->alignment === self::ALIGN_CENTER) { + $y = ($y2 - $y1) / 2 + $y1 - $fontDimension[1] / 2 + $this->offset; + } elseif ($this->alignment === self::ALIGN_TOP) { + $y = $y1 + $this->offset; + } else { + $y = $y2 + $this->offset - $fontDimension[1]; + } + } + + $this->font->setText($this->text); + $this->font->draw($im, $x, $y); + } +} +?> \ No newline at end of file diff --git a/application/libraries/barcodegen/class/BCGParseException.php b/application/libraries/barcodegen/class/BCGParseException.php new file mode 100755 index 000000000..0582d0bca --- /dev/null +++ b/application/libraries/barcodegen/class/BCGParseException.php @@ -0,0 +1,25 @@ +barcode = $barcode; + parent::__construct($message, 10000); + } +} +?> \ No newline at end of file diff --git a/application/libraries/barcodegen/class/BCGcodabar.barcode.php b/application/libraries/barcodegen/class/BCGcodabar.barcode.php new file mode 100755 index 000000000..9616fb905 --- /dev/null +++ b/application/libraries/barcodegen/class/BCGcodabar.barcode.php @@ -0,0 +1,122 @@ +keys = array('0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '-', '$', ':', '/', '.', '+', 'A', 'B', 'C', 'D'); + $this->code = array( // 0 added to add an extra space + '00000110', /* 0 */ + '00001100', /* 1 */ + '00010010', /* 2 */ + '11000000', /* 3 */ + '00100100', /* 4 */ + '10000100', /* 5 */ + '01000010', /* 6 */ + '01001000', /* 7 */ + '01100000', /* 8 */ + '10010000', /* 9 */ + '00011000', /* - */ + '00110000', /* $ */ + '10001010', /* : */ + '10100010', /* / */ + '10101000', /* . */ + '00111110', /* + */ + '00110100', /* A */ + '01010010', /* B */ + '00010110', /* C */ + '00011100' /* D */ + ); + } + + /** + * Parses the text before displaying it. + * + * @param mixed $text + */ + public function parse($text) { + parent::parse(strtoupper($text)); // Only Capital Letters are Allowed + } + + /** + * Draws the barcode. + * + * @param resource $im + */ + public function draw($im) { + $c = strlen($this->text); + for ($i = 0; $i < $c; $i++) { + $this->drawChar($im, $this->findCode($this->text[$i]), true); + } + + $this->drawText($im, 0, 0, $this->positionX, $this->thickness); + } + + /** + * Returns the maximal size of a barcode. + * + * @param int $w + * @param int $h + * @return int[] + */ + public function getDimension($w, $h) { + $textLength = 0; + $c = strlen($this->text); + for ($i = 0; $i < $c; $i++) { + $index = $this->findIndex($this->text[$i]); + if ($index !== false) { + $textLength += 8; + $textLength += substr_count($this->code[$index], '1'); + } + } + + $w += $textLength; + $h += $this->thickness; + return parent::getDimension($w, $h); + } + + /** + * Validates the input. + */ + protected function validate() { + $c = strlen($this->text); + if ($c === 0) { + throw new BCGParseException('codabar', 'No data has been entered.'); + } + + // Checking if all chars are allowed + for ($i = 0; $i < $c; $i++) { + if (array_search($this->text[$i], $this->keys) === false) { + throw new BCGParseException('codabar', 'The character \'' . $this->text[$i] . '\' is not allowed.'); + } + } + + // Must start by A, B, C or D + if ($c == 0 || ($this->text[0] !== 'A' && $this->text[0] !== 'B' && $this->text[0] !== 'C' && $this->text[0] !== 'D')) { + throw new BCGParseException('codabar', 'The text must start by the character A, B, C, or D.'); + } + + // Must end by A, B, C or D + $c2 = $c - 1; + if ($c2 === 0 || ($this->text[$c2] !== 'A' && $this->text[$c2] !== 'B' && $this->text[$c2] !== 'C' && $this->text[$c2] !== 'D')) { + throw new BCGParseException('codabar', 'The text must end by the character A, B, C, or D.'); + } + + parent::validate(); + } +} +?> \ No newline at end of file diff --git a/application/libraries/barcodegen/class/BCGcode11.barcode.php b/application/libraries/barcodegen/class/BCGcode11.barcode.php new file mode 100755 index 000000000..2a21e9b32 --- /dev/null +++ b/application/libraries/barcodegen/class/BCGcode11.barcode.php @@ -0,0 +1,185 @@ +keys = array('0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '-'); + $this->code = array( // 0 added to add an extra space + '000010', /* 0 */ + '100010', /* 1 */ + '010010', /* 2 */ + '110000', /* 3 */ + '001010', /* 4 */ + '101000', /* 5 */ + '011000', /* 6 */ + '000110', /* 7 */ + '100100', /* 8 */ + '100000', /* 9 */ + '001000' /* - */ + ); + } + + /** + * Draws the barcode. + * + * @param resource $im + */ + public function draw($im) { + // Starting Code + $this->drawChar($im, '001100', true); + + // Chars + $c = strlen($this->text); + for ($i = 0; $i < $c; $i++) { + $this->drawChar($im, $this->findCode($this->text[$i]), true); + } + + // Checksum + $this->calculateChecksum(); + $c = count($this->checksumValue); + for ($i = 0; $i < $c; $i++) { + $this->drawChar($im, $this->code[$this->checksumValue[$i]], true); + } + + // Ending Code + $this->drawChar($im, '00110', true); + $this->drawText($im, 0, 0, $this->positionX, $this->thickness); + } + + /** + * Returns the maximal size of a barcode. + * + * @param int $w + * @param int $h + * @return int[] + */ + public function getDimension($w, $h) { + $startlength = 8; + + $textlength = 0; + $c = strlen($this->text); + for ($i = 0; $i < $c; $i++) { + $textlength += $this->getIndexLength($this->findIndex($this->text[$i])); + } + + $checksumlength = 0; + $this->calculateChecksum(); + $c = count($this->checksumValue); + for ($i = 0; $i < $c; $i++) { + $checksumlength += $this->getIndexLength($this->checksumValue[$i]); + } + + $endlength = 7; + + $w += $startlength + $textlength + $checksumlength + $endlength; + $h += $this->thickness; + + return parent::getDimension($w, $h); + } + + /** + * Validates the input. + */ + protected function validate() { + $c = strlen($this->text); + if ($c === 0) { + throw new BCGParseException('code11', 'No data has been entered.'); + } + + // Checking if all chars are allowed + for ($i = 0; $i < $c; $i++) { + if (array_search($this->text[$i], $this->keys) === false) { + throw new BCGParseException('code11', 'The character \'' . $this->text[$i] . '\' is not allowed.'); + } + } + + parent::validate(); + } + + /** + * Overloaded method to calculate checksum. + */ + protected function calculateChecksum() { + // Checksum + // First CheckSUM "C" + // The "C" checksum character is the modulo 11 remainder of the sum of the weighted + // value of the data characters. The weighting value starts at "1" for the right-most + // data character, 2 for the second to last, 3 for the third-to-last, and so on up to 20. + // After 10, the sequence wraps around back to 1. + + // Second CheckSUM "K" + // Same as CheckSUM "C" but we count the CheckSum "C" at the end + // After 9, the sequence wraps around back to 1. + $sequence_multiplier = array(10, 9); + $temp_text = $this->text; + $this->checksumValue = array(); + for ($z = 0; $z < 2; $z++) { + $c = strlen($temp_text); + + // We don't display the K CheckSum if the original text had a length less than 10 + if ($c <= 10 && $z === 1) { + break; + } + + $checksum = 0; + for ($i = $c, $j = 0; $i > 0; $i--, $j++) { + $multiplier = $i % $sequence_multiplier[$z]; + if ($multiplier === 0) { + $multiplier = $sequence_multiplier[$z]; + } + + $checksum += $this->findIndex($temp_text[$j]) * $multiplier; + } + + $this->checksumValue[$z] = $checksum % 11; + $temp_text .= $this->keys[$this->checksumValue[$z]]; + } + } + + /** + * Overloaded method to display the checksum. + */ + protected function processChecksum() { + if ($this->checksumValue === false) { // Calculate the checksum only once + $this->calculateChecksum(); + } + + if ($this->checksumValue !== false) { + $ret = ''; + $c = count($this->checksumValue); + for ($i = 0; $i < $c; $i++) { + $ret .= $this->keys[$this->checksumValue[$i]]; + } + + return $ret; + } + + return false; + } + + private function getIndexLength($index) { + $length = 0; + if ($index !== false) { + $length += 6; + $length += substr_count($this->code[$index], '1'); + } + + return $length; + } +} +?> \ No newline at end of file diff --git a/application/libraries/barcodegen/class/BCGcode128.barcode.php b/application/libraries/barcodegen/class/BCGcode128.barcode.php new file mode 100755 index 000000000..da89080c4 --- /dev/null +++ b/application/libraries/barcodegen/class/BCGcode128.barcode.php @@ -0,0 +1,885 @@ +keysA = ' !"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_'; + for ($i = 0; $i < 32; $i++) { + $this->keysA .= chr($i); + } + + /* CODE 128 B */ + $this->keysB = ' !"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~' . chr(127); + + /* CODE 128 C */ + $this->keysC = '0123456789'; + + $this->code = array( + '101111', /* 00 */ + '111011', /* 01 */ + '111110', /* 02 */ + '010112', /* 03 */ + '010211', /* 04 */ + '020111', /* 05 */ + '011102', /* 06 */ + '011201', /* 07 */ + '021101', /* 08 */ + '110102', /* 09 */ + '110201', /* 10 */ + '120101', /* 11 */ + '001121', /* 12 */ + '011021', /* 13 */ + '011120', /* 14 */ + '002111', /* 15 */ + '012011', /* 16 */ + '012110', /* 17 */ + '112100', /* 18 */ + '110021', /* 19 */ + '110120', /* 20 */ + '102101', /* 21 */ + '112001', /* 22 */ + '201020', /* 23 */ + '200111', /* 24 */ + '210011', /* 25 */ + '210110', /* 26 */ + '201101', /* 27 */ + '211001', /* 28 */ + '211100', /* 29 */ + '101012', /* 30 */ + '101210', /* 31 */ + '121010', /* 32 */ + '000212', /* 33 */ + '020012', /* 34 */ + '020210', /* 35 */ + '001202', /* 36 */ + '021002', /* 37 */ + '021200', /* 38 */ + '100202', /* 39 */ + '120002', /* 40 */ + '120200', /* 41 */ + '001022', /* 42 */ + '001220', /* 43 */ + '021020', /* 44 */ + '002012', /* 45 */ + '002210', /* 46 */ + '022010', /* 47 */ + '202010', /* 48 */ + '100220', /* 49 */ + '120020', /* 50 */ + '102002', /* 51 */ + '102200', /* 52 */ + '102020', /* 53 */ + '200012', /* 54 */ + '200210', /* 55 */ + '220010', /* 56 */ + '201002', /* 57 */ + '201200', /* 58 */ + '221000', /* 59 */ + '203000', /* 60 */ + '110300', /* 61 */ + '320000', /* 62 */ + '000113', /* 63 */ + '000311', /* 64 */ + '010013', /* 65 */ + '010310', /* 66 */ + '030011', /* 67 */ + '030110', /* 68 */ + '001103', /* 69 */ + '001301', /* 70 */ + '011003', /* 71 */ + '011300', /* 72 */ + '031001', /* 73 */ + '031100', /* 74 */ + '130100', /* 75 */ + '110003', /* 76 */ + '302000', /* 77 */ + '130001', /* 78 */ + '023000', /* 79 */ + '000131', /* 80 */ + '010031', /* 81 */ + '010130', /* 82 */ + '003101', /* 83 */ + '013001', /* 84 */ + '013100', /* 85 */ + '300101', /* 86 */ + '310001', /* 87 */ + '310100', /* 88 */ + '101030', /* 89 */ + '103010', /* 90 */ + '301010', /* 91 */ + '000032', /* 92 */ + '000230', /* 93 */ + '020030', /* 94 */ + '003002', /* 95 */ + '003200', /* 96 */ + '300002', /* 97 */ + '300200', /* 98 */ + '002030', /* 99 */ + '003020', /* 100*/ + '200030', /* 101*/ + '300020', /* 102*/ + '100301', /* 103*/ + '100103', /* 104*/ + '100121', /* 105*/ + '122000' /*STOP*/ + ); + $this->setStart($start); + $this->setTilde(true); + + // Latches and Shifts + $this->latch = array( + array(null, self::KEYA_CODEB, self::KEYA_CODEC), + array(self::KEYB_CODEA, null, self::KEYB_CODEC), + array(self::KEYC_CODEA, self::KEYC_CODEB, null) + ); + $this->shift = array( + array(null, self::KEYA_SHIFT), + array(self::KEYB_SHIFT, null) + ); + $this->fnc = array( + array(self::KEYA_FNC1, self::KEYA_FNC2, self::KEYA_FNC3, self::KEYA_FNC4), + array(self::KEYB_FNC1, self::KEYB_FNC2, self::KEYB_FNC3, self::KEYB_FNC4), + array(self::KEYC_FNC1, null, null, null) + ); + + // Method available + $this->METHOD = array(CODE128_A => 'A', CODE128_B => 'B', CODE128_C => 'C'); + } + + /** + * Specifies the start code. Can be 'A', 'B', 'C', or null + * - Table A: Capitals + ASCII 0-31 + punct + * - Table B: Capitals + LowerCase + punct + * - Table C: Numbers + * + * If null is specified, the table selection is automatically made. + * The default is null. + * + * @param string $table + */ + public function setStart($table) { + if ($table !== 'A' && $table !== 'B' && $table !== 'C' && $table !== null) { + throw new BCGArgumentException('The starting table must be A, B, C or null.', 'table'); + } + + $this->starting_text = $table; + } + + /** + * Gets the tilde. + * + * @return bool + */ + public function getTilde() { + return $this->tilde; + } + + /** + * Accepts tilde to be process as a special character. + * If true, you can do this: + * - ~~ : to make ONE tilde + * - ~Fx : to insert FCNx. x is equal from 1 to 4. + * + * @param boolean $accept + */ + public function setTilde($accept) { + $this->tilde = (bool)$accept; + } + + /** + * Parses the text before displaying it. + * + * @param mixed $text + */ + public function parse($text) { + $this->setStartFromText($text); + + $this->text = ''; + $seq = ''; + + $currentMode = $this->starting_text; + + // Here, we format correctly what the user gives. + if (!is_array($text)) { + $seq = $this->getSequence($text, $currentMode); + $this->text = $text; + } else { + // This loop checks for UnknownText AND raises an exception if a character is not allowed in a table + reset($text); + while (list($key1, $val1) = each($text)) { // We take each value + if (!is_array($val1)) { // This is not a table + if (is_string($val1)) { // If it's a string, parse as unknown + $seq .= $this->getSequence($val1, $currentMode); + $this->text .= $val1; + } else { + // it's the case of "array(ENCODING, 'text')" + // We got ENCODING in $val1, calling 'each' again will get 'text' in $val2 + list($key2, $val2) = each($text); + $seq .= $this->{'setParse' . $this->METHOD[$val1]}($val2, $currentMode); + $this->text .= $val2; + } + } else { // The method is specified + // $val1[0] = ENCODING + // $val1[1] = 'text' + $value = isset($val1[1]) ? $val1[1] : ''; // If data available + $seq .= $this->{'setParse' . $this->METHOD[$val1[0]]}($value, $currentMode); + $this->text .= $value; + } + } + } + + if ($seq !== '') { + $bitstream = $this->createBinaryStream($this->text, $seq); + $this->setData($bitstream); + } + + $this->addDefaultLabel(); + } + + /** + * Draws the barcode. + * + * @param resource $im + */ + public function draw($im) { + $c = count($this->data); + for ($i = 0; $i < $c; $i++) { + $this->drawChar($im, $this->data[$i], true); + } + + $this->drawChar($im, '1', true); + $this->drawText($im, 0, 0, $this->positionX, $this->thickness); + } + + /** + * Returns the maximal size of a barcode. + * + * @param int $w + * @param int $h + * @return int[] + */ + public function getDimension($w, $h) { + // Contains start + text + checksum + stop + $textlength = count($this->data) * 11; + $endlength = 2; // + final bar + + $w += $textlength + $endlength; + $h += $this->thickness; + return parent::getDimension($w, $h); + } + + /** + * Validates the input. + */ + protected function validate() { + $c = count($this->data); + if ($c === 0) { + throw new BCGParseException('code128', 'No data has been entered.'); + } + + parent::validate(); + } + + /** + * Overloaded method to calculate checksum. + */ + protected function calculateChecksum() { + // Checksum + // First Char (START) + // + Starting with the first data character following the start character, + // take the value of the character (between 0 and 102, inclusive) multiply + // it by its character position (1) and add that to the running checksum. + // Modulated 103 + $this->checksumValue = $this->indcheck[0]; + $c = count($this->indcheck); + for ($i = 1; $i < $c; $i++) { + $this->checksumValue += $this->indcheck[$i] * $i; + } + + $this->checksumValue = $this->checksumValue % 103; + } + + /** + * Overloaded method to display the checksum. + */ + protected function processChecksum() { + if ($this->checksumValue === false) { // Calculate the checksum only once + $this->calculateChecksum(); + } + + if ($this->checksumValue !== false) { + if ($this->lastTable === 'C') { + return (string)$this->checksumValue; + } + + return $this->{'keys' . $this->lastTable}[$this->checksumValue]; + } + + return false; + } + + /** + * Specifies the starting_text table if none has been specified earlier. + * + * @param string $text + */ + private function setStartFromText($text) { + if ($this->starting_text === null) { + // If we have a forced table at the start, we get that one... + if (is_array($text)) { + if (is_array($text[0])) { + // Code like array(array(ENCODING, '')) + $this->starting_text = $this->METHOD[$text[0][0]]; + return; + } else { + if (is_string($text[0])) { + // Code like array('test') (Automatic text) + $text = $text[0]; + } else { + // Code like array(ENCODING, '') + $this->starting_text = $this->METHOD[$text[0]]; + return; + } + } + } + + // At this point, we had an "automatic" table selection... + // If we can get at least 4 numbers, go in C; otherwise go in B. + $tmp = preg_quote($this->keysC, '/'); + $length = strlen($text); + if ($length >= 4 && preg_match('/[' . $tmp . ']/', substr($text, 0, 4))) { + $this->starting_text = 'C'; + } else { + if ($length > 0 && strpos($this->keysB, $text[0]) !== false) { + $this->starting_text = 'B'; + } else { + $this->starting_text = 'A'; + } + } + } + } + + /** + * Extracts the ~ value from the $text at the $pos. + * If the tilde is not ~~, ~F1, ~F2, ~F3, ~F4; an error is raised. + * + * @param string $text + * @param int $pos + * @return string + */ + private static function extractTilde($text, $pos) { + if ($text[$pos] === '~') { + if (isset($text[$pos + 1])) { + // Do we have a tilde? + if ($text[$pos + 1] === '~') { + return '~~'; + } elseif ($text[$pos + 1] === 'F') { + // Do we have a number after? + if (isset($text[$pos + 2])) { + $v = intval($text[$pos + 2]); + if ($v >= 1 && $v <= 4) { + return '~F' . $v; + } else { + throw new BCGParseException('code128', 'Bad ~F. You must provide a number from 1 to 4.'); + } + } else { + throw new BCGParseException('code128', 'Bad ~F. You must provide a number from 1 to 4.'); + } + } else { + throw new BCGParseException('code128', 'Wrong code after the ~.'); + } + } else { + throw new BCGParseException('code128', 'Wrong code after the ~.'); + } + } else { + throw new BCGParseException('code128', 'There is no ~ at this location.'); + } + } + + /** + * Gets the "dotted" sequence for the $text based on the $currentMode. + * There is also a check if we use the special tilde ~ + * + * @param string $text + * @param string $currentMode + * @return string + */ + private function getSequenceParsed($text, $currentMode) { + if ($this->tilde) { + $sequence = ''; + $previousPos = 0; + while (($pos = strpos($text, '~', $previousPos)) !== false) { + $tildeData = self::extractTilde($text, $pos); + + $simpleTilde = ($tildeData === '~~'); + if ($simpleTilde && $currentMode !== 'B') { + throw new BCGParseException('code128', 'The Table ' . $currentMode . ' doesn\'t contain the character ~.'); + } + + // At this point, we know we have ~Fx + if ($tildeData !== '~F1' && $currentMode === 'C') { + // The mode C doesn't support ~F2, ~F3, ~F4 + throw new BCGParseException('code128', 'The Table C doesn\'t contain the function ' . $tildeData . '.'); + } + + $length = $pos - $previousPos; + if ($currentMode === 'C') { + if ($length % 2 === 1) { + throw new BCGParseException('code128', 'The text "' . $text . '" must have an even number of character to be encoded in Table C.'); + } + } + + $sequence .= str_repeat('.', $length); + $sequence .= '.'; + $sequence .= (!$simpleTilde) ? 'F' : ''; + $previousPos = $pos + strlen($tildeData); + } + + // Flushing + $length = strlen($text) - $previousPos; + if ($currentMode === 'C') { + if ($length % 2 === 1) { + throw new BCGParseException('code128', 'The text "' . $text . '" must have an even number of character to be encoded in Table C.'); + } + } + + $sequence .= str_repeat('.', $length); + + return $sequence; + } else { + return str_repeat('.', strlen($text)); + } + } + + /** + * Parses the text and returns the appropriate sequence for the Table A. + * + * @param string $text + * @param string $currentMode + * @return string + */ + private function setParseA($text, &$currentMode) { + $tmp = preg_quote($this->keysA, '/'); + + // If we accept the ~ for special character, we must allow it. + if ($this->tilde) { + $tmp .= '~'; + } + + $match = array(); + if (preg_match('/[^' . $tmp . ']/', $text, $match) === 1) { + // We found something not allowed + throw new BCGParseException('code128', 'The text "' . $text . '" can\'t be parsed with the Table A. The character "' . $match[0] . '" is not allowed.'); + } else { + $latch = ($currentMode === 'A') ? '' : '0'; + $currentMode = 'A'; + + return $latch . $this->getSequenceParsed($text, $currentMode); + } + } + + /** + * Parses the text and returns the appropriate sequence for the Table B. + * + * @param string $text + * @param string $currentMode + * @return string + */ + private function setParseB($text, &$currentMode) { + $tmp = preg_quote($this->keysB, '/'); + + $match = array(); + if (preg_match('/[^' . $tmp . ']/', $text, $match) === 1) { + // We found something not allowed + throw new BCGParseException('code128', 'The text "' . $text . '" can\'t be parsed with the Table B. The character "' . $match[0] . '" is not allowed.'); + } else { + $latch = ($currentMode === 'B') ? '' : '1'; + $currentMode = 'B'; + + return $latch . $this->getSequenceParsed($text, $currentMode); + } + } + + /** + * Parses the text and returns the appropriate sequence for the Table C. + * + * @param string $text + * @param string $currentMode + * @return string + */ + private function setParseC($text, &$currentMode) { + $tmp = preg_quote($this->keysC, '/'); + + // If we accept the ~ for special character, we must allow it. + if ($this->tilde) { + $tmp .= '~F'; + } + + $match = array(); + if (preg_match('/[^' . $tmp . ']/', $text, $match) === 1) { + // We found something not allowed + throw new BCGParseException('code128', 'The text "' . $text . '" can\'t be parsed with the Table C. The character "' . $match[0] . '" is not allowed.'); + } else { + $latch = ($currentMode === 'C') ? '' : '2'; + $currentMode = 'C'; + + return $latch . $this->getSequenceParsed($text, $currentMode); + } + } + + /** + * Depending on the $text, it will return the correct + * sequence to encode the text. + * + * @param string $text + * @param string $starting_text + * @return string + */ + private function getSequence($text, &$starting_text) { + $e = 10000; + $latLen = array( + array(0, 1, 1), + array(1, 0, 1), + array(1, 1, 0) + ); + $shftLen = array( + array($e, 1, $e), + array(1, $e, $e), + array($e, $e, $e) + ); + $charSiz = array(2, 2, 1); + + $startA = $e; + $startB = $e; + $startC = $e; + if ($starting_text === 'A') { $startA = 0; } + if ($starting_text === 'B') { $startB = 0; } + if ($starting_text === 'C') { $startC = 0; } + + $curLen = array($startA, $startB, $startC); + $curSeq = array(null, null, null); + + $nextNumber = false; + + $x = 0; + $xLen = strlen($text); + for ($x = 0; $x < $xLen; $x++) { + $input = $text[$x]; + + // 1. + for ($i = 0; $i < 3; $i++) { + for ($j = 0; $j < 3; $j++) { + if (($curLen[$i] + $latLen[$i][$j]) < $curLen[$j]) { + $curLen[$j] = $curLen[$i] + $latLen[$i][$j]; + $curSeq[$j] = $curSeq[$i] . $j; + } + } + } + + // 2. + $nxtLen = array($e, $e, $e); + $nxtSeq = array(); + + // 3. + $flag = false; + $posArray = array(); + + // Special case, we do have a tilde and we process them + if ($this->tilde && $input === '~') { + $tildeData = self::extractTilde($text, $x); + + if ($tildeData === '~~') { + // We simply skip a tilde + $posArray[] = 1; + $x++; + } elseif (substr($tildeData, 0, 2) === '~F') { + $v = intval($tildeData[2]); + $posArray[] = 0; + $posArray[] = 1; + if ($v === 1) { + $posArray[] = 2; + } + + $x += 2; + $flag = true; + } + } else { + $pos = strpos($this->keysA, $input); + if ($pos !== false) { + $posArray[] = 0; + } + + $pos = strpos($this->keysB, $input); + if ($pos !== false) { + $posArray[] = 1; + } + + // Do we have the next char a number?? OR a ~F1 + $pos = strpos($this->keysC, $input); + if ($nextNumber || ($pos !== false && isset($text[$x + 1]) && strpos($this->keysC, $text[$x + 1]) !== false)) { + $nextNumber = !$nextNumber; + $posArray[] = 2; + } + } + + $c = count($posArray); + for ($i = 0; $i < $c; $i++) { + if (($curLen[$posArray[$i]] + $charSiz[$posArray[$i]]) < $nxtLen[$posArray[$i]]) { + $nxtLen[$posArray[$i]] = $curLen[$posArray[$i]] + $charSiz[$posArray[$i]]; + $nxtSeq[$posArray[$i]] = $curSeq[$posArray[$i]] . '.'; + } + + for ($j = 0; $j < 2; $j++) { + if ($j === $posArray[$i]) { continue; } + if (($curLen[$j] + $shftLen[$j][$posArray[$i]] + $charSiz[$posArray[$i]]) < $nxtLen[$j]) { + $nxtLen[$j] = $curLen[$j] + $shftLen[$j][$posArray[$i]] + $charSiz[$posArray[$i]]; + $nxtSeq[$j] = $curSeq[$j] . chr($posArray[$i] + 65) . '.'; + } + } + } + + if ($c === 0) { + // We found an unsuported character + throw new BCGParseException('code128', 'Character ' . $input . ' not supported.'); + } + + if ($flag) { + for ($i = 0; $i < 5; $i++) { + if (isset($nxtSeq[$i])) { + $nxtSeq[$i] .= 'F'; + } + } + } + + // 4. + for ($i = 0; $i < 3; $i++) { + $curLen[$i] = $nxtLen[$i]; + if (isset($nxtSeq[$i])) { + $curSeq[$i] = $nxtSeq[$i]; + } + } + } + + // Every curLen under $e is possible but we take the smallest + $m = $e; + $k = -1; + for ($i = 0; $i < 3; $i++) { + if ($curLen[$i] < $m) { + $k = $i; + $m = $curLen[$i]; + } + } + + if ($k === -1) { + return ''; + } + + return $curSeq[$k]; + } + + /** + * Depending on the sequence $seq given (returned from getSequence()), + * this method will return the code stream in an array. Each char will be a + * string of bit based on the Code 128. + * + * Each letter from the sequence represents bits. + * + * 0 to 2 are latches + * A to B are Shift + Letter + * . is a char in the current encoding + * + * @param string $text + * @param string $seq + * @return string[][] + */ + private function createBinaryStream($text, $seq) { + $c = strlen($seq); + + $data = array(); // code stream + $indcheck = array(); // index for checksum + + $currentEncoding = 0; + if ($this->starting_text === 'A') { + $currentEncoding = 0; + $indcheck[] = self::KEY_STARTA; + $this->lastTable = 'A'; + } elseif ($this->starting_text === 'B') { + $currentEncoding = 1; + $indcheck[] = self::KEY_STARTB; + $this->lastTable = 'B'; + } elseif ($this->starting_text === 'C') { + $currentEncoding = 2; + $indcheck[] = self::KEY_STARTC; + $this->lastTable = 'C'; + } + + $data[] = $this->code[103 + $currentEncoding]; + + $temporaryEncoding = -1; + for ($i = 0, $counter = 0; $i < $c; $i++) { + $input = $seq[$i]; + $inputI = intval($input); + if ($input === '.') { + $this->encodeChar($data, $currentEncoding, $seq, $text, $i, $counter, $indcheck); + if ($temporaryEncoding !== -1) { + $currentEncoding = $temporaryEncoding; + $temporaryEncoding = -1; + } + } elseif ($input >= 'A' && $input <= 'B') { + // We shift + $encoding = ord($input) - 65; + $shift = $this->shift[$currentEncoding][$encoding]; + $indcheck[] = $shift; + $data[] = $this->code[$shift]; + if ($temporaryEncoding === -1) { + $temporaryEncoding = $currentEncoding; + } + + $currentEncoding = $encoding; + } elseif ($inputI >= 0 && $inputI < 3) { + $temporaryEncoding = -1; + + // We latch + $latch = $this->latch[$currentEncoding][$inputI]; + if ($latch !== null) { + $indcheck[] = $latch; + $this->lastTable = chr(65 + $inputI); + $data[] = $this->code[$latch]; + $currentEncoding = $inputI; + } + } + } + + return array($indcheck, $data); + } + + /** + * Encodes characters, base on its encoding and sequence + * + * @param int[] $data + * @param int $encoding + * @param string $seq + * @param string $text + * @param int $i + * @param int $counter + * @param int[] $indcheck + */ + private function encodeChar(&$data, $encoding, $seq, $text, &$i, &$counter, &$indcheck) { + if (isset($seq[$i + 1]) && $seq[$i + 1] === 'F') { + // We have a flag !! + if ($text[$counter + 1] === 'F') { + $number = $text[$counter + 2]; + $fnc = $this->fnc[$encoding][$number - 1]; + $indcheck[] = $fnc; + $data[] = $this->code[$fnc]; + + // Skip F + number + $counter += 2; + } else { + // Not supposed + } + + $i++; + } else { + if ($encoding === 2) { + // We take 2 numbers in the same time + $code = (int)substr($text, $counter, 2); + $indcheck[] = $code; + $data[] = $this->code[$code]; + $counter++; + $i++; + } else { + $keys = ($encoding === 0) ? $this->keysA : $this->keysB; + $pos = strpos($keys, $text[$counter]); + $indcheck[] = $pos; + $data[] = $this->code[$pos]; + } + } + + $counter++; + } + + /** + * Saves data into the classes. + * + * This method will save data, calculate real column number + * (if -1 was selected), the real error level (if -1 was + * selected)... It will add Padding to the end and generate + * the error codes. + * + * @param array $data + */ + private function setData($data) { + $this->indcheck = $data[0]; + $this->data = $data[1]; + $this->calculateChecksum(); + $this->data[] = $this->code[$this->checksumValue]; + $this->data[] = $this->code[self::KEY_STOP]; + } +} +?> \ No newline at end of file diff --git a/application/libraries/barcodegen/class/BCGcode39.barcode.php b/application/libraries/barcodegen/class/BCGcode39.barcode.php new file mode 100755 index 000000000..6a77c260a --- /dev/null +++ b/application/libraries/barcodegen/class/BCGcode39.barcode.php @@ -0,0 +1,193 @@ +starting = $this->ending = 43; + $this->keys = array('0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '-', '.', ' ', '$', '/', '+', '%', '*'); + $this->code = array( // 0 added to add an extra space + '0001101000', /* 0 */ + '1001000010', /* 1 */ + '0011000010', /* 2 */ + '1011000000', /* 3 */ + '0001100010', /* 4 */ + '1001100000', /* 5 */ + '0011100000', /* 6 */ + '0001001010', /* 7 */ + '1001001000', /* 8 */ + '0011001000', /* 9 */ + '1000010010', /* A */ + '0010010010', /* B */ + '1010010000', /* C */ + '0000110010', /* D */ + '1000110000', /* E */ + '0010110000', /* F */ + '0000011010', /* G */ + '1000011000', /* H */ + '0010011000', /* I */ + '0000111000', /* J */ + '1000000110', /* K */ + '0010000110', /* L */ + '1010000100', /* M */ + '0000100110', /* N */ + '1000100100', /* O */ + '0010100100', /* P */ + '0000001110', /* Q */ + '1000001100', /* R */ + '0010001100', /* S */ + '0000101100', /* T */ + '1100000010', /* U */ + '0110000010', /* V */ + '1110000000', /* W */ + '0100100010', /* X */ + '1100100000', /* Y */ + '0110100000', /* Z */ + '0100001010', /* - */ + '1100001000', /* . */ + '0110001000', /* */ + '0101010000', /* $ */ + '0101000100', /* / */ + '0100010100', /* + */ + '0001010100', /* % */ + '0100101000' /* * */ + ); + + $this->setChecksum(false); + } + + /** + * Sets if we display the checksum. + * + * @param bool $checksum + */ + public function setChecksum($checksum) { + $this->checksum = (bool)$checksum; + } + + /** + * Parses the text before displaying it. + * + * @param mixed $text + */ + public function parse($text) { + parent::parse(strtoupper($text)); // Only Capital Letters are Allowed + } + + /** + * Draws the barcode. + * + * @param resource $im + */ + public function draw($im) { + // Starting * + $this->drawChar($im, $this->code[$this->starting], true); + + // Chars + $c = strlen($this->text); + for ($i = 0; $i < $c; $i++) { + $this->drawChar($im, $this->findCode($this->text[$i]), true); + } + + // Checksum (rarely used) + if ($this->checksum === true) { + $this->calculateChecksum(); + $this->drawChar($im, $this->code[$this->checksumValue % 43], true); + } + + // Ending * + $this->drawChar($im, $this->code[$this->ending], true); + $this->drawText($im, 0, 0, $this->positionX, $this->thickness); + } + + /** + * Returns the maximal size of a barcode. + * + * @param int $w + * @param int $h + * @return int[] + */ + public function getDimension($w, $h) { + $textlength = 13 * strlen($this->text); + $startlength = 13; + $checksumlength = 0; + if ($this->checksum === true) { + $checksumlength = 13; + } + + $endlength = 13; + + $w += $startlength + $textlength + $checksumlength + $endlength; + $h += $this->thickness; + return parent::getDimension($w, $h); + } + + /** + * Validates the input. + */ + protected function validate() { + $c = strlen($this->text); + if ($c === 0) { + throw new BCGParseException('code39', 'No data has been entered.'); + } + + // Checking if all chars are allowed + for ($i = 0; $i < $c; $i++) { + if (array_search($this->text[$i], $this->keys) === false) { + throw new BCGParseException('code39', 'The character \'' . $this->text[$i] . '\' is not allowed.'); + } + } + + if (strpos($this->text, '*') !== false) { + throw new BCGParseException('code39', 'The character \'*\' is not allowed.'); + } + + parent::validate(); + } + + /** + * Overloaded method to calculate checksum. + */ + protected function calculateChecksum() { + $this->checksumValue = 0; + $c = strlen($this->text); + for ($i = 0; $i < $c; $i++) { + $this->checksumValue += $this->findIndex($this->text[$i]); + } + + $this->checksumValue = $this->checksumValue % 43; + } + + /** + * Overloaded method to display the checksum. + */ + protected function processChecksum() { + if ($this->checksumValue === false) { // Calculate the checksum only once + $this->calculateChecksum(); + } + + if ($this->checksumValue !== false) { + return $this->keys[$this->checksumValue]; + } + + return false; + } +} +?> \ No newline at end of file diff --git a/application/libraries/barcodegen/class/BCGcode39extended.barcode.php b/application/libraries/barcodegen/class/BCGcode39extended.barcode.php new file mode 100755 index 000000000..67d991588 --- /dev/null +++ b/application/libraries/barcodegen/class/BCGcode39extended.barcode.php @@ -0,0 +1,208 @@ +keys[self::EXTENDED_1] = '($)'; + $this->keys[self::EXTENDED_2] = '(/)'; + $this->keys[self::EXTENDED_3] = '(+)'; + $this->keys[self::EXTENDED_4] = '(%)'; + } + + /** + * Parses the text before displaying it. + * + * @param mixed $text + */ + public function parse($text) { + $this->text = $text; + + $data = array(); + $indcheck = array(); + + $c = strlen($this->text); + for ($i = 0; $i < $c; $i++) { + $pos = array_search($this->text[$i], $this->keys); + if ($pos === false) { + // Search in extended? + $extended = self::getExtendedVersion($this->text[$i]); + if ($extended === false) { + throw new BCGParseException('code39extended', 'The character \'' . $this->text[$i] . '\' is not allowed.'); + } else { + $extc = strlen($extended); + for ($j = 0; $j < $extc; $j++) { + $v = $extended[$j]; + if ($v === '$') { + $indcheck[] = self::EXTENDED_1; + $data[] = $this->code[self::EXTENDED_1]; + } elseif ($v === '%') { + $indcheck[] = self::EXTENDED_2; + $data[] = $this->code[self::EXTENDED_2]; + } elseif ($v === '/') { + $indcheck[] = self::EXTENDED_3; + $data[] = $this->code[self::EXTENDED_3]; + } elseif ($v === '+') { + $indcheck[] = self::EXTENDED_4; + $data[] = $this->code[self::EXTENDED_4]; + } else { + $pos2 = array_search($v, $this->keys); + $indcheck[] = $pos2; + $data[] = $this->code[$pos2]; + } + } + } + } else { + $indcheck[] = $pos; + $data[] = $this->code[$pos]; + } + } + + $this->setData(array($indcheck, $data)); + $this->addDefaultLabel(); + } + + /** + * Draws the barcode. + * + * @param resource $im + */ + public function draw($im) { + // Starting * + $this->drawChar($im, $this->code[$this->starting], true); + $c = count($this->data); + for ($i = 0; $i < $c; $i++) { + $this->drawChar($im, $this->data[$i], true); + } + + // Checksum (rarely used) + if ($this->checksum === true) { + $this->drawChar($im, $this->code[$this->checksumValue % 43], true); + } + + // Ending * + $this->drawChar($im, $this->code[$this->ending], true); + $this->drawText($im, 0, 0, $this->positionX, $this->thickness); + } + + /** + * Returns the maximal size of a barcode. + * + * @param int $w + * @param int $h + * @return int[] + */ + public function getDimension($w, $h) { + $textlength = 13 * count($this->data); + $startlength = 13; + $checksumlength = 0; + if ($this->checksum === true) { + $checksumlength = 13; + } + + $endlength = 13; + + $w += $startlength + $textlength + $checksumlength + $endlength; + $h += $this->thickness; + return BCGBarcode1D::getDimension($w, $h); + } + + /** + * Validates the input. + */ + protected function validate() { + $c = count($this->data); + if ($c === 0) { + throw new BCGParseException('code39extended', 'No data has been entered.'); + } + + parent::validate(); + } + + /** + * Overloaded method to calculate checksum. + */ + protected function calculateChecksum() { + $this->checksumValue = 0; + $c = count($this->indcheck); + for ($i = 0; $i < $c; $i++) { + $this->checksumValue += $this->indcheck[$i]; + } + + $this->checksumValue = $this->checksumValue % 43; + } + + /** + * Saves data into the classes. + * + * This method will save data, calculate real column number + * (if -1 was selected), the real error level (if -1 was + * selected)... It will add Padding to the end and generate + * the error codes. + * + * @param array $data + */ + private function setData($data) { + $this->indcheck = $data[0]; + $this->data = $data[1]; + $this->calculateChecksum(); + } + + /** + * Returns the extended reprensentation of the character. + * + * @param string $char + * @return string + */ + private static function getExtendedVersion($char) { + $o = ord($char); + if ($o === 0) { + return '%U'; + } elseif ($o >= 1 && $o <= 26) { + return '$' . chr($o + 64); + } elseif (($o >= 33 && $o <= 44) || $o === 47 || $o === 48) { + return '/' . chr($o + 32); + } elseif ($o >= 97 && $o <= 122) { + return '+' . chr($o - 32); + } elseif ($o >= 27 && $o <= 31) { + return '%' . chr($o + 38); + } elseif ($o >= 59 && $o <= 63) { + return '%' . chr($o + 11); + } elseif ($o >= 91 && $o <= 95) { + return '%' . chr($o - 16); + } elseif ($o >= 123 && $o <= 127) { + return '%' . chr($o - 43); + } elseif ($o === 64) { + return '%V'; + } elseif ($o === 96) { + return '%W'; + } elseif ($o > 127) { + return false; + } else { + return $char; + } + } +} +?> \ No newline at end of file diff --git a/application/libraries/barcodegen/class/BCGcode93.barcode.php b/application/libraries/barcodegen/class/BCGcode93.barcode.php new file mode 100755 index 000000000..7d9397c4b --- /dev/null +++ b/application/libraries/barcodegen/class/BCGcode93.barcode.php @@ -0,0 +1,301 @@ +starting = $this->ending = 47; /* * */ + $this->keys = array('0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '-', '.', ' ', '$', '/', '+', '%', '($)', '(%)', '(/)', '(+)', '(*)'); + $this->code = array( + '020001', /* 0 */ + '000102', /* 1 */ + '000201', /* 2 */ + '000300', /* 3 */ + '010002', /* 4 */ + '010101', /* 5 */ + '010200', /* 6 */ + '000003', /* 7 */ + '020100', /* 8 */ + '030000', /* 9 */ + '100002', /* A */ + '100101', /* B */ + '100200', /* C */ + '110001', /* D */ + '110100', /* E */ + '120000', /* F */ + '001002', /* G */ + '001101', /* H */ + '001200', /* I */ + '011001', /* J */ + '021000', /* K */ + '000012', /* L */ + '000111', /* M */ + '000210', /* N */ + '010011', /* O */ + '020010', /* P */ + '101001', /* Q */ + '101100', /* R */ + '100011', /* S */ + '100110', /* T */ + '110010', /* U */ + '111000', /* V */ + '001011', /* W */ + '001110', /* X */ + '011010', /* Y */ + '012000', /* Z */ + '010020', /* - */ + '200001', /* . */ + '200100', /* */ + '210000', /* $ */ + '001020', /* / */ + '002010', /* + */ + '100020', /* % */ + '010110', /*($)*/ + '201000', /*(%)*/ + '200010', /*(/)*/ + '011100', /*(+)*/ + '000030' /*(*)*/ + ); + } + + /** + * Parses the text before displaying it. + * + * @param mixed $text + */ + public function parse($text) { + $this->text = $text; + + $data = array(); + $indcheck = array(); + + $c = strlen($this->text); + for ($i = 0; $i < $c; $i++) { + $pos = array_search($this->text[$i], $this->keys); + if ($pos === false) { + // Search in extended? + $extended = self::getExtendedVersion($this->text[$i]); + if ($extended === false) { + throw new BCGParseException('code93', 'The character \'' . $this->text[$i] . '\' is not allowed.'); + } else { + $extc = strlen($extended); + for ($j = 0; $j < $extc; $j++) { + $v = $extended[$j]; + if ($v === '$') { + $indcheck[] = self::EXTENDED_1; + $data[] = $this->code[self::EXTENDED_1]; + } elseif ($v === '%') { + $indcheck[] = self::EXTENDED_2; + $data[] = $this->code[self::EXTENDED_2]; + } elseif ($v === '/') { + $indcheck[] = self::EXTENDED_3; + $data[] = $this->code[self::EXTENDED_3]; + } elseif ($v === '+') { + $indcheck[] = self::EXTENDED_4; + $data[] = $this->code[self::EXTENDED_4]; + } else { + $pos2 = array_search($v, $this->keys); + $indcheck[] = $pos2; + $data[] = $this->code[$pos2]; + } + } + } + } else { + $indcheck[] = $pos; + $data[] = $this->code[$pos]; + } + } + + $this->setData(array($indcheck, $data)); + $this->addDefaultLabel(); + } + + /** + * Draws the barcode. + * + * @param resource $im + */ + public function draw($im) { + // Starting * + $this->drawChar($im, $this->code[$this->starting], true); + $c = count($this->data); + for ($i = 0; $i < $c; $i++) { + $this->drawChar($im, $this->data[$i], true); + } + + // Checksum + $c = count($this->checksumValue); + for ($i = 0; $i < $c; $i++) { + $this->drawChar($im, $this->code[$this->checksumValue[$i]], true); + } + + // Ending * + $this->drawChar($im, $this->code[$this->ending], true); + + // Draw a Final Bar + $this->drawChar($im, '0', true); + $this->drawText($im, 0, 0, $this->positionX, $this->thickness); + } + + /** + * Returns the maximal size of a barcode. + * + * @param int $w + * @param int $h + * @return int[] + */ + public function getDimension($w, $h) { + $startlength = 9; + $textlength = 9 * count($this->data); + $checksumlength = 2 * 9; + $endlength = 9 + 1; // + final bar + + $w += $startlength + $textlength + $checksumlength + $endlength; + $h += $this->thickness; + return parent::getDimension($w, $h); + } + + /** + * Validates the input. + */ + protected function validate() { + $c = count($this->data); + if ($c === 0) { + throw new BCGParseException('code93', 'No data has been entered.'); + } + + parent::validate(); + } + + /** + * Overloaded method to calculate checksum. + */ + protected function calculateChecksum() { + // Checksum + // First CheckSUM "C" + // The "C" checksum character is the modulo 47 remainder of the sum of the weighted + // value of the data characters. The weighting value starts at "1" for the right-most + // data character, 2 for the second to last, 3 for the third-to-last, and so on up to 20. + // After 20, the sequence wraps around back to 1. + + // Second CheckSUM "K" + // Same as CheckSUM "C" but we count the CheckSum "C" at the end + // After 15, the sequence wraps around back to 1. + $sequence_multiplier = array(20, 15); + $this->checksumValue = array(); + $indcheck = $this->indcheck; + for ($z = 0; $z < 2; $z++) { + $checksum = 0; + for ($i = count($indcheck), $j = 0; $i > 0; $i--, $j++) { + $multiplier = $i % $sequence_multiplier[$z]; + if ($multiplier === 0) { + $multiplier = $sequence_multiplier[$z]; + } + + $checksum += $indcheck[$j] * $multiplier; + } + + $this->checksumValue[$z] = $checksum % 47; + $indcheck[] = $this->checksumValue[$z]; + } + } + + /** + * Overloaded method to display the checksum. + */ + protected function processChecksum() { + if ($this->checksumValue === false) { // Calculate the checksum only once + $this->calculateChecksum(); + } + + if ($this->checksumValue !== false) { + $ret = ''; + $c = count($this->checksumValue); + for ($i = 0; $i < $c; $i++) { + $ret .= $this->keys[$this->checksumValue[$i]]; + } + + return $ret; + } + + return false; + } + + /** + * Saves data into the classes. + * + * This method will save data, calculate real column number + * (if -1 was selected), the real error level (if -1 was + * selected)... It will add Padding to the end and generate + * the error codes. + * + * @param array $data + */ + private function setData($data) { + $this->indcheck = $data[0]; + $this->data = $data[1]; + $this->calculateChecksum(); + } + + /** + * Returns the extended reprensentation of the character. + * + * @param string $char + * @return string + */ + private static function getExtendedVersion($char) { + $o = ord($char); + if ($o === 0) { + return '%U'; + } elseif ($o >= 1 && $o <= 26) { + return '$' . chr($o + 64); + } elseif (($o >= 33 && $o <= 44) || $o === 47 || $o === 48) { + return '/' . chr($o + 32); + } elseif ($o >= 97 && $o <= 122) { + return '+' . chr($o - 32); + } elseif ($o >= 27 && $o <= 31) { + return '%' . chr($o + 38); + } elseif ($o >= 59 && $o <= 63) { + return '%' . chr($o + 11); + } elseif ($o >= 91 && $o <= 95) { + return '%' . chr($o - 16); + } elseif ($o >= 123 && $o <= 127) { + return '%' . chr($o - 43); + } elseif ($o === 64) { + return '%V'; + } elseif ($o === 96) { + return '%W'; + } elseif ($o > 127) { + return false; + } else { + return $char; + } + } +} +?> \ No newline at end of file diff --git a/application/libraries/barcodegen/class/BCGean13.barcode.php b/application/libraries/barcodegen/class/BCGean13.barcode.php new file mode 100755 index 000000000..3cf6d7175 --- /dev/null +++ b/application/libraries/barcodegen/class/BCGean13.barcode.php @@ -0,0 +1,322 @@ +keys = array('0', '1', '2', '3', '4', '5', '6', '7', '8', '9'); + + // Left-Hand Odd Parity starting with a space + // Left-Hand Even Parity is the inverse (0=0012) starting with a space + // Right-Hand is the same of Left-Hand starting with a bar + $this->code = array( + '2100', /* 0 */ + '1110', /* 1 */ + '1011', /* 2 */ + '0300', /* 3 */ + '0021', /* 4 */ + '0120', /* 5 */ + '0003', /* 6 */ + '0201', /* 7 */ + '0102', /* 8 */ + '2001' /* 9 */ + ); + + // Parity, 0=Odd, 1=Even for manufacturer code. Depending on 1st System Digit + $this->codeParity = array( + array(0, 0, 0, 0, 0), /* 0 */ + array(0, 1, 0, 1, 1), /* 1 */ + array(0, 1, 1, 0, 1), /* 2 */ + array(0, 1, 1, 1, 0), /* 3 */ + array(1, 0, 0, 1, 1), /* 4 */ + array(1, 1, 0, 0, 1), /* 5 */ + array(1, 1, 1, 0, 0), /* 6 */ + array(1, 0, 1, 0, 1), /* 7 */ + array(1, 0, 1, 1, 0), /* 8 */ + array(1, 1, 0, 1, 0) /* 9 */ + ); + + $this->alignDefaultLabel(true); + } + + public function alignDefaultLabel($align) { + $this->alignLabel = (bool)$align; + } + + /** + * Draws the barcode. + * + * @param resource $im + */ + public function draw($im) { + $this->drawBars($im); + $this->drawText($im, 0, 0, $this->positionX, $this->thickness); + + if ($this->isDefaultEanLabelEnabled()) { + $dimension = $this->labelCenter1->getDimension(); + $this->drawExtendedBars($im, $dimension[1] - 2); + } + } + + /** + * Returns the maximal size of a barcode. + * + * @param int $w + * @param int $h + * @return int[] + */ + public function getDimension($w, $h) { + $startlength = 3; + $centerlength = 5; + $textlength = 12 * 7; + $endlength = 3; + + $w += $startlength + $centerlength + $textlength + $endlength; + $h += $this->thickness; + return parent::getDimension($w, $h); + } + + /** + * Adds the default label. + */ + protected function addDefaultLabel() { + if ($this->isDefaultEanLabelEnabled()) { + $this->processChecksum(); + $label = $this->getLabel(); + $font = $this->font; + + $this->labelLeft = new BCGLabel(substr($label, 0, 1), $font, BCGLabel::POSITION_LEFT, BCGLabel::ALIGN_BOTTOM); + $this->labelLeft->setSpacing(4 * $this->scale); + + $this->labelCenter1 = new BCGLabel(substr($label, 1, 6), $font, BCGLabel::POSITION_BOTTOM, BCGLabel::ALIGN_LEFT); + $labelCenter1Dimension = $this->labelCenter1->getDimension(); + $this->labelCenter1->setOffset(($this->scale * 44 - $labelCenter1Dimension[0]) / 2 + $this->scale * 2); + + $this->labelCenter2 = new BCGLabel(substr($label, 7, 5) . $this->keys[$this->checksumValue], $font, BCGLabel::POSITION_BOTTOM, BCGLabel::ALIGN_LEFT); + $this->labelCenter2->setOffset(($this->scale * 44 - $labelCenter1Dimension[0]) / 2 + $this->scale * 48); + + if ($this->alignLabel) { + $labelDimension = $this->labelCenter1->getDimension(); + $this->labelLeft->setOffset($labelDimension[1]); + } else { + $labelDimension = $this->labelLeft->getDimension(); + $this->labelLeft->setOffset($labelDimension[1] / 2); + } + + $this->addLabel($this->labelLeft); + $this->addLabel($this->labelCenter1); + $this->addLabel($this->labelCenter2); + } + } + + /** + * Checks if the default ean label is enabled. + * + * @return bool + */ + protected function isDefaultEanLabelEnabled() { + $label = $this->getLabel(); + $font = $this->font; + return $label !== null && $label !== '' && $font !== null && $this->defaultLabel !== null; + } + + /** + * Validates the input. + */ + protected function validate() { + $c = strlen($this->text); + if ($c === 0) { + throw new BCGParseException('ean13', 'No data has been entered.'); + } + + $this->checkCharsAllowed(); + $this->checkCorrectLength(); + + parent::validate(); + } + + /** + * Check chars allowed. + */ + protected function checkCharsAllowed() { + // Checking if all chars are allowed + $c = strlen($this->text); + for ($i = 0; $i < $c; $i++) { + if (array_search($this->text[$i], $this->keys) === false) { + throw new BCGParseException('ean13', 'The character \'' . $this->text[$i] . '\' is not allowed.'); + } + } + } + + /** + * Check correct length. + */ + protected function checkCorrectLength() { + // If we have 13 chars, just flush the last one without throwing anything + $c = strlen($this->text); + if ($c === 13) { + $this->text = substr($this->text, 0, 12); + } elseif ($c !== 12) { + throw new BCGParseException('ean13', 'Must contain 12 digits, the 13th digit is automatically added.'); + } + } + + /** + * Overloaded method to calculate checksum. + */ + protected function calculateChecksum() { + // Calculating Checksum + // Consider the right-most digit of the message to be in an "odd" position, + // and assign odd/even to each character moving from right to left + // Odd Position = 3, Even Position = 1 + // Multiply it by the number + // Add all of that and do 10-(?mod10) + $odd = true; + $this->checksumValue = 0; + $c = strlen($this->text); + for ($i = $c; $i > 0; $i--) { + if ($odd === true) { + $multiplier = 3; + $odd = false; + } else { + $multiplier = 1; + $odd = true; + } + + if (!isset($this->keys[$this->text[$i - 1]])) { + return; + } + + $this->checksumValue += $this->keys[$this->text[$i - 1]] * $multiplier; + } + + $this->checksumValue = (10 - $this->checksumValue % 10) % 10; + } + + /** + * Overloaded method to display the checksum. + */ + protected function processChecksum() { + if ($this->checksumValue === false) { // Calculate the checksum only once + $this->calculateChecksum(); + } + + if ($this->checksumValue !== false) { + return $this->keys[$this->checksumValue]; + } + + return false; + } + + /** + * Draws the bars + * + * @param resource $im + */ + protected function drawBars($im) { + // Checksum + $this->calculateChecksum(); + $temp_text = $this->text . $this->keys[$this->checksumValue]; + + // Starting Code + $this->drawChar($im, '000', true); + + // Draw Second Code + $this->drawChar($im, $this->findCode($temp_text[1]), false); + + // Draw Manufacturer Code + for ($i = 0; $i < 5; $i++) { + $this->drawChar($im, self::inverse($this->findCode($temp_text[$i + 2]), $this->codeParity[(int)$temp_text[0]][$i]), false); + } + + // Draw Center Guard Bar + $this->drawChar($im, '00000', false); + + // Draw Product Code + for ($i = 7; $i < 13; $i++) { + $this->drawChar($im, $this->findCode($temp_text[$i]), true); + } + + // Draw Right Guard Bar + $this->drawChar($im, '000', true); + } + + /** + * Draws the extended bars on the image. + * + * @param resource $im + * @param int $plus + */ + protected function drawExtendedBars($im, $plus) { + $rememberX = $this->positionX; + $rememberH = $this->thickness; + + // We increase the bars + $this->thickness = $this->thickness + intval($plus / $this->scale); + $this->positionX = 0; + $this->drawSingleBar($im, BCGBarcode::COLOR_FG); + $this->positionX += 2; + $this->drawSingleBar($im, BCGBarcode::COLOR_FG); + + // Center Guard Bar + $this->positionX += 44; + $this->drawSingleBar($im, BCGBarcode::COLOR_FG); + $this->positionX += 2; + $this->drawSingleBar($im, BCGBarcode::COLOR_FG); + + // Last Bars + $this->positionX += 44; + $this->drawSingleBar($im, BCGBarcode::COLOR_FG); + $this->positionX += 2; + $this->drawSingleBar($im, BCGBarcode::COLOR_FG); + + $this->positionX = $rememberX; + $this->thickness = $rememberH; + } + + /** + * Inverses the string when the $inverse parameter is equal to 1. + * + * @param string $text + * @param int $inverse + * @return string + */ + private static function inverse($text, $inverse = 1) { + if ($inverse === 1) { + $text = strrev($text); + } + + return $text; + } +} +?> \ No newline at end of file diff --git a/application/libraries/barcodegen/class/BCGean8.barcode.php b/application/libraries/barcodegen/class/BCGean8.barcode.php new file mode 100755 index 000000000..818a2fd94 --- /dev/null +++ b/application/libraries/barcodegen/class/BCGean8.barcode.php @@ -0,0 +1,244 @@ +keys = array('0', '1', '2', '3', '4', '5', '6', '7', '8', '9'); + + // Left-Hand Odd Parity starting with a space + // Right-Hand is the same of Left-Hand starting with a bar + $this->code = array( + '2100', /* 0 */ + '1110', /* 1 */ + '1011', /* 2 */ + '0300', /* 3 */ + '0021', /* 4 */ + '0120', /* 5 */ + '0003', /* 6 */ + '0201', /* 7 */ + '0102', /* 8 */ + '2001' /* 9 */ + ); + } + + /** + * Draws the barcode. + * + * @param resource $im + */ + public function draw($im) { + // Checksum + $this->calculateChecksum(); + $temp_text = $this->text . $this->keys[$this->checksumValue]; + + // Starting Code + $this->drawChar($im, '000', true); + + // Draw First 4 Chars (Left-Hand) + for ($i = 0; $i < 4; $i++) { + $this->drawChar($im, $this->findCode($temp_text[$i]), false); + } + + // Draw Center Guard Bar + $this->drawChar($im, '00000', false); + + // Draw Last 4 Chars (Right-Hand) + for ($i = 4; $i < 8; $i++) { + $this->drawChar($im, $this->findCode($temp_text[$i]), true); + } + + // Draw Right Guard Bar + $this->drawChar($im, '000', true); + $this->drawText($im, 0, 0, $this->positionX, $this->thickness); + + if ($this->isDefaultEanLabelEnabled()) { + $dimension = $this->labelRight->getDimension(); + $this->drawExtendedBars($im, $dimension[1] - 2); + } + } + + /** + * Returns the maximal size of a barcode. + * + * @param int $w + * @param int $h + * @return int[] + */ + public function getDimension($w, $h) { + $startlength = 3; + $centerlength = 5; + $textlength = 8 * 7; + $endlength = 3; + + $w += $startlength + $centerlength + $textlength + $endlength; + $h += $this->thickness; + return parent::getDimension($w, $h); + } + + /** + * Adds the default label. + */ + protected function addDefaultLabel() { + if ($this->isDefaultEanLabelEnabled()) { + $this->processChecksum(); + $label = $this->getLabel(); + $font = $this->font; + + $this->labelLeft = new BCGLabel(substr($label, 0, 4), $font, BCGLabel::POSITION_BOTTOM, BCGLabel::ALIGN_LEFT); + $labelLeftDimension = $this->labelLeft->getDimension(); + $this->labelLeft->setOffset(($this->scale * 30 - $labelLeftDimension[0]) / 2 + $this->scale * 2); + + $this->labelRight = new BCGLabel(substr($label, 4, 3) . $this->keys[$this->checksumValue], $font, BCGLabel::POSITION_BOTTOM, BCGLabel::ALIGN_LEFT); + $labelRightDimension = $this->labelRight->getDimension(); + $this->labelRight->setOffset(($this->scale * 30 - $labelRightDimension[0]) / 2 + $this->scale * 34); + + $this->addLabel($this->labelLeft); + $this->addLabel($this->labelRight); + } + } + + /** + * Checks if the default ean label is enabled. + * + * @return bool + */ + protected function isDefaultEanLabelEnabled() { + $label = $this->getLabel(); + $font = $this->font; + return $label !== null && $label !== '' && $font !== null && $this->defaultLabel !== null; + } + + /** + * Validates the input. + */ + protected function validate() { + $c = strlen($this->text); + if ($c === 0) { + throw new BCGParseException('ean8', 'No data has been entered.'); + } + + // Checking if all chars are allowed + for ($i = 0; $i < $c; $i++) { + if (array_search($this->text[$i], $this->keys) === false) { + throw new BCGParseException('ean8', 'The character \'' . $this->text[$i] . '\' is not allowed.'); + } + } + + // If we have 8 chars just flush the last one + if ($c === 8) { + $this->text = substr($this->text, 0, 7); + } elseif ($c !== 7) { + throw new BCGParseException('ean8', 'Must contain 7 digits, the 8th digit is automatically added.'); + } + + parent::validate(); + } + + /** + * Overloaded method to calculate checksum. + */ + protected function calculateChecksum() { + // Calculating Checksum + // Consider the right-most digit of the message to be in an "odd" position, + // and assign odd/even to each character moving from right to left + // Odd Position = 3, Even Position = 1 + // Multiply it by the number + // Add all of that and do 10-(?mod10) + $odd = true; + $this->checksumValue = 0; + $c = strlen($this->text); + for ($i = $c; $i > 0; $i--) { + if ($odd === true) { + $multiplier = 3; + $odd = false; + } else { + $multiplier = 1; + $odd = true; + } + + if (!isset($this->keys[$this->text[$i - 1]])) { + return; + } + + $this->checksumValue += $this->keys[$this->text[$i - 1]] * $multiplier; + } + + $this->checksumValue = (10 - $this->checksumValue % 10) % 10; + } + + /** + * Overloaded method to display the checksum. + */ + protected function processChecksum() { + if ($this->checksumValue === false) { // Calculate the checksum only once + $this->calculateChecksum(); + } + + if ($this->checksumValue !== false) { + return $this->keys[$this->checksumValue]; + } + + return false; + } + + /** + * Draws the extended bars on the image. + * + * @param resource $im + * @param int $plus + */ + private function drawExtendedBars($im, $plus) { + $rememberX = $this->positionX; + $rememberH = $this->thickness; + + // We increase the bars + $this->thickness = $this->thickness + intval($plus / $this->scale); + $this->positionX = 0; + $this->drawSingleBar($im, BCGBarcode::COLOR_FG); + $this->positionX += 2; + $this->drawSingleBar($im, BCGBarcode::COLOR_FG); + + // Center Guard Bar + $this->positionX += 30; + $this->drawSingleBar($im, BCGBarcode::COLOR_FG); + $this->positionX += 2; + $this->drawSingleBar($im, BCGBarcode::COLOR_FG); + + // Last Bars + $this->positionX += 30; + $this->drawSingleBar($im, BCGBarcode::COLOR_FG); + $this->positionX += 2; + $this->drawSingleBar($im, BCGBarcode::COLOR_FG); + + $this->positionX = $rememberX; + $this->thickness = $rememberH; + } +} +?> \ No newline at end of file diff --git a/application/libraries/barcodegen/class/BCGgs1128.barcode.php b/application/libraries/barcodegen/class/BCGgs1128.barcode.php new file mode 100755 index 000000000..a3c1a5031 --- /dev/null +++ b/application/libraries/barcodegen/class/BCGgs1128.barcode.php @@ -0,0 +1,679 @@ +identifiersAi = array( + '00' => array(self::NUMERIC, 18, 18, true), + '01' => array(self::NUMERIC, 14, 14, true), + '02' => array(self::NUMERIC, 14, 14, true), + '10' => array(self::ALPHA_NUMERIC, 1, 20, false), + '11' => array(self::DATE_YYMMDD, 6, 6, false), + '12' => array(self::DATE_YYMMDD, 6, 6, false), + '13' => array(self::DATE_YYMMDD, 6, 6, false), + '15' => array(self::DATE_YYMMDD, 6, 6, false), + '17' => array(self::DATE_YYMMDD, 6, 6, false), + '20' => array(self::NUMERIC, 2, 2, false), + '21' => array(self::ALPHA_NUMERIC, 1, 20, false), + '240' => array(self::ALPHA_NUMERIC, 1, 30, false), + '241' => array(self::ALPHA_NUMERIC, 1, 30, false), + '250' => array(self::ALPHA_NUMERIC, 1, 30, false), + '251' => array(self::ALPHA_NUMERIC, 1, 30, false), + '253' => array(self::NUMERIC, 14, 30, false), + '30' => array(self::NUMERIC, 1, 8, false), + '310y' => array(self::NUMERIC, 6, 6, false), + '311y' => array(self::NUMERIC, 6, 6, false), + '312y' => array(self::NUMERIC, 6, 6, false), + '313y' => array(self::NUMERIC, 6, 6, false), + '314y' => array(self::NUMERIC, 6, 6, false), + '315y' => array(self::NUMERIC, 6, 6, false), + '316y' => array(self::NUMERIC, 6, 6, false), + '320y' => array(self::NUMERIC, 6, 6, false), + '321y' => array(self::NUMERIC, 6, 6, false), + '322y' => array(self::NUMERIC, 6, 6, false), + '323y' => array(self::NUMERIC, 6, 6, false), + '324y' => array(self::NUMERIC, 6, 6, false), + '325y' => array(self::NUMERIC, 6, 6, false), + '326y' => array(self::NUMERIC, 6, 6, false), + '327y' => array(self::NUMERIC, 6, 6, false), + '328y' => array(self::NUMERIC, 6, 6, false), + '329y' => array(self::NUMERIC, 6, 6, false), + '330y' => array(self::NUMERIC, 6, 6, false), + '331y' => array(self::NUMERIC, 6, 6, false), + '332y' => array(self::NUMERIC, 6, 6, false), + '333y' => array(self::NUMERIC, 6, 6, false), + '334y' => array(self::NUMERIC, 6, 6, false), + '335y' => array(self::NUMERIC, 6, 6, false), + '336y' => array(self::NUMERIC, 6, 6, false), + '337y' => array(self::NUMERIC, 6, 6, false), + '340y' => array(self::NUMERIC, 6, 6, false), + '341y' => array(self::NUMERIC, 6, 6, false), + '342y' => array(self::NUMERIC, 6, 6, false), + '343y' => array(self::NUMERIC, 6, 6, false), + '344y' => array(self::NUMERIC, 6, 6, false), + '345y' => array(self::NUMERIC, 6, 6, false), + '346y' => array(self::NUMERIC, 6, 6, false), + '347y' => array(self::NUMERIC, 6, 6, false), + '348y' => array(self::NUMERIC, 6, 6, false), + '349y' => array(self::NUMERIC, 6, 6, false), + '350y' => array(self::NUMERIC, 6, 6, false), + '351y' => array(self::NUMERIC, 6, 6, false), + '352y' => array(self::NUMERIC, 6, 6, false), + '353y' => array(self::NUMERIC, 6, 6, false), + '354y' => array(self::NUMERIC, 6, 6, false), + '355y' => array(self::NUMERIC, 6, 6, false), + '356y' => array(self::NUMERIC, 6, 6, false), + '357y' => array(self::NUMERIC, 6, 6, false), + '360y' => array(self::NUMERIC, 6, 6, false), + '361y' => array(self::NUMERIC, 6, 6, false), + '362y' => array(self::NUMERIC, 6, 6, false), + '363y' => array(self::NUMERIC, 6, 6, false), + '364y' => array(self::NUMERIC, 6, 6, false), + '365y' => array(self::NUMERIC, 6, 6, false), + '366y' => array(self::NUMERIC, 6, 6, false), + '367y' => array(self::NUMERIC, 6, 6, false), + '368y' => array(self::NUMERIC, 6, 6, false), + '369y' => array(self::NUMERIC, 6, 6, false), + '37' => array(self::NUMERIC, 1, 8, false), + '390y' => array(self::NUMERIC, 1, 15, false), + '391y' => array(self::NUMERIC, 4, 18, false), + '392y' => array(self::NUMERIC, 1, 15, false), + '393y' => array(self::NUMERIC, 4, 18, false), + '400' => array(self::ALPHA_NUMERIC, 1, 30, false), + '401' => array(self::ALPHA_NUMERIC, 1, 30, false), + '402' => array(self::NUMERIC, 17, 17, false), + '403' => array(self::ALPHA_NUMERIC, 1, 30, false), + '410' => array(self::NUMERIC, 13, 13, true), + '411' => array(self::NUMERIC, 13, 13, true), + '412' => array(self::NUMERIC, 13, 13, true), + '413' => array(self::NUMERIC, 13, 13, true), + '414' => array(self::NUMERIC, 13, 13, true), + '415' => array(self::NUMERIC, 13, 13, true), + '420' => array(self::ALPHA_NUMERIC, 1, 20, false), + '421' => array(self::ALPHA_NUMERIC, 4, 12, false), + '422' => array(self::NUMERIC, 3, 3, false), + '8001' => array(self::NUMERIC, 14, 14, false), + '8002' => array(self::ALPHA_NUMERIC, 1, 20, false), + '8003' => array(self::ALPHA_NUMERIC, 15, 30, false), + '8004' => array(self::ALPHA_NUMERIC, 1, 30, false), + '8005' => array(self::NUMERIC, 6, 6, false), + '8006' => array(self::NUMERIC, 18, 18, false), + '8007' => array(self::ALPHA_NUMERIC, 1, 30, false), + '8018' => array(self::NUMERIC, 18, 18, false), + '8020' => array(self::ALPHA_NUMERIC, 1, 25, false), + '8100' => array(self::NUMERIC, 6, 6, false), + '8101' => array(self::NUMERIC, 10, 10, false), + '8102' => array(self::NUMERIC, 2, 2, false), + '90' => array(self::ALPHA_NUMERIC, 1, 30, false), + '91' => array(self::ALPHA_NUMERIC, 1, 30, false), + '92' => array(self::ALPHA_NUMERIC, 1, 30, false), + '93' => array(self::ALPHA_NUMERIC, 1, 30, false), + '94' => array(self::ALPHA_NUMERIC, 1, 30, false), + '95' => array(self::ALPHA_NUMERIC, 1, 30, false), + '96' => array(self::ALPHA_NUMERIC, 1, 30, false), + '97' => array(self::ALPHA_NUMERIC, 1, 30, false), + '98' => array(self::ALPHA_NUMERIC, 1, 30, false), + '99' => array(self::ALPHA_NUMERIC, 1, 30, false) + ); + + $this->setStrictMode(true); + $this->setTilde(true); + $this->setAllowsUnknownIdentifier(false); + $this->setNoLengthLimit(false); + } + + /** + * Gets the content checksum for an identifier. + * Do not pass the identifier code. + * + * @param string $content + * @return int + */ + public static function getAiContentChecksum($content) { + return self::calculateChecksumMod10($content); + } + + /** + * Enables or disables the strict mode. + * + * @param bool $strictMode + */ + public function setStrictMode($strictMode) { + $this->strictMode = $strictMode; + } + + /** + * Gets if the strict mode is activated. + * + * @return bool + */ + public function getStrictMode() { + return $this->strictMode; + } + + /** + * Allows unknown identifiers. + * + * @param bool $allow + */ + public function setAllowsUnknownIdentifier($allow) { + $this->allowsUnknownIdentifier = (bool)$allow; + } + + /** + * Gets if unkmown identifiers are allowed. + * + * @return bool + */ + public function getAllowsUnknownIdentifier() { + return $this->allowsUnknownIdentifier; + } + + /** + * Removes the limit of 48 characters. + * + * @param bool $noLengthLimit + */ + public function setNoLengthLimit($noLengthLimit) { + $this->noLengthLimit = (bool)$noLengthLimit; + } + + /** + * Gets if the limit of 48 characters is removed. + * + * @return bool + */ + public function getNoLengthLimit() { + return $this->noLengthLimit; + } + + /** + * Parses Text. + * + * @param string $text + */ + public function parse($text) { + parent::parse($this->parseGs1128($text)); + } + + /** + * Formats data for gs1-128. + * + * @return string + */ + private function formatGs1128() { + $formatedText = '~F1'; + $formatedLabel = ''; + $c = count($this->identifiersId); + + for ($i = 0; $i < $c; $i++) { + if ($i > 0) { + $formatedLabel .= ' '; + } + + if ($this->identifiersId[$i] !== null) { + $formatedLabel .= '(' . $this->identifiersId[$i] . ')'; + } + + $formatedText .= $this->identifiersId[$i]; + + $formatedLabel .= $this->identifiersContent[$i]; + $formatedText .= $this->identifiersContent[$i]; + + if (isset($this->identifiersAi[$this->identifiersId[$i]])) { + $ai_data = $this->identifiersAi[$this->identifiersId[$i]]; + } elseif (isset($this->identifiersId[$i][3])) { + $identifierWithVar = substr($this->identifiersId[$i], 0, -1) . 'y'; + $ai_data = isset($this->identifiersAi[$identifierWithVar]) ? $this->identifiersAi[$identifierWithVar] : null; + } else { + $ai_data = null; + } + + /* We'll check if we need to add a ~F1 () char */ + /* If we use the legacy mode, we always add a ~F1 () char between AIs */ + if ($ai_data !== null) { + if ((strlen($this->identifiersContent[$i]) < $ai_data[self::MAXLENGTH] && ($i + 1) !== $c) || (!$this->strictMode && ($i + 1) !== $c)) { + $formatedText .= '~F1'; + } + } elseif ($this->allowsUnknownIdentifier && $this->identifiersId[$i] === null && ($i + 1) !== $c) { + /* If this id is unknown, we add a ~F1 () char */ + $formatedText .= '~F1'; + } + } + + if ($this->noLengthLimit === false && (strlen(str_replace('~F1', chr(29), $formatedText)) - 1) > self::MAX_GS1128_CHARS) { + throw new BCGParseException('gs1128', 'The barcode can\'t contain more than ' . self::MAX_GS1128_CHARS . ' characters.'); + } + + $this->label = $formatedLabel; + return $formatedText; + } + + /** + * Parses the text to gs1-128. + * + * @param mixed $text + * @return mixed + */ + private function parseGs1128($text) { + /* We format correctly what the user gives */ + if (is_array($text)) { + $formatArray = array(); + foreach ($text as $content) { + if (is_array($content)) { /* double array */ + if (count($content) === 2) { + if (is_array($content[self::ID]) || is_array($content[self::CONTENT])) { + throw new BCGParseException('gs1128', 'Double arrays can\'t contain arrays.'); + } else { + $formatArray[] = '(' . $content[self::ID] . ')' . $content[self::CONTENT]; + } + } else { + throw new BCGParseException('gs1128', 'Double arrays must contain 2 values.'); + } + } else { /* simple array */ + $formatArray[] = $content; + } + } + + unset($text); + $text = $formatArray; + } else { /* string */ + $text = array($text); + } + + $textCount = count($text); + for ($cmpt = 0; $cmpt < $textCount; $cmpt++) { + /* We parse the content of the array */ + if (!$this->parseContent($text[$cmpt])) { + return; + } + } + + return $this->formatGs1128(); + } + + /** + * Splits the id and the content for each application identifiers (AIs). + * + * @param string $text + * @param int $cmpt + * @return bool + */ + private function parseContent($text) { + /* $yAlreadySet has 3 states: */ + /* null: There is no variable in the ID; true: the variable is already set; false: the variable is not set yet; */ + $content = null; + $yAlreadySet = null; + $realNameId = null; + $separatorsFound = 0; + $checksumAdded = 0; + $decimalPointRemoved = 0; + $toParse = str_replace('~F1', chr(29), $text); + $nbCharToParse = strlen($toParse); + $nbCharId = 0; + $isFormated = $toParse[0] === '(' ? true : false; + $maxCharId = $isFormated ? self::MAX_ID_FORMATED : self::MAX_ID_NOT_FORMATED; + $id = strtolower(substr($toParse, 0, min($maxCharId, $nbCharToParse))); + $id = $isFormated ? $this->findIdFormated($id, $yAlreadySet, $realNameId) : $this->findIdNotFormated($id, $yAlreadySet, $realNameId); + + if ($id === false) { + if ($this->allowsUnknownIdentifier === false) { + return false; + } + + $id = null; + $nbCharId = 0; + $content = $toParse; + } else { + $nbCharId = strlen($id) + ($isFormated ? 2 : 0); + $n = min($this->identifiersAi[$realNameId][self::MAXLENGTH], $nbCharToParse); + $content = substr($toParse, $nbCharId, $n); + } + + if ($id !== null) { + /* If we have an AI with an "y" var, we check if there is a decimal point in the next *MAXLENGTH* characters */ + /* if there is one, we take an extra character */ + if ($yAlreadySet !== null) { + if (strpos($content, '.') !== false || strpos($content, ',') !== false) { + $n++; + if ($n <= $nbCharToParse) { + /* We take an extra char */ + $content = substr($toParse, $nbCharId, $n); + } + } + } + } + + /* We check for separator */ + $separator = strpos($content, chr(29)); + if ($separator !== false) { + $content = substr($content, 0, $separator); + $separatorsFound++; + } + + if ($id !== null) { + /* We check the conformity */ + if (!$this->checkConformity($content, $id, $realNameId)) { + return false; + } + + /* We check the checksum */ + if (!$this->checkChecksum($content, $id, $realNameId, $checksumAdded)) { + return false; + } + + /* We check the vars */ + if (!$this->checkVars($content, $id, $yAlreadySet, $decimalPointRemoved)) { + return false; + } + } + + $this->identifiersId[] = $id; + $this->identifiersContent[] = $content; + + $nbCharLastContent = (((strlen($content) + $nbCharId) - $checksumAdded) + $decimalPointRemoved) + $separatorsFound; + if ($nbCharToParse - $nbCharLastContent > 0) { + /* If there is more than one content in this array, we parse again */ + $otherContent = substr($toParse, $nbCharLastContent, $nbCharToParse); + $nbCharOtherContent = strlen($otherContent); + + if ($otherContent[0] === chr(29)) { + $otherContent = substr($otherContent, 1); + $nbCharOtherContent--; + } + + if ($nbCharOtherContent > 0) { + $text = $otherContent; + return $this->parseContent($text); + } + } + + return true; + } + + /** + * Checks if an id exists. + * + * @param string $id + * @param bool $yAlreadySet + * @param string $realNameId + * @return bool + */ + private function idExists($id, &$yAlreadySet, &$realNameId) { + $yFound = isset($id[3]) && $id[3] === 'y'; + $idVarAdded = substr($id, 0, -1) . 'y'; + + if (isset($this->identifiersAi[$id])) { + if ($yFound) { + $yAlreadySet = false; + } + + $realNameId = $id; + return true; + } elseif (!$yFound && isset($this->identifiersAi[$idVarAdded])) { + /* if the id don't exist, we try to find this id with "y" at the last char */ + $yAlreadySet = true; + $realNameId = $idVarAdded; + return true; + } + + return false; + } + + /** + * Finds ID with formated content. + * + * @param string $id + * @param bool $yAlreadySet + * @param string $realNameId + * @return mixed + */ + private function findIdFormated($id, &$yAlreadySet, &$realNameId) { + $pos = strpos($id, ')'); + if ($pos === false) { + throw new BCGParseException('gs1128', 'Identifiers must have no more than 4 characters.'); + } else { + if ($pos < 3) { + throw new BCGParseException('gs1128', 'Identifiers must have at least 2 characters.'); + } + + $id = substr($id, 1, $pos - 1); + if ($this->idExists($id, $yAlreadySet, $realNameId)) { + return $id; + } + + if ($this->allowsUnknownIdentifier === false) { + throw new BCGParseException('gs1128', 'The identifier ' . $id . ' doesn\'t exist.'); + } + + return false; + } + } + + /** + * Finds ID with non-formated content. + * + * @param string $id + * @param bool $yAlreadySet + * @param string $realNameId + * @return mixed + */ + private function findIdNotFormated($id, &$yAlreadySet, &$realNameId) { + $tofind = $id; + + while (strlen($tofind) >= 2) { + if ($this->idExists($tofind, $yAlreadySet, $realNameId)) { + return $tofind; + } else { + $tofind = substr($tofind, 0, -1); + } + } + + if ($this->allowsUnknownIdentifier === false) { + throw new BCGParseException('gs1128', 'Error in formatting, can\'t find an identifier.'); + } + + return false; + } + + /** + * Checks confirmity of the content. + * + * @param string $content + * @param string $id + * @param string $realNameId + * @return bool + */ + private function checkConformity(&$content, $id, $realNameId) { + switch ($this->identifiersAi[$realNameId][self::KIND_OF_DATA]) { + case self::NUMERIC: + $content = str_replace(',', '.', $content); + if (!preg_match("/^[0-9.]+$/", $content)) { + throw new BCGParseException('gs1128', 'The value of "' . $id . '" must be numerical.'); + } + + break; + case self::DATE_YYMMDD: + $valid_date = true; + if (preg_match("/^[0-9]{6}$/", $content)) { + $year = substr($content, 0, 2); + $month = substr($content, 2, 2); + $day = substr($content, 4, 2); + + /* day can be 00 if we only need month and year */ + if (intval($month) < 1 || intval($month) > 12 || intval($day) < 0 || intval($day) > 31) { + $valid_date = false; + } + } else { + $valid_date = false; + } + + if (!$valid_date) { + throw new BCGParseException('gs1128', 'The value of "' . $id . '" must be in YYMMDD format.'); + } + + break; + } + + // We check the length of the content + $nbCharContent = strlen($content); + $checksumChar = 0; + $minlengthContent = $this->identifiersAi[$realNameId][self::MINLENGTH]; + $maxlengthContent = $this->identifiersAi[$realNameId][self::MAXLENGTH]; + + if ($this->identifiersAi[$realNameId][self::CHECKSUM]) { + $checksumChar++; + } + + if ($nbCharContent < ($minlengthContent - $checksumChar)) { + if ($minlengthContent === $maxlengthContent) { + throw new BCGParseException('gs1128', 'The value of "' . $id . '" must contain ' . $minlengthContent . ' character(s).'); + } else { + throw new BCGParseException('gs1128', 'The value of "' . $id . '" must contain between ' . $minlengthContent . ' and ' . $maxlengthContent . ' character(s).'); + } + } + + return true; + } + + /** + * Verifies the checksum. + * + * @param string $content + * @param string $id + * @param int $realNameId + * @param int $checksumAdded + * @return bool + */ + private function checkChecksum(&$content, $id, $realNameId, &$checksumAdded) { + if ($this->identifiersAi[$realNameId][self::CHECKSUM]) { + $nbCharContent = strlen($content); + $minlengthContent = $this->identifiersAi[$realNameId][self::MINLENGTH]; + if ($nbCharContent === ($minlengthContent - 1)) { + /* we need to calculate the checksum */ + $content .= self::getAiContentChecksum($content); + $checksumAdded++; + } elseif ($nbCharContent === $minlengthContent) { + /* we need to check the checksum */ + $checksum = self::getAiContentChecksum(substr($content, 0, -1)); + if (intval($content[$nbCharContent - 1]) !== $checksum) { + throw new BCGParseException('gs1128', 'The checksum of "(' . $id . ') ' . $content . '" must be: ' . $checksum); + } + } + } + + return true; + } + + /** + * Checks vars "y". + * + * @param string $content + * @param string $id + * @param bool $yAlreadySet + * @param int $decimalPointRemoved + * @return bool + */ + private function checkVars(&$content, &$id, $yAlreadySet, &$decimalPointRemoved) { + $nbCharContent = strlen($content); + /* We check for "y" var in AI */ + if ($yAlreadySet) { + /* We'll check if we have a decimal point */ + if (strpos($content, '.') !== false) { + throw new BCGParseException('gs1128', 'If you do not use any "y" variable, you have to insert a whole number.'); + } + } elseif ($yAlreadySet !== null) { + /* We need to replace the "y" var with the position of the decimal point */ + $pos = strpos($content, '.'); + if ($pos === false) { + $pos = $nbCharContent - 1; + } + + $id = str_replace('y', $nbCharContent - ($pos + 1), strtolower($id)); + $content = str_replace('.', '', $content); + $decimalPointRemoved++; + } + + return true; + } + + /** + * Checksum Mod10. + * + * @param int $content + * @return int + */ + private static function calculateChecksumMod10($content) { + // Calculating Checksum + // Consider the right-most digit of the message to be in an "odd" position, + // and assign odd/even to each character moving from right to left + // Odd Position = 3, Even Position = 1 + // Multiply it by the number + // Add all of that and do 10-(?mod10) + $odd = true; + $checksumValue = 0; + $c = strlen($content); + + for ($i = $c; $i > 0; $i--) { + if ($odd === true) { + $multiplier = 3; + $odd = false; + } else { + $multiplier = 1; + $odd = true; + } + + $checksumValue += ($content[$i - 1] * $multiplier); + } + + return (10 - $checksumValue % 10) % 10; + } +} +?> \ No newline at end of file diff --git a/application/libraries/barcodegen/class/BCGi25.barcode.php b/application/libraries/barcodegen/class/BCGi25.barcode.php new file mode 100755 index 000000000..871aeabd5 --- /dev/null +++ b/application/libraries/barcodegen/class/BCGi25.barcode.php @@ -0,0 +1,203 @@ +keys = array('0', '1', '2', '3', '4', '5', '6', '7', '8', '9'); + $this->code = array( + '00110', /* 0 */ + '10001', /* 1 */ + '01001', /* 2 */ + '11000', /* 3 */ + '00101', /* 4 */ + '10100', /* 5 */ + '01100', /* 6 */ + '00011', /* 7 */ + '10010', /* 8 */ + '01010' /* 9 */ + ); + + $this->setChecksum(false); + $this->setRatio(2); + } + + /** + * Sets the checksum. + * + * @param bool $checksum + */ + public function setChecksum($checksum) { + $this->checksum = (bool)$checksum; + } + + /** + * Sets the ratio of the black bar compared to the white bars. + * + * @param int $ratio + */ + public function setRatio($ratio) { + $this->ratio = $ratio; + } + + /** + * Draws the barcode. + * + * @param resource $im + */ + public function draw($im) { + $temp_text = $this->text; + + // Checksum + if ($this->checksum === true) { + $this->calculateChecksum(); + $temp_text .= $this->keys[$this->checksumValue]; + } + + // Starting Code + $this->drawChar($im, '0000', true); + + // Chars + $c = strlen($temp_text); + for ($i = 0; $i < $c; $i += 2) { + $temp_bar = ''; + $c2 = strlen($this->findCode($temp_text[$i])); + for ($j = 0; $j < $c2; $j++) { + $temp_bar .= substr($this->findCode($temp_text[$i]), $j, 1); + $temp_bar .= substr($this->findCode($temp_text[$i + 1]), $j, 1); + } + + $this->drawChar($im, $this->changeBars($temp_bar), true); + } + + // Ending Code + $this->drawChar($im, $this->changeBars('100'), true); + $this->drawText($im, 0, 0, $this->positionX, $this->thickness); + } + + /** + * Returns the maximal size of a barcode. + * + * @param int $w + * @param int $h + * @return int[] + */ + public function getDimension($w, $h) { + $textlength = (3 + ($this->ratio + 1) * 2) * strlen($this->text); + $startlength = 4; + $checksumlength = 0; + if ($this->checksum === true) { + $checksumlength = (3 + ($this->ratio + 1) * 2); + } + + $endlength = 2 + ($this->ratio + 1); + + $w += $startlength + $textlength + $checksumlength + $endlength; + $h += $this->thickness; + return parent::getDimension($w, $h); + } + + /** + * Validates the input. + */ + protected function validate() { + $c = strlen($this->text); + if ($c === 0) { + throw new BCGParseException('i25', 'No data has been entered.'); + } + + // Checking if all chars are allowed + for ($i = 0; $i < $c; $i++) { + if (array_search($this->text[$i], $this->keys) === false) { + throw new BCGParseException('i25', 'The character \'' . $this->text[$i] . '\' is not allowed.'); + } + } + + // Must be even + if ($c % 2 !== 0 && $this->checksum === false) { + throw new BCGParseException('i25', 'i25 must contain an even amount of digits if checksum is false.'); + } elseif ($c % 2 === 0 && $this->checksum === true) { + throw new BCGParseException('i25', 'i25 must contain an odd amount of digits if checksum is true.'); + } + + parent::validate(); + } + + /** + * Overloaded method to calculate checksum. + */ + protected function calculateChecksum() { + // Calculating Checksum + // Consider the right-most digit of the message to be in an "even" position, + // and assign odd/even to each character moving from right to left + // Even Position = 3, Odd Position = 1 + // Multiply it by the number + // Add all of that and do 10-(?mod10) + $even = true; + $this->checksumValue = 0; + $c = strlen($this->text); + for ($i = $c; $i > 0; $i--) { + if ($even === true) { + $multiplier = 3; + $even = false; + } else { + $multiplier = 1; + $even = true; + } + + $this->checksumValue += $this->keys[$this->text[$i - 1]] * $multiplier; + } + + $this->checksumValue = (10 - $this->checksumValue % 10) % 10; + } + + /** + * Overloaded method to display the checksum. + */ + protected function processChecksum() { + if ($this->checksumValue === false) { // Calculate the checksum only once + $this->calculateChecksum(); + } + + if ($this->checksumValue !== false) { + return $this->keys[$this->checksumValue]; + } + + return false; + } + + /** + * Changes the size of the bars based on the ratio + * + * @param string $in + * @return string + */ + private function changeBars($in) { + if ($this->ratio > 1) { + $c = strlen($in); + for ($i = 0; $i < $c; $i++) { + $in[$i] = $in[$i] === '1' ? $this->ratio : $in[$i]; + } + } + + return $in; + } +} +?> \ No newline at end of file diff --git a/application/libraries/barcodegen/class/BCGintelligentmail.barcode.php b/application/libraries/barcodegen/class/BCGintelligentmail.barcode.php new file mode 100755 index 000000000..4226abeea --- /dev/null +++ b/application/libraries/barcodegen/class/BCGintelligentmail.barcode.php @@ -0,0 +1,649 @@ +setQuietZone(true); + $this->setThickness(9); + } + + /** + * Gets the Quiet zone. + * + * @return bool + */ + public function getQuietZone() { + return $this->quietZone; + } + + /** + * Sets the Quiet zone. + * + * @param bool $quietZone + */ + public function setQuietZone($quietZone) { + $this->quietZone = (bool)$quietZone; + } + + /** + * Sets the tracking code. + * + * @param int $barcodeIdentifier 2-digit number. 2nd digit must be 0-4 + * @param int $serviceTypeIdentifier 3 digits + * @param int $mailerIdentifier 6 or 9 digits + * @param int $serialNumber 9 (if mailerId is 6) or 6 digits (if mailerId is 9) + */ + public function setTrackingCode($barcodeIdentifier, $serviceTypeIdentifier, $mailerIdentifier, $serialNumber) { + $barcodeIdentifier = (string)(int)$barcodeIdentifier; + $serviceTypeIdentifier = (int)$serviceTypeIdentifier; + $mailerIdentifier = (int)$mailerIdentifier; + $serialNumber = (string)(int)$serialNumber; + + $barcodeIdentifier = str_pad($barcodeIdentifier, 2, '0', STR_PAD_LEFT); + + if (strlen($barcodeIdentifier) !== 2) { + throw new BCGArgumentException('Barcode Identifier must contain 2 digits.', 'barcodeIdentifier'); + } + + $barcodeIdentifierSecondNumber = $barcodeIdentifier[1]; + if ($barcodeIdentifierSecondNumber !== '0' && $barcodeIdentifierSecondNumber !== '1' && $barcodeIdentifierSecondNumber !== '2' && $barcodeIdentifierSecondNumber !== '3' && $barcodeIdentifierSecondNumber !== '4') { + throw new BCGArgumentException('Barcode Identifier second digit must be a number between 0 and 4.', 'barcodeIdentifier'); + } + + if ($serviceTypeIdentifier < 0 || $serviceTypeIdentifier > 999) { + throw new BCGArgumentException('Service Type Identifier must be between 0 and 999.', 'serviceTypeIdentifier'); + } + + $mailerIdentifierLength = 6; + if ($mailerIdentifier > 899999) { + $mailerIdentifierLength = 9; + } + + if ($mailerIdentifierLength === 9 && strlen($serialNumber) > 6) { + throw new BCGArgumentException('If the Serial Number has more than 6 digits, the Mailer Identifier must be lower than 900000.', 'mailerIdentifier'); + } + + if ($mailerIdentifierLength === 9) { + if ($mailerIdentifierLength < 0 || $mailerIdentifier > 999999999) { + throw new BCGArgumentException('Mailer Identifier must be between 0 and 999999999.', 'mailerIdentifier'); + } + } + + $this->barcodeIdentifier = $barcodeIdentifier; + $this->serviceTypeIdentifier = str_pad($serviceTypeIdentifier, 3, '0', STR_PAD_LEFT); + $this->mailerIdentifier = str_pad($mailerIdentifier, $mailerIdentifierLength, '0', STR_PAD_LEFT); + $this->serialNumber = str_pad((int)$serialNumber, $mailerIdentifierLength === 6 ? 9 : 6, '0', STR_PAD_LEFT); + } + + /** + * Parses the text before displaying it. + * + * @param mixed $text + */ + public function parse($text) { + parent::parse($text); + + $number = self::executeStep1($this->text, $this->barcodeIdentifier, $this->serviceTypeIdentifier, $this->mailerIdentifier, $this->serialNumber); + $crc = self::executeStep2($number); + $codewords = self::executeStep3($number); + $codewords = self::executeStep4($codewords, $crc); + $characters = self::executeStep5($codewords, $crc); + $this->data = self::executeStep6($characters); + } + + /** + * Draws the barcode. + * + * @param resource $im + */ + public function draw($im) { + if ($this->quietZone) { + $this->positionX += 9; + } + + $c = strlen($this->data); + for ($i = 0; $i < $c; $i++) { + $this->drawChar($im, $this->data[$i]); + } + + $this->drawText($im, 0, 0, $this->positionX, $this->thickness + ($this->quietZone ? 4 : 0)); + } + + /** + * Returns the maximal size of a barcode. + * + * @param int $w + * @param int $h + * @return int[] + */ + public function getDimension($w, $h) { + $w += 65 * 3; + $h += $this->thickness; + + // We remove the white on the right + $w -= 1.56; + + if ($this->quietZone) { + $w += 18; + $h += 4; + } + + return parent::getDimension($w, $h); + } + + /** + * Validates the input. + */ + protected function validate() { + // Tracking must have been entered + if ($this->barcodeIdentifier === null || $this->serviceTypeIdentifier === null || $this->mailerIdentifier === null || $this->serialNumber === null) { + throw new BCGParseException('intelligentmail', 'The tracking code must be set before calling the parse method.'); + } + + // Checking if all chars are allowed + $match = array(); + if (preg_match('/[^0-9]/', $this->text, $match)) { + throw new BCGParseException('intelligentmail', 'The character \'' . $match[0] . '\' is not allowed.'); + } + + // Must contain 0, 5, 9 or 11 chars + $c = strlen($this->text); + if ($c !== 0 && $c !== 5 && $c !== 9 && $c !== 11) { + throw new BCGParseException('intelligentmail', 'Must contain 0, 5, 9, or 11 characters.'); + } + + parent::validate(); + } + + /** + * Overloaded method for drawing special barcode. + * + * @param resource $im + * @param string $code + * @param boolean $startBar + */ + protected function drawChar($im, $code, $startBar = true) { + $y1 = 0; + $y2 = 0; + switch ($code) { + case 'A': + $y1 = 0; + $y2 = $this->thickness - ($this->thickness / 2.5); + break; + case 'D': + $y1 = 3.096; + $y2 = $this->thickness - 1; + break; + case 'F': + $y1 = 0; + $y2 = $this->thickness - 1; + break; + case 'T': + $y1 = 3.096; + $y2 = $this->thickness - ($this->thickness / 2.5); + break; + } + + if ($this->quietZone) { + $y1 += 2; + $y2 += 2; + } + + $this->drawFilledRectangle($im, $this->positionX, $y1, $this->positionX + 0.44, $y2, BCGBarcode::COLOR_FG); + $this->positionX += 3; + } + + /** + * Executes Step 1: Conversion of Data Fields into Binary Data + * + * @param string $text + * @param string $barcodeIdentifier + * @param string $serviceTypeIdentifier + * @param string $mailerIdentifier + * @param string $serialNumber + * @return string BCNumber + */ + private static function executeStep1($text, $barcodeIdentifier, $serviceTypeIdentifier, $mailerIdentifier, $serialNumber) { + $number = self::conversionRoutingCode($text); + $number = self::conversionTrackingCode($number, $barcodeIdentifier, $serviceTypeIdentifier, $mailerIdentifier, $serialNumber); + + return $number; + } + + /** + * Executes Step 2: Generation of 11-Bit CRC on Binary Data + * + * @param $number BCNumber + * @return int + */ + private static function executeStep2($number) { + $byteArray = str_pad(self::bcdecuc($number), 13, chr(0), STR_PAD_LEFT); + + $generatorPolynomial = 0x0f35; + $frameCheckSequence = 0x07ff; + $data = 0; + $byteIndex = 0; + $bit = 0; + + $data = (ord($byteArray[$byteIndex]) << 5) & 0xffff; + for ($bit = 2; $bit < 8; $bit++) { + if (($frameCheckSequence ^ $data) & 0x400) { + $frameCheckSequence = ($frameCheckSequence << 1) ^ $generatorPolynomial; + } else { + $frameCheckSequence = ($frameCheckSequence << 1); + } + + $frameCheckSequence &= 0x7ff; + $data <<= 1; + $data &= 0xffff; + } + + for ($byteIndex = 1; $byteIndex < 13; $byteIndex++) { + $data = (ord($byteArray[$byteIndex]) << 3) & 0xffff; + for ($bit = 0; $bit < 8; $bit++) { + if (($frameCheckSequence ^ $data) & 0x0400) { + $frameCheckSequence = ($frameCheckSequence << 1) ^ $generatorPolynomial; + } else { + $frameCheckSequence = ($frameCheckSequence << 1); + } + + $frameCheckSequence &= 0x7ff; + $data <<= 1; + $data &= 0xffff; + } + } + + return $frameCheckSequence; + } + + /** + * Executes Step 3: Conversion from Binary Data to Codewords + * + * @param string $number BCNumber + * @return int[] + */ + private static function executeStep3($number) { + $codewords = array(); + $codewords[9] = (int)bcmod($number, '636'); + $number = bcdiv($number, '636', 0); + + for ($i = 8; $i >= 0; $i--) { + $codewords[$i] = (int)bcmod($number, '1365'); + $number = bcdiv($number, '1365', 0); + } + + return $codewords; + } + + /** + * Executes Step 4: Inserting Additional Information into Codewords + * + * @param int[] $codewords + * @param int $crc + * @return int[] + */ + private static function executeStep4($codewords, $crc) { + $codewords[9] *= 2; + if ($crc & 0x400) { + $codewords[0] += 659; + } + + return $codewords; + } + + /** + * Executes Step 5: Conversion from Codewords to Characters + * + * @param int[] $codewords + * @param int $crc + * @return int[] + */ + private static function executeStep5($codewords, $crc) { + $characters = array(); + for ($i = 0; $i < 10; $i++) { + if ($codewords[$i] <= 1286) { + $characters[$i] = self::$characterTable1[$codewords[$i]]; + } else { + $characters[$i] = self::$characterTable2[$codewords[$i] - 1287]; + } + } + + for ($i = 0; $i < 10; $i++) { + $mask = 1 << $i; + if ($crc & $mask) { + $characters[$i] ^= 0x1fff; + } + } + + return $characters; + } + + /** + * Executes Step 6: Conversion from Characters to the Intelligent Mail Barcode + * + * @param int[] $characters + * @return string + */ + private static function executeStep6($characters) { + $bars = ''; + for ($i = 0; $i < 65; $i++) { + $barPosition = self::$barPositions[$i]; + $descender = $barPosition[0]; + $ascender = $barPosition[1]; + $extenderDescender = !!($characters[$descender[0]] & (1 << $descender[1])); + $extenderAscender = !!($characters[$ascender[0]] & (1 << $ascender[1])); + + if ($extenderDescender && $extenderAscender) { + $bars .= 'F'; + } elseif ($extenderDescender) { + $bars .= 'D'; + } elseif ($extenderAscender) { + $bars .= 'A'; + } else { + $bars .= 'T'; + } + } + + return $bars; + } + + /** + * Converts the routing code zipcode. + * + * @param string $zipcode + * @return string BCNumber + */ + private static function conversionRoutingCode($zipcode) { + $number = $zipcode; + switch (strlen($zipcode)) { + case 11: + $number = bcadd($number, '1000000000', 0); + case 9: + $number = bcadd($number, '100000', 0); + case 5: + $number = bcadd($number, '1', 0); + default: + return $number; + } + } + + /** + * Converts the tracking code number. + * + * @param string $number BCNumber + * @param string $barcodeIdentifier + * @param string $serviceTypeIdentifier + * @param string $mailerIdentifier + * @param string $serialNumber + * @return string BCNumber + */ + private static function conversionTrackingCode($number, $barcodeIdentifier, $serviceTypeIdentifier, $mailerIdentifier, $serialNumber) { + $number = bcmul($number, 10, 0); + $number = bcadd($number, $barcodeIdentifier[0], 0); + $number = bcmul($number, 5, 0); + $number = bcadd($number, $barcodeIdentifier[1], 0); + + $temp = $serviceTypeIdentifier . $mailerIdentifier . $serialNumber; + for ($i = 0; $i < 18; $i++) { + $number = bcmul($number, 10, 0); + $number = bcadd($number, $temp[$i], 0); + } + + return $number; + } + + /** + * Transforms a BCNumber into unsigned char*. + * + * @param string $dec BCNumber + * @param string + */ + private static function bcdecuc($dec) { + $last = bcmod($dec, 256); + $remain = bcdiv(bcsub($dec, $last), 256, 0); + + if ($remain == 0) { + return pack('C', $last); + } else { + return self::bcdecuc($remain) . pack('C', $last); + } + } +} +?> \ No newline at end of file diff --git a/application/libraries/barcodegen/class/BCGisbn.barcode.php b/application/libraries/barcodegen/class/BCGisbn.barcode.php new file mode 100755 index 000000000..cba00d6c2 --- /dev/null +++ b/application/libraries/barcodegen/class/BCGisbn.barcode.php @@ -0,0 +1,164 @@ +setGS1($gs1); + } + + /** + * Adds the default label. + */ + protected function addDefaultLabel() { + if ($this->isDefaultEanLabelEnabled()) { + $isbn = $this->createISBNText(); + $font = $this->font; + + $topLabel = new BCGLabel($isbn, $font, BCGLabel::POSITION_TOP, BCGLabel::ALIGN_CENTER); + + $this->addLabel($topLabel); + } + + parent::addDefaultLabel(); + } + + /** + * Sets the first numbers of the barcode. + * - GS1_AUTO: Adds 978 before the code + * - GS1_PREFIX978: Adds 978 before the code + * - GS1_PREFIX979: Adds 979 before the code + * + * @param int $gs1 + */ + public function setGS1($gs1) { + $gs1 = (int)$gs1; + if ($gs1 !== self::GS1_AUTO && $gs1 !== self::GS1_PREFIX978 && $gs1 !== self::GS1_PREFIX979) { + throw new BCGArgumentException('The GS1 argument must be BCGisbn::GS1_AUTO, BCGisbn::GS1_PREFIX978, or BCGisbn::GS1_PREFIX979', 'gs1'); + } + + $this->gs1 = $gs1; + } + + /** + * Check chars allowed. + */ + protected function checkCharsAllowed() { + $c = strlen($this->text); + + // Special case, if we have 10 digits, the last one can be X + if ($c === 10) { + if (array_search($this->text[9], $this->keys) === false && $this->text[9] !== 'X') { + throw new BCGParseException('isbn', 'The character \'' . $this->text[9] . '\' is not allowed.'); + } + + // Drop the last char + $this->text = substr($this->text, 0, 9); + } + + return parent::checkCharsAllowed(); + } + + /** + * Check correct length. + */ + protected function checkCorrectLength() { + $c = strlen($this->text); + + // If we have 13 chars just flush the last one + if ($c === 13) { + $this->text = substr($this->text, 0, 12); + } elseif ($c === 9 || $c === 10) { + if ($c === 10) { + // Before dropping it, we check if it's legal + if (array_search($this->text[9], $this->keys) === false && $this->text[9] !== 'X') { + throw new BCGParseException('isbn', 'The character \'' . $this->text[9] . '\' is not allowed.'); + } + + $this->text = substr($this->text, 0, 9); + } + + if ($this->gs1 === self::GS1_AUTO || $this->gs1 === self::GS1_PREFIX978) { + $this->text = '978' . $this->text; + } elseif ($this->gs1 === self::GS1_PREFIX979) { + $this->text = '979' . $this->text; + } + } elseif ($c !== 12) { + throw new BCGParseException('isbn', 'The code parsed must be 9, 10, 12, or 13 digits long.'); + } + } + + /** + * Creates the ISBN text. + * + * @return string + */ + private function createISBNText() { + $isbn = ''; + if (!empty($this->text)) { + // We try to create the ISBN Text... the hyphen really depends the ISBN agency. + // We just put one before the checksum and one after the GS1 if present. + $c = strlen($this->text); + if ($c === 12 || $c === 13) { + // If we have 13 characters now, just transform it temporarily to find the checksum... + // Further in the code we take care of that anyway. + $lastCharacter = ''; + if ($c === 13) { + $lastCharacter = $this->text[12]; + $this->text = substr($this->text, 0, 12); + } + + $checksum = $this->processChecksum(); + $isbn = 'ISBN ' . substr($this->text, 0, 3) . '-' . substr($this->text, 3, 9) . '-' . $checksum; + + // Put the last character back + if ($c === 13) { + $this->text .= $lastCharacter; + } + } elseif ($c === 9 || $c === 10) { + $checksum = 0; + for ($i = 10; $i >= 2; $i--) { + $checksum += $this->text[10 - $i] * $i; + } + + $checksum = 11 - $checksum % 11; + if ($checksum === 10) { + $checksum = 'X'; // Changing type + } + + $isbn = 'ISBN ' . substr($this->text, 0, 9) . '-' . $checksum; + } + } + + return $isbn; + } +} +?> \ No newline at end of file diff --git a/application/libraries/barcodegen/class/BCGmsi.barcode.php b/application/libraries/barcodegen/class/BCGmsi.barcode.php new file mode 100755 index 000000000..92bb77ff9 --- /dev/null +++ b/application/libraries/barcodegen/class/BCGmsi.barcode.php @@ -0,0 +1,184 @@ +keys = array('0', '1', '2', '3', '4', '5', '6', '7', '8', '9'); + $this->code = array( + '01010101', /* 0 */ + '01010110', /* 1 */ + '01011001', /* 2 */ + '01011010', /* 3 */ + '01100101', /* 4 */ + '01100110', /* 5 */ + '01101001', /* 6 */ + '01101010', /* 7 */ + '10010101', /* 8 */ + '10010110' /* 9 */ + ); + + $this->setChecksum(0); + } + + /** + * Sets how many checksums we display. 0 to 2. + * + * @param int $checksum + */ + public function setChecksum($checksum) { + $checksum = intval($checksum); + if ($checksum < 0 && $checksum > 2) { + throw new BCGArgumentException('The checksum must be between 0 and 2 included.', 'checksum'); + } + + $this->checksum = $checksum; + } + + /** + * Draws the barcode. + * + * @param resource $im + */ + public function draw($im) { + // Checksum + $this->calculateChecksum(); + + // Starting Code + $this->drawChar($im, '10', true); + + // Chars + $c = strlen($this->text); + for ($i = 0; $i < $c; $i++) { + $this->drawChar($im, $this->findCode($this->text[$i]), true); + } + + $c = count($this->checksumValue); + for ($i = 0; $i < $c; $i++) { + $this->drawChar($im, $this->findCode($this->checksumValue[$i]), true); + } + + // Ending Code + $this->drawChar($im, '010', true); + $this->drawText($im, 0, 0, $this->positionX, $this->thickness); + } + + /** + * Returns the maximal size of a barcode. + * + * @param int $w + * @param int $h + * @return int[] + */ + public function getDimension($w, $h) { + $textlength = 12 * strlen($this->text); + $startlength = 3; + $checksumlength = $this->checksum * 12; + $endlength = 4; + + $w += $startlength + $textlength + $checksumlength + $endlength; + $h += $this->thickness; + return parent::getDimension($w, $h); + } + + /** + * Validates the input. + */ + protected function validate() { + $c = strlen($this->text); + if ($c === 0) { + throw new BCGParseException('msi', 'No data has been entered.'); + } + + // Checking if all chars are allowed + for ($i = 0; $i < $c; $i++) { + if (array_search($this->text[$i], $this->keys) === false) { + throw new BCGParseException('msi', 'The character \'' . $this->text[$i] . '\' is not allowed.'); + } + } + } + + /** + * Overloaded method to calculate checksum. + */ + protected function calculateChecksum() { + // Forming a new number + // If the original number is even, we take all even position + // If the original number is odd, we take all odd position + // 123456 = 246 + // 12345 = 135 + // Multiply by 2 + // Add up all the digit in the result (270 : 2+7+0) + // Add up other digit not used. + // 10 - (? Modulo 10). If result = 10, change to 0 + $last_text = $this->text; + $this->checksumValue = array(); + for ($i = 0; $i < $this->checksum; $i++) { + $new_text = ''; + $new_number = 0; + $c = strlen($last_text); + if ($c % 2 === 0) { // Even + $starting = 1; + } else { + $starting = 0; + } + + for ($j = $starting; $j < $c; $j += 2) { + $new_text .= $last_text[$j]; + } + + $new_text = strval(intval($new_text) * 2); + $c2 = strlen($new_text); + for ($j = 0; $j < $c2; $j++) { + $new_number += intval($new_text[$j]); + } + + for ($j = ($starting === 0) ? 1 : 0; $j < $c; $j += 2) { + $new_number += intval($last_text[$j]); + } + + $new_number = (10 - $new_number % 10) % 10; + $this->checksumValue[] = $new_number; + $last_text .= $new_number; + } + } + + /** + * Overloaded method to display the checksum. + */ + protected function processChecksum() { + if ($this->checksumValue === false) { // Calculate the checksum only once + $this->calculateChecksum(); + } + + if ($this->checksumValue !== false) { + $ret = ''; + $c = count($this->checksumValue); + for ($i = 0; $i < $c; $i++) { + $ret .= $this->keys[$this->checksumValue[$i]]; + } + + return $ret; + } + + return false; + } +} +?> \ No newline at end of file diff --git a/application/libraries/barcodegen/class/BCGothercode.barcode.php b/application/libraries/barcodegen/class/BCGothercode.barcode.php new file mode 100755 index 000000000..bb7e6b0d8 --- /dev/null +++ b/application/libraries/barcodegen/class/BCGothercode.barcode.php @@ -0,0 +1,88 @@ +keys = array('0', '1', '2', '3', '4', '5', '6', '7', '8', '9'); + } + + /** + * Draws the barcode. + * + * @param resource $im + */ + public function draw($im) { + $this->drawChar($im, $this->text, true); + $this->drawText($im, 0, 0, $this->positionX, $this->thickness); + } + + /** + * Gets the label. + * If the label was set to BCGBarcode1D::AUTO_LABEL, the label will display the value from the text parsed. + * + * @return string + */ + public function getLabel() { + $label = $this->label; + if ($this->label === BCGBarcode1D::AUTO_LABEL) { + $label = ''; + } + + return $label; + } + + /** + * Returns the maximal size of a barcode. + * + * @param int $w + * @param int $h + * @return int[] + */ + public function getDimension($w, $h) { + $array = str_split($this->text, 1); + $textlength = array_sum($array) + count($array); + + $w += $textlength; + $h += $this->thickness; + return parent::getDimension($w, $h); + } + + /** + * Validates the input. + */ + protected function validate() { + $c = strlen($this->text); + if ($c === 0) { + throw new BCGParseException('othercode', 'No data has been entered.'); + } + + // Checking if all chars are allowed + for ($i = 0; $i < $c; $i++) { + if (array_search($this->text[$i], $this->keys) === false) { + throw new BCGParseException('othercode', 'The character \'' . $this->text[$i] . '\' is not allowed.'); + } + } + + parent::validate(); + } +} +?> \ No newline at end of file diff --git a/application/libraries/barcodegen/class/BCGpostnet.barcode.php b/application/libraries/barcodegen/class/BCGpostnet.barcode.php new file mode 100755 index 000000000..cb0eac2a0 --- /dev/null +++ b/application/libraries/barcodegen/class/BCGpostnet.barcode.php @@ -0,0 +1,138 @@ +keys = array('0', '1', '2', '3', '4', '5', '6', '7', '8', '9'); + $this->code = array( + '11000', /* 0 */ + '00011', /* 1 */ + '00101', /* 2 */ + '00110', /* 3 */ + '01001', /* 4 */ + '01010', /* 5 */ + '01100', /* 6 */ + '10001', /* 7 */ + '10010', /* 8 */ + '10100' /* 9 */ + ); + + $this->setThickness(9); + } + + /** + * Draws the barcode. + * + * @param resource $im + */ + public function draw($im) { + // Checksum + $checksum = 0; + $c = strlen($this->text); + for ($i = 0; $i < $c; $i++) { + $checksum += intval($this->text[$i]); + } + + $checksum = 10 - ($checksum % 10); + + // Starting Code + $this->drawChar($im, '1'); + + // Code + for ($i = 0; $i < $c; $i++) { + $this->drawChar($im, $this->findCode($this->text[$i])); + } + + // Checksum + $this->drawChar($im, $this->findCode($checksum)); + + // Ending Code + $this->drawChar($im, '1'); + $this->drawText($im, 0, 0, $this->positionX, $this->thickness); + } + + /** + * Returns the maximal size of a barcode. + * + * @param int $w + * @param int $h + * @return int[] + */ + public function getDimension($w, $h) { + $c = strlen($this->text); + $startlength = 3; + $textlength = $c * 5 * 3; + $checksumlength = 5 * 3; + $endlength = 3; + + // We remove the white on the right + $removelength = -1.56; + + $w += $startlength + $textlength + $checksumlength + $endlength + $removelength; + $h += $this->thickness; + return parent::getDimension($w, $h); + } + + /** + * Validates the input. + */ + protected function validate() { + $c = strlen($this->text); + if ($c === 0) { + throw new BCGParseException('postnet', 'No data has been entered.'); + } + + // Checking if all chars are allowed + for ($i = 0; $i < $c; $i++) { + if (array_search($this->text[$i], $this->keys) === false) { + throw new BCGParseException('postnet', 'The character \'' . $this->text[$i] . '\' is not allowed.'); + } + } + + // Must contain 5, 9 or 11 chars + if ($c !== 5 && $c !== 9 && $c !== 11) { + throw new BCGParseException('postnet', 'Must contain 5, 9, or 11 characters.'); + } + + parent::validate(); + } + + /** + * Overloaded method for drawing special barcode. + * + * @param resource $im + * @param string $code + * @param boolean $startBar + */ + protected function drawChar($im, $code, $startBar = true) { + $c = strlen($code); + for ($i = 0; $i < $c; $i++) { + if ($code[$i] === '0') { + $posY = $this->thickness - ($this->thickness / 2.5); + } else { + $posY = 0; + } + + $this->drawFilledRectangle($im, $this->positionX, $posY, $this->positionX + 0.44, $this->thickness - 1, BCGBarcode::COLOR_FG); + $this->positionX += 3; + } + } +} +?> \ No newline at end of file diff --git a/application/libraries/barcodegen/class/BCGs25.barcode.php b/application/libraries/barcodegen/class/BCGs25.barcode.php new file mode 100755 index 000000000..6dc10e27e --- /dev/null +++ b/application/libraries/barcodegen/class/BCGs25.barcode.php @@ -0,0 +1,170 @@ + 1/3 or 1/2 for the big bar + * + *-------------------------------------------------------------------- + * Copyright (C) Jean-Sebastien Goupil + * http://www.barcodephp.com + */ +include_once('BCGParseException.php'); +include_once('BCGBarcode1D.php'); + +class BCGs25 extends BCGBarcode1D { + private $checksum; + + /** + * Constructor. + */ + public function __construct() { + parent::__construct(); + + $this->keys = array('0', '1', '2', '3', '4', '5', '6', '7', '8', '9'); + $this->code = array( + '0000202000', /* 0 */ + '2000000020', /* 1 */ + '0020000020', /* 2 */ + '2020000000', /* 3 */ + '0000200020', /* 4 */ + '2000200000', /* 5 */ + '0020200000', /* 6 */ + '0000002020', /* 7 */ + '2000002000', /* 8 */ + '0020002000' /* 9 */ + ); + + $this->setChecksum(false); + } + + /** + * Sets if we display the checksum. + * + * @param bool $checksum + */ + public function setChecksum($checksum) { + $this->checksum = (bool)$checksum; + } + + /** + * Draws the barcode. + * + * @param resource $im + */ + public function draw($im) { + $temp_text = $this->text; + + // Checksum + if ($this->checksum === true) { + $this->calculateChecksum(); + $temp_text .= $this->keys[$this->checksumValue]; + } + + // Starting Code + $this->drawChar($im, '101000', true); + + // Chars + $c = strlen($temp_text); + for ($i = 0; $i < $c; $i++) { + $this->drawChar($im, $this->findCode($temp_text[$i]), true); + } + + // Ending Code + $this->drawChar($im, '10001', true); + $this->drawText($im, 0, 0, $this->positionX, $this->thickness); + } + + /** + * Returns the maximal size of a barcode. + * + * @param int $w + * @param int $h + * @return int[] + */ + public function getDimension($w, $h) { + $c = strlen($this->text); + $startlength = 8; + $textlength = $c * 14; + $checksumlength = 0; + if ($c % 2 !== 0) { + $checksumlength = 14; + } + + $endlength = 7; + + $w += $startlength + $textlength + $checksumlength + $endlength; + $h += $this->thickness; + return parent::getDimension($w, $h); + } + + /** + * Validates the input. + */ + protected function validate() { + $c = strlen($this->text); + if ($c === 0) { + throw new BCGParseException('s25', 'No data has been entered.'); + } + + // Checking if all chars are allowed + for ($i = 0; $i < $c; $i++) { + if (array_search($this->text[$i], $this->keys) === false) { + throw new BCGParseException('s25', 'The character \'' . $this->text[$i] . '\' is not allowed.'); + } + } + + // Must be even + if ($c % 2 !== 0 && $this->checksum === false) { + throw new BCGParseException('s25', 's25 must contain an even amount of digits if checksum is false.'); + } elseif ($c % 2 === 0 && $this->checksum === true) { + throw new BCGParseException('s25', 's25 must contain an odd amount of digits if checksum is true.'); + } + + parent::validate(); + } + + /** + * Overloaded method to calculate checksum. + */ + protected function calculateChecksum() { + // Calculating Checksum + // Consider the right-most digit of the message to be in an "even" position, + // and assign odd/even to each character moving from right to left + // Even Position = 3, Odd Position = 1 + // Multiply it by the number + // Add all of that and do 10-(?mod10) + $even = true; + $this->checksumValue = 0; + $c = strlen($this->text); + for ($i = $c; $i > 0; $i--) { + if ($even === true) { + $multiplier = 3; + $even = false; + } else { + $multiplier = 1; + $even = true; + } + + $this->checksumValue += $this->keys[$this->text[$i - 1]] * $multiplier; + } + $this->checksumValue = (10 - $this->checksumValue % 10) % 10; + } + + /** + * Overloaded method to display the checksum. + */ + protected function processChecksum() { + if ($this->checksumValue === false) { // Calculate the checksum only once + $this->calculateChecksum(); + } + + if ($this->checksumValue !== false) { + return $this->keys[$this->checksumValue]; + } + + return false; + } +} +?> \ No newline at end of file diff --git a/application/libraries/barcodegen/class/BCGupca.barcode.php b/application/libraries/barcodegen/class/BCGupca.barcode.php new file mode 100755 index 000000000..828bb8f07 --- /dev/null +++ b/application/libraries/barcodegen/class/BCGupca.barcode.php @@ -0,0 +1,146 @@ +text = '0' . $this->text; // We will remove it at the end... don't worry + + parent::draw($im); + + // We remove the 0 in front, as we said :) + $this->text = substr($this->text, 1); + } + + /** + * Draws the extended bars on the image. + * + * @param resource $im + * @param int $plus + */ + protected function drawExtendedBars($im, $plus) { + $temp_text = $this->text . $this->keys[$this->checksumValue]; + $rememberX = $this->positionX; + $rememberH = $this->thickness; + + // We increase the bars + // First 2 Bars + $this->thickness = $this->thickness + intval($plus / $this->scale); + $this->positionX = 0; + $this->drawSingleBar($im, BCGBarcode::COLOR_FG); + $this->positionX += 2; + $this->drawSingleBar($im, BCGBarcode::COLOR_FG); + + // Attemping to increase the 2 following bars + $this->positionX += 1; + $temp_value = $this->findCode($temp_text[1]); + $this->drawChar($im, $temp_value, false); + + // Center Guard Bar + $this->positionX += 36; + $this->drawSingleBar($im, BCGBarcode::COLOR_FG); + $this->positionX += 2; + $this->drawSingleBar($im, BCGBarcode::COLOR_FG); + + // Attemping to increase the 2 last bars + $this->positionX += 37; + $temp_value = $this->findCode($temp_text[12]); + $this->drawChar($im, $temp_value, true); + + // Completly last bars + $this->drawSingleBar($im, BCGBarcode::COLOR_FG); + $this->positionX += 2; + $this->drawSingleBar($im, BCGBarcode::COLOR_FG); + + $this->positionX = $rememberX; + $this->thickness = $rememberH; + } + + /** + * Adds the default label. + */ + protected function addDefaultLabel() { + if ($this->isDefaultEanLabelEnabled()) { + $this->processChecksum(); + $label = $this->getLabel(); + $font = $this->font; + + $this->labelLeft = new BCGLabel(substr($label, 0, 1), $font, BCGLabel::POSITION_LEFT, BCGLabel::ALIGN_BOTTOM); + $this->labelLeft->setSpacing(4 * $this->scale); + + $this->labelCenter1 = new BCGLabel(substr($label, 1, 5), $font, BCGLabel::POSITION_BOTTOM, BCGLabel::ALIGN_LEFT); + $labelCenter1Dimension = $this->labelCenter1->getDimension(); + $this->labelCenter1->setOffset(($this->scale * 44 - $labelCenter1Dimension[0]) / 2 + $this->scale * 6); + + $this->labelCenter2 = new BCGLabel(substr($label, 6, 5), $font, BCGLabel::POSITION_BOTTOM, BCGLabel::ALIGN_LEFT); + $this->labelCenter2->setOffset(($this->scale * 44 - $labelCenter1Dimension[0]) / 2 + $this->scale * 45); + + $this->labelRight = new BCGLabel($this->keys[$this->checksumValue], $font, BCGLabel::POSITION_RIGHT, BCGLabel::ALIGN_BOTTOM); + $this->labelRight->setSpacing(4 * $this->scale); + + if ($this->alignLabel) { + $labelDimension = $this->labelCenter1->getDimension(); + $this->labelLeft->setOffset($labelDimension[1]); + $this->labelRight->setOffset($labelDimension[1]); + } else { + $labelDimension = $this->labelLeft->getDimension(); + $this->labelLeft->setOffset($labelDimension[1] / 2); + $labelDimension = $this->labelLeft->getDimension(); + $this->labelRight->setOffset($labelDimension[1] / 2); + } + + $this->addLabel($this->labelLeft); + $this->addLabel($this->labelCenter1); + $this->addLabel($this->labelCenter2); + $this->addLabel($this->labelRight); + } + } + + /** + * Check correct length. + */ + protected function checkCorrectLength() { + // If we have 12 chars, just flush the last one without throwing anything + $c = strlen($this->text); + if ($c === 12) { + $this->text = substr($this->text, 0, 11); + } elseif ($c !== 11) { + throw new BCGParseException('upca', 'Must contain 11 digits, the 12th digit is automatically added.'); + } + } +} +?> \ No newline at end of file diff --git a/application/libraries/barcodegen/class/BCGupce.barcode.php b/application/libraries/barcodegen/class/BCGupce.barcode.php new file mode 100755 index 000000000..f22c408cd --- /dev/null +++ b/application/libraries/barcodegen/class/BCGupce.barcode.php @@ -0,0 +1,336 @@ +keys = array('0', '1', '2', '3', '4', '5', '6', '7', '8', '9'); + + // Odd Parity starting with a space + // Even Parity is the inverse (0=0012) starting with a space + $this->code = array( + '2100', /* 0 */ + '1110', /* 1 */ + '1011', /* 2 */ + '0300', /* 3 */ + '0021', /* 4 */ + '0120', /* 5 */ + '0003', /* 6 */ + '0201', /* 7 */ + '0102', /* 8 */ + '2001' /* 9 */ + ); + + // Parity, 0=Odd, 1=Even for manufacturer code. Depending on 1st System Digit and Checksum + $this->codeParity = array( + array( + array(1, 1, 1, 0, 0, 0), /* 0,0 */ + array(1, 1, 0, 1, 0, 0), /* 0,1 */ + array(1, 1, 0, 0, 1, 0), /* 0,2 */ + array(1, 1, 0, 0, 0, 1), /* 0,3 */ + array(1, 0, 1, 1, 0, 0), /* 0,4 */ + array(1, 0, 0, 1, 1, 0), /* 0,5 */ + array(1, 0, 0, 0, 1, 1), /* 0,6 */ + array(1, 0, 1, 0, 1, 0), /* 0,7 */ + array(1, 0, 1, 0, 0, 1), /* 0,8 */ + array(1, 0, 0, 1, 0, 1) /* 0,9 */ + ), + array( + array(0, 0, 0, 1, 1, 1), /* 0,0 */ + array(0, 0, 1, 0, 1, 1), /* 0,1 */ + array(0, 0, 1, 1, 0, 1), /* 0,2 */ + array(0, 0, 1, 1, 1, 0), /* 0,3 */ + array(0, 1, 0, 0, 1, 1), /* 0,4 */ + array(0, 1, 1, 0, 0, 1), /* 0,5 */ + array(0, 1, 1, 1, 0, 0), /* 0,6 */ + array(0, 1, 0, 1, 0, 1), /* 0,7 */ + array(0, 1, 0, 1, 1, 0), /* 0,8 */ + array(0, 1, 1, 0, 1, 0) /* 0,9 */ + ) + ); + } + + /** + * Draws the barcode. + * + * @param resource $im + */ + public function draw($im) { + $this->calculateChecksum(); + + // Starting Code + $this->drawChar($im, '000', true); + $c = strlen($this->upce); + for ($i = 0; $i < $c; $i++) { + $this->drawChar($im, self::inverse($this->findCode($this->upce[$i]), $this->codeParity[intval($this->text[0])][$this->checksumValue][$i]), false); + } + + // Draw Center Guard Bar + $this->drawChar($im, '00000', false); + + // Draw Right Bar + $this->drawChar($im, '0', true); + $this->text = $this->text[0] . $this->upce; + $this->drawText($im, 0, 0, $this->positionX, $this->thickness); + + if ($this->isDefaultEanLabelEnabled()) { + $dimension = $this->labelCenter->getDimension(); + $this->drawExtendedBars($im, $dimension[1] - 2); + } + } + + /** + * Returns the maximal size of a barcode. + * + * @param int $w + * @param int $h + * @return int[] + */ + public function getDimension($w, $h) { + $startlength = 3; + $centerlength = 5; + $textlength = 6 * 7; + $endlength = 1; + + $w += $startlength + $centerlength + $textlength + $endlength; + $h += $this->thickness; + return parent::getDimension($w, $h); + } + + /** + * Adds the default label. + */ + protected function addDefaultLabel() { + if ($this->isDefaultEanLabelEnabled()) { + $this->processChecksum(); + $font = $this->font; + + $this->labelLeft = new BCGLabel(substr($this->text, 0, 1), $font, BCGLabel::POSITION_LEFT, BCGLabel::ALIGN_BOTTOM); + $labelLeftDimension = $this->labelLeft->getDimension(); + $this->labelLeft->setSpacing(8); + $this->labelLeft->setOffset($labelLeftDimension[1] / 2); + + $this->labelCenter = new BCGLabel($this->upce, $font, BCGLabel::POSITION_BOTTOM, BCGLabel::ALIGN_LEFT); + $labelCenterDimension = $this->labelCenter->getDimension(); + $this->labelCenter->setOffset(($this->scale * 46 - $labelCenterDimension[0]) / 2 + $this->scale * 2); + + $this->labelRight = new BCGLabel($this->keys[$this->checksumValue], $font, BCGLabel::POSITION_RIGHT, BCGLabel::ALIGN_BOTTOM); + $labelRightDimension = $this->labelRight->getDimension(); + $this->labelRight->setSpacing(8); + $this->labelRight->setOffset($labelRightDimension[1] / 2); + + $this->addLabel($this->labelLeft); + $this->addLabel($this->labelCenter); + $this->addLabel($this->labelRight); + } + } + + /** + * Checks if the default ean label is enabled. + * + * @return bool + */ + protected function isDefaultEanLabelEnabled() { + $label = $this->getLabel(); + $font = $this->font; + return $label !== null && $label !== '' && $font !== null && $this->defaultLabel !== null; + } + + /** + * Validates the input. + */ + protected function validate() { + $c = strlen($this->text); + if ($c === 0) { + throw new BCGParseException('upce', 'No data has been entered.'); + } + + // Checking if all chars are allowed + for ($i = 0; $i < $c; $i++) { + if (array_search($this->text[$i], $this->keys) === false) { + throw new BCGParseException('upce', 'The character \'' . $this->text[$i] . '\' is not allowed.'); + } + } + + // Must contain 11 chars + // Must contain 6 chars (if starting with upce directly) + // First Chars must be 0 or 1 + if ($c !== 11 && $c !== 6) { + throw new BCGParseException('upce', 'You must provide a UPC-A (11 characters) or a UPC-E (6 characters).'); + } elseif ($this->text[0] !== '0' && $this->text[0] !== '1' && $c !== 6) { + throw new BCGParseException('upce', 'UPC-A must start with 0 or 1 to be converted to UPC-E.'); + } + + // Convert part + $this->upce = ''; + if ($c !== 6) { + // Checking if UPC-A is convertible + $temp1 = substr($this->text, 3, 3); + if ($temp1 === '000' || $temp1 === '100' || $temp1 === '200') { // manufacturer code ends with 100, 200 or 300 + if (substr($this->text, 6, 2) === '00') { // Product must start with 00 + $this->upce = substr($this->text, 1, 2) . substr($this->text, 8, 3) . substr($this->text, 3, 1); + } + } elseif (substr($this->text, 4, 2) === '00') { // manufacturer code ends with 00 + if (substr($this->text, 6, 3) === '000') { // Product must start with 000 + $this->upce = substr($this->text, 1, 3) . substr($this->text, 9, 2) . '3'; + } + } elseif (substr($this->text, 5, 1) === '0') { // manufacturer code ends with 0 + if (substr($this->text, 6, 4) === '0000') { // Product must start with 0000 + $this->upce = substr($this->text, 1, 4) . substr($this->text, 10, 1) . '4'; + } + } else { // No zero leading at manufacturer code + $temp2 = intval(substr($this->text, 10, 1)); + if (substr($this->text, 6, 4) === '0000' && $temp2 >= 5 && $temp2 <= 9) { // Product must start with 0000 and must end by 5, 6, 7, 8 or 9 + $this->upce = substr($this->text, 1, 5) . substr($this->text, 10, 1); + } + } + } else { + $this->upce = $this->text; + } + + if ($this->upce === '') { + throw new BCGParseException('upce', 'Your UPC-A can\'t be converted to UPC-E.'); + } + + if ($c === 6) { + $upca = ''; + + // We convert UPC-E to UPC-A to find the checksum + if ($this->text[5] === '0' || $this->text[5] === '1' || $this->text[5] === '2') { + $upca = substr($this->text, 0, 2) . $this->text[5] . '0000' . substr($this->text, 2, 3); + } elseif ($this->text[5] === '3') { + $upca = substr($this->text, 0, 3) . '00000' . substr($this->text, 3, 2); + } elseif ($this->text[5] === '4') { + $upca = substr($this->text, 0, 4) . '00000' . $this->text[4]; + } else { + $upca = substr($this->text, 0, 5) . '0000' . $this->text[5]; + } + + $this->text = '0' . $upca; + } + + parent::validate(); + } + + /** + * Overloaded method to calculate checksum. + */ + protected function calculateChecksum() { + // Calculating Checksum + // Consider the right-most digit of the message to be in an "odd" position, + // and assign odd/even to each character moving from right to left + // Odd Position = 3, Even Position = 1 + // Multiply it by the number + // Add all of that and do 10-(?mod10) + $odd = true; + $this->checksumValue = 0; + $c = strlen($this->text); + for ($i = $c; $i > 0; $i--) { + if ($odd === true) { + $multiplier = 3; + $odd = false; + } else { + $multiplier = 1; + $odd = true; + } + + if (!isset($this->keys[$this->text[$i - 1]])) { + return; + } + + $this->checksumValue += $this->keys[$this->text[$i - 1]] * $multiplier; + } + + $this->checksumValue = (10 - $this->checksumValue % 10) % 10; + } + + /** + * Overloaded method to display the checksum. + */ + protected function processChecksum() { + if ($this->checksumValue === false) { // Calculate the checksum only once + $this->calculateChecksum(); + } + + if ($this->checksumValue !== false) { + return $this->keys[$this->checksumValue]; + } + + return false; + } + + /** + * Draws the extended bars on the image. + * + * @param resource $im + * @param int $plus + */ + protected function drawExtendedBars($im, $plus) { + $rememberX = $this->positionX; + $rememberH = $this->thickness; + + // We increase the bars + $this->thickness = $this->thickness + intval($plus / $this->scale); + $this->positionX = 0; + $this->drawSingleBar($im, BCGBarcode::COLOR_FG); + $this->positionX += 2; + $this->drawSingleBar($im, BCGBarcode::COLOR_FG); + + // Last Bars + $this->positionX += 46; + $this->drawSingleBar($im, BCGBarcode::COLOR_FG); + $this->positionX += 2; + $this->drawSingleBar($im, BCGBarcode::COLOR_FG); + + $this->positionX = $rememberX; + $this->thickness = $rememberH; + } + + /** + * Inverses the string when the $inverse parameter is equal to 1. + * + * @param string $text + * @param int $inverse + * @return string + */ + private static function inverse($text, $inverse = 1) { + if ($inverse === 1) { + $text = strrev($text); + } + + return $text; + } +} +?> \ No newline at end of file diff --git a/application/libraries/barcodegen/class/BCGupcext2.barcode.php b/application/libraries/barcodegen/class/BCGupcext2.barcode.php new file mode 100755 index 000000000..3f1be1655 --- /dev/null +++ b/application/libraries/barcodegen/class/BCGupcext2.barcode.php @@ -0,0 +1,138 @@ +keys = array('0', '1', '2', '3', '4', '5', '6', '7', '8', '9'); + $this->code = array( + '2100', /* 0 */ + '1110', /* 1 */ + '1011', /* 2 */ + '0300', /* 3 */ + '0021', /* 4 */ + '0120', /* 5 */ + '0003', /* 6 */ + '0201', /* 7 */ + '0102', /* 8 */ + '2001' /* 9 */ + ); + + // Parity, 0=Odd, 1=Even. Depending on ?%4 + $this->codeParity = array( + array(0, 0), /* 0 */ + array(0, 1), /* 1 */ + array(1, 0), /* 2 */ + array(1, 1) /* 3 */ + ); + } + + /** + * Draws the barcode. + * + * @param resource $im + */ + public function draw($im) { + // Starting Code + $this->drawChar($im, '001', true); + + // Code + for ($i = 0; $i < 2; $i++) { + $this->drawChar($im, self::inverse($this->findCode($this->text[$i]), $this->codeParity[intval($this->text) % 4][$i]), false); + if ($i === 0) { + $this->drawChar($im, '00', false); // Inter-char + } + } + + $this->drawText($im, 0, 0, $this->positionX, $this->thickness); + } + + /** + * Returns the maximal size of a barcode. + * + * @param int $w + * @param int $h + * @return int[] + */ + public function getDimension($w, $h) { + $startlength = 4; + $textlength = 2 * 7; + $intercharlength = 2; + + $w += $startlength + $textlength + $intercharlength; + $h += $this->thickness; + return parent::getDimension($w, $h); + } + + /** + * Adds the default label. + */ + protected function addDefaultLabel() { + parent::addDefaultLabel(); + + if ($this->defaultLabel !== null) { + $this->defaultLabel->setPosition(BCGLabel::POSITION_TOP); + } + } + + /** + * Validates the input. + */ + protected function validate() { + $c = strlen($this->text); + if ($c === 0) { + throw new BCGParseException('upcext2', 'No data has been entered.'); + } + + // Checking if all chars are allowed + for ($i = 0; $i < $c; $i++) { + if (array_search($this->text[$i], $this->keys) === false) { + throw new BCGParseException('upcext2', 'The character \'' . $this->text[$i] . '\' is not allowed.'); + } + } + + // Must contain 2 digits + if ($c !== 2) { + throw new BCGParseException('upcext2', 'Must contain 2 digits.'); + } + + parent::validate(); + } + + /** + * Inverses the string when the $inverse parameter is equal to 1. + * + * @param string $text + * @param int $inverse + * @return string + */ + private static function inverse($text, $inverse = 1) { + if ($inverse === 1) { + $text = strrev($text); + } + + return $text; + } +} +?> \ No newline at end of file diff --git a/application/libraries/barcodegen/class/BCGupcext5.barcode.php b/application/libraries/barcodegen/class/BCGupcext5.barcode.php new file mode 100755 index 000000000..a643672d0 --- /dev/null +++ b/application/libraries/barcodegen/class/BCGupcext5.barcode.php @@ -0,0 +1,200 @@ + No suggested Retail Price + * If 99991 -> Book Complimentary (normally free) + * If 90001 to 98999 -> Internal Purpose of Publisher + * If 99990 -> Used by the National Association of College Stores to mark used books + * If 0xxxx -> Price Expressed in British Pounds (xx.xx) + * If 5xxxx -> Price Expressed in U.S. dollars (US$xx.xx) + * + *-------------------------------------------------------------------- + * Copyright (C) Jean-Sebastien Goupil + * http://www.barcodephp.com + */ +include_once('BCGParseException.php'); +include_once('BCGBarcode1D.php'); +include_once('BCGLabel.php'); + +class BCGupcext5 extends BCGBarcode1D { + protected $codeParity = array(); + + /** + * Constructor. + */ + public function __construct() { + parent::__construct(); + + $this->keys = array('0', '1', '2', '3', '4', '5', '6', '7', '8', '9'); + $this->code = array( + '2100', /* 0 */ + '1110', /* 1 */ + '1011', /* 2 */ + '0300', /* 3 */ + '0021', /* 4 */ + '0120', /* 5 */ + '0003', /* 6 */ + '0201', /* 7 */ + '0102', /* 8 */ + '2001' /* 9 */ + ); + + // Parity, 0=Odd, 1=Even. Depending Checksum + $this->codeParity = array( + array(1, 1, 0, 0, 0), /* 0 */ + array(1, 0, 1, 0, 0), /* 1 */ + array(1, 0, 0, 1, 0), /* 2 */ + array(1, 0, 0, 0, 1), /* 3 */ + array(0, 1, 1, 0, 0), /* 4 */ + array(0, 0, 1, 1, 0), /* 5 */ + array(0, 0, 0, 1, 1), /* 6 */ + array(0, 1, 0, 1, 0), /* 7 */ + array(0, 1, 0, 0, 1), /* 8 */ + array(0, 0, 1, 0, 1) /* 9 */ + ); + } + + /** + * Draws the barcode. + * + * @param resource $im + */ + public function draw($im) { + // Checksum + $this->calculateChecksum(); + + // Starting Code + $this->drawChar($im, '001', true); + + // Code + for ($i = 0; $i < 5; $i++) { + $this->drawChar($im, self::inverse($this->findCode($this->text[$i]), $this->codeParity[$this->checksumValue][$i]), false); + if ($i < 4) { + $this->drawChar($im, '00', false); // Inter-char + } + } + + $this->drawText($im, 0, 0, $this->positionX, $this->thickness); + } + + /** + * Returns the maximal size of a barcode. + * + * @param int $w + * @param int $h + * @return int[] + */ + public function getDimension($w, $h) { + $startlength = 4; + $textlength = 5 * 7; + $intercharlength = 2 * 4; + + $w += $startlength + $textlength + $intercharlength; + $h += $this->thickness; + return parent::getDimension($w, $h); + } + + /** + * Adds the default label. + */ + protected function addDefaultLabel() { + parent::addDefaultLabel(); + + if ($this->defaultLabel !== null) { + $this->defaultLabel->setPosition(BCGLabel::POSITION_TOP); + } + } + + /** + * Validates the input. + */ + protected function validate() { + $c = strlen($this->text); + if ($c === 0) { + throw new BCGParseException('upcext5', 'No data has been entered.'); + } + + // Checking if all chars are allowed + for ($i = 0; $i < $c; $i++) { + if (array_search($this->text[$i], $this->keys) === false) { + throw new BCGParseException('upcext5', 'The character \'' . $this->text[$i] . '\' is not allowed.'); + } + } + + // Must contain 5 digits + if ($c !== 5) { + throw new BCGParseException('upcext5', 'Must contain 5 digits.'); + } + + parent::validate(); + } + + /** + * Overloaded method to calculate checksum. + */ + protected function calculateChecksum() { + // Calculating Checksum + // Consider the right-most digit of the message to be in an "odd" position, + // and assign odd/even to each character moving from right to left + // Odd Position = 3, Even Position = 9 + // Multiply it by the number + // Add all of that and do ?mod10 + $odd = true; + $this->checksumValue = 0; + $c = strlen($this->text); + for ($i = $c; $i > 0; $i--) { + if ($odd === true) { + $multiplier = 3; + $odd = false; + } else { + $multiplier = 9; + $odd = true; + } + + if (!isset($this->keys[$this->text[$i - 1]])) { + return; + } + + $this->checksumValue += $this->keys[$this->text[$i - 1]] * $multiplier; + } + + $this->checksumValue = $this->checksumValue % 10; + } + + /** + * Overloaded method to display the checksum. + */ + protected function processChecksum() { + if ($this->checksumValue === false) { // Calculate the checksum only once + $this->calculateChecksum(); + } + + if ($this->checksumValue !== false) { + return $this->keys[$this->checksumValue]; + } + + return false; + } + + /** + * Inverses the string when the $inverse parameter is equal to 1. + * + * @param string $text + * @param int $inverse + * @return string + */ + private static function inverse($text, $inverse = 1) { + if ($inverse === 1) { + $text = strrev($text); + } + + return $text; + } +} +?> \ No newline at end of file diff --git a/application/libraries/barcodegen/class/JoinDraw.php b/application/libraries/barcodegen/class/JoinDraw.php new file mode 100755 index 000000000..79913a8ef --- /dev/null +++ b/application/libraries/barcodegen/class/JoinDraw.php @@ -0,0 +1,194 @@ +image1 = $image1->get_im(); + } else { + $this->image1 = $image1; + } + if ($image2 instanceof BCGDrawing) { + $this->image2 = $image2->get_im(); + } else { + $this->image2 = $image2; + } + + $this->background = $background; + $this->space = (int)$space; + $this->position = (int)$position; + $this->alignment = (int)$alignment; + + $this->createIm(); + } + + /** + * Destroys the image. + */ + public function __destruct() { + imagedestroy($this->im); + } + + /** + * Finds the position where the barcode should be aligned. + * + * @param int $size1 + * @param int $size2 + * @param int $ailgnment + * @return int + */ + private function findPosition($size1, $size2, $alignment) { + $rsize1 = max($size1, $size2); + $rsize2 = min($size1, $size2); + + if ($alignment === self::ALIGN_LEFT) { // Or TOP + return 0; + } elseif ($alignment === self::ALIGN_CENTER) { + return $rsize1 / 2 - $rsize2 / 2; + } else { // RIGHT or TOP + return $rsize1 - $rsize2; + } + } + + /** + * Change the alignments. + * + * @param int $alignment + * @return int + */ + private function changeAlignment($alignment) { + if ($alignment === 0) { + return 1; + } elseif ($alignment === 1) { + return 0; + } else { + return 2; + } + } + + /** + * Creates the image. + */ + private function createIm() { + $w1 = imagesx($this->image1); + $w2 = imagesx($this->image2); + $h1 = imagesy($this->image1); + $h2 = imagesy($this->image2); + + if ($this->position === self::POSITION_LEFT || $this->position === self::POSITION_RIGHT) { + $w = $w1 + $w2 + $this->space; + $h = max($h1, $h2); + } else { + $w = max($w1, $w2); + $h = $h1 + $h2 + $this->space; + } + + $this->im = imagecreatetruecolor($w, $h); + imagefill($this->im, 0, 0, $this->background->allocate($this->im)); + + // We start defining position of images + if ($this->position === self::POSITION_TOP) { + if ($w1 > $w2) { + $posX1 = 0; + $posX2 = $this->findPosition($w1, $w2, $this->alignment); + } else { + $a = $this->changeAlignment($this->alignment); + $posX1 = $this->findPosition($w1, $w2, $a); + $posX2 = 0; + } + + $posY2 = 0; + $posY1 = $h2 + $this->space; + } elseif ($this->position === self::POSITION_LEFT) { + if ($w1 > $w2) { + $posY1 = 0; + $posY2 = $this->findPosition($h1, $h2, $this->alignment); + } else { + $a = $this->changeAlignment($this->alignment); + $posY2 = 0; + $posY1 = $this->findPosition($h1, $h2, $a); + } + + $posX2 = 0; + $posX1 = $w2 + $this->space; + } elseif ($this->position === self::POSITION_BOTTOM) { + if ($w1 > $w2) { + $posX2 = $this->findPosition($w1, $w2, $this->alignment); + $posX1 = 0; + } else { + $a = $this->changeAlignment($this->alignment); + $posX2 = 0; + $posX1 = $this->findPosition($w1, $w2, $a); + } + + $posY1 = 0; + $posY2 = $h1 + $this->space; + } else { // defaults to RIGHT + if ($w1 > $w2) { + $posY2 = $this->findPosition($h1, $h2, $this->alignment); + $posY1 = 0; + } else { + $a = $this->changeAlignment($this->alignment); + $posY2 = 0; + $posY1 = $this->findPosition($h1, $h2, $a); + } + + $posX1 = 0; + $posX2 = $w1 + $this->space; + } + + imagecopy($this->im, $this->image1, $posX1, $posY1, 0, 0, $w1, $h1); + imagecopy($this->im, $this->image2, $posX2, $posY2, 0, 0, $w2, $h2); + } + + /** + * Returns the new $im created. + * + * @return resource + */ + public function get_im() { + return $this->im; + } +} +?> \ No newline at end of file diff --git a/application/libraries/barcodegen/class/drawer/BCGDraw.php b/application/libraries/barcodegen/class/drawer/BCGDraw.php new file mode 100755 index 000000000..0eab27dd8 --- /dev/null +++ b/application/libraries/barcodegen/class/drawer/BCGDraw.php @@ -0,0 +1,38 @@ +im = $im; + } + + /** + * Sets the filename. + * + * @param string $filename + */ + public function setFilename($filename) { + $this->filename = $filename; + } + + /** + * Method needed to draw the image based on its specification (JPG, GIF, etc.). + */ + abstract public function draw(); +} +?> \ No newline at end of file diff --git a/application/libraries/barcodegen/class/drawer/BCGDrawJPG.php b/application/libraries/barcodegen/class/drawer/BCGDrawJPG.php new file mode 100755 index 000000000..72bdd74de --- /dev/null +++ b/application/libraries/barcodegen/class/drawer/BCGDrawJPG.php @@ -0,0 +1,102 @@ +dpi = max(1, $dpi); + } else { + $this->dpi = null; + } + } + + /** + * Sets the quality of the JPG. + * + * @param int $quality + */ + public function setQuality($quality) { + $this->quality = $quality; + } + + /** + * Draws the JPG on the screen or in a file. + */ + public function draw() { + ob_start(); + imagejpeg($this->im, null, $this->quality); + $bin = ob_get_contents(); + ob_end_clean(); + + $this->setInternalProperties($bin); + + if (empty($this->filename)) { + echo $bin; + } else { + file_put_contents($this->filename, $bin); + } + } + + private function setInternalProperties(&$bin) { + $this->internalSetDPI($bin); + $this->internalSetC($bin); + } + + private function internalSetDPI(&$bin) { + if ($this->dpi !== null) { + $bin = substr_replace($bin, pack("Cnn", 0x01, $this->dpi, $this->dpi), 13, 5); + } + } + + private function internalSetC(&$bin) { + if(strcmp(substr($bin, 0, 4), pack('H*', 'FFD8FFE0')) === 0) { + $offset = 4 + (ord($bin[4]) << 8 | ord($bin[5])); + $firstPart = substr($bin, 0, $offset); + $secondPart = substr($bin, $offset); + $cr = pack('H*', 'FFFE004447656E657261746564207769746820426172636F64652047656E657261746F7220666F722050485020687474703A2F2F7777772E626172636F64657068702E636F6D'); + $bin = $firstPart; + $bin .= $cr; + $bin .= $secondPart; + } + } +} +?> \ No newline at end of file diff --git a/application/libraries/barcodegen/class/drawer/BCGDrawPNG.php b/application/libraries/barcodegen/class/drawer/BCGDrawPNG.php new file mode 100755 index 000000000..cd3164f7a --- /dev/null +++ b/application/libraries/barcodegen/class/drawer/BCGDrawPNG.php @@ -0,0 +1,202 @@ +dpi = max(1, $dpi); + } else { + $this->dpi = null; + } + } + + /** + * Draws the PNG on the screen or in a file. + */ + public function draw() { + ob_start(); + imagepng($this->im); + $bin = ob_get_contents(); + ob_end_clean(); + + $this->setInternalProperties($bin); + + if (empty($this->filename)) { + echo $bin; + } else { + file_put_contents($this->filename, $bin); + } + } + + private function setInternalProperties(&$bin) { + // Scan all the ChunkType + if (strcmp(substr($bin, 0, 8), pack('H*', '89504E470D0A1A0A')) === 0) { + $chunks = $this->detectChunks($bin); + + $this->internalSetDPI($bin, $chunks); + $this->internalSetC($bin, $chunks); + } + } + + private function detectChunks($bin) { + $data = substr($bin, 8); + $chunks = array(); + $c = strlen($data); + + $offset = 0; + while ($offset < $c) { + $packed = unpack('Nsize/a4chunk', $data); + $size = $packed['size']; + $chunk = $packed['chunk']; + + $chunks[] = array('offset' => $offset + 8, 'size' => $size, 'chunk' => $chunk); + $jump = $size + 12; + $offset += $jump; + $data = substr($data, $jump); + } + + return $chunks; + } + + private function internalSetDPI(&$bin, &$chunks) { + if ($this->dpi !== null) { + $meters = (int)($this->dpi * 39.37007874); + + $found = -1; + $c = count($chunks); + for($i = 0; $i < $c; $i++) { + // We already have a pHYs + if($chunks[$i]['chunk'] === 'pHYs') { + $found = $i; + break; + } + } + + $data = 'pHYs' . pack('NNC', $meters, $meters, 0x01); + $crc = self::crc($data, 13); + $cr = pack('Na13N', 9, $data, $crc); + + // We didn't have a pHYs + if($found == -1) { + // Don't do anything if we have a bad PNG + if($c >= 2 && $chunks[0]['chunk'] === 'IHDR') { + array_splice($chunks, 1, 0, array(array('offset' => 33, 'size' => 9, 'chunk' => 'pHYs'))); + + // Push the data + for($i = 2; $i < $c; $i++) { + $chunks[$i]['offset'] += 21; + } + + $firstPart = substr($bin, 0, 33); + $secondPart = substr($bin, 33); + $bin = $firstPart; + $bin .= $cr; + $bin .= $secondPart; + } + } else { + $bin = substr_replace($bin, $cr, $chunks[$i]['offset'], 21); + } + } + } + + private function internalSetC(&$bin, &$chunks) { + if (count($chunks) >= 2 && $chunks[0]['chunk'] === 'IHDR') { + $firstPart = substr($bin, 0, 33); + $secondPart = substr($bin, 33); + $cr = pack('H*', '0000004C74455874436F707972696768740047656E657261746564207769746820426172636F64652047656E657261746F7220666F722050485020687474703A2F2F7777772E626172636F64657068702E636F6D597F70B8'); + $bin = $firstPart; + $bin .= $cr; + $bin .= $secondPart; + } + + // Chunks is dirty!! But we are done. + } + + private static $crc_table = array(); + private static $crc_table_computed = false; + + private static function make_crc_table() { + for ($n = 0; $n < 256; $n++) { + $c = $n; + for ($k = 0; $k < 8; $k++) { + if (($c & 1) == 1) { + $c = 0xedb88320 ^ (self::SHR($c, 1)); + } else { + $c = self::SHR($c, 1); + } + } + self::$crc_table[$n] = $c; + } + + self::$crc_table_computed = true; + } + + private static function SHR($x, $n) { + $mask = 0x40000000; + + if ($x < 0) { + $x &= 0x7FFFFFFF; + $mask = $mask >> ($n - 1); + return ($x >> $n) | $mask; + } + + return (int)$x >> (int)$n; + } + + private static function update_crc($crc, $buf, $len) { + $c = $crc; + + if (!self::$crc_table_computed) { + self::make_crc_table(); + } + + for ($n = 0; $n < $len; $n++) { + $c = self::$crc_table[($c ^ ord($buf[$n])) & 0xff] ^ (self::SHR($c, 8)); + } + + return $c; + } + + private static function crc($data, $len) { + return self::update_crc(-1, $data, $len) ^ -1; + } +} +?> diff --git a/application/libraries/barcodegen/font/Arial.ttf b/application/libraries/barcodegen/font/Arial.ttf new file mode 100755 index 000000000..886789b85 Binary files /dev/null and b/application/libraries/barcodegen/font/Arial.ttf differ diff --git a/application/libraries/barcodegen/html/BCGcodabar.php b/application/libraries/barcodegen/html/BCGcodabar.php new file mode 100755 index 000000000..89feb0e03 --- /dev/null +++ b/application/libraries/barcodegen/html/BCGcodabar.php @@ -0,0 +1,28 @@ + + +
+

Valid Characters

+ +
+ +
+

Explanation

+
    +
  • Known also as Ames Code, NW-7, Monarch, 2 of 7, Rationalized Codabar.
  • +
  • Codabar was developed in 1972 by Pitney Bowes, Inc.
  • +
  • This symbology is useful to encode digital information. It is a self-checking code, there is no check digit.
  • +
  • Codabar is used by blood bank, photo labs, library, FedEx...
  • +
  • Coding can be with an unspecified length composed by numbers, plus and minus sign, colon, slash, dot, dollar.
  • +
+
+ + \ No newline at end of file diff --git a/application/libraries/barcodegen/html/BCGcode11.php b/application/libraries/barcodegen/html/BCGcode11.php new file mode 100755 index 000000000..f7bccd8e2 --- /dev/null +++ b/application/libraries/barcodegen/html/BCGcode11.php @@ -0,0 +1,28 @@ + + +
+

Valid Characters

+ +
+ +
+

Explanation

+
    +
  • Known also as USD-8.
  • +
  • Code 11 was developed in 1977 as a high-density numeric symbology.
  • +
  • Used to identify telecommunications equipment.
  • +
  • Code 11 is a numeric symbology and its character set consists of 10 digital characters and the dash symbol (-).
  • +
  • There is a "C" check digit. If the length of encoded message is greater thant 10, a "K" check digit may be used.
  • +
+
+ + \ No newline at end of file diff --git a/application/libraries/barcodegen/html/BCGcode128.php b/application/libraries/barcodegen/html/BCGcode128.php new file mode 100755 index 000000000..6a458b447 --- /dev/null +++ b/application/libraries/barcodegen/html/BCGcode128.php @@ -0,0 +1,52 @@ +', '?', + '@', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '[', '\\', ']', '^', '_', + '`', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '{', '|', '}', '~', 'DEL' +); +?> + +
    +
  • +
    + +
    +
    + 'Auto', 'A' => 'Code 128-A', 'B' => 'Code 128-B', 'C' => 'Code 128-C')); ?> +
    +
  • +
+ +
+

Valid Characters

+ +
+ +
+

Explanation

+
    +
  • Code 128 is a high-density alphanumeric symbology.
  • +
  • Used extensively worldwide.
  • +
  • Code 128 is designed to encode 128 full ASCII characters.
  • +
  • The symbology includes a checksum digit.
  • +
  • Code 128A handles capital letters
    Code 128B handles capital letters and lowercase
    Code 128C handles group of 2 numbers
  • +
  • Your browser may not be able to write the special characters (NUL, SOH, etc.) but you can write them with the code.
  • +
+
+ + \ No newline at end of file diff --git a/application/libraries/barcodegen/html/BCGcode39.php b/application/libraries/barcodegen/html/BCGcode39.php new file mode 100755 index 000000000..7cd0c96a2 --- /dev/null +++ b/application/libraries/barcodegen/html/BCGcode39.php @@ -0,0 +1,42 @@ + + +
    +
  • +
    + +
    +
    + 1)); ?> +
    +
  • +
+ +
+

Valid Characters

+ +
+ +
+

Explanation

+
    +
  • Known also as USS Code 39, 3 of 9.
  • +
  • Code 39 can encode alphanumeric characters.
  • +
  • The symbology is used in non-retail environment.
  • +
  • Code 39 is designed to encode 26 upper case letters, 10 digits and 7 special characters.
  • +
  • Code 39 has a checksum but it's rarely used.
  • +
+
+ + \ No newline at end of file diff --git a/application/libraries/barcodegen/html/BCGcode39extended.php b/application/libraries/barcodegen/html/BCGcode39extended.php new file mode 100755 index 000000000..9eefaa9e8 --- /dev/null +++ b/application/libraries/barcodegen/html/BCGcode39extended.php @@ -0,0 +1,49 @@ +', '?', + '@', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '[', '\\', ']', '^', '_', + '`', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '{', '|', '}', '~', 'DEL' +); +?> + +
    +
  • +
    + +
    +
    + 1)); ?> +
    +
  • +
+ +
+

Valid Characters

+ +
+ +
+

Explanation

+
    +
  • Supports the ASCII 0 to 127.
  • +
  • This mode is "optional" for Code 39, you have to specify your reader that you have extended code.
  • +
  • Your browser may not be able to write the special characters (NUL, SOH, etc.) but you can write them with the code.
  • +
+
+ + \ No newline at end of file diff --git a/application/libraries/barcodegen/html/BCGcode93.php b/application/libraries/barcodegen/html/BCGcode93.php new file mode 100755 index 000000000..aa3f7dd5b --- /dev/null +++ b/application/libraries/barcodegen/html/BCGcode93.php @@ -0,0 +1,38 @@ +', '?', + '@', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '[', '\\', ']', '^', '_', + '`', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '{', '|', '}', '~', 'DEL' +); +?> + +
+

Valid Characters

+ +
+ +
+

Explanation

+
    +
  • Known also as USS Code 93.
  • +
  • Code 93 was designed to provide a higher density and data security enhancement to Code 39.
  • +
  • Used primarily by Canadian postal office to encode supplementary delivery information.
  • +
  • Similar to Code 39, Code 93 has the same 43 characters plus 5 special ones to encode the ASCII 0 to 127.
  • +
  • This symbology composed of 2 check digits ("C" and "K").
  • +
  • Your browser may not be able to write the special characters (NUL, SOH, etc.) but you can write them with the code.
  • +
+
+ + \ No newline at end of file diff --git a/application/libraries/barcodegen/html/BCGean13.php b/application/libraries/barcodegen/html/BCGean13.php new file mode 100755 index 000000000..761bbf04e --- /dev/null +++ b/application/libraries/barcodegen/html/BCGean13.php @@ -0,0 +1,27 @@ + + +
+

Valid Characters

+ +
+ +
+

Explanation

+
    +
  • EAN means Internal Article Numbering.
  • +
  • It is an extension of UPC-A to include the country information.
  • +
  • Used with consumer products internationally.
  • +
  • Composed by 2 number system, 5 manufacturer code, 5 product code and 1 check digit.
  • +
+
+ + \ No newline at end of file diff --git a/application/libraries/barcodegen/html/BCGean8.php b/application/libraries/barcodegen/html/BCGean8.php new file mode 100755 index 000000000..b1ad3471e --- /dev/null +++ b/application/libraries/barcodegen/html/BCGean8.php @@ -0,0 +1,26 @@ + + +
+

Valid Characters

+ +
+ +
+

Explanation

+
    +
  • EAN-8 is a short version of EAN-13.
  • +
  • Composed by 7 digits and 1 check digit.
  • +
  • There is no conversion available between EAN-8 and EAN-13.
  • +
+
+ + \ No newline at end of file diff --git a/application/libraries/barcodegen/html/BCGgs1128.php b/application/libraries/barcodegen/html/BCGgs1128.php new file mode 100755 index 000000000..2dc9dda25 --- /dev/null +++ b/application/libraries/barcodegen/html/BCGgs1128.php @@ -0,0 +1,250 @@ + 'Select an identifier', + '00' => 'Serial Shipping Container Code (SSCC-18)', + '01' => 'Shipping Container Code (SSC)', + '02' => 'Number of containers', + '10' => 'Batch Number', + '11' => 'Production Date', + '12' => 'Due date', + '13' => 'Packaging Date', + '15' => 'Sell by Date (Quality Control)', + '17' => 'Expiration Date', + '20' => 'Product Variant', + '21' => 'Serial Number', + '240' => 'Additional Product Identification', + '241' => 'Customer part number', + '250' => 'Second Serial Number', + '251' => 'Reference to source entity', + '253' => 'Global Document Type Identifier', + '30' => 'Quantity Each', + '310y' => 'Product Net Weight in kg', + '311y' => 'Product Length/1st Dimension, in meters', + '312y' => 'Product Width/Diameter/2nd Dimension, in meters', + '313y' => 'Product Depth/Thickness/3rd Dimension, in meters', + '314y' => 'Product Area, in square meters', + '315y' => 'Product Volume, in liters', + '316y' => 'product Volume, in cubic meters', + '320y' => 'Product Net Weight, in pounds', + '321y' => 'Product Length/1st Dimension, in inches', + '322y' => 'Product Length/1st Dimension, in feet', + '323y' => 'Product Length/1st Dimension, in yards', + '324y' => 'Product Width/Diameter/2nd Dimension, in inches', + '325y' => 'Product Width/Diameter/2nd Dimension, in feet', + '326y' => 'Product Width/Diameter/2nd Dimension, in yards', + '327y' => 'Product Depth/Thickness/3rd Dimension, in inches', + '328y' => 'Product Depth/Thickness/3rd Dimension, in feet', + '329y' => 'Product Depth/Thickness/3rd Dimension, in yards', + '330y' => 'Container Gross Weight (Kg)', + '331y' => 'Container Length/1st Dimension (Meters)', + '332y' => 'Container Width/Diameter/2nd Dimension (Meters)', + '333y' => 'Container Depth/Thickness/3rd Dimension (Meters)', + '334y' => 'Container Area (Square Meters)', + '335y' => 'Container Gross Volume (Liters)', + '336y' => 'Container Gross Volume (Cubic Meters)', + '337y' => 'Kilograms per square meter', + '340y' => 'Container Gross Weight (Pounds)', + '341y' => 'Container Length/1st Dimension, in inches', + '342y' => 'Container Length/1st Dimension, in feet', + '343y' => 'Container Length/1st Dimension in, in yards', + '344y' => 'Container Width/Diameter/2nd Dimension, in inches', + '345y' => 'Container Width/Diameter/2nd Dimension, in feet', + '346y' => 'Container Width/Diameter/2nd Dimension, in yards', + '347y' => 'Container Depth/Thickness/Height/3rd Dimension, in inches', + '348y' => 'Container Depth/Thickness/Height/3rd Dimension, in feet', + '349y' => 'Container Depth/Thickness/Height/3rd Dimension, in yards', + '350y' => 'Product Area (Square Inches)', + '351y' => 'Product Area (Square Feet)', + '352y' => 'Product Area (Square Yards)', + '353y' => 'Container Area (Square Inches)', + '354y' => 'Container Area (Square Feet)', + '355y' => 'Container Area (Square Yards)', + '356y' => 'Net Weight (Troy Ounces)', + '357y' => 'Kilograms per square meter', + '360y' => 'Product Volume (Quarts)', + '361y' => 'Product Volume (Gallons)', + '362y' => 'Container Gross Volume (Quarts)', + '363y' => 'Container Gross Volume (Gallons)', + '364y' => 'Product Volume (Cubic Inches)', + '365y' => 'Product Volume (Cubic Feet)', + '366y' => 'Product Volume (Cubic Yards)', + '367y' => 'Container Gross Volume (Cubic Inches)', + '368y' => 'Container Gross Volume (Cubic Feet)', + '369y' => 'Container Gross Volume (Cubic Yards)', + '37' => 'Number of Units Contained', + '390y' => 'Amount payable-single monetary area', + '391y' => 'Amount payable with ISO currency code', + '392y' => 'Amount payable for a Variable Measure Trade Item single monetary unit', + '393y' => 'Amount payable for a Variable Measure Trade Item - with ISO currency code', + '400' => 'Customer Purchase Order Number', + '401' => 'Consignment number', + '402' => 'Shipment Identification Number', + '403' => 'Routing code', + '410' => 'Ship To/Deliver To Location Code (EAN13 or DUNS code)', + '411' => 'Bill To/Invoice Location Code (EAN13 or DUNS code)', + '412' => 'Purchase From Location Code (EAN13 or DUNS code)', + '413' => 'Ship for - deliver for - forward to EAN.UCC Global Location Number', + '414' => 'Identification of a physical location EAN.UCC Global Location Number', + '415' => 'EAN.UCC Global Location Number of the invoicing party', + '420' => 'Ship To/Deliver To Postal Code (Single Postal Authority)', + '421' => 'Ship To/Deliver To Postal Code (Multiple Postal Authority)', + '422' => 'Country of origin of a trade item', + '8001' => 'Roll Products - Width/Length/Core Diameter', + '8002' => 'Electronic Serial Number (ESN) for Cellular Phone', + '8003' => 'UPC/EAN Number and Serial Number of Returnable Asset', + '8004' => 'UPC/EAN Serial Identification', + '8005' => 'Price per Unit of Measure', + '8006' => 'Identification of the component of a trade item', + '8007' => 'International Bank Account Number', + '8018' => 'EAN.UCC Global Service Relation Number', + '8020' => 'Payment Slip Reference Number', + '8100' => 'Coupon Extended Code: Number System and Offer', + '8101' => '8101 Coupon Extended Code: Number System, Offer, End of Offer', + '8102' => 'Coupon Extended Code: Number System preceded by 0', + '90' => 'Mutually Agreed Between Trading Partners', + '91' => 'Internal Company Codes', + '92' => 'Internal Company Codes', + '93' => 'Internal Company Codes', + '94' => 'Internal Company Codes', + '95' => 'Internal Company Codes', + '96' => 'Internal Company Codes', + '97' => 'Internal Company Codes', + '98' => 'Internal Company Codes', + '99' => 'Internal Company Codes' +); + +foreach ($identifiers as $key => $value) { + if ($key) { + $identifiers[$key] = $key . ' - ' . $value; + } +} + +registerImageKey('code', 'BCGgs1128'); + +$vals = array(); +for($i = 0; $i <= 127; $i++) { + $vals[] = '%' . sprintf('%02X', $i); +} +$characters = array( + 'NUL', 'SOH', 'STX', 'ETX', 'EOT', 'ENQ', 'ACK', 'BEL', 'BS', 'TAB', 'LF', 'VT', 'FF', 'CR', 'SO', 'SI', 'DLE', 'DC1', 'DC2', 'DC3', 'DC4', 'NAK', 'SYN', 'ETB', 'CAN', 'EM', 'SUB', 'ESC', 'FS', 'GS', 'RS', 'US', + ' ', '!', '"', '#', '$', '%', '&', '\'', '(', ')', '*', '+', ',', '-', '.', '/', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', ':', ';', '<', '=', '>', '?', + '@', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '[', '\\', ']', '^', '_', + '`', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '{', '|', '}', '~', 'DEL' +); +?> + +
    +
  • +
    + +
    +
    + 'Auto', 'A' => 'Code 128-A', 'B' => 'Code 128-B', 'C' => 'Code 128-C')); ?> +
    +
  • +
  • +
    + +
    +
    + +
    +
    +
  • +
+ +
+

Valid Characters

+ +
+ +
+

Explanation

+
    +
  • Encoded as Code 128.
  • +
  • The former correct name was UCC/EAN-128.
  • +
  • Used for shipping containers.
  • +
  • Based on the GS1 standard.
  • +
+
+ + + + \ No newline at end of file diff --git a/application/libraries/barcodegen/html/BCGi25.php b/application/libraries/barcodegen/html/BCGi25.php new file mode 100755 index 000000000..7b5fbe66c --- /dev/null +++ b/application/libraries/barcodegen/html/BCGi25.php @@ -0,0 +1,39 @@ + + +
    +
  • +
    + +
    +
    + 1)); ?> +
    +
  • +
+ +
+

Valid Characters

+ +
+ +
+

Explanation

+
    +
  • Interleaved 2 of 5 is based on Standard 2 of 5 symbology.
  • +
  • There is an optional checksum.
  • +
+
+ + \ No newline at end of file diff --git a/application/libraries/barcodegen/html/BCGintelligentmail.php b/application/libraries/barcodegen/html/BCGintelligentmail.php new file mode 100755 index 000000000..94bba9f87 --- /dev/null +++ b/application/libraries/barcodegen/html/BCGintelligentmail.php @@ -0,0 +1,99 @@ + + +
    +
  • +
    + +
    +
    + 'text', 'maxlength' => 2, 'required' => 'required')); ?> +
    +
  • +
  • +
    + +
    +
    + 'text', 'maxlength' => 3, 'required' => 'required')); ?> +
    +
  • +
  • +
    + +
    +
    + 'text', 'maxlength' => 9, 'required' => 'required')); ?> +
    +
  • +
  • +
    + +
    +
    + 'text', 'maxlength' => 9, 'required' => 'required')); ?> +
    +
  • +
+ +
+

Valid Characters

+ +
+ +
+

Explanation

+
    +
  • Used to encode enveloppe in USA.
  • +
  • + You can provide +
    5 digits (ZIP Code) +
    9 digits (ZIP+4 code) +
    11 digits (ZIP+4 code+2 digits) +
  • +
  • Contains a barcode identifier, service type identifier, mailer id and serial number.
  • +
+
+ + + + \ No newline at end of file diff --git a/application/libraries/barcodegen/html/BCGisbn.php b/application/libraries/barcodegen/html/BCGisbn.php new file mode 100755 index 000000000..2f6581218 --- /dev/null +++ b/application/libraries/barcodegen/html/BCGisbn.php @@ -0,0 +1,27 @@ + + +
+

Valid Characters

+ +
+ +
+

Explanation

+
    +
  • ISBN stands for International Standard Book Number.
  • +
  • ISBN type is based on EAN-13.
  • +
  • Previously, all ISBN were in EAN-10 format. EAN-13 uses the same encoding but may contain different data in the ISBN number.
  • +
  • Composed by a GS1 prefix (for ISBN-13), a group identifier, a publisher code, an item number and a check digit.
  • +
+
+ + \ No newline at end of file diff --git a/application/libraries/barcodegen/html/BCGmsi.php b/application/libraries/barcodegen/html/BCGmsi.php new file mode 100755 index 000000000..6a09c9a1d --- /dev/null +++ b/application/libraries/barcodegen/html/BCGmsi.php @@ -0,0 +1,39 @@ + + +
    +
  • +
    + +
    +
    + 1)); ?> +
    +
  • +
+ +
+

Valid Characters

+ +
+ +
+

Explanation

+
    +
  • Developed by the MSI Data Corporation.
  • +
  • Used primarily to mark retail shelves for inventory control.
  • +
+
+ + \ No newline at end of file diff --git a/application/libraries/barcodegen/html/BCGothercode.php b/application/libraries/barcodegen/html/BCGothercode.php new file mode 100755 index 000000000..3d72c026a --- /dev/null +++ b/application/libraries/barcodegen/html/BCGothercode.php @@ -0,0 +1,39 @@ + + +
    +
  • +
    + +
    +
    + +
    +
  • +
+ +
+

Valid Characters

+ +
+ +
+

Explanation

+
    +
  • Enter width of each bars with one characters. Begin by a bar.
  • +
  • 10523: Will do 2px bar, 1px space, 6px bar, 3px space, 4px bar.
  • +
+
+ + diff --git a/application/libraries/barcodegen/html/BCGpostnet.php b/application/libraries/barcodegen/html/BCGpostnet.php new file mode 100755 index 000000000..5d628b1c8 --- /dev/null +++ b/application/libraries/barcodegen/html/BCGpostnet.php @@ -0,0 +1,48 @@ + + +
+

Valid Characters

+ +
+ +
+

Explanation

+
    +
  • Used to encode enveloppe in USA.
  • +
  • + You can provide +
    5 digits (ZIP Code) +
    9 digits (ZIP+4 code) +
    11 digits (ZIP+4 code+2 digits) +
    (Those 2 digits are taken from your address. If your address is 6453, the code will be 53.) +
  • +
+
+ + + + \ No newline at end of file diff --git a/application/libraries/barcodegen/html/BCGs25.php b/application/libraries/barcodegen/html/BCGs25.php new file mode 100755 index 000000000..441c3bfaa --- /dev/null +++ b/application/libraries/barcodegen/html/BCGs25.php @@ -0,0 +1,41 @@ + + +
    +
  • +
    + +
    +
    + 1)); ?> +
    +
  • +
+ +
+

Valid Characters

+ +
+ +
+

Explanation

+
    +
  • Known also as Industrial 2 of 5.
  • +
  • Standard 2 of 5 is a low-density numeric symbology that has been with us since the 1960s.
  • +
  • There is an optional checksum.
  • +
  • Note: Standard 2 of 5 is really tough to read!
  • +
+
+ + \ No newline at end of file diff --git a/application/libraries/barcodegen/html/BCGupca.php b/application/libraries/barcodegen/html/BCGupca.php new file mode 100755 index 000000000..2bcee8a39 --- /dev/null +++ b/application/libraries/barcodegen/html/BCGupca.php @@ -0,0 +1,36 @@ + + +
+

Valid Characters

+ +
+ +
+

Explanation

+
    +
  • Encoded as EAN-13.
  • +
  • Most common and well-known in the USA.
  • +
  • There is 1 number system (NS), 5 manufacturer code, 5 product code and 1 check digit.
  • +
  • + NS Description : +
    0 = Regular UPC Code +
    2 = Weight Items +
    3 = Drug/Health Items +
    4 = In-Store Use on Non-Food Items +
    5 = Coupons +
    7 = Regular UPC Code +
    And other are Reserved. +
  • +
+
+ + \ No newline at end of file diff --git a/application/libraries/barcodegen/html/BCGupce.php b/application/libraries/barcodegen/html/BCGupce.php new file mode 100755 index 000000000..73a4d8f37 --- /dev/null +++ b/application/libraries/barcodegen/html/BCGupce.php @@ -0,0 +1,27 @@ + + +
+

Valid Characters

+ +
+ +
+

Explanation

+
    +
  • Short version of UPC symbol, 8 characters.
  • +
  • It is a conversion of an UPC-A for small package.
  • +
  • You can provide directly an UPC-A (11 chars) or UPC-E (6 chars) code.
  • +
  • UPC-E contain a system number and a check digit.
  • +
+
+ + \ No newline at end of file diff --git a/application/libraries/barcodegen/html/BCGupcext2.php b/application/libraries/barcodegen/html/BCGupcext2.php new file mode 100755 index 000000000..1288d70be --- /dev/null +++ b/application/libraries/barcodegen/html/BCGupcext2.php @@ -0,0 +1,25 @@ + + +
+

Valid Characters

+ +
+ +
+

Explanation

+
    +
  • Extension for UPC-A, UPC-E, EAN-13 and EAN-8.
  • +
  • Used for encode additional information for newspaper, books...
  • +
+
+ + \ No newline at end of file diff --git a/application/libraries/barcodegen/html/BCGupcext5.php b/application/libraries/barcodegen/html/BCGupcext5.php new file mode 100755 index 000000000..cd911c4da --- /dev/null +++ b/application/libraries/barcodegen/html/BCGupcext5.php @@ -0,0 +1,33 @@ + + +
+

Valid Characters

+ +
+ +
+

Explanation

+
    +
  • Extension for UPC-A, UPC-E, EAN-13 and EAN-8.
  • +
  • Used to encode suggested retail price.
  • +
  • If the first number is a 0, the price xx.xx is expressed in British Pounds. If it is a 5, it is expressed in US dollars.
  • +
  • + Special Code Description: +
    90000: No suggested retail price +
    99991: The item is a complementary of another one. Normally free +
    99990: Used bh National Association of College Stores to mark "used book" +
    90001 to 98999: Internal purposes for some publishers +
  • +
+
+ + \ No newline at end of file diff --git a/application/libraries/barcodegen/html/barcode.js b/application/libraries/barcodegen/html/barcode.js new file mode 100755 index 000000000..016638670 --- /dev/null +++ b/application/libraries/barcodegen/html/barcode.js @@ -0,0 +1,120 @@ +$(function() { + var attachMainBehaviors = function() { + $("select[name=type]").on("change", function() { + var selected = $(this).find("option:selected"); + window.location.href = selected.val(); + }); + + $("select[name=filetype]").on("change", function() { + var selected = $(this).find("option:selected"), + val = selected.val(), + dpi = $("input[name=dpi]"), + dpiUnavailable = $("#dpiUnavailable"); + + if (val === "PNG" || val === "JPEG") { + dpi.prop("disabled", false); + dpiUnavailable.hide(); + } else { + dpi.prop("disabled", true); + dpiUnavailable.show(); + } + }).change(); + + var text = $("input[name=text]"); + + $("#validCharacters").on("click", "[data-output]", function() { + var $this = $(this), + escaped = $this.data("escaped"), + value = $this.data("output"); + if (escaped) { + value = unescape(value); + } + + text + .val(text.val() + value) + .focus(); + }); + }, attachUIBehaviors = function() { + $("table").each(function() { + var $this = $(this); + $this.find("tr:even").addClass("even"); + $this.find("tr:odd").addClass("odd"); + }); + }, attachSpecificBehaviors = function() { + $("#specificOptions li").each(function() { + var $this = $(this), + code = $(""); + code.find(".title").append($this.find(".title")); + code.find(".value").append($this.find(".value")); + + $("div.configurations tr:last").before(code); + }); + }, attachInfoBehaviors = function() { + var showTooltip = function(object) { + object + .on("mouseover", function() { + var timer = $(this).data("timer"); + if (timer) { + clearTimeout(timer); + } + }) + .on("mouseout", function() { + var that = $(this); + that.data("timer", setTimeout(function() { + that.removeClass("visible"); + }, 1000)); + }); + + return function() { + var $this = $(this), + offset = $this.offset(), + timer = object.data("timer"); + + if (timer) { + clearTimeout(timer); + } + + // Show it once so we can get the outerWidth properly + object + .css({ + left: -99999, + top: -99999 + }) + .addClass("visible") + .css({ + left: offset.left + $this.width() - object.outerWidth(), + top: offset.top + $this.height() + }); + return false; + }; + }, + hideTooltip = function(object) { + return function() { + object.data("timer", setTimeout(function() { + object.removeClass("visible"); + }, 1000)); + }; + }, + bubbleize = function(object) { + return object + .addClass("bubble") + .attr("role", "tooltip") + .appendTo(document.body); + }, + explanation = bubbleize($("#explanation")), + validCharacters = bubbleize($("#validCharacters")); + + $(".info.explanation") + .on("mouseover focusin", showTooltip(explanation)) + .on("mouseout focusout", hideTooltip(explanation)); + + $(".info.characters") + .on("mouseover focusin", showTooltip(validCharacters)) + .on("mouseout focusout", hideTooltip(validCharacters)); + }; + + attachSpecificBehaviors(); + attachMainBehaviors(); + attachUIBehaviors(); + attachInfoBehaviors(); +}); \ No newline at end of file diff --git a/application/libraries/barcodegen/html/config/BCGBarcode1D.php b/application/libraries/barcodegen/html/config/BCGBarcode1D.php new file mode 100755 index 000000000..ca56f3589 --- /dev/null +++ b/application/libraries/barcodegen/html/config/BCGBarcode1D.php @@ -0,0 +1,16 @@ +setThickness(max(9, min(90, intval($get['thickness'])))); + } + + $font = 0; + if ($get['font_family'] !== '0' && intval($get['font_size']) >= 1) { + $font = new BCGFontFile($font_dir . '/' . $get['font_family'], intval($get['font_size'])); + } + + $barcode->setFont($font); +} +?> \ No newline at end of file diff --git a/application/libraries/barcodegen/html/config/BCGcodabar.php b/application/libraries/barcodegen/html/config/BCGcodabar.php new file mode 100755 index 000000000..a3a574cf7 --- /dev/null +++ b/application/libraries/barcodegen/html/config/BCGcodabar.php @@ -0,0 +1,6 @@ + \ No newline at end of file diff --git a/application/libraries/barcodegen/html/config/BCGcode11.php b/application/libraries/barcodegen/html/config/BCGcode11.php new file mode 100755 index 000000000..0bd083ae4 --- /dev/null +++ b/application/libraries/barcodegen/html/config/BCGcode11.php @@ -0,0 +1,6 @@ + \ No newline at end of file diff --git a/application/libraries/barcodegen/html/config/BCGcode128.php b/application/libraries/barcodegen/html/config/BCGcode128.php new file mode 100755 index 000000000..521e000bb --- /dev/null +++ b/application/libraries/barcodegen/html/config/BCGcode128.php @@ -0,0 +1,12 @@ +setStart($get['start'] === 'NULL' ? null : $get['start']); + } +} +?> \ No newline at end of file diff --git a/application/libraries/barcodegen/html/config/BCGcode39.php b/application/libraries/barcodegen/html/config/BCGcode39.php new file mode 100755 index 000000000..ce6cfd5df --- /dev/null +++ b/application/libraries/barcodegen/html/config/BCGcode39.php @@ -0,0 +1,12 @@ +setChecksum($get['checksum'] === '1' ? true : false); + } +} +?> \ No newline at end of file diff --git a/application/libraries/barcodegen/html/config/BCGcode39extended.php b/application/libraries/barcodegen/html/config/BCGcode39extended.php new file mode 100755 index 000000000..ab8185475 --- /dev/null +++ b/application/libraries/barcodegen/html/config/BCGcode39extended.php @@ -0,0 +1,12 @@ +setChecksum($get['checksum'] === '1' ? true : false); + } +} +?> \ No newline at end of file diff --git a/application/libraries/barcodegen/html/config/BCGcode93.php b/application/libraries/barcodegen/html/config/BCGcode93.php new file mode 100755 index 000000000..2f58b460d --- /dev/null +++ b/application/libraries/barcodegen/html/config/BCGcode93.php @@ -0,0 +1,6 @@ + \ No newline at end of file diff --git a/application/libraries/barcodegen/html/config/BCGean13.php b/application/libraries/barcodegen/html/config/BCGean13.php new file mode 100755 index 000000000..8f10a68f4 --- /dev/null +++ b/application/libraries/barcodegen/html/config/BCGean13.php @@ -0,0 +1,6 @@ + \ No newline at end of file diff --git a/application/libraries/barcodegen/html/config/BCGean8.php b/application/libraries/barcodegen/html/config/BCGean8.php new file mode 100755 index 000000000..4072741c2 --- /dev/null +++ b/application/libraries/barcodegen/html/config/BCGean8.php @@ -0,0 +1,6 @@ + \ No newline at end of file diff --git a/application/libraries/barcodegen/html/config/BCGgs1128.php b/application/libraries/barcodegen/html/config/BCGgs1128.php new file mode 100755 index 000000000..e4c6b66fe --- /dev/null +++ b/application/libraries/barcodegen/html/config/BCGgs1128.php @@ -0,0 +1,12 @@ +setStart($get['start'] === 'NULL' ? null : $get['start']); + } +} +?> \ No newline at end of file diff --git a/application/libraries/barcodegen/html/config/BCGi25.php b/application/libraries/barcodegen/html/config/BCGi25.php new file mode 100755 index 000000000..cb5003b30 --- /dev/null +++ b/application/libraries/barcodegen/html/config/BCGi25.php @@ -0,0 +1,12 @@ +setChecksum($get['checksum'] === '1' ? true : false); + } +} +?> \ No newline at end of file diff --git a/application/libraries/barcodegen/html/config/BCGintelligentmail.php b/application/libraries/barcodegen/html/config/BCGintelligentmail.php new file mode 100755 index 000000000..eb1bbebcd --- /dev/null +++ b/application/libraries/barcodegen/html/config/BCGintelligentmail.php @@ -0,0 +1,12 @@ +setTrackingCode(intval($get['barcodeIdentifier']), intval($get['serviceType']), intval($get['mailerIdentifier']), intval($get['serialNumber'])); + } +} +?> \ No newline at end of file diff --git a/application/libraries/barcodegen/html/config/BCGisbn.php b/application/libraries/barcodegen/html/config/BCGisbn.php new file mode 100755 index 000000000..57e5ddc87 --- /dev/null +++ b/application/libraries/barcodegen/html/config/BCGisbn.php @@ -0,0 +1,6 @@ + \ No newline at end of file diff --git a/application/libraries/barcodegen/html/config/BCGmsi.php b/application/libraries/barcodegen/html/config/BCGmsi.php new file mode 100755 index 000000000..74c30c35a --- /dev/null +++ b/application/libraries/barcodegen/html/config/BCGmsi.php @@ -0,0 +1,12 @@ +setChecksum($get['checksum'] === '1' ? true : false); + } +} +?> \ No newline at end of file diff --git a/application/libraries/barcodegen/html/config/BCGothercode.php b/application/libraries/barcodegen/html/config/BCGothercode.php new file mode 100755 index 000000000..1acc70969 --- /dev/null +++ b/application/libraries/barcodegen/html/config/BCGothercode.php @@ -0,0 +1,12 @@ +setLabel($get['label']); + } +} +?> \ No newline at end of file diff --git a/application/libraries/barcodegen/html/config/BCGpostnet.php b/application/libraries/barcodegen/html/config/BCGpostnet.php new file mode 100755 index 000000000..142843dff --- /dev/null +++ b/application/libraries/barcodegen/html/config/BCGpostnet.php @@ -0,0 +1,6 @@ + \ No newline at end of file diff --git a/application/libraries/barcodegen/html/config/BCGs25.php b/application/libraries/barcodegen/html/config/BCGs25.php new file mode 100755 index 000000000..5266cecab --- /dev/null +++ b/application/libraries/barcodegen/html/config/BCGs25.php @@ -0,0 +1,12 @@ +setChecksum($get['checksum'] === '1' ? true : false); + } +} +?> \ No newline at end of file diff --git a/application/libraries/barcodegen/html/config/BCGupca.php b/application/libraries/barcodegen/html/config/BCGupca.php new file mode 100755 index 000000000..b4e5e2b70 --- /dev/null +++ b/application/libraries/barcodegen/html/config/BCGupca.php @@ -0,0 +1,6 @@ + \ No newline at end of file diff --git a/application/libraries/barcodegen/html/config/BCGupce.php b/application/libraries/barcodegen/html/config/BCGupce.php new file mode 100755 index 000000000..294a9ecd3 --- /dev/null +++ b/application/libraries/barcodegen/html/config/BCGupce.php @@ -0,0 +1,6 @@ + \ No newline at end of file diff --git a/application/libraries/barcodegen/html/config/BCGupcext2.php b/application/libraries/barcodegen/html/config/BCGupcext2.php new file mode 100755 index 000000000..158a20292 --- /dev/null +++ b/application/libraries/barcodegen/html/config/BCGupcext2.php @@ -0,0 +1,6 @@ + \ No newline at end of file diff --git a/application/libraries/barcodegen/html/config/BCGupcext5.php b/application/libraries/barcodegen/html/config/BCGupcext5.php new file mode 100755 index 000000000..f518ebc13 --- /dev/null +++ b/application/libraries/barcodegen/html/config/BCGupcext5.php @@ -0,0 +1,6 @@ + \ No newline at end of file diff --git a/application/libraries/barcodegen/html/delete.png b/application/libraries/barcodegen/html/delete.png new file mode 100755 index 000000000..fb0c022de Binary files /dev/null and b/application/libraries/barcodegen/html/delete.png differ diff --git a/application/libraries/barcodegen/html/error.png b/application/libraries/barcodegen/html/error.png new file mode 100755 index 000000000..ceab5af8c Binary files /dev/null and b/application/libraries/barcodegen/html/error.png differ diff --git a/application/libraries/barcodegen/html/favicon.ico b/application/libraries/barcodegen/html/favicon.ico new file mode 100755 index 000000000..939bd60ac Binary files /dev/null and b/application/libraries/barcodegen/html/favicon.ico differ diff --git a/application/libraries/barcodegen/html/image.php b/application/libraries/barcodegen/html/image.php new file mode 100755 index 000000000..9f8dc7c3f --- /dev/null +++ b/application/libraries/barcodegen/html/image.php @@ -0,0 +1,97 @@ + BCGDrawing::IMG_FORMAT_PNG, 'JPEG' => BCGDrawing::IMG_FORMAT_JPEG, 'GIF' => BCGDrawing::IMG_FORMAT_GIF); + +$drawException = null; +try { + $color_black = new BCGColor(0, 0, 0); + $color_white = new BCGColor(255, 255, 255); + + $code_generated = new $className(); + + if (function_exists('baseCustomSetup')) { + baseCustomSetup($code_generated, $_GET); + } + + if (function_exists('customSetup')) { + customSetup($code_generated, $_GET); + } + + $code_generated->setScale(max(1, min(4, $_GET['scale']))); + $code_generated->setBackgroundColor($color_white); + $code_generated->setForegroundColor($color_black); + + if ($_GET['text'] !== '') { + $text = convertText($_GET['text']); + $code_generated->parse($text); + } +} catch(Exception $exception) { + $drawException = $exception; +} + +$drawing = new BCGDrawing('', $color_white); +if($drawException) { + $drawing->drawException($drawException); +} else { + $drawing->setBarcode($code_generated); + $drawing->setRotationAngle($_GET['rotation']); + $drawing->setDPI($_GET['dpi'] === 'NULL' ? null : max(72, min(300, intval($_GET['dpi'])))); + $drawing->draw(); +} + +switch ($_GET['filetype']) { + case 'PNG': + header('Content-Type: image/png'); + break; + case 'JPEG': + header('Content-Type: image/jpeg'); + break; + case 'GIF': + header('Content-Type: image/gif'); + break; +} + +$drawing->finish($filetypes[$_GET['filetype']]); +?> \ No newline at end of file diff --git a/application/libraries/barcodegen/html/include/BCGBarcode1D.php b/application/libraries/barcodegen/html/include/BCGBarcode1D.php new file mode 100755 index 000000000..dcb4ce9fd --- /dev/null +++ b/application/libraries/barcodegen/html/include/BCGBarcode1D.php @@ -0,0 +1,11 @@ + + + + 'number', 'min' => 20, 'max' => 90, 'step' => 5, 'required' => 'required')); ?> + \ No newline at end of file diff --git a/application/libraries/barcodegen/html/include/barcode.php b/application/libraries/barcodegen/html/include/barcode.php new file mode 100755 index 000000000..317d8c525 --- /dev/null +++ b/application/libraries/barcodegen/html/include/barcode.php @@ -0,0 +1,39 @@ + 'Codabar', + 'BCGcode11.php' => 'Code 11', + 'BCGcode39.php' => 'Code 39', + 'BCGcode39extended.php' => 'Code 39 Extended', + 'BCGcode93.php' => 'Code 93', + 'BCGcode128.php' => 'Code 128', + 'BCGean8.php' => 'EAN-8', + 'BCGean13.php' => 'EAN-13', + 'BCGgs1128.php' => 'GS1-128 (EAN-128)', + 'BCGisbn.php' => 'ISBN', + 'BCGi25.php' => 'Interleaved 2 of 5', + 'BCGs25.php' => 'Standard 2 of 5', + 'BCGmsi.php' => 'MSI Plessey', + 'BCGupca.php' => 'UPC-A', + 'BCGupce.php' => 'UPC-E', + 'BCGupcext2.php' => 'UPC Extenstion 2 Digits', + 'BCGupcext5.php' => 'UPC Extenstion 5 Digits', + 'BCGpostnet.php' => 'Postnet', + 'BCGintelligentmail.php' => 'Intelligent Mail', + 'BCGothercode.php' => 'Other Barcode', + + // Databar + 'BCGdatabarexpanded.php' => 'Databar Expanded', + 'BCGdatabarlimited.php' => 'Databar Limited', + 'BCGdatabaromni.php' => 'Databar Omni', + + // 2D + 'BCGaztec.php' => 'Aztec', + 'BCGdatamatrix.php' => 'DataMatrix', + 'BCGmaxicode.php' => 'MaxiCode', + 'BCGpdf417.php' => 'PDF417', + 'BCGqrcode.php' => 'QRCode' +); +?> \ No newline at end of file diff --git a/application/libraries/barcodegen/html/include/footer.php b/application/libraries/barcodegen/html/include/footer.php new file mode 100755 index 000000000..c1bde56d7 --- /dev/null +++ b/application/libraries/barcodegen/html/include/footer.php @@ -0,0 +1,32 @@ + + +
+
+

Output

+ $value) { + $finalRequest .= '&' . $key . '=' . urlencode($value); + } + if (strlen($finalRequest) > 0) { + $finalRequest[0] = '?'; + } + ?> +
+ Barcode ImageFill the form to generate a barcode. +
+
+
+ + + + + \ No newline at end of file diff --git a/application/libraries/barcodegen/html/include/function.php b/application/libraries/barcodegen/html/include/function.php new file mode 100755 index 000000000..40543d280 --- /dev/null +++ b/application/libraries/barcodegen/html/include/function.php @@ -0,0 +1,170 @@ + $value) { + $code .= ' ' . $attribute . '="' . htmlentities(stripslashes($value), ENT_COMPAT) . '"'; + } + + if ($content === false || $content === null) { + $code .= ' />'; + } else { + $code .= '>' . $content . ''; + } + + return $code; +} + +function getInputTextHtml($name, $currentValue, $attributes = array()) { + $defaultAttributes = array( + 'id' => $name, + 'name' => $name + ); + + $finalAttributes = array_merge($defaultAttributes, $attributes); + if ($currentValue !== null) { + $finalAttributes['value'] = $currentValue; + } + + return getElementHtml('input', $finalAttributes, false); +} + +function getOptionGroup($options, $currentValue) { + $content = ''; + foreach ($options as $optionKey => $optionValue) { + if (is_array($optionValue)) { + $content .= '' . getOptionGroup($optionValue, $currentValue) . ''; + } else { + $optionAttributes = array(); + if ($currentValue == $optionKey) { + $optionAttributes['selected'] = 'selected'; + } + $content .= getOptionHtml($optionKey, $optionValue, $optionAttributes); + } + } + + return $content; +} + +function getOptionHtml($value, $content, $attributes = array()) { + $defaultAttributes = array( + 'value' => $value + ); + + $finalAttributes = array_merge($defaultAttributes, $attributes); + + return getElementHtml('option', $finalAttributes, $content); +} + +function getSelectHtml($name, $currentValue, $options, $attributes = array()) { + $defaultAttributes = array( + 'size' => 1, + 'id' => $name, + 'name' => $name + ); + + $finalAttributes = array_merge($defaultAttributes, $attributes); + $content = getOptionGroup($options, $currentValue); + + return getElementHtml('select', $finalAttributes, $content); +} + +function getCheckboxHtml($name, $currentValue, $attributes = array()) { + $defaultAttributes = array( + 'type' => 'checkbox', + 'id' => $name, + 'name' => $name, + 'value' => isset($attributes['value']) ? $attributes['value'] : 'On' + ); + + $finalAttributes = array_merge($defaultAttributes, $attributes); + if ($currentValue == $finalAttributes['value']) { + $finalAttributes['checked'] = 'checked'; + } + + return getElementHtml('input', $finalAttributes, false); +} + +function getButton($value, $output = null) { + $escaped = false; + $finalValue = $value[0] === '&' ? $value : htmlentities($value); + if ($output === null) { + $output = $value; + } else { + $escaped = true; + } + + $code = ''; + return $code; +} + +/** + * Returns the fonts available for drawing. + * + * @return string[] + */ +function listfonts($folder) { + $array = array(); + if (($handle = opendir($folder)) !== false) { + while (($file = readdir($handle)) !== false) { + if(substr($file, -4, 4) === '.ttf') { + $array[$file] = $file; + } + } + } + closedir($handle); + + array_unshift($array, 'No Label'); + + return $array; +} + +/** + * Returns the barcodes present for drawing. + * + * @return string[] + */ +function listbarcodes() { + include_once('barcode.php'); + + $availableBarcodes = array(); + foreach ($supportedBarcodes as $file => $title) { + if (file_exists($file)) { + $availableBarcodes[$file] = $title; + } + } + + return $availableBarcodes; +} + +function findValueFromKey($haystack, $needle) { + foreach ($haystack as $key => $value) { + if (strcasecmp($key, $needle) === 0) { + return $value; + } + } + + return null; +} + +function convertText($text) { + $text = stripslashes($text); + if (function_exists('mb_convert_encoding')) { + $text = mb_convert_encoding($text, 'ISO-8859-1', 'UTF-8'); + } + + return $text; +} +?> \ No newline at end of file diff --git a/application/libraries/barcodegen/html/include/header.php b/application/libraries/barcodegen/html/include/header.php new file mode 100755 index 000000000..ed37a527f --- /dev/null +++ b/application/libraries/barcodegen/html/include/header.php @@ -0,0 +1,130 @@ +=') !== true) { + exit('Sorry, but you have to run this script with PHP5... You currently have the version ' . phpversion() . '.'); +} + +if (!function_exists('imagecreate')) { + exit('Sorry, make sure you have the GD extension installed before running this script.'); +} + +include_once('function.php'); + +// FileName & Extension +$system_temp_array = explode('/', $_SERVER['PHP_SELF']); +$filename = $system_temp_array[count($system_temp_array) - 1]; +$system_temp_array2 = explode('.', $filename); +$availableBarcodes = listBarcodes(); +$barcodeName = findValueFromKey($availableBarcodes, $filename); +$code = $system_temp_array2[0]; + +// Check if the code is valid +if (file_exists('config' . DIRECTORY_SEPARATOR . $code . '.php')) { + include_once('config' . DIRECTORY_SEPARATOR . $code . '.php'); +} +?> + + + + <?php echo $barcodeName; ?> - Barcode Generator + + + + + + + + + + +
+
+ + +
+
+ +
+

Barcode Generator

+

+
+
+

Configurations

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
'PNG - Portable Network Graphics', 'JPEG' => 'JPEG - Joint Photographic Experts Group', 'GIF' => 'GIF - Graphics Interchange Format')); ?>
'number', 'min' => 72, 'max' => 300, 'required' => 'required')); ?> DPI is available only for PNG and JPEG.
'number', 'min' => 1, 'max' => 4, 'required' => 'required')); ?>
'No rotation', 90 => '90° clockwise', 180 => '180° clockwise', 270 => '270° clockwise')); ?>
'number', 'min' => 1, 'max' => 30)); ?>
+
'text', 'required' => 'required')); ?>
+
Help
+
+
+
\ No newline at end of file diff --git a/application/libraries/barcodegen/html/index.php b/application/libraries/barcodegen/html/index.php new file mode 100755 index 000000000..f806fcc53 --- /dev/null +++ b/application/libraries/barcodegen/html/index.php @@ -0,0 +1,3 @@ + \ No newline at end of file diff --git a/application/libraries/barcodegen/html/info.gif b/application/libraries/barcodegen/html/info.gif new file mode 100755 index 000000000..f7fda8881 Binary files /dev/null and b/application/libraries/barcodegen/html/info.gif differ diff --git a/application/libraries/barcodegen/html/jquery-1.7.2.min.js b/application/libraries/barcodegen/html/jquery-1.7.2.min.js new file mode 100755 index 000000000..45bb4fc1f --- /dev/null +++ b/application/libraries/barcodegen/html/jquery-1.7.2.min.js @@ -0,0 +1,4 @@ +/*! jQuery v1.7.2 jquery.com | jquery.org/license */ +(function(a,b){function cy(a){return f.isWindow(a)?a:a.nodeType===9?a.defaultView||a.parentWindow:!1}function cu(a){if(!cj[a]){var b=c.body,d=f("<"+a+">").appendTo(b),e=d.css("display");d.remove();if(e==="none"||e===""){ck||(ck=c.createElement("iframe"),ck.frameBorder=ck.width=ck.height=0),b.appendChild(ck);if(!cl||!ck.createElement)cl=(ck.contentWindow||ck.contentDocument).document,cl.write((f.support.boxModel?"":"")+""),cl.close();d=cl.createElement(a),cl.body.appendChild(d),e=f.css(d,"display"),b.removeChild(ck)}cj[a]=e}return cj[a]}function ct(a,b){var c={};f.each(cp.concat.apply([],cp.slice(0,b)),function(){c[this]=a});return c}function cs(){cq=b}function cr(){setTimeout(cs,0);return cq=f.now()}function ci(){try{return new a.ActiveXObject("Microsoft.XMLHTTP")}catch(b){}}function ch(){try{return new a.XMLHttpRequest}catch(b){}}function cb(a,c){a.dataFilter&&(c=a.dataFilter(c,a.dataType));var d=a.dataTypes,e={},g,h,i=d.length,j,k=d[0],l,m,n,o,p;for(g=1;g0){if(c!=="border")for(;e=0===c})}function S(a){return!a||!a.parentNode||a.parentNode.nodeType===11}function K(){return!0}function J(){return!1}function n(a,b,c){var d=b+"defer",e=b+"queue",g=b+"mark",h=f._data(a,d);h&&(c==="queue"||!f._data(a,e))&&(c==="mark"||!f._data(a,g))&&setTimeout(function(){!f._data(a,e)&&!f._data(a,g)&&(f.removeData(a,d,!0),h.fire())},0)}function m(a){for(var b in a){if(b==="data"&&f.isEmptyObject(a[b]))continue;if(b!=="toJSON")return!1}return!0}function l(a,c,d){if(d===b&&a.nodeType===1){var e="data-"+c.replace(k,"-$1").toLowerCase();d=a.getAttribute(e);if(typeof d=="string"){try{d=d==="true"?!0:d==="false"?!1:d==="null"?null:f.isNumeric(d)?+d:j.test(d)?f.parseJSON(d):d}catch(g){}f.data(a,c,d)}else d=b}return d}function h(a){var b=g[a]={},c,d;a=a.split(/\s+/);for(c=0,d=a.length;c)[^>]*$|#([\w\-]*)$)/,j=/\S/,k=/^\s+/,l=/\s+$/,m=/^<(\w+)\s*\/?>(?:<\/\1>)?$/,n=/^[\],:{}\s]*$/,o=/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,p=/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,q=/(?:^|:|,)(?:\s*\[)+/g,r=/(webkit)[ \/]([\w.]+)/,s=/(opera)(?:.*version)?[ \/]([\w.]+)/,t=/(msie) ([\w.]+)/,u=/(mozilla)(?:.*? rv:([\w.]+))?/,v=/-([a-z]|[0-9])/ig,w=/^-ms-/,x=function(a,b){return(b+"").toUpperCase()},y=d.userAgent,z,A,B,C=Object.prototype.toString,D=Object.prototype.hasOwnProperty,E=Array.prototype.push,F=Array.prototype.slice,G=String.prototype.trim,H=Array.prototype.indexOf,I={};e.fn=e.prototype={constructor:e,init:function(a,d,f){var g,h,j,k;if(!a)return this;if(a.nodeType){this.context=this[0]=a,this.length=1;return this}if(a==="body"&&!d&&c.body){this.context=c,this[0]=c.body,this.selector=a,this.length=1;return this}if(typeof a=="string"){a.charAt(0)!=="<"||a.charAt(a.length-1)!==">"||a.length<3?g=i.exec(a):g=[null,a,null];if(g&&(g[1]||!d)){if(g[1]){d=d instanceof e?d[0]:d,k=d?d.ownerDocument||d:c,j=m.exec(a),j?e.isPlainObject(d)?(a=[c.createElement(j[1])],e.fn.attr.call(a,d,!0)):a=[k.createElement(j[1])]:(j=e.buildFragment([g[1]],[k]),a=(j.cacheable?e.clone(j.fragment):j.fragment).childNodes);return e.merge(this,a)}h=c.getElementById(g[2]);if(h&&h.parentNode){if(h.id!==g[2])return f.find(a);this.length=1,this[0]=h}this.context=c,this.selector=a;return this}return!d||d.jquery?(d||f).find(a):this.constructor(d).find(a)}if(e.isFunction(a))return f.ready(a);a.selector!==b&&(this.selector=a.selector,this.context=a.context);return e.makeArray(a,this)},selector:"",jquery:"1.7.2",length:0,size:function(){return this.length},toArray:function(){return F.call(this,0)},get:function(a){return a==null?this.toArray():a<0?this[this.length+a]:this[a]},pushStack:function(a,b,c){var d=this.constructor();e.isArray(a)?E.apply(d,a):e.merge(d,a),d.prevObject=this,d.context=this.context,b==="find"?d.selector=this.selector+(this.selector?" ":"")+c:b&&(d.selector=this.selector+"."+b+"("+c+")");return d},each:function(a,b){return e.each(this,a,b)},ready:function(a){e.bindReady(),A.add(a);return this},eq:function(a){a=+a;return a===-1?this.slice(a):this.slice(a,a+1)},first:function(){return this.eq(0)},last:function(){return this.eq(-1)},slice:function(){return this.pushStack(F.apply(this,arguments),"slice",F.call(arguments).join(","))},map:function(a){return this.pushStack(e.map(this,function(b,c){return a.call(b,c,b)}))},end:function(){return this.prevObject||this.constructor(null)},push:E,sort:[].sort,splice:[].splice},e.fn.init.prototype=e.fn,e.extend=e.fn.extend=function(){var a,c,d,f,g,h,i=arguments[0]||{},j=1,k=arguments.length,l=!1;typeof i=="boolean"&&(l=i,i=arguments[1]||{},j=2),typeof i!="object"&&!e.isFunction(i)&&(i={}),k===j&&(i=this,--j);for(;j0)return;A.fireWith(c,[e]),e.fn.trigger&&e(c).trigger("ready").off("ready")}},bindReady:function(){if(!A){A=e.Callbacks("once memory");if(c.readyState==="complete")return setTimeout(e.ready,1);if(c.addEventListener)c.addEventListener("DOMContentLoaded",B,!1),a.addEventListener("load",e.ready,!1);else if(c.attachEvent){c.attachEvent("onreadystatechange",B),a.attachEvent("onload",e.ready);var b=!1;try{b=a.frameElement==null}catch(d){}c.documentElement.doScroll&&b&&J()}}},isFunction:function(a){return e.type(a)==="function"},isArray:Array.isArray||function(a){return e.type(a)==="array"},isWindow:function(a){return a!=null&&a==a.window},isNumeric:function(a){return!isNaN(parseFloat(a))&&isFinite(a)},type:function(a){return a==null?String(a):I[C.call(a)]||"object"},isPlainObject:function(a){if(!a||e.type(a)!=="object"||a.nodeType||e.isWindow(a))return!1;try{if(a.constructor&&!D.call(a,"constructor")&&!D.call(a.constructor.prototype,"isPrototypeOf"))return!1}catch(c){return!1}var d;for(d in a);return d===b||D.call(a,d)},isEmptyObject:function(a){for(var b in a)return!1;return!0},error:function(a){throw new Error(a)},parseJSON:function(b){if(typeof b!="string"||!b)return null;b=e.trim(b);if(a.JSON&&a.JSON.parse)return a.JSON.parse(b);if(n.test(b.replace(o,"@").replace(p,"]").replace(q,"")))return(new Function("return "+b))();e.error("Invalid JSON: "+b)},parseXML:function(c){if(typeof c!="string"||!c)return null;var d,f;try{a.DOMParser?(f=new DOMParser,d=f.parseFromString(c,"text/xml")):(d=new ActiveXObject("Microsoft.XMLDOM"),d.async="false",d.loadXML(c))}catch(g){d=b}(!d||!d.documentElement||d.getElementsByTagName("parsererror").length)&&e.error("Invalid XML: "+c);return d},noop:function(){},globalEval:function(b){b&&j.test(b)&&(a.execScript||function(b){a.eval.call(a,b)})(b)},camelCase:function(a){return a.replace(w,"ms-").replace(v,x)},nodeName:function(a,b){return a.nodeName&&a.nodeName.toUpperCase()===b.toUpperCase()},each:function(a,c,d){var f,g=0,h=a.length,i=h===b||e.isFunction(a);if(d){if(i){for(f in a)if(c.apply(a[f],d)===!1)break}else for(;g0&&a[0]&&a[j-1]||j===0||e.isArray(a));if(k)for(;i1?i.call(arguments,0):b,j.notifyWith(k,e)}}function l(a){return function(c){b[a]=arguments.length>1?i.call(arguments,0):c,--g||j.resolveWith(j,b)}}var b=i.call(arguments,0),c=0,d=b.length,e=Array(d),g=d,h=d,j=d<=1&&a&&f.isFunction(a.promise)?a:f.Deferred(),k=j.promise();if(d>1){for(;c
a",d=p.getElementsByTagName("*"),e=p.getElementsByTagName("a")[0];if(!d||!d.length||!e)return{};g=c.createElement("select"),h=g.appendChild(c.createElement("option")),i=p.getElementsByTagName("input")[0],b={leadingWhitespace:p.firstChild.nodeType===3,tbody:!p.getElementsByTagName("tbody").length,htmlSerialize:!!p.getElementsByTagName("link").length,style:/top/.test(e.getAttribute("style")),hrefNormalized:e.getAttribute("href")==="/a",opacity:/^0.55/.test(e.style.opacity),cssFloat:!!e.style.cssFloat,checkOn:i.value==="on",optSelected:h.selected,getSetAttribute:p.className!=="t",enctype:!!c.createElement("form").enctype,html5Clone:c.createElement("nav").cloneNode(!0).outerHTML!=="<:nav>",submitBubbles:!0,changeBubbles:!0,focusinBubbles:!1,deleteExpando:!0,noCloneEvent:!0,inlineBlockNeedsLayout:!1,shrinkWrapBlocks:!1,reliableMarginRight:!0,pixelMargin:!0},f.boxModel=b.boxModel=c.compatMode==="CSS1Compat",i.checked=!0,b.noCloneChecked=i.cloneNode(!0).checked,g.disabled=!0,b.optDisabled=!h.disabled;try{delete p.test}catch(r){b.deleteExpando=!1}!p.addEventListener&&p.attachEvent&&p.fireEvent&&(p.attachEvent("onclick",function(){b.noCloneEvent=!1}),p.cloneNode(!0).fireEvent("onclick")),i=c.createElement("input"),i.value="t",i.setAttribute("type","radio"),b.radioValue=i.value==="t",i.setAttribute("checked","checked"),i.setAttribute("name","t"),p.appendChild(i),j=c.createDocumentFragment(),j.appendChild(p.lastChild),b.checkClone=j.cloneNode(!0).cloneNode(!0).lastChild.checked,b.appendChecked=i.checked,j.removeChild(i),j.appendChild(p);if(p.attachEvent)for(n in{submit:1,change:1,focusin:1})m="on"+n,o=m in p,o||(p.setAttribute(m,"return;"),o=typeof p[m]=="function"),b[n+"Bubbles"]=o;j.removeChild(p),j=g=h=p=i=null,f(function(){var d,e,g,h,i,j,l,m,n,q,r,s,t,u=c.getElementsByTagName("body")[0];!u||(m=1,t="padding:0;margin:0;border:",r="position:absolute;top:0;left:0;width:1px;height:1px;",s=t+"0;visibility:hidden;",n="style='"+r+t+"5px solid #000;",q="
"+""+"
",d=c.createElement("div"),d.style.cssText=s+"width:0;height:0;position:static;top:0;margin-top:"+m+"px",u.insertBefore(d,u.firstChild),p=c.createElement("div"),d.appendChild(p),p.innerHTML="
t
",k=p.getElementsByTagName("td"),o=k[0].offsetHeight===0,k[0].style.display="",k[1].style.display="none",b.reliableHiddenOffsets=o&&k[0].offsetHeight===0,a.getComputedStyle&&(p.innerHTML="",l=c.createElement("div"),l.style.width="0",l.style.marginRight="0",p.style.width="2px",p.appendChild(l),b.reliableMarginRight=(parseInt((a.getComputedStyle(l,null)||{marginRight:0}).marginRight,10)||0)===0),typeof p.style.zoom!="undefined"&&(p.innerHTML="",p.style.width=p.style.padding="1px",p.style.border=0,p.style.overflow="hidden",p.style.display="inline",p.style.zoom=1,b.inlineBlockNeedsLayout=p.offsetWidth===3,p.style.display="block",p.style.overflow="visible",p.innerHTML="
",b.shrinkWrapBlocks=p.offsetWidth!==3),p.style.cssText=r+s,p.innerHTML=q,e=p.firstChild,g=e.firstChild,i=e.nextSibling.firstChild.firstChild,j={doesNotAddBorder:g.offsetTop!==5,doesAddBorderForTableAndCells:i.offsetTop===5},g.style.position="fixed",g.style.top="20px",j.fixedPosition=g.offsetTop===20||g.offsetTop===15,g.style.position=g.style.top="",e.style.overflow="hidden",e.style.position="relative",j.subtractsBorderForOverflowNotVisible=g.offsetTop===-5,j.doesNotIncludeMarginInBodyOffset=u.offsetTop!==m,a.getComputedStyle&&(p.style.marginTop="1%",b.pixelMargin=(a.getComputedStyle(p,null)||{marginTop:0}).marginTop!=="1%"),typeof d.style.zoom!="undefined"&&(d.style.zoom=1),u.removeChild(d),l=p=d=null,f.extend(b,j))});return b}();var j=/^(?:\{.*\}|\[.*\])$/,k=/([A-Z])/g;f.extend({cache:{},uuid:0,expando:"jQuery"+(f.fn.jquery+Math.random()).replace(/\D/g,""),noData:{embed:!0,object:"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000",applet:!0},hasData:function(a){a=a.nodeType?f.cache[a[f.expando]]:a[f.expando];return!!a&&!m(a)},data:function(a,c,d,e){if(!!f.acceptData(a)){var g,h,i,j=f.expando,k=typeof c=="string",l=a.nodeType,m=l?f.cache:a,n=l?a[j]:a[j]&&j,o=c==="events";if((!n||!m[n]||!o&&!e&&!m[n].data)&&k&&d===b)return;n||(l?a[j]=n=++f.uuid:n=j),m[n]||(m[n]={},l||(m[n].toJSON=f.noop));if(typeof c=="object"||typeof c=="function")e?m[n]=f.extend(m[n],c):m[n].data=f.extend(m[n].data,c);g=h=m[n],e||(h.data||(h.data={}),h=h.data),d!==b&&(h[f.camelCase(c)]=d);if(o&&!h[c])return g.events;k?(i=h[c],i==null&&(i=h[f.camelCase(c)])):i=h;return i}},removeData:function(a,b,c){if(!!f.acceptData(a)){var d,e,g,h=f.expando,i=a.nodeType,j=i?f.cache:a,k=i?a[h]:h;if(!j[k])return;if(b){d=c?j[k]:j[k].data;if(d){f.isArray(b)||(b in d?b=[b]:(b=f.camelCase(b),b in d?b=[b]:b=b.split(" ")));for(e=0,g=b.length;e1,null,!1)},removeData:function(a){return this.each(function(){f.removeData(this,a)})}}),f.extend({_mark:function(a,b){a&&(b=(b||"fx")+"mark",f._data(a,b,(f._data(a,b)||0)+1))},_unmark:function(a,b,c){a!==!0&&(c=b,b=a,a=!1);if(b){c=c||"fx";var d=c+"mark",e=a?0:(f._data(b,d)||1)-1;e?f._data(b,d,e):(f.removeData(b,d,!0),n(b,c,"mark"))}},queue:function(a,b,c){var d;if(a){b=(b||"fx")+"queue",d=f._data(a,b),c&&(!d||f.isArray(c)?d=f._data(a,b,f.makeArray(c)):d.push(c));return d||[]}},dequeue:function(a,b){b=b||"fx";var c=f.queue(a,b),d=c.shift(),e={};d==="inprogress"&&(d=c.shift()),d&&(b==="fx"&&c.unshift("inprogress"),f._data(a,b+".run",e),d.call(a,function(){f.dequeue(a,b)},e)),c.length||(f.removeData(a,b+"queue "+b+".run",!0),n(a,b,"queue"))}}),f.fn.extend({queue:function(a,c){var d=2;typeof a!="string"&&(c=a,a="fx",d--);if(arguments.length1)},removeAttr:function(a){return this.each(function(){f.removeAttr(this,a)})},prop:function(a,b){return f.access(this,f.prop,a,b,arguments.length>1)},removeProp:function(a){a=f.propFix[a]||a;return this.each(function(){try{this[a]=b,delete this[a]}catch(c){}})},addClass:function(a){var b,c,d,e,g,h,i;if(f.isFunction(a))return this.each(function(b){f(this).addClass(a.call(this,b,this.className))});if(a&&typeof a=="string"){b=a.split(p);for(c=0,d=this.length;c-1)return!0;return!1},val:function(a){var c,d,e,g=this[0];{if(!!arguments.length){e=f.isFunction(a);return this.each(function(d){var g=f(this),h;if(this.nodeType===1){e?h=a.call(this,d,g.val()):h=a,h==null?h="":typeof h=="number"?h+="":f.isArray(h)&&(h=f.map(h,function(a){return a==null?"":a+""})),c=f.valHooks[this.type]||f.valHooks[this.nodeName.toLowerCase()];if(!c||!("set"in c)||c.set(this,h,"value")===b)this.value=h}})}if(g){c=f.valHooks[g.type]||f.valHooks[g.nodeName.toLowerCase()];if(c&&"get"in c&&(d=c.get(g,"value"))!==b)return d;d=g.value;return typeof d=="string"?d.replace(q,""):d==null?"":d}}}}),f.extend({valHooks:{option:{get:function(a){var b=a.attributes.value;return!b||b.specified?a.value:a.text}},select:{get:function(a){var b,c,d,e,g=a.selectedIndex,h=[],i=a.options,j=a.type==="select-one";if(g<0)return null;c=j?g:0,d=j?g+1:i.length;for(;c=0}),c.length||(a.selectedIndex=-1);return c}}},attrFn:{val:!0,css:!0,html:!0,text:!0,data:!0,width:!0,height:!0,offset:!0},attr:function(a,c,d,e){var g,h,i,j=a.nodeType;if(!!a&&j!==3&&j!==8&&j!==2){if(e&&c in f.attrFn)return f(a)[c](d);if(typeof a.getAttribute=="undefined")return f.prop(a,c,d);i=j!==1||!f.isXMLDoc(a),i&&(c=c.toLowerCase(),h=f.attrHooks[c]||(u.test(c)?x:w));if(d!==b){if(d===null){f.removeAttr(a,c);return}if(h&&"set"in h&&i&&(g=h.set(a,d,c))!==b)return g;a.setAttribute(c,""+d);return d}if(h&&"get"in h&&i&&(g=h.get(a,c))!==null)return g;g=a.getAttribute(c);return g===null?b:g}},removeAttr:function(a,b){var c,d,e,g,h,i=0;if(b&&a.nodeType===1){d=b.toLowerCase().split(p),g=d.length;for(;i=0}})});var z=/^(?:textarea|input|select)$/i,A=/^([^\.]*)?(?:\.(.+))?$/,B=/(?:^|\s)hover(\.\S+)?\b/,C=/^key/,D=/^(?:mouse|contextmenu)|click/,E=/^(?:focusinfocus|focusoutblur)$/,F=/^(\w*)(?:#([\w\-]+))?(?:\.([\w\-]+))?$/,G=function( +a){var b=F.exec(a);b&&(b[1]=(b[1]||"").toLowerCase(),b[3]=b[3]&&new RegExp("(?:^|\\s)"+b[3]+"(?:\\s|$)"));return b},H=function(a,b){var c=a.attributes||{};return(!b[1]||a.nodeName.toLowerCase()===b[1])&&(!b[2]||(c.id||{}).value===b[2])&&(!b[3]||b[3].test((c["class"]||{}).value))},I=function(a){return f.event.special.hover?a:a.replace(B,"mouseenter$1 mouseleave$1")};f.event={add:function(a,c,d,e,g){var h,i,j,k,l,m,n,o,p,q,r,s;if(!(a.nodeType===3||a.nodeType===8||!c||!d||!(h=f._data(a)))){d.handler&&(p=d,d=p.handler,g=p.selector),d.guid||(d.guid=f.guid++),j=h.events,j||(h.events=j={}),i=h.handle,i||(h.handle=i=function(a){return typeof f!="undefined"&&(!a||f.event.triggered!==a.type)?f.event.dispatch.apply(i.elem,arguments):b},i.elem=a),c=f.trim(I(c)).split(" ");for(k=0;k=0&&(h=h.slice(0,-1),k=!0),h.indexOf(".")>=0&&(i=h.split("."),h=i.shift(),i.sort());if((!e||f.event.customEvent[h])&&!f.event.global[h])return;c=typeof c=="object"?c[f.expando]?c:new f.Event(h,c):new f.Event(h),c.type=h,c.isTrigger=!0,c.exclusive=k,c.namespace=i.join("."),c.namespace_re=c.namespace?new RegExp("(^|\\.)"+i.join("\\.(?:.*\\.)?")+"(\\.|$)"):null,o=h.indexOf(":")<0?"on"+h:"";if(!e){j=f.cache;for(l in j)j[l].events&&j[l].events[h]&&f.event.trigger(c,d,j[l].handle.elem,!0);return}c.result=b,c.target||(c.target=e),d=d!=null?f.makeArray(d):[],d.unshift(c),p=f.event.special[h]||{};if(p.trigger&&p.trigger.apply(e,d)===!1)return;r=[[e,p.bindType||h]];if(!g&&!p.noBubble&&!f.isWindow(e)){s=p.delegateType||h,m=E.test(s+h)?e:e.parentNode,n=null;for(;m;m=m.parentNode)r.push([m,s]),n=m;n&&n===e.ownerDocument&&r.push([n.defaultView||n.parentWindow||a,s])}for(l=0;le&&j.push({elem:this,matches:d.slice(e)});for(k=0;k0?this.on(b,null,a,c):this.trigger(b)},f.attrFn&&(f.attrFn[b]=!0),C.test(b)&&(f.event.fixHooks[b]=f.event.keyHooks),D.test(b)&&(f.event.fixHooks[b]=f.event.mouseHooks)}),function(){function x(a,b,c,e,f,g){for(var h=0,i=e.length;h0){k=j;break}}j=j[a]}e[h]=k}}}function w(a,b,c,e,f,g){for(var h=0,i=e.length;h+~,(\[\\]+)+|[>+~])(\s*,\s*)?((?:.|\r|\n)*)/g,d="sizcache"+(Math.random()+"").replace(".",""),e=0,g=Object.prototype.toString,h=!1,i=!0,j=/\\/g,k=/\r\n/g,l=/\W/;[0,0].sort(function(){i=!1;return 0});var m=function(b,d,e,f){e=e||[],d=d||c;var h=d;if(d.nodeType!==1&&d.nodeType!==9)return[];if(!b||typeof b!="string")return e;var i,j,k,l,n,q,r,t,u=!0,v=m.isXML(d),w=[],x=b;do{a.exec(""),i=a.exec(x);if(i){x=i[3],w.push(i[1]);if(i[2]){l=i[3];break}}}while(i);if(w.length>1&&p.exec(b))if(w.length===2&&o.relative[w[0]])j=y(w[0]+w[1],d,f);else{j=o.relative[w[0]]?[d]:m(w.shift(),d);while(w.length)b=w.shift(),o.relative[b]&&(b+=w.shift()),j=y(b,j,f)}else{!f&&w.length>1&&d.nodeType===9&&!v&&o.match.ID.test(w[0])&&!o.match.ID.test(w[w.length-1])&&(n=m.find(w.shift(),d,v),d=n.expr?m.filter(n.expr,n.set)[0]:n.set[0]);if(d){n=f?{expr:w.pop(),set:s(f)}:m.find(w.pop(),w.length===1&&(w[0]==="~"||w[0]==="+")&&d.parentNode?d.parentNode:d,v),j=n.expr?m.filter(n.expr,n.set):n.set,w.length>0?k=s(j):u=!1;while(w.length)q=w.pop(),r=q,o.relative[q]?r=w.pop():q="",r==null&&(r=d),o.relative[q](k,r,v)}else k=w=[]}k||(k=j),k||m.error(q||b);if(g.call(k)==="[object Array]")if(!u)e.push.apply(e,k);else if(d&&d.nodeType===1)for(t=0;k[t]!=null;t++)k[t]&&(k[t]===!0||k[t].nodeType===1&&m.contains(d,k[t]))&&e.push(j[t]);else for(t=0;k[t]!=null;t++)k[t]&&k[t].nodeType===1&&e.push(j[t]);else s(k,e);l&&(m(l,h,e,f),m.uniqueSort(e));return e};m.uniqueSort=function(a){if(u){h=i,a.sort(u);if(h)for(var b=1;b0},m.find=function(a,b,c){var d,e,f,g,h,i;if(!a)return[];for(e=0,f=o.order.length;e":function(a,b){var c,d=typeof b=="string",e=0,f=a.length;if(d&&!l.test(b)){b=b.toLowerCase();for(;e=0)?c||d.push(h):c&&(b[g]=!1));return!1},ID:function(a){return a[1].replace(j,"")},TAG:function(a,b){return a[1].replace(j,"").toLowerCase()},CHILD:function(a){if(a[1]==="nth"){a[2]||m.error(a[0]),a[2]=a[2].replace(/^\+|\s*/g,"");var b=/(-?)(\d*)(?:n([+\-]?\d*))?/.exec(a[2]==="even"&&"2n"||a[2]==="odd"&&"2n+1"||!/\D/.test(a[2])&&"0n+"+a[2]||a[2]);a[2]=b[1]+(b[2]||1)-0,a[3]=b[3]-0}else a[2]&&m.error(a[0]);a[0]=e++;return a},ATTR:function(a,b,c,d,e,f){var g=a[1]=a[1].replace(j,"");!f&&o.attrMap[g]&&(a[1]=o.attrMap[g]),a[4]=(a[4]||a[5]||"").replace(j,""),a[2]==="~="&&(a[4]=" "+a[4]+" ");return a},PSEUDO:function(b,c,d,e,f){if(b[1]==="not")if((a.exec(b[3])||"").length>1||/^\w/.test(b[3]))b[3]=m(b[3],null,null,c);else{var g=m.filter(b[3],c,d,!0^f);d||e.push.apply(e,g);return!1}else if(o.match.POS.test(b[0])||o.match.CHILD.test(b[0]))return!0;return b},POS:function(a){a.unshift(!0);return a}},filters:{enabled:function(a){return a.disabled===!1&&a.type!=="hidden"},disabled:function(a){return a.disabled===!0},checked:function(a){return a.checked===!0},selected:function(a){a.parentNode&&a.parentNode.selectedIndex;return a.selected===!0},parent:function(a){return!!a.firstChild},empty:function(a){return!a.firstChild},has:function(a,b,c){return!!m(c[3],a).length},header:function(a){return/h\d/i.test(a.nodeName)},text:function(a){var b=a.getAttribute("type"),c=a.type;return a.nodeName.toLowerCase()==="input"&&"text"===c&&(b===c||b===null)},radio:function(a){return a.nodeName.toLowerCase()==="input"&&"radio"===a.type},checkbox:function(a){return a.nodeName.toLowerCase()==="input"&&"checkbox"===a.type},file:function(a){return a.nodeName.toLowerCase()==="input"&&"file"===a.type},password:function(a){return a.nodeName.toLowerCase()==="input"&&"password"===a.type},submit:function(a){var b=a.nodeName.toLowerCase();return(b==="input"||b==="button")&&"submit"===a.type},image:function(a){return a.nodeName.toLowerCase()==="input"&&"image"===a.type},reset:function(a){var b=a.nodeName.toLowerCase();return(b==="input"||b==="button")&&"reset"===a.type},button:function(a){var b=a.nodeName.toLowerCase();return b==="input"&&"button"===a.type||b==="button"},input:function(a){return/input|select|textarea|button/i.test(a.nodeName)},focus:function(a){return a===a.ownerDocument.activeElement}},setFilters:{first:function(a,b){return b===0},last:function(a,b,c,d){return b===d.length-1},even:function(a,b){return b%2===0},odd:function(a,b){return b%2===1},lt:function(a,b,c){return bc[3]-0},nth:function(a,b,c){return c[3]-0===b},eq:function(a,b,c){return c[3]-0===b}},filter:{PSEUDO:function(a,b,c,d){var e=b[1],f=o.filters[e];if(f)return f(a,c,b,d);if(e==="contains")return(a.textContent||a.innerText||n([a])||"").indexOf(b[3])>=0;if(e==="not"){var g=b[3];for(var h=0,i=g.length;h=0}},ID:function(a,b){return a.nodeType===1&&a.getAttribute("id")===b},TAG:function(a,b){return b==="*"&&a.nodeType===1||!!a.nodeName&&a.nodeName.toLowerCase()===b},CLASS:function(a,b){return(" "+(a.className||a.getAttribute("class"))+" ").indexOf(b)>-1},ATTR:function(a,b){var c=b[1],d=m.attr?m.attr(a,c):o.attrHandle[c]?o.attrHandle[c](a):a[c]!=null?a[c]:a.getAttribute(c),e=d+"",f=b[2],g=b[4];return d==null?f==="!=":!f&&m.attr?d!=null:f==="="?e===g:f==="*="?e.indexOf(g)>=0:f==="~="?(" "+e+" ").indexOf(g)>=0:g?f==="!="?e!==g:f==="^="?e.indexOf(g)===0:f==="$="?e.substr(e.length-g.length)===g:f==="|="?e===g||e.substr(0,g.length+1)===g+"-":!1:e&&d!==!1},POS:function(a,b,c,d){var e=b[2],f=o.setFilters[e];if(f)return f(a,c,b,d)}}},p=o.match.POS,q=function(a,b){return"\\"+(b-0+1)};for(var r in o.match)o.match[r]=new RegExp(o.match[r].source+/(?![^\[]*\])(?![^\(]*\))/.source),o.leftMatch[r]=new RegExp(/(^(?:.|\r|\n)*?)/.source+o.match[r].source.replace(/\\(\d+)/g,q));o.match.globalPOS=p;var s=function(a,b){a=Array.prototype.slice.call(a,0);if(b){b.push.apply(b,a);return b}return a};try{Array.prototype.slice.call(c.documentElement.childNodes,0)[0].nodeType}catch(t){s=function(a,b){var c=0,d=b||[];if(g.call(a)==="[object Array]")Array.prototype.push.apply(d,a);else if(typeof a.length=="number")for(var e=a.length;c",e.insertBefore(a,e.firstChild),c.getElementById(d)&&(o.find.ID=function(a,c,d){if(typeof c.getElementById!="undefined"&&!d){var e=c.getElementById(a[1]);return e?e.id===a[1]||typeof e.getAttributeNode!="undefined"&&e.getAttributeNode("id").nodeValue===a[1]?[e]:b:[]}},o.filter.ID=function(a,b){var c=typeof a.getAttributeNode!="undefined"&&a.getAttributeNode("id");return a.nodeType===1&&c&&c.nodeValue===b}),e.removeChild(a),e=a=null}(),function(){var a=c.createElement("div");a.appendChild(c.createComment("")),a.getElementsByTagName("*").length>0&&(o.find.TAG=function(a,b){var c=b.getElementsByTagName(a[1]);if(a[1]==="*"){var d=[];for(var e=0;c[e];e++)c[e].nodeType===1&&d.push(c[e]);c=d}return c}),a.innerHTML="",a.firstChild&&typeof a.firstChild.getAttribute!="undefined"&&a.firstChild.getAttribute("href")!=="#"&&(o.attrHandle.href=function(a){return a.getAttribute("href",2)}),a=null}(),c.querySelectorAll&&function(){var a=m,b=c.createElement("div"),d="__sizzle__";b.innerHTML="

";if(!b.querySelectorAll||b.querySelectorAll(".TEST").length!==0){m=function(b,e,f,g){e=e||c;if(!g&&!m.isXML(e)){var h=/^(\w+$)|^\.([\w\-]+$)|^#([\w\-]+$)/.exec(b);if(h&&(e.nodeType===1||e.nodeType===9)){if(h[1])return s(e.getElementsByTagName(b),f);if(h[2]&&o.find.CLASS&&e.getElementsByClassName)return s(e.getElementsByClassName(h[2]),f)}if(e.nodeType===9){if(b==="body"&&e.body)return s([e.body],f);if(h&&h[3]){var i=e.getElementById(h[3]);if(!i||!i.parentNode)return s([],f);if(i.id===h[3])return s([i],f)}try{return s(e.querySelectorAll(b),f)}catch(j){}}else if(e.nodeType===1&&e.nodeName.toLowerCase()!=="object"){var k=e,l=e.getAttribute("id"),n=l||d,p=e.parentNode,q=/^\s*[+~]/.test(b);l?n=n.replace(/'/g,"\\$&"):e.setAttribute("id",n),q&&p&&(e=e.parentNode);try{if(!q||p)return s(e.querySelectorAll("[id='"+n+"'] "+b),f)}catch(r){}finally{l||k.removeAttribute("id")}}}return a(b,e,f,g)};for(var e in a)m[e]=a[e];b=null}}(),function(){var a=c.documentElement,b=a.matchesSelector||a.mozMatchesSelector||a.webkitMatchesSelector||a.msMatchesSelector;if(b){var d=!b.call(c.createElement("div"),"div"),e=!1;try{b.call(c.documentElement,"[test!='']:sizzle")}catch(f){e=!0}m.matchesSelector=function(a,c){c=c.replace(/\=\s*([^'"\]]*)\s*\]/g,"='$1']");if(!m.isXML(a))try{if(e||!o.match.PSEUDO.test(c)&&!/!=/.test(c)){var f=b.call(a,c);if(f||!d||a.document&&a.document.nodeType!==11)return f}}catch(g){}return m(c,null,null,[a]).length>0}}}(),function(){var a=c.createElement("div");a.innerHTML="
";if(!!a.getElementsByClassName&&a.getElementsByClassName("e").length!==0){a.lastChild.className="e";if(a.getElementsByClassName("e").length===1)return;o.order.splice(1,0,"CLASS"),o.find.CLASS=function(a,b,c){if(typeof b.getElementsByClassName!="undefined"&&!c)return b.getElementsByClassName(a[1])},a=null}}(),c.documentElement.contains?m.contains=function(a,b){return a!==b&&(a.contains?a.contains(b):!0)}:c.documentElement.compareDocumentPosition?m.contains=function(a,b){return!!(a.compareDocumentPosition(b)&16)}:m.contains=function(){return!1},m.isXML=function(a){var b=(a?a.ownerDocument||a:0).documentElement;return b?b.nodeName!=="HTML":!1};var y=function(a,b,c){var d,e=[],f="",g=b.nodeType?[b]:b;while(d=o.match.PSEUDO.exec(a))f+=d[0],a=a.replace(o.match.PSEUDO,"");a=o.relative[a]?a+"*":a;for(var h=0,i=g.length;h0)for(h=g;h=0:f.filter(a,this).length>0:this.filter(a).length>0)},closest:function(a,b){var c=[],d,e,g=this[0];if(f.isArray(a)){var h=1;while(g&&g.ownerDocument&&g!==b){for(d=0;d-1:f.find.matchesSelector(g,a)){c.push(g);break}g=g.parentNode;if(!g||!g.ownerDocument||g===b||g.nodeType===11)break}}c=c.length>1?f.unique(c):c;return this.pushStack(c,"closest",a)},index:function(a){if(!a)return this[0]&&this[0].parentNode?this.prevAll().length:-1;if(typeof a=="string")return f.inArray(this[0],f(a));return f.inArray(a.jquery?a[0]:a,this)},add:function(a,b){var c=typeof a=="string"?f(a,b):f.makeArray(a&&a.nodeType?[a]:a),d=f.merge(this.get(),c);return this.pushStack(S(c[0])||S(d[0])?d:f.unique(d))},andSelf:function(){return this.add(this.prevObject)}}),f.each({parent:function(a){var b=a.parentNode;return b&&b.nodeType!==11?b:null},parents:function(a){return f.dir(a,"parentNode")},parentsUntil:function(a,b,c){return f.dir(a,"parentNode",c)},next:function(a){return f.nth(a,2,"nextSibling")},prev:function(a){return f.nth(a,2,"previousSibling")},nextAll:function(a){return f.dir(a,"nextSibling")},prevAll:function(a){return f.dir(a,"previousSibling")},nextUntil:function(a,b,c){return f.dir(a,"nextSibling",c)},prevUntil:function(a,b,c){return f.dir(a,"previousSibling",c)},siblings:function(a){return f.sibling((a.parentNode||{}).firstChild,a)},children:function(a){return f.sibling(a.firstChild)},contents:function(a){return f.nodeName(a,"iframe")?a.contentDocument||a.contentWindow.document:f.makeArray(a.childNodes)}},function(a,b){f.fn[a]=function(c,d){var e=f.map(this,b,c);L.test(a)||(d=c),d&&typeof d=="string"&&(e=f.filter(d,e)),e=this.length>1&&!R[a]?f.unique(e):e,(this.length>1||N.test(d))&&M.test(a)&&(e=e.reverse());return this.pushStack(e,a,P.call(arguments).join(","))}}),f.extend({filter:function(a,b,c){c&&(a=":not("+a+")");return b.length===1?f.find.matchesSelector(b[0],a)?[b[0]]:[]:f.find.matches(a,b)},dir:function(a,c,d){var e=[],g=a[c];while(g&&g.nodeType!==9&&(d===b||g.nodeType!==1||!f(g).is(d)))g.nodeType===1&&e.push(g),g=g[c];return e},nth:function(a,b,c,d){b=b||1;var e=0;for(;a;a=a[c])if(a.nodeType===1&&++e===b)break;return a},sibling:function(a,b){var c=[];for(;a;a=a.nextSibling)a.nodeType===1&&a!==b&&c.push(a);return c}});var V="abbr|article|aside|audio|bdi|canvas|data|datalist|details|figcaption|figure|footer|header|hgroup|mark|meter|nav|output|progress|section|summary|time|video",W=/ jQuery\d+="(?:\d+|null)"/g,X=/^\s+/,Y=/<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/ig,Z=/<([\w:]+)/,$=/]","i"),bd=/checked\s*(?:[^=]|=\s*.checked.)/i,be=/\/(java|ecma)script/i,bf=/^\s*",""],legend:[1,"
","
"],thead:[1,"","
"],tr:[2,"","
"],td:[3,"","
"],col:[2,"","
"],area:[1,"",""],_default:[0,"",""]},bh=U(c);bg.optgroup=bg.option,bg.tbody=bg.tfoot=bg.colgroup=bg.caption=bg.thead,bg.th=bg.td,f.support.htmlSerialize||(bg._default=[1,"div
","
"]),f.fn.extend({text:function(a){return f.access(this,function(a){return a===b?f.text(this):this.empty().append((this[0]&&this[0].ownerDocument||c).createTextNode(a))},null,a,arguments.length)},wrapAll:function(a){if(f.isFunction(a))return this.each(function(b){f(this).wrapAll(a.call(this,b))});if(this[0]){var b=f(a,this[0].ownerDocument).eq(0).clone(!0);this[0].parentNode&&b.insertBefore(this[0]),b.map(function(){var a=this;while(a.firstChild&&a.firstChild.nodeType===1)a=a.firstChild;return a}).append(this)}return this},wrapInner:function(a){if(f.isFunction(a))return this.each(function(b){f(this).wrapInner(a.call(this,b))});return this.each(function(){var b=f(this),c=b.contents();c.length?c.wrapAll(a):b.append(a)})},wrap:function(a){var b=f.isFunction(a);return this.each(function(c){f(this).wrapAll(b?a.call(this,c):a)})},unwrap:function(){return this.parent().each(function(){f.nodeName(this,"body")||f(this).replaceWith(this.childNodes)}).end()},append:function(){return this.domManip(arguments,!0,function(a){this.nodeType===1&&this.appendChild(a)})},prepend:function(){return this.domManip(arguments,!0,function(a){this.nodeType===1&&this.insertBefore(a,this.firstChild)})},before:function(){if(this[0]&&this[0].parentNode)return this.domManip(arguments,!1,function(a){this.parentNode.insertBefore(a,this)});if(arguments.length){var a=f +.clean(arguments);a.push.apply(a,this.toArray());return this.pushStack(a,"before",arguments)}},after:function(){if(this[0]&&this[0].parentNode)return this.domManip(arguments,!1,function(a){this.parentNode.insertBefore(a,this.nextSibling)});if(arguments.length){var a=this.pushStack(this,"after",arguments);a.push.apply(a,f.clean(arguments));return a}},remove:function(a,b){for(var c=0,d;(d=this[c])!=null;c++)if(!a||f.filter(a,[d]).length)!b&&d.nodeType===1&&(f.cleanData(d.getElementsByTagName("*")),f.cleanData([d])),d.parentNode&&d.parentNode.removeChild(d);return this},empty:function(){for(var a=0,b;(b=this[a])!=null;a++){b.nodeType===1&&f.cleanData(b.getElementsByTagName("*"));while(b.firstChild)b.removeChild(b.firstChild)}return this},clone:function(a,b){a=a==null?!1:a,b=b==null?a:b;return this.map(function(){return f.clone(this,a,b)})},html:function(a){return f.access(this,function(a){var c=this[0]||{},d=0,e=this.length;if(a===b)return c.nodeType===1?c.innerHTML.replace(W,""):null;if(typeof a=="string"&&!ba.test(a)&&(f.support.leadingWhitespace||!X.test(a))&&!bg[(Z.exec(a)||["",""])[1].toLowerCase()]){a=a.replace(Y,"<$1>");try{for(;d1&&l0?this.clone(!0):this).get();f(e[h])[b](j),d=d.concat(j)}return this.pushStack(d,a,e.selector)}}),f.extend({clone:function(a,b,c){var d,e,g,h=f.support.html5Clone||f.isXMLDoc(a)||!bc.test("<"+a.nodeName+">")?a.cloneNode(!0):bo(a);if((!f.support.noCloneEvent||!f.support.noCloneChecked)&&(a.nodeType===1||a.nodeType===11)&&!f.isXMLDoc(a)){bk(a,h),d=bl(a),e=bl(h);for(g=0;d[g];++g)e[g]&&bk(d[g],e[g])}if(b){bj(a,h);if(c){d=bl(a),e=bl(h);for(g=0;d[g];++g)bj(d[g],e[g])}}d=e=null;return h},clean:function(a,b,d,e){var g,h,i,j=[];b=b||c,typeof b.createElement=="undefined"&&(b=b.ownerDocument||b[0]&&b[0].ownerDocument||c);for(var k=0,l;(l=a[k])!=null;k++){typeof l=="number"&&(l+="");if(!l)continue;if(typeof l=="string")if(!_.test(l))l=b.createTextNode(l);else{l=l.replace(Y,"<$1>");var m=(Z.exec(l)||["",""])[1].toLowerCase(),n=bg[m]||bg._default,o=n[0],p=b.createElement("div"),q=bh.childNodes,r;b===c?bh.appendChild(p):U(b).appendChild(p),p.innerHTML=n[1]+l+n[2];while(o--)p=p.lastChild;if(!f.support.tbody){var s=$.test(l),t=m==="table"&&!s?p.firstChild&&p.firstChild.childNodes:n[1]===""&&!s?p.childNodes:[];for(i=t.length-1;i>=0;--i)f.nodeName(t[i],"tbody")&&!t[i].childNodes.length&&t[i].parentNode.removeChild(t[i])}!f.support.leadingWhitespace&&X.test(l)&&p.insertBefore(b.createTextNode(X.exec(l)[0]),p.firstChild),l=p.childNodes,p&&(p.parentNode.removeChild(p),q.length>0&&(r=q[q.length-1],r&&r.parentNode&&r.parentNode.removeChild(r)))}var u;if(!f.support.appendChecked)if(l[0]&&typeof (u=l.length)=="number")for(i=0;i1)},f.extend({cssHooks:{opacity:{get:function(a,b){if(b){var c=by(a,"opacity");return c===""?"1":c}return a.style.opacity}}},cssNumber:{fillOpacity:!0,fontWeight:!0,lineHeight:!0,opacity:!0,orphans:!0,widows:!0,zIndex:!0,zoom:!0},cssProps:{"float":f.support.cssFloat?"cssFloat":"styleFloat"},style:function(a,c,d,e){if(!!a&&a.nodeType!==3&&a.nodeType!==8&&!!a.style){var g,h,i=f.camelCase(c),j=a.style,k=f.cssHooks[i];c=f.cssProps[i]||i;if(d===b){if(k&&"get"in k&&(g=k.get(a,!1,e))!==b)return g;return j[c]}h=typeof d,h==="string"&&(g=bu.exec(d))&&(d=+(g[1]+1)*+g[2]+parseFloat(f.css(a,c)),h="number");if(d==null||h==="number"&&isNaN(d))return;h==="number"&&!f.cssNumber[i]&&(d+="px");if(!k||!("set"in k)||(d=k.set(a,d))!==b)try{j[c]=d}catch(l){}}},css:function(a,c,d){var e,g;c=f.camelCase(c),g=f.cssHooks[c],c=f.cssProps[c]||c,c==="cssFloat"&&(c="float");if(g&&"get"in g&&(e=g.get(a,!0,d))!==b)return e;if(by)return by(a,c)},swap:function(a,b,c){var d={},e,f;for(f in b)d[f]=a.style[f],a.style[f]=b[f];e=c.call(a);for(f in b)a.style[f]=d[f];return e}}),f.curCSS=f.css,c.defaultView&&c.defaultView.getComputedStyle&&(bz=function(a,b){var c,d,e,g,h=a.style;b=b.replace(br,"-$1").toLowerCase(),(d=a.ownerDocument.defaultView)&&(e=d.getComputedStyle(a,null))&&(c=e.getPropertyValue(b),c===""&&!f.contains(a.ownerDocument.documentElement,a)&&(c=f.style(a,b))),!f.support.pixelMargin&&e&&bv.test(b)&&bt.test(c)&&(g=h.width,h.width=c,c=e.width,h.width=g);return c}),c.documentElement.currentStyle&&(bA=function(a,b){var c,d,e,f=a.currentStyle&&a.currentStyle[b],g=a.style;f==null&&g&&(e=g[b])&&(f=e),bt.test(f)&&(c=g.left,d=a.runtimeStyle&&a.runtimeStyle.left,d&&(a.runtimeStyle.left=a.currentStyle.left),g.left=b==="fontSize"?"1em":f,f=g.pixelLeft+"px",g.left=c,d&&(a.runtimeStyle.left=d));return f===""?"auto":f}),by=bz||bA,f.each(["height","width"],function(a,b){f.cssHooks[b]={get:function(a,c,d){if(c)return a.offsetWidth!==0?bB(a,b,d):f.swap(a,bw,function(){return bB(a,b,d)})},set:function(a,b){return bs.test(b)?b+"px":b}}}),f.support.opacity||(f.cssHooks.opacity={get:function(a,b){return bq.test((b&&a.currentStyle?a.currentStyle.filter:a.style.filter)||"")?parseFloat(RegExp.$1)/100+"":b?"1":""},set:function(a,b){var c=a.style,d=a.currentStyle,e=f.isNumeric(b)?"alpha(opacity="+b*100+")":"",g=d&&d.filter||c.filter||"";c.zoom=1;if(b>=1&&f.trim(g.replace(bp,""))===""){c.removeAttribute("filter");if(d&&!d.filter)return}c.filter=bp.test(g)?g.replace(bp,e):g+" "+e}}),f(function(){f.support.reliableMarginRight||(f.cssHooks.marginRight={get:function(a,b){return f.swap(a,{display:"inline-block"},function(){return b?by(a,"margin-right"):a.style.marginRight})}})}),f.expr&&f.expr.filters&&(f.expr.filters.hidden=function(a){var b=a.offsetWidth,c=a.offsetHeight;return b===0&&c===0||!f.support.reliableHiddenOffsets&&(a.style&&a.style.display||f.css(a,"display"))==="none"},f.expr.filters.visible=function(a){return!f.expr.filters.hidden(a)}),f.each({margin:"",padding:"",border:"Width"},function(a,b){f.cssHooks[a+b]={expand:function(c){var d,e=typeof c=="string"?c.split(" "):[c],f={};for(d=0;d<4;d++)f[a+bx[d]+b]=e[d]||e[d-2]||e[0];return f}}});var bC=/%20/g,bD=/\[\]$/,bE=/\r?\n/g,bF=/#.*$/,bG=/^(.*?):[ \t]*([^\r\n]*)\r?$/mg,bH=/^(?:color|date|datetime|datetime-local|email|hidden|month|number|password|range|search|tel|text|time|url|week)$/i,bI=/^(?:about|app|app\-storage|.+\-extension|file|res|widget):$/,bJ=/^(?:GET|HEAD)$/,bK=/^\/\//,bL=/\?/,bM=/)<[^<]*)*<\/script>/gi,bN=/^(?:select|textarea)/i,bO=/\s+/,bP=/([?&])_=[^&]*/,bQ=/^([\w\+\.\-]+:)(?:\/\/([^\/?#:]*)(?::(\d+))?)?/,bR=f.fn.load,bS={},bT={},bU,bV,bW=["*/"]+["*"];try{bU=e.href}catch(bX){bU=c.createElement("a"),bU.href="",bU=bU.href}bV=bQ.exec(bU.toLowerCase())||[],f.fn.extend({load:function(a,c,d){if(typeof a!="string"&&bR)return bR.apply(this,arguments);if(!this.length)return this;var e=a.indexOf(" ");if(e>=0){var g=a.slice(e,a.length);a=a.slice(0,e)}var h="GET";c&&(f.isFunction(c)?(d=c,c=b):typeof c=="object"&&(c=f.param(c,f.ajaxSettings.traditional),h="POST"));var i=this;f.ajax({url:a,type:h,dataType:"html",data:c,complete:function(a,b,c){c=a.responseText,a.isResolved()&&(a.done(function(a){c=a}),i.html(g?f("
").append(c.replace(bM,"")).find(g):c)),d&&i.each(d,[c,b,a])}});return this},serialize:function(){return f.param(this.serializeArray())},serializeArray:function(){return this.map(function(){return this.elements?f.makeArray(this.elements):this}).filter(function(){return this.name&&!this.disabled&&(this.checked||bN.test(this.nodeName)||bH.test(this.type))}).map(function(a,b){var c=f(this).val();return c==null?null:f.isArray(c)?f.map(c,function(a,c){return{name:b.name,value:a.replace(bE,"\r\n")}}):{name:b.name,value:c.replace(bE,"\r\n")}}).get()}}),f.each("ajaxStart ajaxStop ajaxComplete ajaxError ajaxSuccess ajaxSend".split(" "),function(a,b){f.fn[b]=function(a){return this.on(b,a)}}),f.each(["get","post"],function(a,c){f[c]=function(a,d,e,g){f.isFunction(d)&&(g=g||e,e=d,d=b);return f.ajax({type:c,url:a,data:d,success:e,dataType:g})}}),f.extend({getScript:function(a,c){return f.get(a,b,c,"script")},getJSON:function(a,b,c){return f.get(a,b,c,"json")},ajaxSetup:function(a,b){b?b$(a,f.ajaxSettings):(b=a,a=f.ajaxSettings),b$(a,b);return a},ajaxSettings:{url:bU,isLocal:bI.test(bV[1]),global:!0,type:"GET",contentType:"application/x-www-form-urlencoded; charset=UTF-8",processData:!0,async:!0,accepts:{xml:"application/xml, text/xml",html:"text/html",text:"text/plain",json:"application/json, text/javascript","*":bW},contents:{xml:/xml/,html:/html/,json:/json/},responseFields:{xml:"responseXML",text:"responseText"},converters:{"* text":a.String,"text html":!0,"text json":f.parseJSON,"text xml":f.parseXML},flatOptions:{context:!0,url:!0}},ajaxPrefilter:bY(bS),ajaxTransport:bY(bT),ajax:function(a,c){function w(a,c,l,m){if(s!==2){s=2,q&&clearTimeout(q),p=b,n=m||"",v.readyState=a>0?4:0;var o,r,u,w=c,x=l?ca(d,v,l):b,y,z;if(a>=200&&a<300||a===304){if(d.ifModified){if(y=v.getResponseHeader("Last-Modified"))f.lastModified[k]=y;if(z=v.getResponseHeader("Etag"))f.etag[k]=z}if(a===304)w="notmodified",o=!0;else try{r=cb(d,x),w="success",o=!0}catch(A){w="parsererror",u=A}}else{u=w;if(!w||a)w="error",a<0&&(a=0)}v.status=a,v.statusText=""+(c||w),o?h.resolveWith(e,[r,w,v]):h.rejectWith(e,[v,w,u]),v.statusCode(j),j=b,t&&g.trigger("ajax"+(o?"Success":"Error"),[v,d,o?r:u]),i.fireWith(e,[v,w]),t&&(g.trigger("ajaxComplete",[v,d]),--f.active||f.event.trigger("ajaxStop"))}}typeof a=="object"&&(c=a,a=b),c=c||{};var d=f.ajaxSetup({},c),e=d.context||d,g=e!==d&&(e.nodeType||e instanceof f)?f(e):f.event,h=f.Deferred(),i=f.Callbacks("once memory"),j=d.statusCode||{},k,l={},m={},n,o,p,q,r,s=0,t,u,v={readyState:0,setRequestHeader:function(a,b){if(!s){var c=a.toLowerCase();a=m[c]=m[c]||a,l[a]=b}return this},getAllResponseHeaders:function(){return s===2?n:null},getResponseHeader:function(a){var c;if(s===2){if(!o){o={};while(c=bG.exec(n))o[c[1].toLowerCase()]=c[2]}c=o[a.toLowerCase()]}return c===b?null:c},overrideMimeType:function(a){s||(d.mimeType=a);return this},abort:function(a){a=a||"abort",p&&p.abort(a),w(0,a);return this}};h.promise(v),v.success=v.done,v.error=v.fail,v.complete=i.add,v.statusCode=function(a){if(a){var b;if(s<2)for(b in a)j[b]=[j[b],a[b]];else b=a[v.status],v.then(b,b)}return this},d.url=((a||d.url)+"").replace(bF,"").replace(bK,bV[1]+"//"),d.dataTypes=f.trim(d.dataType||"*").toLowerCase().split(bO),d.crossDomain==null&&(r=bQ.exec(d.url.toLowerCase()),d.crossDomain=!(!r||r[1]==bV[1]&&r[2]==bV[2]&&(r[3]||(r[1]==="http:"?80:443))==(bV[3]||(bV[1]==="http:"?80:443)))),d.data&&d.processData&&typeof d.data!="string"&&(d.data=f.param(d.data,d.traditional)),bZ(bS,d,c,v);if(s===2)return!1;t=d.global,d.type=d.type.toUpperCase(),d.hasContent=!bJ.test(d.type),t&&f.active++===0&&f.event.trigger("ajaxStart");if(!d.hasContent){d.data&&(d.url+=(bL.test(d.url)?"&":"?")+d.data,delete d.data),k=d.url;if(d.cache===!1){var x=f.now(),y=d.url.replace(bP,"$1_="+x);d.url=y+(y===d.url?(bL.test(d.url)?"&":"?")+"_="+x:"")}}(d.data&&d.hasContent&&d.contentType!==!1||c.contentType)&&v.setRequestHeader("Content-Type",d.contentType),d.ifModified&&(k=k||d.url,f.lastModified[k]&&v.setRequestHeader("If-Modified-Since",f.lastModified[k]),f.etag[k]&&v.setRequestHeader("If-None-Match",f.etag[k])),v.setRequestHeader("Accept",d.dataTypes[0]&&d.accepts[d.dataTypes[0]]?d.accepts[d.dataTypes[0]]+(d.dataTypes[0]!=="*"?", "+bW+"; q=0.01":""):d.accepts["*"]);for(u in d.headers)v.setRequestHeader(u,d.headers[u]);if(d.beforeSend&&(d.beforeSend.call(e,v,d)===!1||s===2)){v.abort();return!1}for(u in{success:1,error:1,complete:1})v[u](d[u]);p=bZ(bT,d,c,v);if(!p)w(-1,"No Transport");else{v.readyState=1,t&&g.trigger("ajaxSend",[v,d]),d.async&&d.timeout>0&&(q=setTimeout(function(){v.abort("timeout")},d.timeout));try{s=1,p.send(l,w)}catch(z){if(s<2)w(-1,z);else throw z}}return v},param:function(a,c){var d=[],e=function(a,b){b=f.isFunction(b)?b():b,d[d.length]=encodeURIComponent(a)+"="+encodeURIComponent(b)};c===b&&(c=f.ajaxSettings.traditional);if(f.isArray(a)||a.jquery&&!f.isPlainObject(a))f.each(a,function(){e(this.name,this.value)});else for(var g in a)b_(g,a[g],c,e);return d.join("&").replace(bC,"+")}}),f.extend({active:0,lastModified:{},etag:{}});var cc=f.now(),cd=/(\=)\?(&|$)|\?\?/i;f.ajaxSetup({jsonp:"callback",jsonpCallback:function(){return f.expando+"_"+cc++}}),f.ajaxPrefilter("json jsonp",function(b,c,d){var e=typeof b.data=="string"&&/^application\/x\-www\-form\-urlencoded/.test(b.contentType);if(b.dataTypes[0]==="jsonp"||b.jsonp!==!1&&(cd.test(b.url)||e&&cd.test(b.data))){var g,h=b.jsonpCallback=f.isFunction(b.jsonpCallback)?b.jsonpCallback():b.jsonpCallback,i=a[h],j=b.url,k=b.data,l="$1"+h+"$2";b.jsonp!==!1&&(j=j.replace(cd,l),b.url===j&&(e&&(k=k.replace(cd,l)),b.data===k&&(j+=(/\?/.test(j)?"&":"?")+b.jsonp+"="+h))),b.url=j,b.data=k,a[h]=function(a){g=[a]},d.always(function(){a[h]=i,g&&f.isFunction(i)&&a[h](g[0])}),b.converters["script json"]=function(){g||f.error(h+" was not called");return g[0]},b.dataTypes[0]="json";return"script"}}),f.ajaxSetup({accepts:{script:"text/javascript, application/javascript, application/ecmascript, application/x-ecmascript"},contents:{script:/javascript|ecmascript/},converters:{"text script":function(a){f.globalEval(a);return a}}}),f.ajaxPrefilter("script",function(a){a.cache===b&&(a.cache=!1),a.crossDomain&&(a.type="GET",a.global=!1)}),f.ajaxTransport("script",function(a){if(a.crossDomain){var d,e=c.head||c.getElementsByTagName("head")[0]||c.documentElement;return{send:function(f,g){d=c.createElement("script"),d.async="async",a.scriptCharset&&(d.charset=a.scriptCharset),d.src=a.url,d.onload=d.onreadystatechange=function(a,c){if(c||!d.readyState||/loaded|complete/.test(d.readyState))d.onload=d.onreadystatechange=null,e&&d.parentNode&&e.removeChild(d),d=b,c||g(200,"success")},e.insertBefore(d,e.firstChild)},abort:function(){d&&d.onload(0,1)}}}});var ce=a.ActiveXObject?function(){for(var a in cg)cg[a](0,1)}:!1,cf=0,cg;f.ajaxSettings.xhr=a.ActiveXObject?function(){return!this.isLocal&&ch()||ci()}:ch,function(a){f.extend(f.support,{ajax:!!a,cors:!!a&&"withCredentials"in a})}(f.ajaxSettings.xhr()),f.support.ajax&&f.ajaxTransport(function(c){if(!c.crossDomain||f.support.cors){var d;return{send:function(e,g){var h=c.xhr(),i,j;c.username?h.open(c.type,c.url,c.async,c.username,c.password):h.open(c.type,c.url,c.async);if(c.xhrFields)for(j in c.xhrFields)h[j]=c.xhrFields[j];c.mimeType&&h.overrideMimeType&&h.overrideMimeType(c.mimeType),!c.crossDomain&&!e["X-Requested-With"]&&(e["X-Requested-With"]="XMLHttpRequest");try{for(j in e)h.setRequestHeader(j,e[j])}catch(k){}h.send(c.hasContent&&c.data||null),d=function(a,e){var j,k,l,m,n;try{if(d&&(e||h.readyState===4)){d=b,i&&(h.onreadystatechange=f.noop,ce&&delete cg[i]);if(e)h.readyState!==4&&h.abort();else{j=h.status,l=h.getAllResponseHeaders(),m={},n=h.responseXML,n&&n.documentElement&&(m.xml=n);try{m.text=h.responseText}catch(a){}try{k=h.statusText}catch(o){k=""}!j&&c.isLocal&&!c.crossDomain?j=m.text?200:404:j===1223&&(j=204)}}}catch(p){e||g(-1,p)}m&&g(j,k,m,l)},!c.async||h.readyState===4?d():(i=++cf,ce&&(cg||(cg={},f(a).unload(ce)),cg[i]=d),h.onreadystatechange=d)},abort:function(){d&&d(0,1)}}}});var cj={},ck,cl,cm=/^(?:toggle|show|hide)$/,cn=/^([+\-]=)?([\d+.\-]+)([a-z%]*)$/i,co,cp=[["height","marginTop","marginBottom","paddingTop","paddingBottom"],["width","marginLeft","marginRight","paddingLeft","paddingRight"],["opacity"]],cq;f.fn.extend({show:function(a,b,c){var d,e;if(a||a===0)return this.animate(ct("show",3),a,b,c);for(var g=0,h=this.length;g=i.duration+this.startTime){this.now=this.end,this.pos=this.state=1,this.update(),i.animatedProperties[this.prop]=!0;for(b in i.animatedProperties)i.animatedProperties[b]!==!0&&(g=!1);if(g){i.overflow!=null&&!f.support.shrinkWrapBlocks&&f.each(["","X","Y"],function(a,b){h.style["overflow"+b]=i.overflow[a]}),i.hide&&f(h).hide();if(i.hide||i.show)for(b in i.animatedProperties)f.style(h,b,i.orig[b]),f.removeData(h,"fxshow"+b,!0),f.removeData(h,"toggle"+b,!0);d=i.complete,d&&(i.complete=!1,d.call(h))}return!1}i.duration==Infinity?this.now=e:(c=e-this.startTime,this.state=c/i.duration,this.pos=f.easing[i.animatedProperties[this.prop]](this.state,c,0,1,i.duration),this.now=this.start+(this.end-this.start)*this.pos),this.update();return!0}},f.extend(f.fx,{tick:function(){var a,b=f.timers,c=0;for(;c-1,k={},l={},m,n;j?(l=e.position(),m=l.top,n=l.left):(m=parseFloat(h)||0,n=parseFloat(i)||0),f.isFunction(b)&&(b=b.call(a,c,g)),b.top!=null&&(k.top=b.top-g.top+m),b.left!=null&&(k.left=b.left-g.left+n),"using"in b?b.using.call(a,k):e.css(k)}},f.fn.extend({position:function(){if(!this[0])return null;var a=this[0],b=this.offsetParent(),c=this.offset(),d=cx.test(b[0].nodeName)?{top:0,left:0}:b.offset();c.top-=parseFloat(f.css(a,"marginTop"))||0,c.left-=parseFloat(f.css(a,"marginLeft"))||0,d.top+=parseFloat(f.css(b[0],"borderTopWidth"))||0,d.left+=parseFloat(f.css(b[0],"borderLeftWidth"))||0;return{top:c.top-d.top,left:c.left-d.left}},offsetParent:function(){return this.map(function(){var a=this.offsetParent||c.body;while(a&&!cx.test(a.nodeName)&&f.css(a,"position")==="static")a=a.offsetParent;return a})}}),f.each({scrollLeft:"pageXOffset",scrollTop:"pageYOffset"},function(a,c){var d=/Y/.test(c);f.fn[a]=function(e){return f.access(this,function(a,e,g){var h=cy(a);if(g===b)return h?c in h?h[c]:f.support.boxModel&&h.document.documentElement[e]||h.document.body[e]:a[e];h?h.scrollTo(d?f(h).scrollLeft():g,d?g:f(h).scrollTop()):a[e]=g},a,e,arguments.length,null)}}),f.each({Height:"height",Width:"width"},function(a,c){var d="client"+a,e="scroll"+a,g="offset"+a;f.fn["inner"+a]=function(){var a=this[0];return a?a.style?parseFloat(f.css(a,c,"padding")):this[c]():null},f.fn["outer"+a]=function(a){var b=this[0];return b?b.style?parseFloat(f.css(b,c,a?"margin":"border")):this[c]():null},f.fn[c]=function(a){return f.access(this,function(a,c,h){var i,j,k,l;if(f.isWindow(a)){i=a.document,j=i.documentElement[d];return f.support.boxModel&&j||i.body&&i.body[d]||j}if(a.nodeType===9){i=a.documentElement;if(i[d]>=i[e])return i[d];return Math.max(a.body[e],i[e],a.body[g],i[g])}if(h===b){k=f.css(a,c),l=parseFloat(k);return f.isNumeric(l)?l:k}f(a).css(c,h)},c,a,arguments.length,null)}}),a.jQuery=a.$=f,typeof define=="function"&&define.amd&&define.amd.jQuery&&define("jquery",[],function(){return f})})(window); \ No newline at end of file diff --git a/application/libraries/barcodegen/html/logo.png b/application/libraries/barcodegen/html/logo.png new file mode 100755 index 000000000..0e85c449c Binary files /dev/null and b/application/libraries/barcodegen/html/logo.png differ diff --git a/application/libraries/barcodegen/html/style.css b/application/libraries/barcodegen/html/style.css new file mode 100755 index 000000000..5895cb0ff --- /dev/null +++ b/application/libraries/barcodegen/html/style.css @@ -0,0 +1,204 @@ +body { + font-family: Segoe UI, Calibri, Arial, Helvetica; + font-size: 12px; + color: #111; + margin: 8px; +} + +.footer { + text-align: center; + margin-top: 40px; +} + +form, .header { + display: block; + margin: auto; + width: 60%; + min-width: 600px; + max-width: 700px; + position: relative; +} + +input, select { + margin: 0; +} + +input[type=text], input[type=number], select { + border: 1px solid #ababab; + padding: 2px; +} + +select { + padding-top: 1px; + padding-bottom: 1px; +} + +ul { + margin: 0; + padding: 0; + list-style: none; +} + +section { + margin-bottom: 24px; +} + +h1 { + display: none; +} + +h2 { + margin: 14px 0 8px 0; + font-weight: normal; + font-size: 20px; +} + +h3 { + font-size: 16px; + font-weight: normal; + font-style: italic; + padding-bottom: 4px; + border-bottom: 1px solid #c8c8c8; + margin: 0 0 14px 0; +} + +.logo { + margin-top: 8px; +} + +nav { + float: right; + position: absolute; + top: 34px; + right: 0; +} + +nav label { + display: block; +} + +nav select { + margin: 2px 0; + margin-left: 0; +} + +table { + table-layout: fixed; + border-collapse: collapse; + width: 100%; +} + +table td { + padding: 3px 25px 1px 4px; + vertical-align: top; + height: 26px; /* This act as a min-height */ + line-height: 30px; +} + +table tr.odd { + background-color: #eee; +} + +table tr.even { +} + +table .col1 { + width: 180px; +} + +table .info { + position: absolute; + dtop: 0; + dright: 5px; + line-height: 34px; +} + +.info img { + border: 0; + vertical-align: text-bottom; +} + +.generate { + float: left; +} + +.possiblechars { + float: right; + position: relative; +} + +#dpiUnavailable { + display: none; + padding-left: 8px; +} + +div.configurations select { + min-width: 70px; +} + +div.configurations input[type=number] { + width: 70px; +} + +/* Moved section by script */ +#explanation, #dpiExplain, #validCharacters { + display: none; + max-width: 450px; +} + +#explanation ul { + list-style: disc; + margin-left: 20px; +} + +#specificOptions { + display: none; +} + +#validCharacters input[type=button] { + width: 25px; + padding: 1px 6px; +} + +.BCGcode128 #validCharacters input[type=button], +.BCGcode39extended #validCharacters input[type=button], +.BCGcode93 #validCharacters input[type=button], +.BCGgs1128 #validCharacters input[type=button], +.BCGaztec #validCharacters input[type=button], +.BCGdatamatrix #validCharacters input[type=button], +.BCGmaxicode #validCharacters input[type=button], +.BCGqrcode #validCharacters input[type=button], +.BCGpdf417 #validCharacters input[type=button] { + width: 39px; +} + +.bubble { + display: none; +} + +.bubble.visible { + display: block !important; + position: absolute; + background-color: #f8f8f8; + border: 2px solid #ddd; + padding: 16px; +} + +.gs1128_id { + width: 40px; + text-align: center; +} + +.gs1128_value { + width: 295px; +} + +.gs1128_delete img { + border: 0; + margin-left: 5px; + vertical-align: text-bottom; +} + +#identifierContainer { + margin-top: 4px; +} \ No newline at end of file diff --git a/application/libraries/barcodegen/img.png b/application/libraries/barcodegen/img.png new file mode 100644 index 000000000..229151a5a Binary files /dev/null and b/application/libraries/barcodegen/img.png differ diff --git a/application/libraries/barcodegen/index.php b/application/libraries/barcodegen/index.php new file mode 100644 index 000000000..506e9ae08 --- /dev/null +++ b/application/libraries/barcodegen/index.php @@ -0,0 +1,12 @@ + + + + \ No newline at end of file diff --git a/application/libraries/barcodegen/test_1D.html b/application/libraries/barcodegen/test_1D.html new file mode 100644 index 000000000..7663d1ef9 --- /dev/null +++ b/application/libraries/barcodegen/test_1D.html @@ -0,0 +1,36 @@ + + + +Test with embedded image + + + barcode + + + + + +Test with embedded image + + + barcode + + + + + +Test with embedded image + + + barcode + + + + + +Test with embedded image + + + barcode + + \ No newline at end of file diff --git a/application/libraries/barcodegen/test_1D.php b/application/libraries/barcodegen/test_1D.php new file mode 100644 index 000000000..33b891475 --- /dev/null +++ b/application/libraries/barcodegen/test_1D.php @@ -0,0 +1,200 @@ +setScale(2); // Resolution + $code->setThickness(30); // Thickness + $code->setForegroundColor($color_black); // Color of bars + $code->setBackgroundColor($color_white); // Color of spaces + $code->setFont($font); // Font (or 0) + $code->parse($text); // Text +} catch(Exception $exception) { + $drawException = $exception; +} + +/* Here is the list of the arguments +1 - Filename (empty : display on screen) +2 - Background color */ +$drawing = new BCGDrawing('', $color_white); +if($drawException) { + $drawing->drawException($drawException); +} else { + $drawing->setBarcode($code); + $drawing->draw(); +} + +// Header that says it is an image (remove it if you save the barcode to a file) +header('Content-Type: image/png'); +header('Content-Disposition: inline; filename="barcode.png"'); + +// Draw (or save) the image into PNG format. +$drawing->finish(BCGDrawing::IMG_FORMAT_PNG); +?> +setScale(2); // Resolution + $code->setThickness(30); // Thickness + $code->setForegroundColor($color_black); // Color of bars + $code->setBackgroundColor($color_white); // Color of spaces + $code->setFont($font); // Font (or 0) + $code->parse($text); // Text +} catch(Exception $exception) { + $drawException = $exception; +} + +/* Here is the list of the arguments +1 - Filename (empty : display on screen) +2 - Background color */ +$drawing = new BCGDrawing('', $color_white); +if($drawException) { + $drawing->drawException($drawException); +} else { + $drawing->setBarcode($code); + $drawing->draw(); +} + +// Header that says it is an image (remove it if you save the barcode to a file) +header('Content-Type: image/png'); +header('Content-Disposition: inline; filename="barcode.png"'); + +// Draw (or save) the image into PNG format. +$drawing->finish(BCGDrawing::IMG_FORMAT_PNG); +?> +setScale(2); // Resolution + $code->setThickness(30); // Thickness + $code->setForegroundColor($color_black); // Color of bars + $code->setBackgroundColor($color_white); // Color of spaces + $code->setFont($font); // Font (or 0) + $code->parse($text); // Text +} catch(Exception $exception) { + $drawException = $exception; +} + +/* Here is the list of the arguments +1 - Filename (empty : display on screen) +2 - Background color */ +$drawing = new BCGDrawing('', $color_white); +if($drawException) { + $drawing->drawException($drawException); +} else { + $drawing->setBarcode($code); + $drawing->draw(); +} + +// Header that says it is an image (remove it if you save the barcode to a file) +header('Content-Type: image/png'); +header('Content-Disposition: inline; filename="barcode.png"'); + +// Draw (or save) the image into PNG format. +$drawing->finish(BCGDrawing::IMG_FORMAT_PNG); +?> +setScale(2); // Resolution + $code->setThickness(30); // Thickness + $code->setForegroundColor($color_black); // Color of bars + $code->setBackgroundColor($color_white); // Color of spaces + $code->setFont($font); // Font (or 0) + $code->parse($text); // Text +} catch(Exception $exception) { + $drawException = $exception; +} + +/* Here is the list of the arguments +1 - Filename (empty : display on screen) +2 - Background color */ +$drawing = new BCGDrawing('', $color_white); +if($drawException) { + $drawing->drawException($drawException); +} else { + $drawing->setBarcode($code); + $drawing->draw(); +} + +// Header that says it is an image (remove it if you save the barcode to a file) +header('Content-Type: image/png'); +header('Content-Disposition: inline; filename="barcode.png"'); + +// Draw (or save) the image into PNG format. +$drawing->finish(BCGDrawing::IMG_FORMAT_PNG); +?> \ No newline at end of file diff --git a/application/models/item.php b/application/models/item.php index 7025e1294..ea3553db0 100644 --- a/application/models/item.php +++ b/application/models/item.php @@ -131,7 +131,7 @@ class Item extends CI_Model { $this->db->from('items'); $this->db->where_in('item_id',$item_ids); - $this->db->order_by("item", "asc"); + $this->db->order_by('item_id', 'asc'); return $this->db->get(); } diff --git a/application/views/barcode.php b/application/views/barcode.php index b80af25b9..284b18480 100644 --- a/application/views/barcode.php +++ b/application/views/barcode.php @@ -1,362 +1,96 @@ =1 to enable - - - NOTE: You must have GD-1.8 or higher compiled into PHP - in order to use PNG and JPEG. GIF images only work with - GD-1.5 and lower. (http://www.boutell.com) - - - ANOTHER NOTE: If you actually intend to print the barcodes - and scan them with a scanner, I highly recommend choosing - JPEG with a quality of 100. Most browsers can't seem to print - a PNG without mangling it beyond recognition. - - - USAGE EXAMPLES FOR ANY PLAIN OLD HTML DOCUMENT: - ----------------------------------------------- - - - - - - - - -*/ -/*=============================================================================*/ - - -//----------------------------------------------------------------------------- -// Startup code -//----------------------------------------------------------------------------- - - -if(isset($_GET["text"])) $text=$_GET["text"]; -if(isset($_GET["format"])) $format=$_GET["format"]; -if(isset($_GET["quality"])) $quality=$_GET["quality"]; -if(isset($_GET["width"])) $width=$_GET["width"]; -if(isset($_GET["height"])) $height=$_GET["height"]; -if(isset($_GET["type"])) $type=$_GET["type"]; -if(isset($_GET["barcode"])) $barcode=$_GET["barcode"]; - - -if(isset($_POST["text"])) $text=$_POST["text"]; -if(isset($_POST["format"])) $format=$_POST["format"]; -if(isset($_POST["quality"])) $quality=$_POST["quality"]; -if(isset($_POST["width"])) $width=$_POST["width"]; -if(isset($_POST["height"])) $height=$_POST["height"]; -if(isset($_POST["type"])) $type=$_POST["type"]; -if(isset($_POST["barcode"])) $barcode=$_POST["barcode"]; - - -if (!isset ($text)) $text = 1; -if (!isset ($type)) $type = 1; -if (empty ($quality)) $quality = 100; -if (empty ($width)) $width = 160; -if (empty ($height)) $height = 80; -if (!empty ($format)) $format = strtoupper ($format); - else $format="PNG"; - - -switch ($type) -{ - default: - $type = 1; - case 1: - Barcode39 ($barcode, $width, $height, $quality, $format, $text); - break; +function showError() { + header('Content-Type: image/png'); + readfile('error.png'); + exit; } +$requiredKeys = array('code', 'filetype', 'dpi', 'scale', 'rotation', 'font_family', 'font_size', 'text'); -//----------------------------------------------------------------------------- -// Generate a Code 3 of 9 barcode -//----------------------------------------------------------------------------- -function Barcode39 ($barcode, $width, $height, $quality, $format, $text) -{ - switch ($format) - { - default: - $format = "JPEG"; - case "JPEG": - header ("Content-type: image/jpeg"); - break; - case "PNG": - header ("Content-type: image/png"); - break; - case "GIF": - header ("Content-type: image/gif"); - break; - } - - - $im = ImageCreate ($width, $height) - or die ("Cannot Initialize new GD image stream"); - $White = ImageColorAllocate ($im, 255, 255, 255); - $Black = ImageColorAllocate ($im, 0, 0, 0); - //ImageColorTransparent ($im, $White); - ImageInterLace ($im, 1); - - - - $NarrowRatio = 20; - $WideRatio = 55; - $QuietRatio = 35; - - - $nChars = (strlen($barcode)+2) * ((6 * $NarrowRatio) + (3 * $WideRatio) + ($QuietRatio)); - $Pixels = $width / $nChars; - $NarrowBar = (int)(20 * $Pixels); - $WideBar = (int)(55 * $Pixels); - $QuietBar = (int)(35 * $Pixels); - - - $ActualWidth = (($NarrowBar * 6) + ($WideBar*3) + $QuietBar) * (strlen ($barcode)+2); - - if (($NarrowBar == 0) || ($NarrowBar == $WideBar) || ($NarrowBar == $QuietBar) || ($WideBar == 0) || ($WideBar == $QuietBar) || ($QuietBar == 0)) - { - ImageString ($im, 1, 0, 0, "Image is too small!", $Black); - OutputImage ($im, $format, $quality); - exit; - } - - $CurrentBarX = (int)(($width - $ActualWidth) / 2); - $Color = $White; - $BarcodeFull = "*".strtoupper ($barcode)."*"; - settype ($BarcodeFull, "string"); - - $FontNum = 3; - $FontHeight = ImageFontHeight ($FontNum); - $FontWidth = ImageFontWidth ($FontNum); - if (!empty($text)) - { - $CenterLoc = (int)(($width) / 2) - (int)(($FontWidth * strlen($text)) / 2); - ImageString ($im, $FontNum, $CenterLoc, $height-$FontHeight, "$text", $Black); - } - else - { - $FontHeight=-2; - } - - - for ($i=0; $i BCGDrawing::IMG_FORMAT_PNG, 'JPEG' => BCGDrawing::IMG_FORMAT_JPEG, 'GIF' => BCGDrawing::IMG_FORMAT_GIF); + +$drawException = null; +try { + $color_black = new BCGColor(0, 0, 0); + $color_white = new BCGColor(255, 255, 255); + + $code_generated = new $className(); + + if (function_exists('baseCustomSetup')) { + baseCustomSetup($code_generated, $_GET); + } + + if (function_exists('customSetup')) { + customSetup($code_generated, $_GET); + } + + $code_generated->setScale(max(1, min(4, $_GET['scale']))); + $code_generated->setBackgroundColor($color_white); + $code_generated->setForegroundColor($color_black); + + if ($_GET['text'] !== '') { + $text = convertText($_GET['text']); + $code_generated->parse($text); + } +} catch(Exception $exception) { + $drawException = $exception; +} + +$drawing = new BCGDrawing('', $color_white); +if($drawException) { + $drawing->drawException($drawException); +} else { + $drawing->setBarcode($code_generated); + $drawing->setRotationAngle($_GET['rotation']); + $drawing->setDPI($_GET['dpi'] === 'NULL' ? null : max(72, min(300, intval($_GET['dpi'])))); + $drawing->draw(); +} + +switch ($_GET['filetype']) { +case 'PNG': + header('Content-Type: image/png'); + break; +case 'JPEG': + header('Content-Type: image/jpeg'); + break; +case 'GIF': + header('Content-Type: image/gif'); + break; +} + +$drawing->finish($filetypes[$_GET['filetype']]); ?> diff --git a/application/views/barcode_sheet.php b/application/views/barcode_sheet.php index d8e89addd..54cd14f67 100644 --- a/application/views/barcode_sheet.php +++ b/application/views/barcode_sheet.php @@ -1,8 +1,11 @@ - + + + <?php echo $this->lang->line('items_generate_barcodes'); ?> + - -
+ +barcode_lib->get_font_name($barcode_config['barcode_font']); ?> + style="font-size:px"> +
width= > -config->item('barcode_content') === "id" ? $item['id'] : $item['item_number']; - $text = $this->config->item('barcode_content') === "id" ? $item['name'] : $item['item_number']; - - if ($count % 2 ==0 and $count!=0) + if ($count % $barcode_config['barcode_num_in_row'] ==0 and $count!=0) { echo ''; } - echo ""; - $count++; + echo ""; + $count++; } ?> diff --git a/application/views/configs/barcode_config.php b/application/views/configs/barcode_config.php new file mode 100644 index 000000000..6c8435ddc --- /dev/null +++ b/application/views/configs/barcode_config.php @@ -0,0 +1,297 @@ + + + +
lang->line('config_barcode_configuration'); ?>
+'barcode_config_form')); +?> +
+
+
lang->line('common_fields_required_message'); ?>
+
    + lang->line("config_barcode_info"); ?> + +
    + lang->line('config_barcode_type').':', 'barcode_type',array('class'=>'wide')); ?> +
    + config->item('barcode_type'));?> +
    +
    + +
    + lang->line('config_barcode_dpi').':', 'barcode_dpi',array('class'=>'wide required')); ?> +
    + '300', + 'min'=>'72', + 'type'=>'number', + 'name'=>'barcode_dpi', + 'id'=>'barcode_dpi', + 'value'=>$this->config->item('barcode_dpi')));?> +
    +
    + +
    + lang->line('config_barcode_thickness').':', 'barcode_thickness',array('class'=>'wide required')); ?> +
    + '5', + 'max'=>'90', + 'min'=>'20', + 'type'=>'number', + 'name'=>'barcode_thickness', + 'id'=>'barcode_thickness', + 'value'=>$this->config->item('barcode_thickness')));?> +
    +
    + +
    + lang->line('config_barcode_scale').':', 'barcode_scale',array('class'=>'wide required')); ?> +
    + 'number', + 'min' => 1, + 'max' => 4, + 'name'=>'barcode_scale', + 'id'=>'barcode_scale', + 'value'=>$this->config->item('barcode_scale')));?> +
    +
    + +
    + lang->line('config_barcode_rotation').':', 'barcode_rotation',array('class'=>'wide')); ?> +
    + 'No rotation', + '90' => '90° clockwise', + '180' => '180° clockwise', + '270' => '270° clockwise' + ), + $this->config->item('barcode_rotation')); + ?> +
    +
    + +
    + lang->line('config_barcode_font').':', 'barcode_font',array('class'=>'wide required')); ?> +
    + config->item('barcode_font')); + ?> + + 'number', + 'min' => '1', + 'max' => '30', + 'name'=>'barcode_font_size', + 'id'=>'barcode_font_size', + 'value'=>$this->config->item('barcode_font_size')));?> +
    +
    + +
    + lang->line('config_barcode_checksum').':', 'barcode_checksum',array('class'=>'wide')); ?> +
    + 'barcode_checksum', + 'id'=>'barcode_checksum', + 'value'=>'barcode_checksum', + 'checked'=>$this->config->item('barcode_checksum')));?> +
    +
    + +
    + lang->line('config_barcode_layout').':', 'barcode_layout',array('class'=>'wide')); ?> +
    + lang->line('config_barcode_first_row').' '; ?> + 'Not show', + 'name' => 'Name', + 'category' => 'Category', + 'item_code' => 'Item code', + 'cost_price' => 'Cost price', + 'unit_price' => 'Unit price' + ), + $this->config->item('barcode_first_row')); + ?> + lang->line('config_barcode_second_row').' '; ?> + 'Not show', + 'name' => 'Name', + 'category' => 'Category', + 'item_code' => 'Item code', + 'cost_price' => 'Cost price', + 'unit_price' => 'Unit price' + ), + $this->config->item('barcode_second_row')); + ?> + lang->line('config_barcode_third_row').' '; ?> + 'Not show', + 'name' => 'Name', + 'category' => 'Category', + 'item_code' => 'Item code', + 'cost_price' => 'Cost price', + 'unit_price' => 'Unit price' + ), + $this->config->item('barcode_third_row')); + ?> +
    +
    + +
    + lang->line('config_barcode_number_in_row').':', 'barcode_num_in_row',array('class'=>'wide required')); ?> +
    + 'barcode_num_in_row', + 'id'=>'barcode_num_in_row', + 'value'=>$this->config->item('barcode_num_in_row')));?> +
    +
    + +
    + lang->line('config_barcode_page_width').':', 'barcode_page_width',array('class'=>'wide required')); ?> +
    + 'barcode_page_width', + 'id'=>'barcode_page_width', + 'value'=>$this->config->item('barcode_page_width')));?> + % +
    +
    + +
    + lang->line('config_barcode_page_cellspacing').':', 'barcode_page_cellspacing',array('class'=>'wide required')); ?> +
    + 'barcode_page_cellspacing', + 'id'=>'barcode_page_cellspacing', + 'value'=>$this->config->item('barcode_page_cellspacing')));?> + pixl +
    +
    + + 'submit', + 'id'=>'submit', + 'value'=>$this->lang->line('common_submit'), + 'class'=>'submit_button float_right') + ); + ?> +
    +
    + + + + diff --git a/application/views/configs/general_config.php b/application/views/configs/general_config.php new file mode 100644 index 000000000..4955df7dd --- /dev/null +++ b/application/views/configs/general_config.php @@ -0,0 +1,438 @@ +
    lang->line('config_general_config'); ?>
    +'config_form')); +?> +
    +
    +
    lang->line('common_fields_required_message'); ?>
    +
      +lang->line("config_info"); ?> + +
      +lang->line('config_company').':', 'company',array('class'=>'wide required')); ?> +
      + 'company', + 'id'=>'company', + 'value'=>$this->config->item('company')));?> +
      +
      + +
      +lang->line('config_address').':', 'address',array('class'=>'wide required')); ?> +
      + 'address', + 'id'=>'address', + 'rows'=>4, + 'cols'=>17, + 'value'=>$this->config->item('address')));?> +
      +
      + +
      +lang->line('config_phone').':', 'phone',array('class'=>'wide required')); ?> +
      + 'phone', + 'id'=>'phone', + 'value'=>$this->config->item('phone')));?> +
      +
      + +
      +lang->line('config_default_tax_rate_1').':', 'default_tax_1_rate',array('class'=>'wide required')); ?> +
      + 'default_tax_1_name', + 'id'=>'default_tax_1_name', + 'size'=>'10', + 'value'=>$this->config->item('default_tax_1_name')!==FALSE ? $this->config->item('default_tax_1_name') : $this->lang->line('items_sales_tax_1')));?> + + 'default_tax_1_rate', + 'id'=>'default_tax_1_rate', + 'size'=>'4', + 'value'=>$this->config->item('default_tax_1_rate')));?>% +
      +
      + +
      +lang->line('config_default_tax_rate_2').':', 'default_tax_1_rate',array('class'=>'wide')); ?> +
      + 'default_tax_2_name', + 'id'=>'default_tax_2_name', + 'size'=>'10', + 'value'=>$this->config->item('default_tax_2_name')!==FALSE ? $this->config->item('default_tax_2_name') : $this->lang->line('items_sales_tax_2')));?> + + 'default_tax_2_rate', + 'id'=>'default_tax_2_rate', + 'size'=>'4', + 'value'=>$this->config->item('default_tax_2_rate')));?>% +
      +
      + +
      + lang->line('config_currency_symbol').':', 'currency_symbol',array('class'=>'wide')); ?> +
      + 'currency_symbol', + 'id'=>'currency_symbol', + 'value'=>$this->config->item('currency_symbol')));?> +
      + + lang->line('config_currency_side').':', 'currency_side',array('class'=>''));?> +
      + 'currency_side', + 'id'=>'currency_side', + 'value'=>'currency_side', + 'checked'=>$this->config->item('currency_side')));?> +
      +
      + + +
      +lang->line('common_email').':', 'email',array('class'=>'wide')); ?> +
      + 'email', + 'id'=>'email', + 'value'=>$this->config->item('email')));?> +
      +
      + + +
      +lang->line('config_fax').':', 'fax',array('class'=>'wide')); ?> +
      + 'fax', + 'id'=>'fax', + 'value'=>$this->config->item('fax')));?> +
      +
      + +
      +lang->line('config_website').':', 'website',array('class'=>'wide')); ?> +
      + 'website', + 'id'=>'website', + 'value'=>$this->config->item('website')));?> +
      +
      + +
      +lang->line('common_return_policy').':', 'return_policy',array('class'=>'wide required')); ?> +
      + 'return_policy', + 'id'=>'return_policy', + 'rows'=>'4', + 'cols'=>'17', + 'value'=>$this->config->item('return_policy')));?> +
      +
      + +
      +lang->line('config_language').':', 'language',array('class'=>'wide required')); ?> +
      + 'Azerbaijan', + 'BahasaIndonesia' => 'BahasaIndonesia', + 'english' => 'English', + 'Spanish' => 'Spanish', + 'Russian' => 'Russian', + 'Thai' => 'Thai' + ), + $this->config->item('language')); + ?> +
      +
      + +
      +lang->line('config_timezone').':', 'timezone',array('class'=>'wide required')); ?> +
      + '(GMT-11:00) Midway Island, Samoa', + 'America/Adak'=>'(GMT-10:00) Hawaii-Aleutian', + 'Etc/GMT+10'=>'(GMT-10:00) Hawaii', + 'Pacific/Marquesas'=>'(GMT-09:30) Marquesas Islands', + 'Pacific/Gambier'=>'(GMT-09:00) Gambier Islands', + 'America/Anchorage'=>'(GMT-09:00) Alaska', + 'America/Ensenada'=>'(GMT-08:00) Tijuana, Baja California', + 'Etc/GMT+8'=>'(GMT-08:00) Pitcairn Islands', + 'America/Los_Angeles'=>'(GMT-08:00) Pacific Time (US & Canada)', + 'America/Denver'=>'(GMT-07:00) Mountain Time (US & Canada)', + 'America/Chihuahua'=>'(GMT-07:00) Chihuahua, La Paz, Mazatlan', + 'America/Dawson_Creek'=>'(GMT-07:00) Arizona', + 'America/Belize'=>'(GMT-06:00) Saskatchewan, Central America', + 'America/Cancun'=>'(GMT-06:00) Guadalajara, Mexico City, Monterrey', + 'Chile/EasterIsland'=>'(GMT-06:00) Easter Island', + 'America/Chicago'=>'(GMT-06:00) Central Time (US & Canada)', + 'America/New_York'=>'(GMT-05:00) Eastern Time (US & Canada)', + 'America/Havana'=>'(GMT-05:00) Cuba', + 'America/Bogota'=>'(GMT-05:00) Bogota, Lima, Quito, Rio Branco', + 'America/Caracas'=>'(GMT-04:30) Caracas', + 'America/Santiago'=>'(GMT-04:00) Santiago', + 'America/La_Paz'=>'(GMT-04:00) La Paz', + 'Atlantic/Stanley'=>'(GMT-04:00) Faukland Islands', + 'America/Campo_Grande'=>'(GMT-04:00) Brazil', + 'America/Goose_Bay'=>'(GMT-04:00) Atlantic Time (Goose Bay)', + 'America/Glace_Bay'=>'(GMT-04:00) Atlantic Time (Canada)', + 'America/St_Johns'=>'(GMT-03:30) Newfoundland', + 'America/Araguaina'=>'(GMT-03:00) UTC-3', + 'America/Montevideo'=>'(GMT-03:00) Montevideo', + 'America/Miquelon'=>'(GMT-03:00) Miquelon, St. Pierre', + 'America/Godthab'=>'(GMT-03:00) Greenland', + 'America/Argentina/Buenos_Aires'=>'(GMT-03:00) Buenos Aires', + 'America/Sao_Paulo'=>'(GMT-03:00) Brasilia', + 'America/Noronha'=>'(GMT-02:00) Mid-Atlantic', + 'Atlantic/Cape_Verde'=>'(GMT-01:00) Cape Verde Is.', + 'Atlantic/Azores'=>'(GMT-01:00) Azores', + 'Europe/Belfast'=>'(GMT) Greenwich Mean Time : Belfast', + 'Europe/Dublin'=>'(GMT) Greenwich Mean Time : Dublin', + 'Europe/Lisbon'=>'(GMT) Greenwich Mean Time : Lisbon', + 'Europe/London'=>'(GMT) Greenwich Mean Time : London', + 'Africa/Abidjan'=>'(GMT) Monrovia, Reykjavik', + 'Europe/Amsterdam'=>'(GMT+01:00) Amsterdam, Berlin, Bern, Rome, Stockholm, Vienna', + 'Europe/Belgrade'=>'(GMT+01:00) Belgrade, Bratislava, Budapest, Ljubljana, Prague', + 'Europe/Brussels'=>'(GMT+01:00) Brussels, Copenhagen, Madrid, Paris', + 'Africa/Algiers'=>'(GMT+01:00) West Central Africa', + 'Africa/Windhoek'=>'(GMT+01:00) Windhoek', + 'Asia/Beirut'=>'(GMT+02:00) Beirut', + 'Africa/Cairo'=>'(GMT+02:00) Cairo', + 'Asia/Gaza'=>'(GMT+02:00) Gaza', + 'Africa/Blantyre'=>'(GMT+02:00) Harare, Pretoria', + 'Asia/Jerusalem'=>'(GMT+02:00) Jerusalem', + 'Europe/Minsk'=>'(GMT+02:00) Minsk', + 'Asia/Damascus'=>'(GMT+02:00) Syria', + 'Europe/Moscow'=>'(GMT+03:00) Moscow, St. Petersburg, Volgograd', + 'Africa/Addis_Ababa'=>'(GMT+03:00) Nairobi', + 'Asia/Tehran'=>'(GMT+03:30) Tehran', + 'Asia/Dubai'=>'(GMT+04:00) Abu Dhabi, Muscat', + 'Asia/Yerevan'=>'(GMT+04:00) Yerevan', + 'Asia/Kabul'=>'(GMT+04:30) Kabul', + 'Asia/Baku'=>'(GMT+05:00) Baku',/*GARRISON ADDED 4/20/2013*/ + 'Asia/Yekaterinburg'=>'(GMT+05:00) Ekaterinburg', + 'Asia/Tashkent'=>'(GMT+05:00) Tashkent', + 'Asia/Kolkata'=>'(GMT+05:30) Chennai, Kolkata, Mumbai, New Delhi', + 'Asia/Katmandu'=>'(GMT+05:45) Kathmandu', + 'Asia/Dhaka'=>'(GMT+06:00) Astana, Dhaka', + 'Asia/Novosibirsk'=>'(GMT+06:00) Novosibirsk', + 'Asia/Rangoon'=>'(GMT+06:30) Yangon (Rangoon)', + 'Asia/Bangkok'=>'(GMT+07:00) Bangkok, Hanoi, Jakarta', + 'Asia/Krasnoyarsk'=>'(GMT+07:00) Krasnoyarsk', + 'Asia/Hong_Kong'=>'(GMT+08:00) Beijing, Chongqing, Hong Kong, Urumqi', + 'Asia/Irkutsk'=>'(GMT+08:00) Irkutsk, Ulaan Bataar', + 'Australia/Perth'=>'(GMT+08:00) Perth', + 'Australia/Eucla'=>'(GMT+08:45) Eucla', + 'Asia/Tokyo'=>'(GMT+09:00) Osaka, Sapporo, Tokyo', + 'Asia/Seoul'=>'(GMT+09:00) Seoul', + 'Asia/Yakutsk'=>'(GMT+09:00) Yakutsk', + 'Australia/Adelaide'=>'(GMT+09:30) Adelaide', + 'Australia/Darwin'=>'(GMT+09:30) Darwin', + 'Australia/Brisbane'=>'(GMT+10:00) Brisbane', + 'Australia/Hobart'=>'(GMT+10:00) Hobart', + 'Asia/Vladivostok'=>'(GMT+10:00) Vladivostok', + 'Australia/Lord_Howe'=>'(GMT+10:30) Lord Howe Island', + 'Etc/GMT-11'=>'(GMT+11:00) Solomon Is., New Caledonia', + 'Asia/Magadan'=>'(GMT+11:00) Magadan', + 'Pacific/Norfolk'=>'(GMT+11:30) Norfolk Island', + 'Asia/Anadyr'=>'(GMT+12:00) Anadyr, Kamchatka', + 'Pacific/Auckland'=>'(GMT+12:00) Auckland, Wellington', + 'Etc/GMT-12'=>'(GMT+12:00) Fiji, Kamchatka, Marshall Is.', + 'Pacific/Chatham'=>'(GMT+12:45) Chatham Islands', + 'Pacific/Tongatapu'=>'(GMT+13:00) Nuku\'alofa', + 'Pacific/Kiritimati'=>'(GMT+14:00) Kiritimati' + ), $this->config->item('timezone') ? $this->config->item('timezone') : date_default_timezone_get()); + ?> +
      +
      + +
      +lang->line('config_print_after_sale').':', 'print_after_sale',array('class'=>'wide')); ?> +
      + 'print_after_sale', + 'id'=>'print_after_sale', + 'value'=>'print_after_sale', + 'checked'=>$this->config->item('print_after_sale')));?> +
      +
      + +
      +lang->line('config_custom1').':', 'website',array('class'=>'wide')); ?> +
      + 'custom1_name', + 'id'=>'custom1_name', + 'value'=>$this->config->item('custom1_name')));?> +
      +
      + +
      +lang->line('config_custom2').':', 'website',array('class'=>'wide')); ?> +
      + 'custom2_name', + 'id'=>'custom2_name', + 'value'=>$this->config->item('custom2_name')));?> +
      +
      + +
      +lang->line('config_custom3').':', 'website',array('class'=>'wide')); ?> +
      + 'custom3_name', + 'id'=>'custom3_name', + 'value'=>$this->config->item('custom3_name')));?> +
      +
      + +
      +lang->line('config_custom4').':', 'website',array('class'=>'wide')); ?> +
      + 'custom4_name', + 'id'=>'custom4_name', + 'value'=>$this->config->item('custom4_name')));?> +
      +
      + +
      +lang->line('config_custom5').':', 'website',array('class'=>'wide')); ?> +
      + 'custom5_name', + 'id'=>'custom5_name', + 'value'=>$this->config->item('custom5_name')));?> +
      +
      + +
      +lang->line('config_custom6').':', 'website',array('class'=>'wide')); ?> +
      + 'custom6_name', + 'id'=>'custom6_name', + 'value'=>$this->config->item('custom6_name')));?> +
      +
      + +
      +lang->line('config_custom7').':', 'website',array('class'=>'wide')); ?> +
      + 'custom7_name', + 'id'=>'custom7_name', + 'value'=>$this->config->item('custom7_name')));?> +
      +
      + +
      +lang->line('config_custom8').':', 'website',array('class'=>'wide')); ?> +
      + 'custom8_name', + 'id'=>'custom8_name', + 'value'=>$this->config->item('custom8_name')));?> +
      +
      + +
      +lang->line('config_custom9').':', 'website',array('class'=>'wide')); ?> +
      + 'custom9_name', + 'id'=>'custom9_name', + 'value'=>$this->config->item('custom9_name')));?> +
      +
      + +
      +lang->line('config_custom10').':', 'website',array('class'=>'wide')); ?> +
      + 'custom10_name', + 'id'=>'custom10_name', + 'value'=>$this->config->item('custom10_name')));?> +
      +
      + +'submit', + 'id'=>'submit', + 'value'=>$this->lang->line('common_submit'), + 'class'=>'submit_button float_right') +); +?> +
      +
      + + + \ No newline at end of file diff --git a/application/views/configs/manage.php b/application/views/configs/manage.php new file mode 100644 index 000000000..4248db6c4 --- /dev/null +++ b/application/views/configs/manage.php @@ -0,0 +1,22 @@ +load->view("partial/header"); ?> + + + +
      +
      lang->line('module_config'); ?>
      +
      + + +
      +
      + load->view("configs/general_config"); ?> +
      +
      + load->view("configs/barcode_config"); ?> +
      +
      +
      +load->view("partial/footer"); ?> \ No newline at end of file diff --git a/application/views/items/form.php b/application/views/items/form.php index 4ae726a77..37cd6466d 100644 --- a/application/views/items/form.php +++ b/application/views/items/form.php @@ -7,7 +7,7 @@ echo form_open('items/save/'.$item_info->item_id,array('id'=>'item_form')); lang->line("items_basic_information"); ?>
      -lang->line('items_item_number').':', 'name',array('class'=>'wide')); ?> +lang->line('items_item_number').':', 'name',array('class'=>'required wide')); ?>
      'item_number', @@ -447,6 +447,7 @@ $(document).ready(function() wrapper: "li", rules: { + item_number:"required", name:"required", category:"required", cost_price: @@ -474,6 +475,7 @@ $(document).ready(function() }, messages: { + item_number:"lang->line('items_number_required'); ?>", name:"lang->line('items_name_required'); ?>", category:"lang->line('items_category_required'); ?>", cost_price: diff --git a/barcode.png b/barcode.png new file mode 100644 index 000000000..229151a5a Binary files /dev/null and b/barcode.png differ diff --git a/css/barcode_font.css b/css/barcode_font.css new file mode 100644 index 000000000..dd6007319 --- /dev/null +++ b/css/barcode_font.css @@ -0,0 +1,44 @@ +@font-face +{ + font-family:'SansationLight'; + src: url('../font/SansationLight.eot'); + src: local('SansationLight'), url('../font/SansationLight.woff') format('woff'), url('../font/SansationLight.ttf') format('truetype'); +} + +.font_SansationLight { + font-family: 'SansationLight' !important; +} + +@font-face +{ + font-family:'Arial'; + src: url('../font/Arial.eot'); + src: local('Arial'), url('../font/Arial.woff') format('woff'), url('../font/Arial.ttf') format('truetype'); +} + +.font_Arial { + font-family: 'Arial' !important; +} + +@font-face +{ + font-family:'JUNEBUG'; + src: url('../font/JUNEBUG.eot'); + src: local('JUNEBUG'), url('../font/JUNEBUG.woff') format('woff'), url('../font/JUNEBUG.ttf') format('truetype'); +} + +.font_JUNEBUG { + font-family: 'JUNEBUG' !important; +} + +@font-face +{ + font-family:'b-de-bonita-shadow'; + src: url('../font/b-de-bonita-shadow.eot'); + src: local('JUNEBUG'), url('../font/b-de-bonita-shadow.woff') format('woff'), url('../font/b-de-bonita-shadow.ttf') format('truetype'); +} + +.font_b-de-bonita-shadow { + font-family: 'b-de-bonita-shadow' !important; +} + diff --git a/css/tabcontent.css b/css/tabcontent.css new file mode 100644 index 000000000..dc9eb1247 --- /dev/null +++ b/css/tabcontent.css @@ -0,0 +1,69 @@ +/* Tab Content - menucool.com */ + +ul.tabs +{ + padding: 7px 0; + font-size: 0; + margin:0; + list-style-type: none; + text-align: left; /*set to left, center, or right to align the tabs as desired*/ +} + +ul.tabs li +{ + display: inline; + margin: 0; + margin-right:3px; /*distance between tabs*/ +} + +ul.tabs li a +{ + font: normal 12px Verdana; + text-decoration: none; + position: relative; + padding: 7px 16px; + border: 1px solid #CCC; + border-bottom-color:#B7B7B7; + color: #000; + background: #F0F0F0 url(../images/tabbg.gif) 0 0 repeat-x; + border-radius: 3px 3px 0 0; + outline:none; +} + +ul.tabs li a:visited +{ + color: #000; +} + +ul.tabs li a:hover +{ + border: 1px solid #B7B7B7; + background-color:#F0F0F0; + background-image:url(../images/tabbg.gif); + background-position:0 -36px; + background-repeat:repeat-x; +} + +ul.tabs li.selected a, ul.tabs li.selected a:hover +{ + position: relative; + top: 0px; + font-weight:bold; + background: white; + border: 1px solid #B7B7B7; + border-bottom-color: white; +} + + +ul.tabs li.selected a:hover +{ + text-decoration: none; +} + + +div.tabcontents +{ + border: 1px solid #B7B7B7; padding: 30px; + background-color:#FFF; + border-radius: 0 3px 3px 3px; +} \ No newline at end of file diff --git a/database/2.3_to_2.3.1.sql b/database/2.3_to_2.3.1.sql index 93291b1c8..a7f413649 100644 --- a/database/2.3_to_2.3.1.sql +++ b/database/2.3_to_2.3.1.sql @@ -89,7 +89,20 @@ INSERT INTO `ospos_app_config` (`key`, `value`) VALUES ('recv_invoice_format', '$CO'), ('sales_invoice_format', '$CO'), ('barcode_content', 'id'), -('barcode_labels', ''); +('barcode_labels', ''), +('barcode_dpi', '72'), +('barcode_scale', '1'), +('barcode_rotation', 'no_rotation'), +('barcode_font', ''), +('barcode_font_size', ''), +('barcode_thickness', '20'), +('barcode_checksum', '0'), +('barcode_first_row', 'category'), +('barcode_second_row', 'item_code'), +('barcode_third_row', 'cost_price'), +('barcode_num_in_row', '2'), +('barcode_page_width', '100'), +('barcode_page_cellspacing', '20'); -- add invoice_number column to receivings table ALTER TABLE `ospos_receivings` diff --git a/database/database.sql b/database/database.sql index 67c53e136..64487bf1e 100644 --- a/database/database.sql +++ b/database/database.sql @@ -41,7 +41,20 @@ INSERT INTO `ospos_app_config` (`key`, `value`) VALUES ('sales_invoice_format', '$CO'), ('tax_included', '0'), ('barcode_content', 'id'), -('barcode_labels', ''); +('barcode_labels', ''), +('barcode_dpi', '72'), +('barcode_scale', '1'), +('barcode_rotation', 'no_rotation'), +('barcode_font', 'Arial'), +('barcode_font_size', '10'), +('barcode_thickness', '20'), +('barcode_checksum', '0'), +('barcode_first_row', 'category'), +('barcode_second_row', 'item_code'), +('barcode_third_row', 'cost_price'), +('barcode_num_in_row', '2'), +('barcode_page_width', '100'), +('barcode_page_cellspacing', '20'); -- -------------------------------------------------------- diff --git a/font/Arial.ttf b/font/Arial.ttf new file mode 100755 index 000000000..886789b85 Binary files /dev/null and b/font/Arial.ttf differ diff --git a/font/Arial.woff b/font/Arial.woff new file mode 100644 index 000000000..96262d4df Binary files /dev/null and b/font/Arial.woff differ diff --git a/font/SansationLight.ttf b/font/SansationLight.ttf new file mode 100644 index 000000000..b2be9b093 Binary files /dev/null and b/font/SansationLight.ttf differ diff --git a/font/b-de-bonita-shadow.ttf b/font/b-de-bonita-shadow.ttf new file mode 100644 index 000000000..5d259b02d Binary files /dev/null and b/font/b-de-bonita-shadow.ttf differ diff --git a/images/Thumbs.db b/images/Thumbs.db deleted file mode 100644 index 10eecf861..000000000 Binary files a/images/Thumbs.db and /dev/null differ diff --git a/images/tabbg.gif b/images/tabbg.gif new file mode 100644 index 000000000..5edb3fad3 Binary files /dev/null and b/images/tabbg.gif differ diff --git a/js/tabcontent.js b/js/tabcontent.js new file mode 100644 index 000000000..a9402000f --- /dev/null +++ b/js/tabcontent.js @@ -0,0 +1,3 @@ + +/* http://www.menucool.com/tabbed-content Free to use. Version 2013.7.6 */ +(function(){var g=function(a){if(a&&a.stopPropagation)a.stopPropagation();else window.event.cancelBubble=true;var b=a?a:window.event;b.preventDefault&&b.preventDefault()},d=function(a,c,b){if(a.addEventListener)a.addEventListener(c,b,false);else a.attachEvent&&a.attachEvent("on"+c,b)},a=function(c,a){var b=new RegExp("(^| )"+a+"( |$)");return b.test(c.className)?true:false},j=function(b,c,d){if(!a(b,c))if(b.className=="")b.className=c;else if(d)b.className=c+" "+b.className;else b.className+=" "+c},h=function(a,b){var c=new RegExp("(^| )"+b+"( |$)");a.className=a.className.replace(c,"$1");a.className=a.className.replace(/ $/,"")},e=function(){var b=window.location.pathname;if(b.indexOf("/")!=-1)b=b.split("/");var a=b[b.length-1]||"root";if(a.indexOf(".")!=-1)a=a.substring(0,a.indexOf("."));if(a>20)a=a.substring(a.length-19);return a},c="mi"+e(),b=function(b,a){this.g(b,a)};b.prototype={h:function(){var b=new RegExp(c+this.a+"=(\\d+)"),a=document.cookie.match(b);return a?a[1]:this.i()},i:function(){for(var b=0,c=this.b.length;b=this.b.length)a=0;this.j(this.b[a],0)}};var k=[],i=function(e){var b=false;function a(){if(b)return;b=true;setTimeout(e,4)}if(document.addEventListener)document.addEventListener("DOMContentLoaded",a,false);else if(document.attachEvent){try{var f=window.frameElement!=null}catch(g){}if(document.documentElement.doScroll&&!f){function c(){if(b)return;try{document.documentElement.doScroll("left");a()}catch(d){setTimeout(c,10)}}c()}document.attachEvent("onreadystatechange",function(){document.readyState==="complete"&&a()})}d(window,"load",a)},f=function(){for(var d=document.getElementsByTagName("ul"),c=0,e=d.length;c
      "; - if (strstr($this->config->item('barcode_labels'), 'company')) - { - echo $this->config->item('company'); - } - echo "

      "; - if (strstr($this->config->item('barcode_labels'), 'price')) - { - echo to_currency($item['unit_price']); - } - if (strstr($this->config->item('barcode_labels'), 'name')) - { - echo " " . $item['name']; - } - echo "
      ". $this->barcode_lib->create_display_barcode($item,$barcode_config)."