2013-12-15 03:23:10 +01:00
< ? php
2015-05-03 11:51:54 +02:00
/* Copyright ( C ) 2003 Rodolphe Quiedeville < rodolphe @ quiedeville . org >
* Copyright ( C ) 2003 Jean - Louis Bergamo < jlb @ j1b . org >
2017-06-09 01:06:52 +02:00
* Copyright ( C ) 2006 - 2017 Laurent Destailleur < eldy @ users . sourceforge . net >
2013-12-15 03:23:10 +01: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 3 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
2015-05-03 11:51:54 +02:00
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
2013-12-15 03:23:10 +01:00
* GNU General Public License for more details .
*
* You should have received a copy of the GNU General Public License
2019-09-23 21:55:30 +02:00
* along with this program . If not , see < https :// www . gnu . org / licenses />.
2013-12-15 03:23:10 +01:00
*/
/**
2015-05-03 11:51:54 +02:00
* \file htdocs / barcode / printsheet . php
* \ingroup member
* \brief Page to print sheets with barcodes using the document templates into core / modules / printsheets
2013-12-15 03:23:10 +01:00
*/
2021-02-02 01:30:23 +01:00
2022-02-22 23:44:56 +01:00
if ( ! empty ( $_POST [ 'mode' ]) && $_POST [ 'mode' ] === 'label' ) { // Page is called to build a PDF and output, we must not renew the token.
2021-02-22 19:05:32 +01:00
if ( ! defined ( 'NOTOKENRENEWAL' )) {
2021-10-25 22:07:31 +02:00
define ( 'NOTOKENRENEWAL' , '1' ); // Do not roll the Anti CSRF token (used if MAIN_SECURITY_CSRF_WITH_TOKEN is on)
2021-02-22 19:05:32 +01:00
}
2021-02-02 01:30:23 +01:00
}
2013-12-15 03:23:10 +01:00
require '../main.inc.php' ;
require_once DOL_DOCUMENT_ROOT . '/core/lib/format_cards.lib.php' ;
require_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php' ;
require_once DOL_DOCUMENT_ROOT . '/core/modules/printsheet/modules_labels.php' ;
2014-01-08 00:05:42 +01:00
require_once DOL_DOCUMENT_ROOT . '/core/class/genericobject.class.php' ;
2013-12-15 03:23:10 +01:00
2018-05-27 09:58:23 +02:00
// Load translation files required by the page
$langs -> loadLangs ( array ( 'admin' , 'members' , 'errors' ));
2013-12-15 03:23:10 +01:00
2014-02-27 09:42:00 +01:00
// Choice of print year or current year.
2013-12-15 03:23:10 +01:00
$now = dol_now ();
2019-11-14 12:09:15 +01:00
$year = dol_print_date ( $now , '%Y' );
$month = dol_print_date ( $now , '%m' );
$day = dol_print_date ( $now , '%d' );
2020-09-17 22:26:54 +02:00
$forbarcode = GETPOST ( 'forbarcode' , 'alphanohtml' );
$fk_barcode_type = GETPOST ( 'fk_barcode_type' , 'int' );
$mode = GETPOST ( 'mode' , 'aZ09' );
$modellabel = GETPOST ( " modellabel " , 'aZ09' ); // Doc template to use
2019-11-14 12:09:15 +01:00
$numberofsticker = GETPOST ( 'numberofsticker' , 'int' );
2014-01-08 00:05:42 +01:00
2019-11-14 12:09:15 +01:00
$mesg = '' ;
2013-12-15 03:23:10 +01:00
2019-11-14 12:09:15 +01:00
$action = GETPOST ( 'action' , 'aZ09' );
2014-01-08 00:05:42 +01:00
2019-11-14 12:09:15 +01:00
$producttmp = new Product ( $db );
$thirdpartytmp = new Societe ( $db );
2014-01-20 17:18:56 +01:00
2013-12-15 03:23:10 +01:00
/*
* Actions
*/
2021-02-22 19:05:32 +01:00
if ( GETPOST ( 'submitproduct' ) && GETPOST ( 'submitproduct' )) {
2019-11-14 12:09:15 +01:00
$action = '' ; // We reset because we don't want to build doc
2020-09-17 22:26:54 +02:00
if ( GETPOST ( 'productid' , 'int' ) > 0 ) {
$result = $producttmp -> fetch ( GETPOST ( 'productid' , 'int' ));
2020-07-31 16:09:38 +02:00
if ( $result < 0 ) {
setEventMessage ( $producttmp -> error , 'errors' );
}
2019-11-14 12:09:15 +01:00
$forbarcode = $producttmp -> barcode ;
$fk_barcode_type = $producttmp -> barcode_type ;
2014-02-19 17:04:21 +01:00
2021-02-22 19:05:32 +01:00
if ( empty ( $fk_barcode_type ) && ! empty ( $conf -> global -> PRODUIT_DEFAULT_BARCODE_TYPE )) {
$fk_barcode_type = $conf -> global -> PRODUIT_DEFAULT_BARCODE_TYPE ;
}
2014-02-19 17:04:21 +01:00
2021-02-22 19:05:32 +01:00
if ( empty ( $forbarcode ) || empty ( $fk_barcode_type )) {
2019-01-27 11:55:16 +01:00
setEventMessages ( $langs -> trans ( " DefinitionOfBarCodeForProductNotComplete " , $producttmp -> getNomUrl ()), null , 'warnings' );
2014-01-20 17:18:56 +01:00
}
}
}
2021-02-22 19:05:32 +01:00
if ( GETPOST ( 'submitthirdparty' ) && GETPOST ( 'submitthirdparty' )) {
2019-11-14 12:09:15 +01:00
$action = '' ; // We reset because we don't want to build doc
2021-02-22 19:05:32 +01:00
if ( GETPOST ( 'socid' , 'int' ) > 0 ) {
2020-09-17 22:26:54 +02:00
$thirdpartytmp -> fetch ( GETPOST ( 'socid' , 'int' ));
2019-11-14 12:09:15 +01:00
$forbarcode = $thirdpartytmp -> barcode ;
$fk_barcode_type = $thirdpartytmp -> barcode_type_code ;
2014-02-19 17:04:21 +01:00
2021-02-22 19:05:32 +01:00
if ( empty ( $fk_barcode_type ) && ! empty ( $conf -> global -> GENBARCODE_BARCODETYPE_THIRDPARTY )) {
$fk_barcode_type = $conf -> global -> GENBARCODE_BARCODETYPE_THIRDPARTY ;
}
2014-02-19 17:04:21 +01:00
2021-02-22 19:05:32 +01:00
if ( empty ( $forbarcode ) || empty ( $fk_barcode_type )) {
2019-01-27 11:55:16 +01:00
setEventMessages ( $langs -> trans ( " DefinitionOfBarCodeForThirdpartyNotComplete " , $thirdpartytmp -> getNomUrl ()), null , 'warnings' );
2014-01-20 17:18:56 +01:00
}
}
}
2021-02-22 19:05:32 +01:00
if ( $action == 'builddoc' ) {
2019-11-14 12:09:15 +01:00
$result = 0 ; $error = 0 ;
2013-12-15 03:23:10 +01:00
2021-02-22 19:05:32 +01:00
if ( empty ( $forbarcode )) { // barcode value
2015-10-17 16:18:33 +02:00
setEventMessages ( $langs -> trans ( " ErrorFieldRequired " , $langs -> transnoentitiesnoconv ( " BarcodeValue " )), null , 'errors' );
2015-05-03 11:51:54 +02:00
$error ++ ;
2014-01-08 00:05:42 +01:00
}
2021-02-22 19:05:32 +01:00
if ( empty ( $fk_barcode_type )) { // barcode type = barcode encoding
2015-10-17 16:18:33 +02:00
setEventMessages ( $langs -> trans ( " ErrorFieldRequired " , $langs -> transnoentitiesnoconv ( " BarcodeType " )), null , 'errors' );
2015-05-03 11:51:54 +02:00
$error ++ ;
2014-01-08 00:05:42 +01:00
}
2013-12-15 03:23:10 +01:00
2021-02-22 19:05:32 +01:00
if ( ! $error ) {
2014-01-08 00:05:42 +01:00
// Get encoder (barcode_type_coder) from barcode type id (barcode_type)
2019-11-14 12:09:15 +01:00
$stdobject = new GenericObject ( $db );
$stdobject -> barcode_type = $fk_barcode_type ;
$result = $stdobject -> fetch_barcode ();
2021-02-22 19:05:32 +01:00
if ( $result <= 0 ) {
2014-01-08 00:05:42 +01:00
$error ++ ;
2015-10-30 21:59:22 +01:00
setEventMessages ( 'Failed to get bar code type information ' . $stdobject -> error , $stdobject -> errors , 'errors' );
2013-12-15 03:23:10 +01:00
}
}
2021-02-22 19:05:32 +01:00
if ( ! $error ) {
2019-11-14 12:09:15 +01:00
$code = $forbarcode ;
$generator = $stdobject -> barcode_type_coder ; // coder (loaded by fetch_barcode). Engine.
$encoding = strtoupper ( $stdobject -> barcode_type_code ); // code (loaded by fetch_barcode). Example 'ean', 'isbn', ...
2013-12-15 03:23:10 +01:00
2019-11-14 12:09:15 +01:00
$diroutput = $conf -> barcode -> dir_temp ;
2014-01-08 00:05:42 +01:00
dol_mkdir ( $diroutput );
2013-12-15 03:23:10 +01:00
2014-01-08 00:05:42 +01:00
// Generate barcode
2019-11-14 12:09:15 +01:00
$dirbarcode = array_merge ( array ( " /core/modules/barcode/doc/ " ), $conf -> modules_parts [ 'barcode' ]);
2015-05-03 11:51:54 +02:00
2021-02-22 19:05:32 +01:00
foreach ( $dirbarcode as $reldir ) {
2019-11-14 12:09:15 +01:00
$dir = dol_buildpath ( $reldir , 0 );
$newdir = dol_osencode ( $dir );
2015-05-03 11:51:54 +02:00
// Check if directory exists (we do not use dol_is_dir to avoid loading files.lib.php)
2021-02-22 19:05:32 +01:00
if ( ! is_dir ( $newdir )) {
continue ;
}
2015-05-03 11:51:54 +02:00
2019-11-14 12:09:15 +01:00
$result = @ include_once $newdir . $generator . '.modules.php' ;
2021-02-22 19:05:32 +01:00
if ( $result ) {
break ;
}
2015-05-03 11:51:54 +02:00
}
2015-08-12 22:38:40 +02:00
2015-05-03 11:51:54 +02:00
// Load barcode class for generating barcode image
$classname = " mod " . ucfirst ( $generator );
$module = new $classname ( $db );
2021-02-22 19:05:32 +01:00
if ( $generator != 'tcpdfbarcode' ) {
2020-10-31 14:32:18 +01:00
// May be phpbarcode
2015-05-03 11:51:54 +02:00
$template = 'standardlabel' ;
$is2d = false ;
2021-02-22 19:05:32 +01:00
if ( $module -> encodingIsSupported ( $encoding )) {
2019-11-14 12:09:15 +01:00
$barcodeimage = $conf -> barcode -> dir_temp . '/barcode_' . $code . '_' . $encoding . '.png' ;
2015-05-03 11:51:54 +02:00
dol_delete_file ( $barcodeimage );
// File is created with full name $barcodeimage = $conf->barcode->dir_temp.'/barcode_'.$code.'_'.$encoding.'.png';
2019-11-14 12:09:15 +01:00
$result = $module -> writeBarCode ( $code , $encoding , 'Y' , 4 , 1 );
2021-02-22 19:05:32 +01:00
if ( $result <= 0 || ! dol_is_file ( $barcodeimage )) {
2015-05-03 11:51:54 +02:00
$error ++ ;
2015-10-30 21:59:22 +01:00
setEventMessages ( 'Failed to generate image file of barcode for code=' . $code . ' encoding=' . $encoding . ' file=' . basename ( $barcodeimage ), null , 'errors' );
2016-02-08 16:42:34 +01:00
setEventMessages ( $module -> error , null , 'errors' );
2015-05-03 11:51:54 +02:00
}
2020-05-21 15:05:19 +02:00
} else {
2015-05-03 11:51:54 +02:00
$error ++ ;
2015-10-30 21:59:22 +01:00
setEventMessages ( " Error, encoding " . $encoding . " is not supported by encoder " . $generator . '. You must choose another barcode type or install a barcode generation engine that support ' . $encoding , null , 'errors' );
2015-05-03 11:51:54 +02:00
}
} else {
$template = 'tcpdflabel' ;
$encoding = $module -> getTcpdfEncodingType ( $encoding ); //convert to TCPDF compatible encoding types
$is2d = $module -> is2d ;
}
2014-01-08 00:05:42 +01:00
}
2021-02-22 19:05:32 +01:00
if ( ! $error ) {
2014-01-08 00:05:42 +01:00
// List of values to scan for a replacement
2019-11-14 12:09:15 +01:00
$substitutionarray = array (
2020-10-31 14:32:18 +01:00
'%LOGIN%' => $user -> login ,
'%COMPANY%' => $mysoc -> name ,
'%ADDRESS%' => $mysoc -> address ,
'%ZIP%' => $mysoc -> zip ,
'%TOWN%' => $mysoc -> town ,
'%COUNTRY%' => $mysoc -> country ,
'%COUNTRY_CODE%' => $mysoc -> country_code ,
'%EMAIL%' => $mysoc -> email ,
'%YEAR%' => $year ,
'%MONTH%' => $month ,
'%DAY%' => $day ,
'%DOL_MAIN_URL_ROOT%' => DOL_MAIN_URL_ROOT ,
'%SERVER%' => " http:// " . $_SERVER [ " SERVER_NAME " ] . " / " ,
2014-01-08 00:05:42 +01:00
);
complete_substitutions_array ( $substitutionarray , $langs );
// For labels
2021-02-22 19:05:32 +01:00
if ( $mode == 'label' ) {
2019-11-14 12:09:15 +01:00
$txtforsticker = " %PHOTO% " ; // Photo will be barcode image, %BARCODE% posible when using TCPDF generator
$textleft = make_substitutions (( empty ( $conf -> global -> BARCODE_LABEL_LEFT_TEXT ) ? $txtforsticker : $conf -> global -> BARCODE_LABEL_LEFT_TEXT ), $substitutionarray );
$textheader = make_substitutions (( empty ( $conf -> global -> BARCODE_LABEL_HEADER_TEXT ) ? '' : $conf -> global -> BARCODE_LABEL_HEADER_TEXT ), $substitutionarray );
$textfooter = make_substitutions (( empty ( $conf -> global -> BARCODE_LABEL_FOOTER_TEXT ) ? '' : $conf -> global -> BARCODE_LABEL_FOOTER_TEXT ), $substitutionarray );
$textright = make_substitutions (( empty ( $conf -> global -> BARCODE_LABEL_RIGHT_TEXT ) ? '' : $conf -> global -> BARCODE_LABEL_RIGHT_TEXT ), $substitutionarray );
$forceimgscalewidth = ( empty ( $conf -> global -> BARCODE_FORCEIMGSCALEWIDTH ) ? 1 : $conf -> global -> BARCODE_FORCEIMGSCALEWIDTH );
$forceimgscaleheight = ( empty ( $conf -> global -> BARCODE_FORCEIMGSCALEHEIGHT ) ? 1 : $conf -> global -> BARCODE_FORCEIMGSCALEHEIGHT );
2021-02-22 19:05:32 +01:00
for ( $i = 0 ; $i < $numberofsticker ; $i ++ ) {
2019-11-14 12:09:15 +01:00
$arrayofrecords [] = array (
2014-01-08 00:05:42 +01:00
'textleft' => $textleft ,
'textheader' => $textheader ,
'textfooter' => $textfooter ,
'textright' => $textright ,
2015-05-03 11:51:54 +02:00
'code' => $code ,
'encoding' => $encoding ,
'is2d' => $is2d ,
2014-01-08 00:05:42 +01:00
'photo' => $barcodeimage // Photo must be a file that exists with format supported by TCPDF
);
}
2013-12-15 03:23:10 +01:00
}
2014-01-08 00:05:42 +01:00
$i ++ ;
2019-11-14 12:09:15 +01:00
$mesg = '' ;
2014-01-08 00:05:42 +01:00
// Build and output PDF
2021-02-22 19:05:32 +01:00
if ( $mode == 'label' ) {
if ( ! count ( $arrayofrecords )) {
2019-11-14 12:09:15 +01:00
$mesg = $langs -> trans ( " ErrorRecordNotFound " );
2014-01-08 00:05:42 +01:00
}
2021-02-22 19:05:32 +01:00
if ( empty ( $modellabel ) || $modellabel == '-1' ) {
2019-11-14 12:09:15 +01:00
$mesg = $langs -> trans ( " ErrorFieldRequired " , $langs -> transnoentitiesnoconv ( " DescADHERENT_ETIQUETTE_TYPE " ));
2014-01-08 00:05:42 +01:00
}
2017-11-24 09:30:21 +01:00
2019-01-27 11:55:16 +01:00
$outfile = $langs -> trans ( " BarCode " ) . '_sheets_' . dol_print_date ( dol_now (), 'dayhourlog' ) . '.pdf' ;
2017-11-24 09:30:21 +01:00
2021-02-02 01:30:23 +01:00
if ( ! $mesg ) {
$outputlangs = $langs ;
2013-12-15 03:23:10 +01:00
2021-02-02 01:30:23 +01:00
// This generates and send PDF to output
// TODO Move
$result = doc_label_pdf_create ( $db , $arrayofrecords , $modellabel , $outputlangs , $diroutput , $template , dol_sanitizeFileName ( $outfile ));
}
2014-01-08 00:05:42 +01:00
}
2013-12-15 03:23:10 +01:00
2021-02-02 01:30:23 +01:00
if ( $result <= 0 || $mesg ) {
if ( empty ( $mesg )) {
$mesg = 'Error ' . $result ;
}
setEventMessages ( $mesg , null , 'errors' );
} else {
2015-05-03 11:51:54 +02:00
$db -> close ();
exit ;
}
2014-01-08 00:05:42 +01:00
}
2013-12-15 03:23:10 +01:00
}
/*
* View
*/
2021-02-22 19:05:32 +01:00
if ( empty ( $conf -> barcode -> enabled )) {
accessforbidden ();
}
2014-02-19 17:04:21 +01:00
2019-11-14 12:09:15 +01:00
$form = new Form ( $db );
2013-12-15 03:23:10 +01:00
2019-01-27 11:55:16 +01:00
llxHeader ( '' , $langs -> trans ( " BarCodePrintsheet " ));
2013-12-15 03:23:10 +01:00
2020-01-20 12:47:49 +01:00
print load_fiche_titre ( $langs -> trans ( " BarCodePrintsheet " ), '' , 'barcode' );
2013-12-15 03:23:10 +01:00
print '<br>' ;
2020-06-19 00:25:59 +02:00
print '<span class="opacitymedium">' . $langs -> trans ( " PageToGenerateBarCodeSheets " , $langs -> transnoentitiesnoconv ( " BuildPageToPrint " )) . '</span><br>' ;
2013-12-15 03:23:10 +01:00
print '<br>' ;
dol_htmloutput_errors ( $mesg );
2014-01-08 00:05:42 +01:00
//print img_picto('','puce').' '.$langs->trans("PrintsheetForOneBarCode").'<br>';
//print '<br>';
2021-10-25 22:07:31 +02:00
print '<form action="' . $_SERVER [ " PHP_SELF " ] . '" method="POST">' ; // The target is for brothers that open the file instead of downloading it
2013-12-15 03:23:10 +01:00
print '<input type="hidden" name="mode" value="label">' ;
print '<input type="hidden" name="action" value="builddoc">' ;
2021-10-25 22:07:31 +02:00
print '<input type="hidden" name="token" value="' . currentToken () . '">' ; // The page will not renew the token but force download of a file, so we must use here currentToken
2014-01-08 00:05:42 +01:00
print '<div class="tagtable">' ;
// Sheet format
print ' <div class="tagtr">' ;
2021-03-19 14:46:30 +01:00
print ' <div class="tagtd">' ;
2014-01-08 00:05:42 +01:00
print $langs -> trans ( " DescADHERENT_ETIQUETTE_TYPE " ) . ' ' ;
2014-04-22 00:04:31 +02:00
print '</div><div class="tagtd maxwidthonsmartphone" style="overflow: hidden; white-space: nowrap;">' ;
2016-02-08 16:42:34 +01:00
// List of possible labels (defined into $_Avery_Labels variable set into core/lib/format_cards.lib.php)
2019-11-14 12:09:15 +01:00
$arrayoflabels = array ();
2021-02-22 19:05:32 +01:00
foreach ( array_keys ( $_Avery_Labels ) as $codecards ) {
2020-10-31 14:32:18 +01:00
$labeltoshow = $_Avery_Labels [ $codecards ][ 'name' ];
//$labeltoshow.=' ('.$_Avery_Labels[$row['code']]['paper-size'].')';
2019-11-14 12:09:15 +01:00
$arrayoflabels [ $codecards ] = $labeltoshow ;
2013-12-15 03:23:10 +01:00
}
2017-11-24 09:23:18 +01:00
asort ( $arrayoflabels );
2019-11-14 12:09:15 +01:00
print $form -> selectarray ( 'modellabel' , $arrayoflabels , ( GETPOST ( 'modellabel' ) ? GETPOST ( 'modellabel' ) : $conf -> global -> ADHERENT_ETIQUETTE_TYPE ), 1 , 0 , 0 , '' , 0 , 0 , 0 , '' , '' , 1 );
2014-01-08 00:05:42 +01:00
print '</div></div>' ;
// Number of stickers to print
print ' <div class="tagtr">' ;
2021-03-19 14:46:30 +01:00
print ' <div class="tagtd">' ;
2014-01-08 00:05:42 +01:00
print $langs -> trans ( " NumberOfStickers " ) . ' ' ;
2014-04-22 00:04:31 +02:00
print '</div><div class="tagtd maxwidthonsmartphone" style="overflow: hidden; white-space: nowrap;">' ;
2019-11-14 12:09:15 +01:00
print '<input size="4" type="text" name="numberofsticker" value="' . ( GETPOST ( 'numberofsticker' ) ? GETPOST ( 'numberofsticker' , 'int' ) : 10 ) . '">' ;
2014-01-08 00:05:42 +01:00
print '</div></div>' ;
print '</div>' ;
2013-12-15 03:23:10 +01:00
2014-01-08 00:05:42 +01:00
print '<br>' ;
2014-01-20 17:18:56 +01:00
// Add javascript to make choice dynamic
2021-11-29 15:09:18 +01:00
print ' < script type = " text/javascript " >
2014-01-20 17:18:56 +01:00
jQuery ( document ) . ready ( function () {
function init_selectors ()
{
if ( jQuery ( " #fillmanually:checked " ) . val () == " fillmanually " )
{
2015-05-12 14:47:33 +02:00
jQuery ( " #submitproduct " ) . prop ( " disabled " , true );
jQuery ( " #submitthirdparty " ) . prop ( " disabled " , true );
jQuery ( " #search_productid " ) . prop ( " disabled " , true );
jQuery ( " #socid " ) . prop ( " disabled " , true );
2014-01-20 17:18:56 +01:00
jQuery ( " .showforproductselector " ) . hide ();
jQuery ( " .showforthirdpartyselector " ) . hide ();
}
if ( jQuery ( " #fillfromproduct:checked " ) . val () == " fillfromproduct " )
{
2015-05-12 14:47:33 +02:00
jQuery ( " #submitproduct " ) . removeAttr ( " disabled " );
jQuery ( " #submitthirdparty " ) . prop ( " disabled " , true );
jQuery ( " #search_productid " ) . removeAttr ( " disabled " );
jQuery ( " #socid " ) . prop ( " disabled " , true );
2014-01-20 17:18:56 +01:00
jQuery ( " .showforproductselector " ) . show ();
jQuery ( " .showforthirdpartyselector " ) . hide ();
}
if ( jQuery ( " #fillfromthirdparty:checked " ) . val () == " fillfromthirdparty " )
{
2015-05-12 14:47:33 +02:00
jQuery ( " #submitproduct " ) . prop ( " disabled " , true );
jQuery ( " #submitthirdparty " ) . removeAttr ( " disabled " );
jQuery ( " #search_productid " ) . prop ( " disabled " , true );
jQuery ( " #socid " ) . removeAttr ( " disabled " );
2014-01-20 17:18:56 +01:00
jQuery ( " .showforproductselector " ) . hide ();
jQuery ( " .showforthirdpartyselector " ) . show ();
}
}
init_selectors ();
jQuery ( " .radiobarcodeselect " ) . click ( function () {
init_selectors ();
});
2014-02-19 17:04:21 +01:00
2014-01-20 17:18:56 +01:00
function init_gendoc_button ()
{
if ( jQuery ( " #select_fk_barcode_type " ) . val () > 0 && jQuery ( " #forbarcode " ) . val ())
{
2015-05-12 14:47:33 +02:00
jQuery ( " #submitformbarcodegen " ) . removeAttr ( " disabled " );
2014-01-20 17:18:56 +01:00
}
else
{
2015-05-12 14:47:33 +02:00
jQuery ( " #submitformbarcodegen " ) . prop ( " disabled " , true );
2014-01-20 17:18:56 +01:00
}
}
init_gendoc_button ();
jQuery ( " #select_fk_barcode_type " ) . change ( function () {
init_gendoc_button ();
});
jQuery ( " #forbarcode " ) . keyup ( function () {
init_gendoc_button ()
});
});
</ script > ' ;
2014-01-08 00:05:42 +01:00
// Checkbox to select from free text
2022-02-11 15:30:45 +01:00
print '<input id="fillmanually" type="radio" ' . (( ! GETPOST ( " selectorforbarcode " ) || GETPOST ( " selectorforbarcode " ) == 'fillmanually' ) ? 'checked ' : '' ) . 'name="selectorforbarcode" value="fillmanually" class="radiobarcodeselect"><label for="fillmanually"> ' . $langs -> trans ( " FillBarCodeTypeAndValueManually " ) . '</label>' ;
2014-01-08 00:05:42 +01:00
print '<br>' ;
2021-02-22 19:05:32 +01:00
if ( ! empty ( $user -> rights -> produit -> lire ) || ! empty ( $user -> rights -> service -> lire )) {
2022-02-11 15:30:45 +01:00
print '<input id="fillfromproduct" type="radio" ' . (( GETPOST ( " selectorforbarcode " ) == 'fillfromproduct' ) ? 'checked ' : '' ) . 'name="selectorforbarcode" value="fillfromproduct" class="radiobarcodeselect"><label for="fillfromproduct"> ' . $langs -> trans ( " FillBarCodeTypeAndValueFromProduct " ) . '</label>' ;
2020-10-31 14:32:18 +01:00
print '<br>' ;
print '<div class="showforproductselector">' ;
$form -> select_produits ( GETPOST ( 'productid' , 'int' ), 'productid' , '' , '' , 0 , - 1 , 2 , '' , 0 , array (), 0 , '1' , 0 , 'minwidth400imp' , 1 );
2022-02-11 15:30:45 +01:00
print ' <input type="submit" class="button small" id="submitproduct" name="submitproduct" value="' . ( dol_escape_htmltag ( $langs -> trans ( " GetBarCode " ))) . '">' ;
2020-10-31 14:32:18 +01:00
print '</div>' ;
2017-06-09 01:06:52 +02:00
}
2014-01-08 00:05:42 +01:00
2021-02-22 19:05:32 +01:00
if ( ! empty ( $user -> rights -> societe -> lire )) {
2022-02-11 15:30:45 +01:00
print '<input id="fillfromthirdparty" type="radio" ' . (( GETPOST ( " selectorforbarcode " ) == 'fillfromthirdparty' ) ? 'checked ' : '' ) . 'name="selectorforbarcode" value="fillfromthirdparty" class="radiobarcodeselect"><label for="fillfromthirdparty"> ' . $langs -> trans ( " FillBarCodeTypeAndValueFromThirdParty " ) . '</label>' ;
2020-10-31 14:32:18 +01:00
print '<br>' ;
print '<div class="showforthirdpartyselector">' ;
print $form -> select_company ( GETPOST ( 'socid' , 'int' ), 'socid' , '' , 'SelectThirdParty' , 0 , 0 , array (), 0 , 'minwidth300' );
2022-02-11 15:30:45 +01:00
print ' <input type="submit" id="submitthirdparty" name="submitthirdparty" class="button showforthirdpartyselector small" value="' . ( dol_escape_htmltag ( $langs -> trans ( " GetBarCode " ))) . '">' ;
2020-10-31 14:32:18 +01:00
print '</div>' ;
2017-06-09 01:06:52 +02:00
}
2014-01-20 17:18:56 +01:00
2014-01-08 00:05:42 +01:00
print '<br>' ;
2014-01-20 17:18:56 +01:00
2021-02-22 19:05:32 +01:00
if ( $producttmp -> id > 0 ) {
2019-01-27 11:55:16 +01:00
print $langs -> trans ( " BarCodeDataForProduct " , '' ) . ' ' . $producttmp -> getNomUrl ( 1 ) . '<br>' ;
2014-01-20 17:18:56 +01:00
}
2021-02-22 19:05:32 +01:00
if ( $thirdpartytmp -> id > 0 ) {
2019-01-27 11:55:16 +01:00
print $langs -> trans ( " BarCodeDataForThirdparty " , '' ) . ' ' . $thirdpartytmp -> getNomUrl ( 1 ) . '<br>' ;
2014-01-20 17:18:56 +01:00
}
2014-01-08 00:05:42 +01:00
print '<div class="tagtable">' ;
// Barcode type
print ' <div class="tagtr">' ;
print ' <div class="tagtd" style="overflow: hidden; white-space: nowrap; max-width: 300px;">' ;
print $langs -> trans ( " BarcodeType " ) . ' ' ;
print '</div><div class="tagtd" style="overflow: hidden; white-space: nowrap; max-width: 300px;">' ;
require_once DOL_DOCUMENT_ROOT . '/core/class/html.formbarcode.class.php' ;
$formbarcode = new FormBarCode ( $db );
2018-09-10 23:50:48 +02:00
print $formbarcode -> selectBarcodeType ( $fk_barcode_type , 'fk_barcode_type' , 1 );
2014-01-08 00:05:42 +01:00
print '</div></div>' ;
// Barcode value
print ' <div class="tagtr">' ;
print ' <div class="tagtd" style="overflow: hidden; white-space: nowrap; max-width: 300px;">' ;
print $langs -> trans ( " BarcodeValue " ) . ' ' ;
print '</div><div class="tagtd" style="overflow: hidden; white-space: nowrap; max-width: 300px;">' ;
2014-01-20 17:18:56 +01:00
print '<input size="16" type="text" name="forbarcode" id="forbarcode" value="' . $forbarcode . '">' ;
2014-01-08 00:05:42 +01:00
print '</div></div>' ;
/*
2013-12-15 03:23:10 +01:00
$barcodestickersmask = GETPOST ( 'barcodestickersmask' );
2014-01-08 00:05:42 +01:00
print '<br>' . $langs -> trans ( " BarcodeStickersMask " ) . ':<br>' ;
print '<textarea cols="40" type="text" name="barcodestickersmask" value="' . GETPOST ( 'barcodestickersmask' ) . '">' . $barcodestickersmask . '</textarea>' ;
print '<br>' ;
*/
2014-01-20 17:18:56 +01:00
print '</div>' ;
2021-08-24 17:04:17 +02:00
print '<br><input type="submit" class="button" id="submitformbarcodegen" ' . (( GETPOST ( " selectorforbarcode " ) && GETPOST ( " selectorforbarcode " )) ? '' : 'disabled ' ) . 'value="' . $langs -> trans ( " BuildPageToPrint " ) . '">' ;
2014-01-08 00:05:42 +01:00
2013-12-15 03:23:10 +01:00
print '</form>' ;
print '<br>' ;
2018-07-29 11:33:52 +02:00
// End of page
2013-12-15 03:23:10 +01:00
llxFooter ();
$db -> close ();