From 062230050f30cea516c0411317943cc9e645e8b9 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 20 Jan 2014 17:18:56 +0100 Subject: [PATCH] New: Can call back barcode number from a product ref or thirdparty ref. --- htdocs/barcode/printsheet.php | 137 +++++++++++++++++-- htdocs/core/class/html.formbarcode.class.php | 4 +- htdocs/langs/en_US/admin.lang | 1 + htdocs/langs/en_US/products.lang | 10 +- htdocs/langs/fr_FR/admin.lang | 1 + htdocs/langs/fr_FR/products.lang | 10 +- 6 files changed, 144 insertions(+), 19 deletions(-) diff --git a/htdocs/barcode/printsheet.php b/htdocs/barcode/printsheet.php index 2ed50dc6f2a..4230ffe4ba2 100644 --- a/htdocs/barcode/printsheet.php +++ b/htdocs/barcode/printsheet.php @@ -47,11 +47,49 @@ $mesg=''; $action=GETPOST('action'); +$producttmp=new Product($db); +$thirdpartytmp=new Societe($db); + /* * Actions */ +if (GETPOST('submitproduct') && GETPOST('submitproduct')) +{ + $action=''; // We reset because we dont want to build doc + if (GETPOST('productid') > 0) + { + $producttmp->fetch(GETPOST('productid')); + $forbarcode=$producttmp->barcode; + $fk_barcode_type=$thirdpartytmp->barcode_type_code; + + if (empty($fk_barcode_type) && ! empty($conf->global->PRODUIT_DEFAULT_BARCODE_TYPE)) $fk_barcode_type = $conf->global->PRODUIT_DEFAULT_BARCODE_TYPE; + + if (empty($forbarcode) || empty($fk_barcode_type)) + { + setEventMessage($langs->trans("DefinitionOfBarCodeForProductNotComplete",$producttmp->getNomUrl()), 'warnings'); + } + } +} +if (GETPOST('submitthirdparty') && GETPOST('submitthirdparty')) +{ + $action=''; // We reset because we dont want to build doc + if (GETPOST('socid') > 0) + { + $thirdpartytmp->fetch(GETPOST('socid')); + $forbarcode=$thirdpartytmp->barcode; + $fk_barcode_type=$thirdpartytmp->barcode_type_code; + + if (empty($fk_barcode_type) && ! empty($conf->global->GENBARCODE_BARCODETYPE_THIRDPARTY)) $fk_barcode_type = $conf->global->GENBARCODE_BARCODETYPE_THIRDPARTY; + + if (empty($forbarcode) || empty($fk_barcode_type)) + { + setEventMessage($langs->trans("DefinitionOfBarCodeForProductNotComplete",$thirdpartytmp->getNomUrl()), 'warnings'); + } + } +} + if ($action == 'builddoc') { $result=0; $error=0; @@ -150,8 +188,8 @@ if ($action == 'builddoc') // For labels if ($mode == 'label') { - if (empty($conf->global->ADHERENT_ETIQUETTE_TEXT)) $conf->global->ADHERENT_ETIQUETTE_TEXT="%PHOTO%"; - $textleft=make_substitutions($conf->global->ADHERENT_ETIQUETTE_TEXT, $substitutionarray); + $txtforsticker="%PHOTO%"; + $textleft=make_substitutions($txtforsticker, $substitutionarray); $textheader=''; $textfooter=''; $textright=''; @@ -253,19 +291,94 @@ print ''; print '
'; + +// Add javascript to make choice dynamic +print ''; + // Checkbox to select from free text -print ' '.$langs->trans("FillBarCodeTypeAndValueManually").'   '; +print ' '.$langs->trans("FillBarCodeTypeAndValueManually").'   '; print '
'; -/* -print ' '.$langs->trans("FillBarCodeTypeAndValueFromProduct").'   '; +print ' '.$langs->trans("FillBarCodeTypeAndValueFromProduct").'   '; +print '
'; +print '
'; print $form->select_produits(GETPOST('productid'), 'productid', ''); +print '   '; +print '
'; + +print ' '.$langs->trans("FillBarCodeTypeAndValueFromThirdParty").'   '; +print '
'; +print '
'; +print $form->select_company(GETPOST('socid'), 'socid', '', 1); +print '   '; +print '
'; + print '
'; -print ' '.$langs->trans("FillBarCodeTypeAndValueFromThirdParty").'   '; -print $form->select_company(GETPOST('socid'), 'socid', '', 1); -print '
'; -*/ +if ($producttmp->id > 0) +{ + print $langs->trans("BarCodeDataForProduct",$producttmp->getNomUrl(1)).'
'; +} +if ($thirdpartytmp->id > 0) +{ + print $langs->trans("BarCodeDataForThirdparty",$thirdpartytmp->getNomUrl(1)).'
'; +} print '
'; @@ -284,7 +397,7 @@ print '
'; print '
'; print $langs->trans("BarcodeValue").'   '; print '
'; -print ''; +print ''; print '
'; /* @@ -294,7 +407,9 @@ print '