New: Can call back barcode number from a product ref or thirdparty ref.

This commit is contained in:
Laurent Destailleur 2014-01-20 17:18:56 +01:00
parent 30aae38efa
commit 062230050f
6 changed files with 144 additions and 19 deletions

View File

@ -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 '</div>';
print '<br>';
// Add javascript to make choice dynamic
print '<script type="text/javascript" language="javascript">
jQuery(document).ready(function() {
function init_selectors()
{
if (jQuery("#fillmanually:checked").val() == "fillmanually")
{
jQuery("#submitproduct").attr(\'disabled\',\'disabled\');
jQuery("#submitthirdparty").attr(\'disabled\',\'disabled\');
jQuery("#search_productid").attr(\'disabled\',\'disabled\');
jQuery("#socid").attr(\'disabled\',\'disabled\');
jQuery(".showforproductselector").hide();
jQuery(".showforthirdpartyselector").hide();
}
if (jQuery("#fillfromproduct:checked").val() == "fillfromproduct")
{
jQuery("#submitproduct").removeAttr(\'disabled\');
jQuery("#submitthirdparty").attr(\'disabled\',\'disabled\');
jQuery("#search_productid").removeAttr(\'disabled\');
jQuery("#socid").attr(\'disabled\',\'disabled\');
jQuery(".showforproductselector").show();
jQuery(".showforthirdpartyselector").hide();
}
if (jQuery("#fillfromthirdparty:checked").val() == "fillfromthirdparty")
{
jQuery("#submitproduct").attr(\'disabled\',\'disabled\');
jQuery("#submitthirdparty").removeAttr(\'disabled\');
jQuery("#search_productid").attr(\'disabled\',\'disabled\');
jQuery("#socid").removeAttr(\'disabled\');
jQuery(".showforproductselector").hide();
jQuery(".showforthirdpartyselector").show();
}
}
init_selectors();
jQuery(".radiobarcodeselect").click(function() {
init_selectors();
});
function init_gendoc_button()
{
if (jQuery("#select_fk_barcode_type").val() > 0 && jQuery("#forbarcode").val())
{
jQuery("#submitformbarcodegen").removeAttr(\'disabled\');
}
else
{
jQuery("#submitformbarcodegen").attr(\'disabled\',\'disabled\');
}
}
init_gendoc_button();
jQuery("#select_fk_barcode_type").change(function() {
init_gendoc_button();
});
jQuery("#forbarcode").keyup(function() {
init_gendoc_button()
});
});
</script>';
// Checkbox to select from free text
print '<input id="fillmanually" type="checkbox" checked="checked"> '.$langs->trans("FillBarCodeTypeAndValueManually").' &nbsp; ';
print '<input id="fillmanually" type="radio" '.((! GETPOST("selectorforbarcode") || GETPOST("selectorforbarcode")=='fillmanually')?'checked="checked" ':'').'name="selectorforbarcode" value="fillmanually" class="radiobarcodeselect"> '.$langs->trans("FillBarCodeTypeAndValueManually").' &nbsp; ';
print '<br>';
/*
print '<input id="fillfromproduct" type="checkbox" checked="checked" disabled="true"> '.$langs->trans("FillBarCodeTypeAndValueFromProduct").' &nbsp; ';
print '<input id="fillfromproduct" type="radio" '.((GETPOST("selectorforbarcode")=='fillfromproduct')?'checked="checked" ':'').'name="selectorforbarcode" value="fillfromproduct" class="radiobarcodeselect"> '.$langs->trans("FillBarCodeTypeAndValueFromProduct").' &nbsp; ';
print '<br>';
print '<div class="showforproductselector">';
print $form->select_produits(GETPOST('productid'), 'productid', '');
print ' &nbsp; <input type="submit" id="submitproduct" name="submitproduct" class="button" value="'.(dol_escape_htmltag($langs->trans("GetBarCode"))).'">';
print '</div>';
print '<input id="fillfromthirdparty" type="radio" '.((GETPOST("selectorforbarcode")=='fillfromthirdparty')?'checked="checked" ':'').'name="selectorforbarcode" value="fillfromthirdparty" class="radiobarcodeselect"> '.$langs->trans("FillBarCodeTypeAndValueFromThirdParty").' &nbsp; ';
print '<br>';
print '<div class="showforthirdpartyselector">';
print $form->select_company(GETPOST('socid'), 'socid', '', 1);
print ' &nbsp; <input type="submit" id="submitthirdparty" name="submitthirdparty" class="button showforthirdpartyselector" value="'.(dol_escape_htmltag($langs->trans("GetBarCode"))).'">';
print '</div>';
print '<br>';
print '<input id="fillfromthirdparty" type="checkbox" checked="checked" disabled="true"> '.$langs->trans("FillBarCodeTypeAndValueFromThirdParty").' &nbsp; ';
print $form->select_company(GETPOST('socid'), 'socid', '', 1);
print '<br>';
*/
if ($producttmp->id > 0)
{
print $langs->trans("BarCodeDataForProduct",$producttmp->getNomUrl(1)).'<br>';
}
if ($thirdpartytmp->id > 0)
{
print $langs->trans("BarCodeDataForThirdparty",$thirdpartytmp->getNomUrl(1)).'<br>';
}
print '<div class="tagtable">';
@ -284,7 +397,7 @@ print ' <div class="tagtr">';
print ' <div class="tagtd" style="overflow: hidden; white-space: nowrap; max-width: 300px;">';
print $langs->trans("BarcodeValue").' &nbsp; ';
print '</div><div class="tagtd" style="overflow: hidden; white-space: nowrap; max-width: 300px;">';
print '<input size="16" type="text" name="forbarcode" value="'.GETPOST('forbarcode').'">';
print '<input size="16" type="text" name="forbarcode" id="forbarcode" value="'.$forbarcode.'">';
print '</div></div>';
/*
@ -294,7 +407,9 @@ print '<textarea cols="40" type="text" name="barcodestickersmask" value="'.GETPO
print '<br>';
*/
print '<br><input class="button" type="submit" value="'.$langs->trans("BuildPageToPrint").'">';
print '</div>';
print '<br><input class="button" type="submit" id="submitformbarcodegen" '.((GETPOST("selectorforbarcode") && GETPOST("selectorforbarcode"))?'':'disabled="checked" ').'value="'.$langs->trans("BuildPageToPrint").'">';
print '</form>';
print '<br>';

View File

@ -122,13 +122,13 @@ class FormBarCode
if ($useempty && $num > 0)
{
print '<select class="flat" name="'.$htmlname.'">';
print '<select class="flat" name="'.$htmlname.'" id="select_'.$htmlname.'">';
print '<option value="0">&nbsp;</option>';
}
else
{
$langs->load("errors");
print '<select disabled="disabled" class="flat" name="'.$htmlname.'">';
print '<select disabled="disabled" class="flat" name="'.$htmlname.'" id="select_'.$htmlname.'">';
print '<option value="0" selected="selected">'.$langs->trans('ErrorNoActivatedBarcode').'</option>';
}

View File

@ -1013,6 +1013,7 @@ AddRefInList=Display customer/supplier ref into list (select list or combobox) a
FieldEdition=Edition of field %s
FixTZ=TimeZone fix
FillThisOnlyIfRequired=Example: +2 (fill only if timezone offset problems are experienced)
GetBarCode=Get barcode
##### Module password generation
PasswordGenerationStandard=Return a password generated according to internal Dolibarr algorithm: 8 characters containing shared numbers and characters in lowercase.
PasswordGenerationNone=Do not suggest any generated password. Password must be type in manually.

View File

@ -209,8 +209,12 @@ PageToGenerateBarCodeSheets=With this tool, you can print sheets of bar code sti
NumberOfStickers=Number of stickers to print on page
PrintsheetForOneBarCode=Print several stickers for one barcode
BuildPageToPrint=Generate page to print
FillBarCodeTypeAndValueManually=Fill barcode type and value manually
FillBarCodeTypeAndValueFromProduct=Fill barcode type and value from a product
FillBarCodeTypeAndValueFromThirdParty=Fill barcode type and value from a thirdparty
FillBarCodeTypeAndValueManually=Fill barcode type and value manually.
FillBarCodeTypeAndValueFromProduct=Fill barcode type and value from barcode of a product.
FillBarCodeTypeAndValueFromThirdParty=Fill barcode type and value from barcode of a thirdparty.
DefinitionOfBarCodeForProductNotComplete=Definition of type or value of bar code not complete for product %s.
DefinitionOfBarCodeForThirdpartyNotComplete=Definition of type or value of bar code non complete for thirdparty %s.
BarCodeDataForProduct=Barcode information of product %s :
BarCodeDataForThirdparty=Barcode information of thirdparty %s :
BarcodeStickersMask=xxx

View File

@ -1011,6 +1011,7 @@ AddRefInList=Afficher le code client/fournisseur dans les liste (déroulante ou
FieldEdition=Édition du champ %s
FixTZ=Correction du Timezone
FillThisOnlyIfRequired=Exemple: +2 (ne remplir que si un décalage d'heure est constaté dans l'export)
GetBarCode=Récupérer code barre
##### Module password generation
PasswordGenerationStandard=Renvoie un mot de passe généré selon l'algorithme interne de Dolibarr : 8 caractères, chiffres et caractères en minuscules mélangés.
PasswordGenerationNone=Ne propose pas de mots de passe générés. Le mot de passe est à saisir manuellement.

View File

@ -209,7 +209,11 @@ PageToGenerateBarCodeSheets=Avec cet outils, vous pouvez imprimer une planche d'
NumberOfStickers=Nombre d'étiquettes à imprimer sur la/les planches
PrintsheetForOneBarCode=Imprimer des étiquettes d'un code barre particulier
BuildPageToPrint=Générer la page à imprimer
FillBarCodeTypeAndValueManually=Remplir le type et la valeur du code barre manuellement
FillBarCodeTypeAndValueFromProduct=Remplir le type et la valeur du code barre depuis un produit
FillBarCodeTypeAndValueFromThirdParty=Remplir le type et la valeur du code barre depuis un tiers
FillBarCodeTypeAndValueManually=Remplir le type et la valeur du code barre manuellement.
FillBarCodeTypeAndValueFromProduct=Remplir le type et la valeur du code barre par celui d'un produit.
FillBarCodeTypeAndValueFromThirdParty=Remplir le type et la valeur du code barre par celui d'un tiers.
DefinitionOfBarCodeForProductNotComplete=Définition du type ou valeure du code bar incomplète sur le produit %s.
DefinitionOfBarCodeForThirdpartyNotComplete=Définition du type ou valeure du code bar incomplète sur le tiers %s.
BarCodeDataForProduct=Information de code barre du produit %s :
BarCodeDataForThirdparty=Information de code barre du tiers %s :
BarcodeStickersMask=xxx