package it.integry.integrywmsnative.view.dialogs.input_quantity;

import android.app.AlertDialog;
import android.app.DatePickerDialog;
import android.app.ProgressDialog;
import android.content.Context;
import android.content.res.ColorStateList;
import androidx.databinding.DataBindingUtil;
import androidx.databinding.Observable;
import androidx.databinding.ViewDataBinding;
import android.os.Handler;
import com.google.android.material.textfield.TextInputLayout;
import androidx.core.content.ContextCompat;
import androidx.appcompat.widget.AppCompatTextView;
import android.text.Html;
import android.text.SpannableString;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.inputmethod.InputMethodManager;
import android.widget.Button;
import android.widget.EditText;

import java.math.BigDecimal;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;

import it.integry.integrywmsnative.MainApplication;
import it.integry.integrywmsnative.R;
import it.integry.integrywmsnative.core.REST.consumers.BarcodeRESTConsumer;
import it.integry.integrywmsnative.core.REST.consumers.ISingleValueOperationCallback;
import it.integry.integrywmsnative.core.REST.model.Ean13PesoModel;
import it.integry.integrywmsnative.core.barcode_reader.BarcodeCallbackDTO;
import it.integry.integrywmsnative.core.barcode_reader.BarcodeManager;
import it.integry.integrywmsnative.core.expansion.RunnableArgs;
import it.integry.integrywmsnative.core.model.MtbAart;
import it.integry.integrywmsnative.core.utility.UtilityBarcode;
import it.integry.integrywmsnative.core.utility.UtilityDate;
import it.integry.integrywmsnative.core.utility.UtilityExceptions;
import it.integry.integrywmsnative.core.utility.UtilityLogger;
import it.integry.integrywmsnative.core.utility.UtilityProgress;
import it.integry.integrywmsnative.core.utility.UtilityString;
import it.integry.integrywmsnative.databinding.DialogInputQuantityArticoloBinding;
import it.integry.integrywmsnative.view.dialogs.DialogSimpleMessageHelper;
import it.integry.plugins.barcode_base_library.model.BarcodeScanDTO;

public class DialogInputQuantity {

    public static class DTO {
        private MtbAart mtbAart;
        private String batchLot;
        private BigDecimal qtaDaEvadere;
        private BigDecimal qtaDisponibile;
        private BigDecimal qtaEvasa;
        private BigDecimal qtaOrd;
        private BigDecimal qtaTot;
        private BigDecimal qtaCnf;
        private Integer numCnf;
        private BigDecimal maxQta;
        private String codArtFor;
        private Date dataScad;
        private boolean canPartitaMagBeChanged;
        private Boolean canDataScadBeChanged;
        private Boolean shouldAskDataScad;

        public MtbAart getMtbAart() {
            return mtbAart;
        }

        public DTO setMtbAart(MtbAart mtbAart) {
            this.mtbAart = mtbAart;
            return this;
        }

        public String getBatchLot() {
            return batchLot;
        }

        public DTO setBatchLot(String batchLot) {
            this.batchLot = batchLot;
            return this;
        }

        public BigDecimal getQtaDaEvadere() {
            return qtaDaEvadere;
        }

        public DTO setQtaDaEvadere(BigDecimal qtaDaEvadere) {
            this.qtaDaEvadere = qtaDaEvadere;
            return this;
        }

        public BigDecimal getQtaDisponibile() {
            return qtaDisponibile;
        }

        public DTO setQtaDisponibile(BigDecimal qtaDisponibile) {
            this.qtaDisponibile = qtaDisponibile;
            return this;
        }

        public BigDecimal getQtaOrd() {
            return qtaOrd;
        }

        public DTO setQtaOrd(BigDecimal qtaOrd) {
            this.qtaOrd = qtaOrd;
            return this;
        }

        public BigDecimal getQtaTot() {
            return qtaTot;
        }

        public DTO setQtaTot(BigDecimal qtaTot) {
            this.qtaTot = qtaTot;
            return this;
        }

        public BigDecimal getQtaCnf() {
            return qtaCnf;
        }

        public DTO setQtaCnf(BigDecimal qtaCnf) {
            this.qtaCnf = qtaCnf;
            return this;
        }

        public Integer getNumCnf() {
            return numCnf;
        }

        public DTO setNumCnf(Integer numCnf) {
            this.numCnf = numCnf;
            return this;
        }

