diff --git a/htdocs/admin/barcode.php b/htdocs/admin/barcode.php index d99458c9da5c465f70d0d285a62fc8805581f74a..58e6642bfa451b3318f543295a2d9e69968e1785 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 '<br>'; print_titre($langs->trans("BarcodeEncodeModule")); print '<table class="noborder" width="100%">'; - print '<tr class="liste_titre">'; - print '<td>'.$langs->trans("Name").'</td>'; print '<td>'.$langs->trans("Description").'</td>'; -print '<td>'.$langs->trans("Example").'</td>'; +print '<td width="200">'.$langs->trans("Example").'</td>'; print '<td align="center" width="60">'.$langs->trans("Default").'</td>'; print "</tr>\n"; -clearstatcache(); -$var=true; - -//EAN8 - $var=!$var; - print '<tr '.$bc[$var].'><td width="100">'; - print "EAN8"; - print "</td><td>\n"; - - print "L'EAN se compose de 8 caract�res, 7 chiffres plus une cl� de contr�le.<br>"; - print "L'utilisation des symbologies EAN8 impose la souscription et l'abonnement aupr�s d'organisme tel que GENCOD.<br>"; - print "Codes num�riques utilis�s exclusivement � l'identification des produits susceptibles d'�tre vendus au grand public."; - print '</td>'; - - // Affiche exemple - print '<td align="center"><img src="'.dol_genbarcode('1234567','EAN',2).'"></td>'; - - print '<td align="center">'; - if ($barcode_encode_type_set == "EAN8") - { - print img_tick(); - } - else - { - print '<a href="barcode.php?action=settype&value=EAN8">'.$langs->trans("Default").'</a>'; - } - print "</td></tr>\n"; - +$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); + + print '<tr '.$bc[$var].'><td width="100">'; + print $obj->libelle; + print "</td><td>\n"; + print $langs->trans('BarcodeDesc'.$obj->code); + //print "L'EAN se compose de 8 caract�res, 7 chiffres plus une cl� de contr�le.<br>"; + //print "L'utilisation des symbologies EAN8 impose la souscription et l'abonnement aupr�s d'organisme tel que GENCOD.<br>"; + //print "Codes num�riques utilis�s exclusivement � l'identification des produits susceptibles d'�tre vendus au grand public."; + print '</td>'; + + // Affiche exemple + print '<td align="center"><img src="'.dol_genbarcode($obj->example,$obj->code,$obj->coder).'"></td>'; + + print '<td align="center">'; + print $html->setBarcodeEncoder($obj->coder,$obj->rowid,'form'.$i); + print "</td></tr>\n"; + $var=!$var; + $i++; + } +} +/* //EAN13 $var=!$var; print '<tr '.$bc[$var].'><td width="100">'; @@ -110,15 +112,9 @@ $var=true; print '<td align="center"><img src="'.dol_genbarcode('123456789012','EAN',1).'"></td>'; print '<td align="center">'; - if ($barcode_encode_type_set == "EAN13") - { - print img_tick(); - } - else - { - print '<a href="barcode.php?action=settype&value=EAN13">'.$langs->trans("Default").'</a>'; - } + print $html->setBarcodeEncoder('EAN13','form'.$i); print "</td></tr>\n"; + $i++; //UPC $var=!$var; @@ -135,15 +131,9 @@ $var=true; print '<td align="center"><img src="'.dol_genbarcode('123456789012','UPC',1).'"></td>'; print '<td align="center">'; - if ($barcode_encode_type_set == "UPC") - { - print img_tick(); - } - else - { - print '<a href="barcode.php?action=settype&value=UPC">'.$langs->trans("Default").'</a>'; - } + print $html->setBarcodeEncoder('UPC','form'.$i); print "</td></tr>\n"; + $i++; //ISBN $var=!$var; @@ -157,15 +147,9 @@ $var=true; print '<td align="center"><img src="'.dol_genbarcode('123456789','ISBN',1).'"></td>'; print '<td align="center">'; - if ($barcode_encode_type_set == "ISBN") - { - print img_tick(); - } - else - { - print '<a href="barcode.php?action=settype&value=ISBN">'.$langs->trans("Default").'</a>'; - } + print $html->setBarcodeEncoder('ISBN','form'.$i); print "</td></tr>\n"; + $i++; //code 39 $var=!$var; @@ -183,15 +167,9 @@ $var=true; print '<td align="center"><img src="'.dol_genbarcode('1234567890','39',1).'"></td>'; print '<td align="center">'; - if ($barcode_encode_type_set == "code39") - { - print img_tick(); - } - else - { - print '<a href="barcode.php?action=settype&value=code39">'.$langs->trans("Default").'</a>'; - } + print $html->setBarcodeEncoder('C39','form'.$i); print "</td></tr>\n"; + $i++; //code 128 @@ -210,15 +188,9 @@ $var=true; print '<td align="center"><img src="'.dol_genbarcode('ABCD1234567890','128',1).'"></td>'; print '<td align="center">'; - if ($barcode_encode_type_set == "code128") - { - print img_tick(); - } - else - { - print '<a href="barcode.php?action=settype&value=code128">'.$langs->trans("Default").'</a>'; - } + print $html->setBarcodeEncoder('C128','form'.$i); print "</td></tr>\n"; + $i++; //I25 $var=!$var; @@ -232,16 +204,10 @@ $var=true; print '<td align="center"><img src="'.dol_genbarcode('1234567890','I25',1).'"></td>'; print '<td align="center">'; - if ($barcode_encode_type_set == "I25") - { - print img_tick(); - } - else - { - print '<a href="barcode.php?action=settype&value=I25">'.$langs->trans("Default").'</a>'; - } + print $html->setBarcodeEncoder('I25','form'.$i); print "</td></tr>\n"; - + $i++; +*/ print "</table>\n"; print "<br>"; @@ -249,4 +215,4 @@ print "<br>"; $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 dff1e19593d21ad75273a205d81d6e056ed90d7b..6be9aa897b02c407016f49b0a84838169bb984fb 100644 --- a/htdocs/html.form.class.php +++ b/htdocs/html.form.class.php @@ -3505,7 +3505,25 @@ class Form $ret.='</td></tr></table>'; } return $ret; - } + } + + /** + * + */ + function setBarcodeEncoder($selected=0,$code_id,$formName='formbarcode') + { + global $langs; + + $select_encoder = '<form action="barcode.php" method="post" id="'.$formName.'">'; + $select_encoder.= '<input type="hidden" name="action" value="update">'; + $select_encoder.= '<input type="hidden" name="code_id" value="'.$code_id.'">'; + $select_encoder.= '<select class="flat" name="coder" onChange="barcode_coder_save(\''.$formName.'\')">'; + $select_encoder.= '<option value="0"'.($selected==0?' selected="true"':'').'>'.$langs->trans('Disable').'</option>'; + $select_encoder.= '<option value="1"'.($selected==1?' selected="true"':'').'>php-barcode</option>'; + $select_encoder.= '<option value="2"'.($selected==2?' selected="true"':'').'>pi_barcode</option>'; + $select_encoder.= '</select></form>'; + return $select_encoder; + } } ?> diff --git a/htdocs/lib/functions.inc.php b/htdocs/lib/functions.inc.php index fd299607d85d01b0ee4b394e0a62264222d6c000..c5106067fc39e6ae1273428b564107d28823471c 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 99d62e82fa8193a8810f82a7b085bdf1ff7758b7..7314d41179fea9cc20cd69f3a9ee68ac7a248dde 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 0722b9c7e7e0109bc125e6494d4bd8b41dfb9445..8ddfee04ed76b49ed217415f9cc656cf3d669e77 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 28f3f142dc9b5e1a0df19e461d983078682277e1..40f78be1e50b6a3f7d7632dd0acbc0b30f06224d 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 0000000000000000000000000000000000000000..f7fbfafeabb31db15bd0b373534e76ab355382a8 --- /dev/null +++ b/mysql/tables/llx_c_barcode.sql @@ -0,0 +1,30 @@ +-- ======================================================================== +-- Copyright (C) 2007 Regis Houssin <regis.houssin@cap-networks.com> +-- +-- $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;