diff --git a/htdocs/admin/barcode.php b/htdocs/admin/barcode.php index d99458c9da5..58e6642bfa4 100644 --- a/htdocs/admin/barcode.php +++ b/htdocs/admin/barcode.php @@ -31,21 +31,20 @@ require("./pre.inc.php"); $langs->load("admin"); -$langs->load("bills"); if (!$user->admin) accessforbidden(); -$barcode_encode_type_set = BARCODE_ENCODE_TYPE; - -$typeconst=array('yesno','texte','chaine'); - -if ($_GET["action"] == 'settype' && $user->admin) +if ($_POST["action"] == 'setcoder' && $user->admin) { - if (dolibarr_set_const($db, "BARCODE_ENCODE_TYPE",$_GET["value"])) - $barcode_encode_type_set = $_GET["value"]; + $sqlp = "UPDATE ".MAIN_DB_PREFIX."c_barcode"; + $sqlp.= " SET coder = " . $_POST["coder"]; + $sqlp.= " WHERE rowid = ". $_POST["code_id"]; + $resql=$db->query($sqlp); } +$html = new Form($db); + llxHeader('',$langs->trans("BarcodeSetup"),'BarcodeConfiguration'); print_fiche_titre($langs->trans("BarcodeSetup"),'','setup'); @@ -53,48 +52,51 @@ print_fiche_titre($langs->trans("BarcodeSetup"),'','setup'); /* * CHOIX ENCODAGE */ - + print '
'; print_titre($langs->trans("BarcodeEncodeModule")); print ''; - print ''; - print ''; print ''; -print ''; +print ''; print ''; print "\n"; -clearstatcache(); -$var=true; +$sql = "SELECT rowid, code, libelle, coder, example"; +$sql .= " FROM ".MAIN_DB_PREFIX."c_barcode"; +$resql=$db->query($sql); +if ($resql) +{ + $num = $db->num_rows($resql); + $i = 0; + $var=true; + + while ($i < $num) + { + $obj = $db->fetch_object($resql); -//EAN8 - $var=!$var; - print ''; - - // Affiche exemple - print ''; - - print '\n"; + print ''; + // Affiche exemple + print ''; + + print '\n"; + $var=!$var; + $i++; + } +} +/* //EAN13 $var=!$var; print ''; print '\n"; + $i++; //UPC $var=!$var; @@ -135,15 +131,9 @@ $var=true; print ''; print '\n"; + $i++; //ISBN $var=!$var; @@ -157,15 +147,9 @@ $var=true; print ''; print '\n"; + $i++; //code 39 $var=!$var; @@ -183,15 +167,9 @@ $var=true; print ''; print '\n"; + $i++; //code 128 @@ -210,15 +188,9 @@ $var=true; print ''; print '\n"; + $i++; //I25 $var=!$var; @@ -232,16 +204,10 @@ $var=true; print ''; print '\n"; - + $i++; +*/ print "
'.$langs->trans("Name").''.$langs->trans("Description").''.$langs->trans("Example").''.$langs->trans("Example").''.$langs->trans("Default").'
'; - print "EAN8"; - print "\n"; - - print "L'EAN se compose de 8 caractères, 7 chiffres plus une clé de contrôle.
"; - print "L'utilisation des symbologies EAN8 impose la souscription et l'abonnement auprès d'organisme tel que GENCOD.
"; - print "Codes numériques utilisés exclusivement à l'identification des produits susceptibles d'être vendus au grand public."; - print '
'; - if ($barcode_encode_type_set == "EAN8") - { - print img_tick(); - } - else - { - print ''.$langs->trans("Default").''; - } - print "
'; + print $obj->libelle; + print "\n"; + print $langs->trans('BarcodeDesc'.$obj->code); + //print "L'EAN se compose de 8 caractères, 7 chiffres plus une clé de contrôle.
"; + //print "L'utilisation des symbologies EAN8 impose la souscription et l'abonnement auprès d'organisme tel que GENCOD.
"; + //print "Codes numériques utilisés exclusivement à l'identification des produits susceptibles d'être vendus au grand public."; + print '
'; + print $html->setBarcodeEncoder($obj->coder,$obj->rowid,'form'.$i); + print "
'; @@ -110,15 +112,9 @@ $var=true; print ''; - if ($barcode_encode_type_set == "EAN13") - { - print img_tick(); - } - else - { - print ''.$langs->trans("Default").''; - } + print $html->setBarcodeEncoder('EAN13','form'.$i); print "
'; - if ($barcode_encode_type_set == "UPC") - { - print img_tick(); - } - else - { - print ''.$langs->trans("Default").''; - } + print $html->setBarcodeEncoder('UPC','form'.$i); print "
'; - if ($barcode_encode_type_set == "ISBN") - { - print img_tick(); - } - else - { - print ''.$langs->trans("Default").''; - } + print $html->setBarcodeEncoder('ISBN','form'.$i); print "
'; - if ($barcode_encode_type_set == "code39") - { - print img_tick(); - } - else - { - print ''.$langs->trans("Default").''; - } + print $html->setBarcodeEncoder('C39','form'.$i); print "
'; - if ($barcode_encode_type_set == "code128") - { - print img_tick(); - } - else - { - print ''.$langs->trans("Default").''; - } + print $html->setBarcodeEncoder('C128','form'.$i); print "
'; - if ($barcode_encode_type_set == "I25") - { - print img_tick(); - } - else - { - print ''.$langs->trans("Default").''; - } + print $html->setBarcodeEncoder('I25','form'.$i); print "
\n"; print "
"; @@ -249,4 +215,4 @@ print "
"; $db->close(); llxFooter('$Date$ - $Revision$'); -?> +?> \ No newline at end of file diff --git a/htdocs/html.form.class.php b/htdocs/html.form.class.php index dff1e19593d..6be9aa897b0 100644 --- a/htdocs/html.form.class.php +++ b/htdocs/html.form.class.php @@ -3505,7 +3505,25 @@ class Form $ret.=''; } return $ret; - } + } + + /** + * + */ + function setBarcodeEncoder($selected=0,$code_id,$formName='formbarcode') + { + global $langs; + + $select_encoder = '
'; + $select_encoder.= ''; + $select_encoder.= ''; + $select_encoder.= '
'; + return $select_encoder; + } } ?> diff --git a/htdocs/lib/functions.inc.php b/htdocs/lib/functions.inc.php index fd299607d85..c5106067fc3 100644 --- a/htdocs/lib/functions.inc.php +++ b/htdocs/lib/functions.inc.php @@ -3571,8 +3571,11 @@ function viewExcelFileContent($file_to_include='',$max_rows=0,$max_cols=0) */ function dol_genbarcode($code,$encoding,$generator=1,$readable='Y') { + if ($encoding == 'EAN8' || $encoding == 'EAN13') $encoding = 'EAN'; + if ($generator == 1) { + if ($encoding == 'C39' || $encoding == 'C128') $encoding = substr($encoding,1); $url = DOL_URL_ROOT.'/includes/barcode/php-barcode/genbarcode.php?code='.$code.'&encoding='.$encoding.'&scale=1'; } else if ($generator == 2) diff --git a/htdocs/lib/lib_head.js b/htdocs/lib/lib_head.js index 99d62e82fa8..7314d41179f 100644 --- a/htdocs/lib/lib_head.js +++ b/htdocs/lib/lib_head.js @@ -16,6 +16,13 @@ function dolibarr_type_reload(param) document.formsoc.submit(); } +function barcode_coder_save(formNameID) +{ + var formName = document.getElementById(formNameID); + formName.action.value='setcoder'; + formName.submit(); +} + /*================================================================= Purpose: Pour la fonction de saisie auto des villes Input: postalcode,objectville diff --git a/mysql/data/data.sql b/mysql/data/data.sql index 0722b9c7e7e..8ddfee04ed7 100644 --- a/mysql/data/data.sql +++ b/mysql/data/data.sql @@ -1575,3 +1575,13 @@ INSERT INTO `llx_c_ecotaxe` (`rowid`, `code`, `libelle`, `price`, `organization` INSERT INTO `llx_c_ecotaxe` (`rowid`, `code`, `libelle`, `price`, `organization`, `fk_pays`, `active`) VALUES (36, 'ES-A-F', 'Jouets et équipements de loisirs et de sports < 0,5 kg', 0.04200000, 'Eco-systèmes', 1, 1); INSERT INTO `llx_c_ecotaxe` (`rowid`, `code`, `libelle`, `price`, `organization`, `fk_pays`, `active`) VALUES (37, 'ES-A-G', 'Jouets et équipements de loisirs et de sports > 0,5 kg', 0.17000000, 'Eco-systèmes', 1, 1); INSERT INTO `llx_c_ecotaxe` (`rowid`, `code`, `libelle`, `price`, `organization`, `fk_pays`, `active`) VALUES (38, 'ES-A-H', 'Jouets et équipements de loisirs et de sports > 10 kg', 1.25000000, 'Eco-systèmes', 1, 1); + +-- +-- Codes barres +-- +INSERT INTO llx_c_barcode (rowid, code, libelle, coder, example) VALUES (1, 'EAN8', 'EAN8', 0, '1234567'); +INSERT INTO llx_c_barcode (rowid, code, libelle, coder, example) VALUES (2, 'EAN13', 'EAN13', 0, '123456789012'); +INSERT INTO llx_c_barcode (rowid, code, libelle, coder, example) VALUES (3, 'UPC', 'UPC', 0, '123456789012'); +INSERT INTO llx_c_barcode (rowid, code, libelle, coder, example) VALUES (4, 'ISBN', 'ISBN', 0, '123456789'); +INSERT INTO llx_c_barcode (rowid, code, libelle, coder, example) VALUES (5, 'C39', 'Code 39', 0, '1234567890'); +INSERT INTO llx_c_barcode (rowid, code, libelle, coder, example) VALUES (6, 'C128', 'Code 128', 0, 'ABCD1234567890'); \ No newline at end of file diff --git a/mysql/migration/2.1.0-2.2.0.sql b/mysql/migration/2.1.0-2.2.0.sql index 28f3f142dc9..40f78be1e50 100644 --- a/mysql/migration/2.1.0-2.2.0.sql +++ b/mysql/migration/2.1.0-2.2.0.sql @@ -880,4 +880,20 @@ ALTER TABLE llx_element_contact ADD INDEX idx_element_contact_fk_socpeople (fk_s -- Supprimme orphelins pour permettre montée de la clé -- V4 DELETE llx_fichinter FROM llx_fichinter LEFT JOIN llx_societe ON llx_fichinter.fk_soc = llx_societe.rowid WHERE llx_societe.rowid IS NULL; -ALTER TABLE llx_societe ADD COLUMN supplier_account varchar(32) after fournisseur; \ No newline at end of file +ALTER TABLE llx_societe ADD COLUMN supplier_account varchar(32) after fournisseur; + +create table llx_c_barcode +( + rowid integer AUTO_INCREMENT PRIMARY KEY, + code varchar(16) NOT NULL, + libelle varchar(50) NOT NULL, + coder integer NOT NULL DEFAULT 0, + example varchar(16) NOT NULL +)type=innodb; + +INSERT INTO llx_c_barcode (rowid, code, libelle, coder, example) VALUES (1, 'EAN8', 'EAN8', 0, '1234567'); +INSERT INTO llx_c_barcode (rowid, code, libelle, coder, example) VALUES (2, 'EAN13', 'EAN13', 0, '123456789012'); +INSERT INTO llx_c_barcode (rowid, code, libelle, coder, example) VALUES (3, 'UPC', 'UPC', 0, '123456789012'); +INSERT INTO llx_c_barcode (rowid, code, libelle, coder, example) VALUES (4, 'ISBN', 'ISBN', 0, '123456789'); +INSERT INTO llx_c_barcode (rowid, code, libelle, coder, example) VALUES (5, 'C39', 'Code 39', 0, '1234567890'); +INSERT INTO llx_c_barcode (rowid, code, libelle, coder, example) VALUES (6, 'C128', 'Code 128', 0, 'ABCD1234567890'); \ No newline at end of file diff --git a/mysql/tables/llx_c_barcode.sql b/mysql/tables/llx_c_barcode.sql new file mode 100644 index 00000000000..f7fbfafeabb --- /dev/null +++ b/mysql/tables/llx_c_barcode.sql @@ -0,0 +1,30 @@ +-- ======================================================================== +-- Copyright (C) 2007 Regis Houssin +-- +-- $Id$ +-- $Source$ +-- +-- This program is free software; you can redistribute it and/or modify +-- it under the terms of the GNU General Public License as published by +-- the Free Software Foundation; either version 2 of the License, or +-- (at your option) any later version. +-- +-- This program is distributed in the hope that it will be useful, +-- but WITHOUT ANY WARRANTY; without even the implied warranty of +-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +-- GNU General Public License for more details. +-- +-- You should have received a copy of the GNU General Public License +-- along with this program; if not, write to the Free Software +-- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +-- +-- ======================================================================== + +create table llx_c_barcode +( + rowid integer AUTO_INCREMENT PRIMARY KEY, + code varchar(16) NOT NULL, + libelle varchar(50) NOT NULL, + coder integer NOT NULL DEFAULT 0, + example varchar(16) NOT NULL +)type=innodb;