        public BigDecimal getQtaEvasa() {
            return qtaEvasa;
        }

        public DTO setQtaEvasa(BigDecimal qtaEvasa) {
            this.qtaEvasa = qtaEvasa;
            return this;
        }

        public BigDecimal getMaxQta() {
            return maxQta;
        }

        public DTO setMaxQta(BigDecimal maxQta) {
            this.maxQta = maxQta;
            return this;
        }

        public String getCodArtFor() {
            return codArtFor;
        }

        public DTO setCodArtFor(String codArtFor) {
            this.codArtFor = codArtFor;
            return this;
        }

        public Date getDataScad() {
            return dataScad;
        }

        public DTO setDataScad(Date dataScad) {
            this.dataScad = dataScad;
            return this;
        }

        public boolean getCanPartitaMagBeChanged() {
            return canPartitaMagBeChanged;
        }

        public DTO setCanPartitaMagBeChanged(boolean canPartitaMagBeChanged) {
            this.canPartitaMagBeChanged = canPartitaMagBeChanged;
            return this;
        }

        public Boolean isCanDataScadBeChanged() {
            return canDataScadBeChanged;
        }

        public DTO setCanDataScadBeChanged(boolean canDataScadBeChanged) {
            this.canDataScadBeChanged = canDataScadBeChanged;
            return this;
        }

        public Boolean getShouldAskDataScad() {
            return shouldAskDataScad;
        }

        public DTO setShouldAskDataScad(Boolean shouldAskDataScad) {
            this.shouldAskDataScad = shouldAskDataScad;
            return this;
        }
    }

    private ColorStateList originalColorStateList = null;

    private String scadenzaString = "Scadenza";

    private AlertDialog currentAlert;
    private Context currentContext;

    private DialogInputQuantityArticoloBinding currentBinding;

    private MtbAart currentMtbAart;
    private QuantityDTO currentQuantityDto;
    private DTO currentDTO;

    public static AlertDialog makeBase(final Context context, final DTO dto, boolean canOverflowQuantity, final ISingleValueOperationCallback<QuantityDTO> dialogCallback) {
        return new DialogInputQuantity(context, dto, canOverflowQuantity, dialogCallback).currentAlert;
    }

    public DialogInputQuantity(Context context, final DTO dto, boolean canOverflowQuantity, final ISingleValueOperationCallback<QuantityDTO> dialogCallback) {
        currentContext = context;
        currentMtbAart = dto.getMtbAart();
        currentDTO = dto;

        LayoutInflater inflater = (LayoutInflater) context.getSystemService( Context.LAYOUT_INFLATER_SERVICE );
        currentBinding = DataBindingUtil.inflate(inflater, R.layout.dialog_input_quantity_articolo, null, false);

        final TextInputLayout txlInputBatchLot = currentBinding.inputPartitaMag;

        final TextInputLayout txlInputNumDiCnf = currentBinding.inputNumCnf;
        final TextInputLayout txlInputQtaPerCnf = currentBinding.inputQtaCnf;
        final TextInputLayout txlInputQtaTot = currentBinding.inputQtaTot;

        txlInputNumDiCnf.getEditText().setSelectAllOnFocus(true);
        txlInputQtaPerCnf.getEditText().setSelectAllOnFocus(true);
        txlInputQtaTot.getEditText().setSelectAllOnFocus(true);


        originalColorStateList = txlInputNumDiCnf.getEditText().getTextColors();

        currentQuantityDto = new QuantityDTO();
        currentQuantityDto.canOverflowQuantity = canOverflowQuantity;

        setupQuantities(dto, currentQuantityDto);

        setupQuantityListener(currentQuantityDto, txlInputNumDiCnf, txlInputQtaPerCnf, txlInputQtaTot);

        currentBinding.setViewmodel(dto);
        currentBinding.setQuantityViewModel(currentQuantityDto);

        final AlertDialog.Builder alertDialog = new AlertDialog.Builder(context)
                .setView(currentBinding.getRoot())
                .setPositiveButton(context.getText(R.string.confirm), null)
                .setNegativeButton(context.getText(R.string.abort), null);

        currentAlert = alertDialog.create();
        currentAlert.setCanceledOnTouchOutside(false);

        currentAlert.setOnShowListener(dialogInterface -> {

            final Handler handler = new Handler();
            handler.postDelayed(() -> {
                EditText editTextToFocus;
                if(currentQuantityDto.canPartitaMagBeChanged.get()) {
                    editTextToFocus = txlInputBatchLot.getEditText();
                } else {
                    editTextToFocus = txlInputNumDiCnf.getEditText();
                }


                editTextToFocus.requestFocus();

                InputMethodManager imm = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);
                imm.showSoftInput(editTextToFocus, InputMethodManager.SHOW_IMPLICIT);
            }, 100);

            Button positiveButton = currentAlert.getButton(AlertDialog.BUTTON_POSITIVE);

            positiveButton.setOnClickListener(view -> onConfirm(context, currentQuantityDto, dialogCallback));
        });


