2005-07-15 16:17:33 +02:00
< ? php
/* Copyright ( C ) 2003 - 2004 Rodolphe Quiedeville < rodolphe @ quiedeville . org >
2008-01-03 19:41:32 +01:00
* Copyright ( C ) 2004 - 2008 Laurent Destailleur < eldy @ users . sourceforge . net >
2008-01-04 01:04:33 +01:00
* Copyright ( C ) 2005 - 2008 Regis Houssin < regis @ dolibarr . fr >
2005-07-15 16:17:33 +02:00
*
* 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 .
*/
2008-08-28 02:31:27 +02:00
/**
\file htdocs / admin / barcode . php
\ingroup barcode
\brief Page d ' administration / configuration du module Code barre
\version $Id $
*/
2005-07-15 16:17:33 +02:00
require ( " ./pre.inc.php " );
2008-02-01 01:09:23 +01:00
require_once ( DOL_DOCUMENT_ROOT . " /lib/admin.lib.php " );
2008-01-03 20:02:40 +01:00
require_once ( DOL_DOCUMENT_ROOT . " /includes/barcode/html.formbarcode.class.php " );
2005-07-15 16:17:33 +02:00
2008-01-03 19:41:32 +01:00
$dir = DOL_DOCUMENT_ROOT . " /includes/modules/barcode/ " ;
2005-07-15 16:17:33 +02:00
$langs -> load ( " admin " );
if ( ! $user -> admin )
2008-08-28 02:31:27 +02:00
accessforbidden ();
2005-07-15 16:17:33 +02:00
2007-09-29 22:15:02 +02:00
if ( $_POST [ " action " ] == 'setcoder' )
2005-07-15 16:17:33 +02:00
{
2007-09-29 13:35:43 +02:00
$sqlp = " UPDATE " . MAIN_DB_PREFIX . " c_barcode_type " ;
2008-01-03 19:41:32 +01:00
$sqlp .= " SET coder = ' " . $_POST [ " coder " ] . " ' " ;
$sqlp .= " WHERE rowid = " . $_POST [ " code_id " ];
$resql = $db -> query ( $sqlp );
//print $sqlp;
2005-07-15 18:35:08 +02:00
}
2007-09-29 22:15:02 +02:00
else if ( $_POST [ " action " ] == 'setgenbarcodelocation' )
{
dolibarr_set_const ( $db , " GENBARCODE_LOCATION " , $_POST [ " genbarcodelocation " ]);
}
2008-08-28 02:31:27 +02:00
else if ( $_POST [ " action " ] == 'setdefaultbarcodetype' )
{
dolibarr_set_const ( $db , " PRODUIT_DEFAULT_BARCODE_TYPE " , $_POST [ " coder_id " ]);
}
else if ( $_POST [ " action " ] == 'GENBARCODE_BARCODETYPE_THIRDPARTY' )
2007-09-29 22:15:02 +02:00
{
2008-08-28 02:31:27 +02:00
dolibarr_set_const ( $db , " GENBARCODE_BARCODETYPE_THIRDPARTY " , $_POST [ " coder_id " ]);
2007-09-29 22:15:02 +02:00
}
2008-08-28 02:31:27 +02:00
/*
else if ( $_POST [ " action " ] == 'setproductusebarcode' )
{
dolibarr_set_const ( $db , " PRODUIT_USE_BARCODE " , $_POST [ " value " ]);
Header ( " Location: barcode.php " );
exit ;
}
*/
2008-01-03 19:41:32 +01:00
2007-09-28 20:15:19 +02:00
$html = new Form ( $db );
2008-01-03 20:02:40 +01:00
$formbarcode = new FormBarCode ( $db );
2007-09-28 20:15:19 +02:00
2005-07-15 16:17:33 +02:00
llxHeader ( '' , $langs -> trans ( " BarcodeSetup " ), 'BarcodeConfiguration' );
2008-01-26 16:10:18 +01:00
$linkback = '<a href="' . DOL_URL_ROOT . '/admin/modules.php">' . $langs -> trans ( " BackToModuleList " ) . '</a>' ;
print_fiche_titre ( $langs -> trans ( " BarcodeSetup " ), $linkback , 'setup' );
2005-07-15 16:17:33 +02:00
2008-01-03 19:41:32 +01:00
// Detect bar codes modules
$barcodelist = array ();
clearstatcache ();
$handle = opendir ( $dir );
$var = true ;
while (( $file = readdir ( $handle )) !== false )
{
2008-01-04 00:50:01 +01:00
if ( substr ( $file , 0 , 1 ) <> '.' && substr ( $file , 0 , 3 ) <> 'CVS' )
2008-08-28 02:31:27 +02:00
{
2008-01-03 19:41:32 +01:00
if ( is_readable ( $dir . $file ))
{
if ( eregi ( '(.*)\.modules\.php' , $file , $reg ))
{
2008-01-04 00:50:01 +01:00
$filebis = $reg [ 1 ];
2008-08-28 02:31:27 +02:00
2008-01-03 19:41:32 +01:00
// Chargement de la classe de codage
2008-08-28 02:31:27 +02:00
require_once ( $dir . $file );
$classname = " mod " . ucfirst ( $filebis );
$module = new $classname ( $db );
2008-01-03 19:41:32 +01:00
// Show modules according to features level
2008-08-28 02:31:27 +02:00
if ( $module -> version == 'development' && $conf -> global -> MAIN_FEATURES_LEVEL < 2 ) continue ;
if ( $module -> version == 'experimental' && $conf -> global -> MAIN_FEATURES_LEVEL < 1 ) continue ;
2008-01-03 19:41:32 +01:00
$barcodelist [ $filebis ] = $module -> info ();
}
}
}
}
2005-07-15 16:17:33 +02:00
/*
* CHOIX ENCODAGE
*/
2007-09-28 20:15:19 +02:00
2005-07-15 16:17:33 +02:00
print '<br>' ;
print_titre ( $langs -> trans ( " BarcodeEncodeModule " ));
print '<table class="noborder" width="100%">' ;
print '<tr class="liste_titre">' ;
2005-07-15 18:35:08 +02:00
print '<td>' . $langs -> trans ( " Name " ) . '</td>' ;
print '<td>' . $langs -> trans ( " Description " ) . '</td>' ;
2007-10-03 23:02:04 +02:00
print '<td width="200" align="center">' . $langs -> trans ( " Example " ) . '</td>' ;
print '<td align="center" width="60">' . $langs -> trans ( " CodeBarGenerator " ) . '</td>' ;
2005-07-15 16:17:33 +02:00
print " </tr> \n " ;
2008-01-03 19:41:32 +01:00
$sql = " SELECT rowid, code as encoding, libelle, coder, example " ;
2007-09-29 12:57:20 +02:00
$sql .= " FROM " . MAIN_DB_PREFIX . " c_barcode_type " ;
2007-09-28 20:15:19 +02:00
$resql = $db -> query ( $sql );
if ( $resql )
{
$num = $db -> num_rows ( $resql );
$i = 0 ;
$var = true ;
2008-08-28 02:31:27 +02:00
2007-09-28 20:15:19 +02:00
while ( $i < $num )
{
$obj = $db -> fetch_object ( $resql );
2007-10-03 23:02:04 +02:00
print '<tr ' . $bc [ $var ] . '><td width="100">' ;
print $obj -> libelle ;
print " </td><td> \n " ;
2008-08-28 02:31:27 +02:00
print $langs -> trans ( 'BarcodeDesc' . $obj -> encoding );
2008-01-27 18:12:56 +01:00
//print "L'EAN se compose de 8 caract<63> res, 7 chiffres plus une cl<63> de contr<74> le.<br>";
//print "L'utilisation des symbologies EAN8 impose la souscription et l'abonnement aupr<70> s d'organisme tel que GENCOD.<br>";
//print "Codes num<75> riques utilis<69> s exclusivement <20> l'identification des produits susceptibles d'<27> tre vendus au grand public.";
2007-10-03 23:02:04 +02:00
print '</td>' ;
// Affiche exemple
print '<td align="center">' ;
if ( $obj -> coder )
{
2008-01-03 19:41:32 +01:00
// Chargement de la classe de codage
require_once ( $dir . $obj -> coder . " .modules.php " );
$classname = " mod " . ucfirst ( $obj -> coder );
$module = new $classname ( $db );
if ( $module -> encodingIsSupported ( $obj -> encoding ))
{
$url = DOL_URL_ROOT . '/viewimage.php?modulepart=barcode&generator=' . urlencode ( $obj -> coder ) . '&code=' . urlencode ( $obj -> example ) . '&encoding=' . urlencode ( $obj -> encoding );
//print $url;
2008-08-28 02:31:27 +02:00
print '<img src="' . $url . '" title="' . $obj -> example . '" border="0">' ;
2008-01-03 19:41:32 +01:00
}
else
{
print $langs -> trans ( " FormatNotSupportedByGenerator " );
}
2007-10-03 23:02:04 +02:00
}
else
{
print $langs -> trans ( " ChooseABarCode " );
}
print '</td>' ;
print '<td align="center">' ;
2008-01-03 20:02:40 +01:00
print $formbarcode -> setBarcodeEncoder ( $obj -> coder , $barcodelist , $obj -> rowid , 'form' . $i );
2007-10-03 23:02:04 +02:00
print " </td></tr> \n " ;
$var =! $var ;
$i ++ ;
2007-09-28 20:15:19 +02:00
}
}
2007-09-29 22:15:02 +02:00
print " </table> \n " ;
print " <br> " ;
/*
* Autres options
*
*/
print_titre ( $langs -> trans ( " OtherOptions " ));
$var = true ;
print '<table class="noborder" width="100%">' ;
print '<tr class="liste_titre">' ;
print '<td>' . $langs -> trans ( " Parameter " ) . '</td>' ;
print '<td width="60" align="center">' . $langs -> trans ( " Value " ) . '</td>' ;
print '<td> </td>' ;
print '</tr>' ;
// Chemin du binaire genbarcode sous linux
if ( ! isset ( $_ENV [ 'windir' ]) && ! file_exists ( $_ENV [ 'windir' ]))
{
$var =! $var ;
print '<form method="post" action="' . $_SERVER [ " PHP_SELF " ] . '">' ;
print '<input type="hidden" name="action" value="setgenbarcodelocation">' ;
print '<tr ' . $bc [ $var ] . '>' ;
print '<td>' . $langs -> trans ( " GenbarcodeLocation " ) . '</td>' ;
print '<td width="60" align="center">' ;
2007-09-29 22:21:29 +02:00
print '<input type="text" size="40" name="genbarcodelocation" value="' . $conf -> global -> GENBARCODE_LOCATION . '">' ;
2008-01-27 18:12:56 +01:00
if ( ! empty ( $conf -> global -> GENBARCODE_LOCATION ) && ! file_exists ( $conf -> global -> GENBARCODE_LOCATION ))
{
$langs -> load ( " errors " );
print '<br><font class="error">' . $langs -> trans ( " ErrorGenbarCodeNotfound " ) . '</font>' ;
}
2007-09-29 22:15:02 +02:00
print '</td>' ;
print '<td width="60" align="center"><input type="submit" class="button" value="' . $langs -> trans ( " Modify " ) . '"></td>' ;
print '</tr>' ;
print '</form>' ;
}
// Module produits
2008-08-28 02:31:27 +02:00
if ( $conf -> societe -> enabled )
{
$var =! $var ;
print " <form method= \" post \" action= \" " . $_SERVER [ " PHP_SELF " ] . " \" > " ;
print " <input type= \" hidden \" name= \" action \" value= \" setdefaultbarcodetype \" > " ;
print " <tr " . $bc [ $var ] . " > " ;
print '<td>' . $langs -> trans ( " SetDefaultBarcodeTypeProducts " ) . '</td>' ;
print '<td width="60" align="right">' ;
print $formbarcode -> select_barcode_type ( $conf -> global -> PRODUIT_DEFAULT_BARCODE_TYPE , " coder_id " , 1 );
print '</td><td align="right">' ;
print '<input type="submit" class="button" value="' . $langs -> trans ( " Modify " ) . '">' ;
print " </td> " ;
print '</tr>' ;
print '</form>' ;
}
// Module produits
2007-09-29 22:15:02 +02:00
if ( $conf -> produit -> enabled )
{
$var =! $var ;
2008-08-28 02:31:27 +02:00
print " <form method= \" post \" action= \" " . $_SERVER [ " PHP_SELF " ] . " \" > " ;
print " <input type= \" hidden \" name= \" action \" value= \" GENBARCODE_BARCODETYPE_THIRDPARTY \" > " ;
print " <tr " . $bc [ $var ] . " > " ;
print '<td>' . $langs -> trans ( " SetDefaultBarcodeTypeThirdParties " ) . '</td>' ;
2007-09-29 22:22:54 +02:00
print '<td width="60" align="right">' ;
2008-08-28 02:31:27 +02:00
print $formbarcode -> select_barcode_type ( $conf -> global -> GENBARCODE_BARCODETYPE_THIRDPARTY , " coder_id " , 1 );
print '</td><td align="right">' ;
print '<input type="submit" class="button" value="' . $langs -> trans ( " Modify " ) . '">' ;
print " </td> " ;
2007-09-29 22:15:02 +02:00
print '</tr>' ;
print '</form>' ;
}
print '</table>' ;
2008-08-28 02:07:52 +02:00
2007-09-28 20:15:19 +02:00
/*
2008-08-28 02:31:27 +02:00
//EAN13
$var =! $var ;
print '<tr ' . $bc [ $var ] . '><td width="100">' ;
print " EAN13 " ;
print " </td><td> \n " ;
print " L'EAN se compose de 13 caract<63> res, 12 chiffres plus une cl<63> de contr<74> le. Il fonctionne de la m<> me mani<6E> re que l'UPC, avec lequel il est compatible.<br> " ;
print " L'utilisation des symbologies EAN13 impose la souscription et l'abonnement aupr<70> s d'organisme tel que GENCOD.<br> " ;
print " Codes num<75> riques utilis<69> s exclusivement <20> l'identification des produits susceptibles d'<27> tre vendus au grand public. " ;
print '</td>' ;
// Affiche exemple
print '<td align="center"><img src="' . dol_genbarcode ( '123456789012' , 'EAN' , 1 ) . '"></td>' ;
print '<td align="center">' ;
print $formbarcode -> setBarcodeEncoder ( 'EAN13' , 'form' . $i );
print " </td></tr> \n " ;
$i ++ ;
//UPC
$var =! $var ;
print '<tr ' . $bc [ $var ] . '><td width="100">' ;
print " UPC " ;
print " </td><td> \n " ;
print " L'UPC est l'<27> quivalent de l'EAN8/13 pour des pays codificateurs autre que l'Europe.<br> " ;
print " Il ne comporte que 11 chiffres plus la cl<63> .<br> " ;
print " C'est en r<> alit<69> un code EAN13 dont le premier chiffre serait z<> ro et dont la pr<70> sentation serait l<> g<EFBFBD> rement diff<66> rente.<br> " ;
print " Codes num<75> riques utilis<69> s exclusivement <20> l'identification des produits susceptibles d'<27> tre vendus au grand public. " ;
print '</td>' ;
// Affiche exemple
print '<td align="center"><img src="' . dol_genbarcode ( '123456789012' , 'UPC' , 1 ) . '"></td>' ;
print '<td align="center">' ;
print $formbarcode -> setBarcodeEncoder ( 'UPC' , 'form' . $i );
print " </td></tr> \n " ;
$i ++ ;
//ISBN
$var =! $var ;
print '<tr ' . $bc [ $var ] . '><td width="100">' ;
print " ISBN " ;
print " </td><td> \n " ;
print " Le code ISBN est un code d<> di<64> au milieu de la presse <20> crite. " ;
print '</td>' ;
// Affiche exemple
print '<td align="center"><img src="' . dol_genbarcode ( '123456789' , 'ISBN' , 1 ) . '"></td>' ;
print '<td align="center">' ;
print $formbarcode -> setBarcodeEncoder ( 'ISBN' , 'form' . $i );
print " </td></tr> \n " ;
$i ++ ;
//code 39
$var =! $var ;
print '<tr ' . $bc [ $var ] . '><td width="100">' ;
print " Code 39 " ;
print " </td><td> \n " ;
print " Premier code alpha num<75> rique utilis<69> massivement dans l'Industrie pour sa capacit<69> d'encodage (chiffres et lettres)<br> " ;
print " ainsi que par son degr<67> de s<> curit<69> <20> l'encodage (clef de contr<74> le).<br> " ;
print " Il met a disposition les 10 chiffres, les 26 lettres de l'alphabet et sept symboles.<br> " ;
print " l'ast<73> risque (*) sert de caract<63> re de bornage. La lecture est bidirectionnelle.<br> " ;
print " La longueur est variable mais en g<> n<EFBFBD> ral ne d<> passe pas 32 caract<63> res. " ;
print '</td>' ;
// Affiche exemple
print '<td align="center"><img src="' . dol_genbarcode ( '1234567890' , '39' , 1 ) . '"></td>' ;
print '<td align="center">' ;
print $formbarcode -> setBarcodeEncoder ( 'C39' , 'form' . $i );
print " </td></tr> \n " ;
$i ++ ;
//code 128
$var =! $var ;
print '<tr ' . $bc [ $var ] . '><td width="100">' ;
print " Code 128 " ;
print " </td><td> \n " ;
print " Ce code \" derni<EFBFBD> re g<> n<EFBFBD> ration \" alpha num<75> rique est susceptible d'encoder les 128 caract<63> res de la table ASCII ( chiffres + lettres + symboles ).<br> " ;
print " Le code 128 poss<73> de des algorithmes de cryptage s<> curis<69> s assez avanc<6E> s.<br> " ;
print " C'est le plus complet des codes <20> barres, il propose 3 jeux de 128 caract<63> res.<br> " ;
print " La lecture est bidirectionnelle.<br> " ;
print " La longueur est variable mais en g<> n<EFBFBD> ral ne d<> passe pas 20 caract<63> res. " ;
print '</td>' ;
// Affiche exemple
print '<td align="center"><img src="' . dol_genbarcode ( 'ABCD1234567890' , '128' , 1 ) . '"></td>' ;
print '<td align="center">' ;
print $formbarcode -> setBarcodeEncoder ( 'C128' , 'form' . $i );
print " </td></tr> \n " ;
$i ++ ;
//I25
$var =! $var ;
print '<tr ' . $bc [ $var ] . '><td width="100">' ;
print " I25 " ;
print " </td><td> \n " ;
print " information " ;
print '</td>' ;
// Affiche exemple
print '<td align="center"><img src="' . dol_genbarcode ( '1234567890' , 'I25' , 1 ) . '"></td>' ;
print '<td align="center">' ;
print $formbarcode -> setBarcodeEncoder ( 'I25' , 'form' . $i );
print " </td></tr> \n " ;
$i ++ ;
*/
2005-07-15 16:17:33 +02:00
print " <br> " ;
$db -> close ();
llxFooter ( '$Date$ - $Revision$' );
2007-09-28 20:15:19 +02:00
?>