        initDatePicker(context, currentQuantityDto, currentBinding.getRoot().findViewById(R.id.input_data_scad));

        setupBarcode(context);
    }

    private void setupQuantities(DTO dto, QuantityDTO quantityDTO){
        if(dto.getQtaTot() != null) quantityDTO.qtaTot.set(dto.getQtaTot().floatValue());
        if(dto.getMaxQta() != null) quantityDTO.maxQta.set(dto.getMaxQta().floatValue());

        float qtaDisponibile = dto.getQtaDisponibile() != null ? dto.getQtaDisponibile().floatValue() : 0f;
        if (qtaDisponibile < 0) {
            currentBinding.layoutQtaDisponibile.setVisibility(View.GONE);
            qtaDisponibile = 0;
        }
        if(qtaDisponibile > 0) quantityDTO.qtaDisponibile.set(qtaDisponibile);

        float qtaDaEvadere = dto.qtaDaEvadere != null ? dto.qtaDaEvadere.floatValue() : 0f;
        if (qtaDaEvadere < 0) {
            currentBinding.layoutQtaDaEvadere.setVisibility(View.GONE);
            qtaDaEvadere = 0;
        }

        if(qtaDaEvadere > 0) quantityDTO.qtaDaEvadere.set(qtaDaEvadere);
        quantityDTO.qtaEvasa.set(dto.qtaEvasa != null ? dto.qtaEvasa.floatValue() : null);

        quantityDTO.batchLot.set(dto.batchLot);
        if(quantityDTO.qtaCnf.get(false) == null) {
            if(dto.getQtaCnf() != null) {
                quantityDTO.qtaCnf.set(dto.getQtaCnf().floatValue());
            } else {
                quantityDTO.qtaCnf.set(dto.mtbAart.getQtaCnf().floatValue());
            }
        }

        if(quantityDTO.qtaTot.get(false) == null) {
            quantityDTO.qtaTot.set(qtaDaEvadere);
        }

        if(dto.getNumCnf() != null) {
            quantityDTO.numCnf.set(new BigDecimal(dto.getNumCnf()).floatValue());
        }

        if(quantityDTO.numCnf.get(false) == null) {
            quantityDTO.numCnf.set(quantityDTO.qtaTot.get() / quantityDTO.qtaCnf.get());
        }

        quantityDTO.canPartitaMagBeChanged.set(dto.getCanPartitaMagBeChanged());

        if(dto.isCanDataScadBeChanged() != null){
            quantityDTO.canDataScadBeChanged.set(dto.isCanDataScadBeChanged());
        }

        quantityDTO.shouldAskDataScad.set(dto.mtbAart.isFlagTracciabilita() && dto.mtbAart.getGgScadPartita() != null && dto.mtbAart.getGgScadPartita() > 0);

        if(dto.getShouldAskDataScad() != null) {
            quantityDTO.shouldAskDataScad.set(dto.getShouldAskDataScad());
        }

        if(dto.getDataScad() != null) {
            quantityDTO.expireDate = dto.getDataScad();
        }

        if(quantityDTO.expireDate == null && dto.mtbAart.getGgScadPartita() != null && dto.mtbAart.getGgScadPartita() > 0) {
            Calendar c = Calendar.getInstance();
            c.add(Calendar.DATE, dto.mtbAart.getGgScadPartita());  // number of days to add

            quantityDTO.expireDate = c.getTime();
        }

    }


    private void setupBarcode(Context context) {

        int barcodeIstanceID = BarcodeManager.addCallback(new BarcodeCallbackDTO()
                .setOnScanSuccessfull(onScanSuccessfull)
                .setOnScanFailed(ex -> UtilityExceptions.defaultException(context, ex, false)));

        currentAlert.setOnDismissListener(dialog -> {
            BarcodeManager.removeCallback(barcodeIstanceID);
        });

    }


    private RunnableArgs<BarcodeScanDTO> onScanSuccessfull = data -> {
        BarcodeManager.disable();

        if(UtilityBarcode.isEanPeso(data)){

            try {
                Ean13PesoModel ean13PesoModel = Ean13PesoModel.fromBarcode(data.getStringValue());

                if(ean13PesoModel.getPrecode().contains(currentMtbAart.getBarCode())) {

                    currentQuantityDto.numCnf.set(1f);
                    currentQuantityDto.qtaCnf.set(ean13PesoModel.getPeso());
                    currentQuantityDto.qtaTot.set(ean13PesoModel.getPeso());

                    BarcodeManager.enable();
                } else {
                    BarcodeManager.enable();
                }

            } catch (Exception e) {
                UtilityLogger.errorMe(e);
                BarcodeManager.enable();
            }

        } else if(UtilityBarcode.isEtichetta128(data)){
            final ProgressDialog progressDialog = UtilityProgress.createDefaultProgressDialog(currentContext);

            BarcodeRESTConsumer.decodeEan128(data, ean128Model -> {
                progressDialog.dismiss();
                BarcodeManager.enable();

                if(ean128Model != null){
                    if(!UtilityString.isNullOrEmpty(ean128Model.BatchLot)) {
                        currentQuantityDto.batchLot.set(ean128Model.BatchLot);
                    }

                    try {
                        if(!UtilityString.isNullOrEmpty(ean128Model.BestBefore)){
                            currentQuantityDto.expireDate = UtilityDate.recognizeDate(ean128Model.BestBefore);
                        } else if(!UtilityString.isNullOrEmpty(ean128Model.Expiry)) {
                            currentQuantityDto.expireDate = UtilityDate.recognizeDate(ean128Model.Expiry);
                        }

                        if(currentQuantityDto.expireDate != null) {
                            currentQuantityDto.expireDateString.set(UtilityDate.formatDate(currentQuantityDto.expireDate, UtilityDate.COMMONS_DATE_FORMATS.DMY_HUMAN));
                        }

                    } catch (Exception e) {
                        UtilityLogger.errorMe(e);
                    }


                    if(ean128Model.Count != null && ean128Model.Count > 0) {
                        currentQuantityDto.numCnf.set((float) ean128Model.Count);
                    }

                    if (ean128Model.NetWeightKg != null && ean128Model.NetWeightKg > 0) {
                        currentQuantityDto.qtaTot.set(ean128Model.NetWeightKg);
                    }

                    if(currentQuantityDto.qtaTot.get() > 0 && currentQuantityDto.numCnf.get() > 0) {
                        currentQuantityDto.qtaCnf.set(currentQuantityDto.qtaTot.get() / currentQuantityDto.numCnf.get());
                    }

                }


            }, ex -> {
                UtilityExceptions.defaultException(currentContext, ex, progressDialog);

                BarcodeManager.enable();
            });

        } else {
            BarcodeManager.enable();
        }

    };

    private void setupQuantityListener(final QuantityDTO quantityDTO, final TextInputLayout txlInputNumDiCnf, final TextInputLayout txlInputQtaPerCnf, final TextInputLayout txlInputQtaTot) {

        quantityDTO.numCnf.addOnPropertyChangedCallback(new Observable.OnPropertyChangedCallback() {
            @Override
            public void onPropertyChanged(Observable sender, int propertyId) {

                if(quantityDTO.numCnfNotificationEnabled) {

                    quantityDTO.blockedNumDiCnf.set(!(quantityDTO.numCnf.get(true) == 0 || quantityDTO.numCnf.get().toString() == ""));

                    toggleTextInputLayoutError(txlInputNumDiCnf, quantityDTO.blockedNumDiCnf.get());

                    if (!quantityDTO.blockedQtaTot.get()) {

                        quantityDTO.qtaTotNotificationEnabled = false;
                        quantityDTO.qtaTot.set((float) Math.round(quantityDTO.qtaCnf.get(true) * quantityDTO.numCnf.get(true) * 1000) / 1000);
                        quantityDTO.qtaTotNotificationEnabled = true;


                    } else if (!quantityDTO.blockedQtaPerCnf.get()) {

                        quantityDTO.qtaCnfNotificationEnabled = false;
                        if(quantityDTO.numCnf.get(true) != 0) {
                            quantityDTO.qtaCnf.set((float) Math.round(quantityDTO.qtaTot.get(true) / quantityDTO.numCnf.get(true) * 1000) / 1000);
                        } else {
                            quantityDTO.qtaCnf.set((float) Math.round(quantityDTO.qtaTot.get(true) / 1 * 1000) / 1000);
                        }
                        quantityDTO.qtaCnfNotificationEnabled = true;

                    } else {
                        Log.e("DialogInputQuantity", "Tutti i campi sono bloccati, non è possibile modificare il numero di confezioni");
                    }

                }
            }
        });

        quantityDTO.qtaCnf.addOnPropertyChangedCallback(new Observable.OnPropertyChangedCallback() {
            @Override
            public void onPropertyChanged(Observable sender, int propertyId) {

                if(quantityDTO.qtaCnfNotificationEnabled) {

                    quantityDTO.blockedQtaPerCnf.set(!(quantityDTO.qtaCnf.get(true) == 0 || quantityDTO.qtaCnf.get().toString() == ""));

                    toggleTextInputLayoutError(txlInputQtaPerCnf, quantityDTO.blockedQtaPerCnf.get());

                    if (!quantityDTO.blockedQtaTot.get()) {

                        quantityDTO.qtaTotNotificationEnabled = false;
                        quantityDTO.qtaTot.set((float) Math.round(quantityDTO.qtaCnf.get(true) * quantityDTO.numCnf.get(true) * 1000) / 1000);
                        quantityDTO.qtaTotNotificationEnabled = true;

                    } else if (!quantityDTO.blockedNumDiCnf.get()) {

                        quantityDTO.numCnfNotificationEnabled = false;
                        if(quantityDTO.qtaCnf.get(true) != 0){
                            quantityDTO.numCnf.set((float) Math.ceil(quantityDTO.qtaTot.get(true) / quantityDTO.qtaCnf.get(true)));
                        } else {
                            quantityDTO.numCnf.set((float) Math.ceil(quantityDTO.qtaTot.get(true)));
                        }

                        quantityDTO.numCnfNotificationEnabled = true;

                    } else {
                        Log.e("DialogInputQuantity", "Tutti i campi sono bloccati, non è possibile modificare la quantità per confezione");
                    }
                }

            }
        });

        quantityDTO.qtaTot.addOnPropertyChangedCallback(new Observable.OnPropertyChangedCallback() {
            @Override
            public void onPropertyChanged(Observable sender, int propertyId) {

                if (quantityDTO.qtaTotNotificationEnabled) {

                    quantityDTO.blockedQtaTot.set(!(quantityDTO.qtaTot.get(true) == 0 || quantityDTO.qtaTot.get().toString() == ""));

                    toggleTextInputLayoutError(txlInputQtaTot, quantityDTO.blockedQtaTot.get());

                    if(!quantityDTO.blockedQtaPerCnf.get()){

                        quantityDTO.qtaCnfNotificationEnabled = false;
                        quantityDTO.qtaCnf.set((float) Math.round(quantityDTO.qtaTot.get(true) / quantityDTO.numCnf.get(true) *1000)/1000);
                        quantityDTO.qtaCnfNotificationEnabled = true;

                    } else if(!quantityDTO.blockedNumDiCnf.get()) {

                        quantityDTO.numCnfNotificationEnabled = false;
                        quantityDTO.numCnf.set((float) Math.ceil(quantityDTO.qtaTot.get(true) / quantityDTO.qtaCnf.get(true)));
                        quantityDTO.numCnfNotificationEnabled = true;

                    } else {
                        Log.e("DialogInputQuantity", "Tutti i campi sono bloccati, non è possibile modificare la quantità totale");
                    }

                }
            }
        });

    }


    private void toggleTextInputLayoutError(TextInputLayout textInputLayout, boolean isError) {
        if(isError){
            textInputLayout.setErrorEnabled(true);
            textInputLayout.setError(" ");
            textInputLayout.getEditText().setTextColor(ContextCompat.getColor(MainApplication.Context, R.color.red_600));
            textInputLayout.setHintTextAppearance(R.style.ErrorFloatingLabel);

            if (textInputLayout.getChildCount() == 2) {
                textInputLayout.getChildAt(1).setVisibility(View.GONE);
            }
        } else {
            textInputLayout.setErrorEnabled(false);
            textInputLayout.setError(null);
            textInputLayout.getEditText().setTextColor(originalColorStateList);
            textInputLayout.setHintTextAppearance(R.style.NormalFloatingLabel);
        }
    }

    private void initDatePicker(Context context, QuantityDTO quantityDTO, AppCompatTextView textInputLayout) {
        quantityDTO.expireDateString.set(scadenzaString);

        if(quantityDTO.expireDate != null) {
            quantityDTO.expireDateString.set(UtilityDate.formatDate(quantityDTO.expireDate, UtilityDate.COMMONS_DATE_FORMATS.DMY_HUMAN));
        }


        Runnable onTextClicked = () -> {
            // Get Current Date
            Calendar c = Calendar.getInstance();

            if(quantityDTO.expireDate != null) {
                c.setTime(quantityDTO.expireDate);
            }

            int mYear = c.get(Calendar.YEAR);
            int mMonth = c.get(Calendar.MONTH);
            int mDay = c.get(Calendar.DAY_OF_MONTH);

            DatePickerDialog datePickerDialog = new DatePickerDialog(context,
                    (view, year, month, day) -> {

                        quantityDTO.expireDate = new GregorianCalendar(year, month, day).getTime();
                        quantityDTO.expireDateString.set(UtilityDate.formatDate(quantityDTO.expireDate, UtilityDate.COMMONS_DATE_FORMATS.DMY_HUMAN));

                    }, mYear, mMonth, mDay);
            datePickerDialog.show();
        };

        textInputLayout.setOnClickListener(v -> onTextClicked.run());


    }


    private void onConfirm(Context context, QuantityDTO quantityDTO, ISingleValueOperationCallback<QuantityDTO> dialogCallback){
        if(currentDTO.mtbAart.isFlagTracciabilita() && (quantityDTO.batchLot == null || quantityDTO.batchLot.get().trim().length() == 0)){

            showBatchLotErrorPrompt(context);

        } else if(quantityDTO.shouldAskDataScad.get() && (quantityDTO.batchLot == null || quantityDTO.batchLot.get().trim().length() == 0)){

            showBatchLotErrorPrompt(context);

        } else if(quantityDTO.shouldAskDataScad.get() && quantityDTO.expireDate == null){

            showExpireDateErrorPrompt(context);

        } else if(!quantityDTO.canOverflowQuantity && quantityDTO.qtaTot.get() > quantityDTO.maxQta.get()) {

            showQuantityOverflowErrorPrompt(context);

        } else if(quantityDTO.qtaCnf.get() <= 0 || quantityDTO.numCnf.get() <= 0 || quantityDTO.qtaTot.get() <= 0) {

            showQuantityErrorDialog(context);

        } else {

            dialogCallback.onResult(quantityDTO);
            currentAlert.dismiss();

        }
    }


    private void showQuantityErrorDialog(Context mContext){

        String errorMessage = mContext.getText(R.string.wrong_quantity_input_message).toString();

        DialogSimpleMessageHelper.makeErrorDialog(mContext, new SpannableString(Html.fromHtml(errorMessage)), null, null).show();
    }


    private void showQuantityOverflowErrorPrompt(Context mContext){

        String errorMessage = mContext.getText(R.string.quantity_overflow_error_message).toString();

        DialogSimpleMessageHelper.makeErrorDialog(mContext, new SpannableString(Html.fromHtml(errorMessage)), null, null).show();
    }


    private void showExpireDateErrorPrompt(Context mContext){

        String errorMessage = mContext.getText(R.string.expire_date_error_message).toString();

        DialogSimpleMessageHelper.makeErrorDialog(mContext, new SpannableString(Html.fromHtml(errorMessage)), null, null).show();
    }


    private void showBatchLotErrorPrompt(Context mContext){

        String errorMessage = mContext.getText(R.string.batch_lot_error_message).toString();

        DialogSimpleMessageHelper.makeErrorDialog(mContext, new SpannableString(Html.fromHtml(errorMessage)), null, null).show();
    }

}
