diff --git a/app/src/main/java/es/verdnatura/presentation/view/component/CustomDialogDynamicButtons.kt b/app/src/main/java/es/verdnatura/presentation/view/component/CustomDialogDynamicButtons.kt index 148ea20e..c391641c 100644 --- a/app/src/main/java/es/verdnatura/presentation/view/component/CustomDialogDynamicButtons.kt +++ b/app/src/main/java/es/verdnatura/presentation/view/component/CustomDialogDynamicButtons.kt @@ -14,15 +14,18 @@ import es.verdnatura.presentation.common.OnClickDynamic import es.verdnatura.presentation.common.setMargins import es.verdnatura.presentation.view.feature.articulo.model.AddressLoses -class CustomDialogDynamicButtons(context: Context, private val onClickDynamic: OnClickDynamic) : Dialog(context, R.style.DialogTheme) { +class CustomDialogDynamicButtons( + context: Context, + private val onClickDynamic: OnClickDynamic +) : Dialog(context, R.style.DialogTheme) { private var binding: ComponentCustomDynamicDialogBinding = ComponentCustomDynamicDialogBinding.inflate(layoutInflater) + private val buttonContainer = binding.layoutButtons init { setContentView(binding.root) - } fun setTitle(title: String): CustomDialogDynamicButtons { @@ -41,8 +44,9 @@ class CustomDialogDynamicButtons(context: Context, private val onClickDynamic: O fun createDynamicButtons(buttonInfoList: List) { + buttonContainer.removeAllViews() for (buttonInfo in buttonInfoList) { - setDynamicButton(buttonInfo.nickname,buttonInfo.id) + setDynamicButton(buttonInfo.address!!.nickname, buttonInfo.addressFk) } } @@ -77,14 +81,20 @@ class CustomDialogDynamicButtons(context: Context, private val onClickDynamic: O button.setBackgroundResource(typedArray.getResourceId(1, 0)) typedArray.recycle() + + buttonContainer.addView(button) + button.setOnClickListener { onClickDynamic.onClickDynamic(addressFk) + } - val buttonContainer = binding.layoutButtons - buttonContainer.addView(button) + } - +fun removeViewsDialog( +){ + buttonContainer.removeAllViews() +} } \ No newline at end of file diff --git a/app/src/main/java/es/verdnatura/presentation/view/component/CustomDialogInput.kt b/app/src/main/java/es/verdnatura/presentation/view/component/CustomDialogInput.kt index 7d5ad0e1..902fa68d 100644 --- a/app/src/main/java/es/verdnatura/presentation/view/component/CustomDialogInput.kt +++ b/app/src/main/java/es/verdnatura/presentation/view/component/CustomDialogInput.kt @@ -81,6 +81,8 @@ class CustomDialogInput(context: Context) : Dialog(context, R.style.DialogTheme) binding.customDialogButtonKo.text = text binding.customDialogButtonKo.setOnClickListener { onButtonClicked() } + // binding.customDialogButtonKo.setOnClickListener { dismiss() } + /*custom_dialog_button_ko.visibility = View.VISIBLE custom_dialog_button_ko.text = text custom_dialog_button_ko.setOnClickListener { onButtonClicked() }*/ diff --git a/app/src/main/java/es/verdnatura/presentation/view/component/CustomDialogList.kt b/app/src/main/java/es/verdnatura/presentation/view/component/CustomDialogList.kt index b0b689f1..7d3065cf 100644 --- a/app/src/main/java/es/verdnatura/presentation/view/component/CustomDialogList.kt +++ b/app/src/main/java/es/verdnatura/presentation/view/component/CustomDialogList.kt @@ -20,6 +20,7 @@ class CustomDialogList(context: Context) : Dialog(context, R.style.DialogTheme) init { setContentView(binding.root) + getEditText().requestFocus() //setContentView(R.layout.component_custom_list_dialog) } @@ -47,6 +48,7 @@ class CustomDialogList(context: Context) : Dialog(context, R.style.DialogTheme) fun setValue(value: String): CustomDialogList { binding.customDialogValue.setText(value) binding.textinputlayoutUsername.visibility = View.VISIBLE + /*custom_dialog_value.setText(value) textinputlayout_username.visibility = View.VISIBLE*/ return this @@ -107,8 +109,11 @@ class CustomDialogList(context: Context) : Dialog(context, R.style.DialogTheme) binding.customDialogButtonKo.text = text /*custom_dialog_button_ko.visibility = View.VISIBLE custom_dialog_button_ko.text = text*/ - binding.customDialogButtonKo.setOnClickListener { onButtonClicked() } -// custom_dialog_button_ko.setOnClickListener { onButtonClicked() } + binding.customDialogButtonKo.setOnClickListener { + onButtonClicked() + dismiss() + } + return this } @@ -136,6 +141,7 @@ class CustomDialogList(context: Context) : Dialog(context, R.style.DialogTheme) //custom_dialog_value.visibility = View.GONE return this } + fun hideDescription(): CustomDialogList { binding.customDialogDescription.visibility = View.GONE @@ -147,5 +153,4 @@ class CustomDialogList(context: Context) : Dialog(context, R.style.DialogTheme) return this } - } \ No newline at end of file diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/articulo/model/ItemProposal.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/articulo/model/ItemProposal.kt index c48cd473..c003333e 100644 --- a/app/src/main/java/es/verdnatura/presentation/view/feature/articulo/model/ItemProposal.kt +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/articulo/model/ItemProposal.kt @@ -4,7 +4,7 @@ class ItemProposal( var itemFk: Int? = null, var longName: String? = null, - var subName:String? = null, + var subName: String? = null, var tag5: String? = null, var value5: String? = null, var match5: String? = null, @@ -35,10 +35,26 @@ class AddressLosesList( ) data class AddressLoses( - val id: Int = 0, - val nickname: String = "", - val name: String = "", + val addressFk: Int = 0, + val address: Address? = null, var isError: Boolean = false, var errorMessage: String = "" ) +data class Address( + val nickname: String = "" +) + +//Tarea 5652 +/*data class AddressLosesTest( + val id: Int = 0, + val nickname: String = "", + val name: String = "", + val client: ClientTest? = null , + var isError: Boolean = false, + var errorMessage: String = "" +) +data class ClientTest( + val id: Int, + val name :String +)*/ diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/buffer/fragment/BufferLoadFragment.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/buffer/fragment/BufferLoadFragment.kt index c63a9cd5..5b5841cc 100644 --- a/app/src/main/java/es/verdnatura/presentation/view/feature/buffer/fragment/BufferLoadFragment.kt +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/buffer/fragment/BufferLoadFragment.kt @@ -2,7 +2,8 @@ package es.verdnatura.presentation.view.feature.buffer.fragment import android.media.MediaPlayer -import android.view.View.* +import android.view.View.GONE +import android.view.View.VISIBLE import android.view.inputmethod.EditorInfo import androidx.lifecycle.Observer import androidx.recyclerview.widget.LinearLayoutManager @@ -10,10 +11,10 @@ import es.verdnatura.R import es.verdnatura.databinding.FragmentBufferLoadexpeditionBinding import es.verdnatura.domain.toast import es.verdnatura.presentation.base.BaseFragment -import es.verdnatura.presentation.common.* +import es.verdnatura.presentation.common.OnSmartTagRowClickListener import es.verdnatura.presentation.view.component.CustomDialogList import es.verdnatura.presentation.view.feature.main.activity.MainActivity -import es.verdnatura.presentation.view.feature.smarttag.adapter.SmartTagAdapter +import es.verdnatura.presentation.view.feature.smarttag.adapter.BufferAdapter import es.verdnatura.presentation.view.feature.smarttag.model.SmartTag class BufferLoadFragment( @@ -26,7 +27,7 @@ class BufferLoadFragment( override fun getLayoutId(): Int = R.layout.fragment_buffer_loadexpedition private lateinit var customDialogList: CustomDialogList private var listTags: ArrayList = ArrayList() - private var tagsAdapter: SmartTagAdapter? = null + private var tagsAdapter: BufferAdapter? = null private var itemScaned: Int = 0 var mperror: MediaPlayer? = null var mpok: MediaPlayer? = null @@ -66,10 +67,10 @@ class BufferLoadFragment( } - private fun checkLoadExpedition(ExpeditionOrBuffer: Int) { + private fun checkLoadExpedition(expeditionOrBuffer: Int) { - listTags.add(SmartTag(ExpeditionOrBuffer.toString(), getTextScaned(listTags.size + 1) + ExpeditionOrBuffer)) - customDialogList.setTitle(getTextToPosition(listTags.size + 1)) + listTags.add(SmartTag(expeditionOrBuffer.toString(), getTextScaned(listTags.size + 1) + " $expeditionOrBuffer")) + customDialogList.setTitle(getString(R.string.scanBuffer)) tagsAdapter!!.notifyDataSetChanged() @@ -77,12 +78,12 @@ class BufferLoadFragment( if (listTags.size==2) { binding.splashProgress.visibility = VISIBLE viewModel.expeditionLoading_add( - vBufferFk = ExpeditionOrBuffer, + vBufferFk = expeditionOrBuffer, vExpeditionFk = listTags.first().code.toString().toInt()) } - itemScaned = ExpeditionOrBuffer + itemScaned = expeditionOrBuffer } @@ -107,8 +108,8 @@ class BufferLoadFragment( if (it.isError) { ma.messageWithSound(it.errorMessage,it.isError,true) } else { - // sergio: viene de la bbdd así - if (it.response.equals(getString(R.string.registerAdded))){ + + if (it.response == getString(R.string.registerAdded)){ it.response?.let { it1 -> ma.messageWithSound(it1,false,true) } }else{ @@ -129,19 +130,9 @@ class BufferLoadFragment( } - private fun getTextToPosition(TagsScaned: Int): String { + private fun getTextScaned(tagScaned: Int): String { - return getString(R.string.scanBuffer) - /* when (TagsScaned) { - 1 -> getString(R.string.scanBuffer) - else -> {getString(R.string.scanBuffer)} - }*/ - - } - - private fun getTextScaned(TagScaned: Int): String { - - return when (TagScaned) { + return when (tagScaned) { 1 -> getString(R.string.expedition) 2 -> getString(R.string.buffer) else -> { ""} @@ -157,13 +148,10 @@ class BufferLoadFragment( .setOkButton(getString(R.string.close)) { ma.hideKeyboard(customDialogList.getEditText()) - - listTags.clear() customDialogList.dismiss() requireActivity().onBackPressed() - }.setValue("").show() @@ -174,9 +162,7 @@ class BufferLoadFragment( if (actionId == EditorInfo.IME_ACTION_SEARCH || actionId == EditorInfo.IME_ACTION_DONE || actionId == 0 || actionId == 5 || actionId == 6) { if (!customDialogList.getValue().isNullOrEmpty()) { - checkLoadExpedition(customDialogList.getValue().toInt()) - } customDialogList.setValue("") ma.hideKeyboard(customDialogList.getEditText()) @@ -186,7 +172,7 @@ class BufferLoadFragment( } - tagsAdapter = SmartTagAdapter(listTags, object : OnSmartTagRowClickListener { + tagsAdapter = BufferAdapter(listTags, object : OnSmartTagRowClickListener { override fun OnSmartTagRowClickListener(item: SmartTag) { } }, showDelete = false) diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/category/ChangeCategoryFragment.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/category/ChangeCategoryFragment.kt deleted file mode 100644 index 444a78d1..00000000 --- a/app/src/main/java/es/verdnatura/presentation/view/feature/category/ChangeCategoryFragment.kt +++ /dev/null @@ -1,180 +0,0 @@ -package es.verdnatura.presentation.view.feature.category - -import android.view.View -import android.view.inputmethod.EditorInfo -import es.verdnatura.R -import es.verdnatura.databinding.FragmentGeneralBlackBinding -import es.verdnatura.domain.toast -import es.verdnatura.presentation.base.BaseFragment -import es.verdnatura.presentation.common.itemScanValue -import es.verdnatura.presentation.view.component.CustomDialogInput -import es.verdnatura.presentation.view.feature.packingHolland.fragment.PackingHollandViewModel - - - //Tarea #4940 - class ChangeCategoryFragment(var entrypoint: String) : - BaseFragment( - PackingHollandViewModel::class - ) { - - override fun getLayoutId(): Int = R.layout.fragment_general_black - private var itemScaned: Int = 0 - private lateinit var customDialogInput: CustomDialogInput - - companion object { - fun newInstance(entrypoint: String) = ChangeCategoryFragment(entrypoint = entrypoint) - } - - override fun init() { - - customDialogInput = CustomDialogInput(requireContext()) - binding.mainToolbar.toolbarTitle.text = entrypoint - binding.scanInput.hint = "Escanear item" - binding.splashProgress.visibility = View.GONE - binding.scanInput.visibility = View.VISIBLE - setEvents() - - super.init() - } - - private fun setEvents() { - - binding.mainToolbar.backButton.setOnClickListener { - requireActivity().onBackPressed() - } - - binding.scanInput.requestFocus() - binding.scanInput.setOnEditorActionListener { _, actionId, _ -> - if (actionId == EditorInfo.IME_ACTION_SEARCH || actionId == EditorInfo.IME_ACTION_DONE || actionId == 0 || actionId == 5) { - if (!binding.scanInput.text.isNullOrEmpty()) { - - try { - - binding.scanInput.setText( - itemScanValue( - binding.scanInput.text.toString(), - "buy", - "more" - ).toString() - ) - itemScaned = binding.scanInput.text.toString().toInt() - showQuantityPacking() - } catch (ex: Exception) { - ex.message!!.toast(requireActivity()) - } - - } - - binding.scanInput.setText("") - ma.hideKeyboard(binding.scanInput) - return@setOnEditorActionListener true - } - false - } - } - - override fun observeViewModel() { - with(viewModel) { - response.observe(viewLifecycleOwner) { - binding.splashProgress.visibility = View.GONE - if (it.isError) { - ma.messageWithSound(it.errorMessage, true, false) - } else { - showQuantityPacking() - } - - } - - } - } - - - private fun showQuantityPacking() { - - - customDialogInput.setTitle(getString(R.string.titleChangeCategory)) - customDialogInput.setDescription(getString(R.string.ubication) + itemScaned) - .setValue("") - .setOkButton(getString(R.string.modify)) { - - if (customDialogInput.getValue().isNotEmpty() - ) { - callPacking(customDialogInput.getValue()) - } - - - }.setKoButton(getString(R.string.cancel)) { - customDialogInput.dismiss() - }.show() - - //ma.hideKeyboard(customDialogInput.getEditText()) - - customDialogInput.getEditText().setOnEditorActionListener { _, actionId, _ -> - if (actionId == EditorInfo.IME_ACTION_SEARCH || actionId == EditorInfo.IME_ACTION_DONE || actionId == 0 || actionId == 5 || actionId == 6) { - - if (customDialogInput.getValue().isNotEmpty()) { - //callPacking(customDialogInput.getValue()) - getNewPrice(customDialogInput.getValue(), itemScaned, 5.51) - } - - return@setOnEditorActionListener true - } - false - } - - customDialogInput.setFocusText() - ma.hideKeyboard(customDialogInput.getEditText()) - } - - private fun getNewPrice(shelving:String,item:Int,price:Double) { - customDialogInput.setTitle(getString(R.string.titleChangeCategory)) - customDialogInput.setDescription(getString(R.string.itemChangePrice) + item + "-" + "Matrícula:"+shelving) - .setValue(price.toString()) - .setOkButton(getString(R.string.modify)) { - - if (customDialogInput.getValue().isNotEmpty() - ) { - callPacking(customDialogInput.getValue()) - } - - - }.setKoButton(getString(R.string.cancel)) { - customDialogInput.dismiss() - }.show() - - //ma.hideKeyboard(customDialogInput.getEditText()) - - customDialogInput.getEditText().setOnEditorActionListener { _, actionId, _ -> - if (actionId == EditorInfo.IME_ACTION_SEARCH || actionId == EditorInfo.IME_ACTION_DONE || actionId == 0 || actionId == 5 || actionId == 6) { - - if (customDialogInput.getValue().isNotEmpty()) { - //callPacking(customDialogInput.getValue()) - //getNewPrice(customDialogInput.getValue().toInt(), 5.51) - } - - return@setOnEditorActionListener true - } - false - } - - customDialogInput.setFocusText() - ma.hideKeyboard(customDialogInput.getEditText()) - - } - - private fun callPacking(value: String) { - try { - // binding.splashProgress.visibility = View.VISIBLE - /* viewModel.travel_updatePacking( - itemFk = shelvingScaned, - packingFk = value.toInt() - )*/ - - } catch (ex: Exception) { - getString(R.string.errorInput).toast(requireActivity()) - } - customDialogInput.setValue("") - } - } - - diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/claim/fragment/ClaimFragment.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/claim/fragment/ClaimFragment.kt index 0b356885..9ec9a570 100644 --- a/app/src/main/java/es/verdnatura/presentation/view/feature/claim/fragment/ClaimFragment.kt +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/claim/fragment/ClaimFragment.kt @@ -190,7 +190,6 @@ class ClaimFragment( if (actionId == EditorInfo.IME_ACTION_SEARCH || actionId == EditorInfo.IME_ACTION_DONE || actionId == 0 || actionId == 5 || actionId == 6) { if (!customDialogList.getValue().isEmpty()) { - //listClaims.add(GeneralItem(customDialogList.getValue(),customDialogList.getValue())) add_item(customDialogList.getValue()) if (listClaims.size > 1) { diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/collection/fragment/CollectionFragment.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/collection/fragment/CollectionFragment.kt index 5c9f6908..8161c06b 100644 --- a/app/src/main/java/es/verdnatura/presentation/view/feature/collection/fragment/CollectionFragment.kt +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/collection/fragment/CollectionFragment.kt @@ -382,7 +382,7 @@ class CollectionFragment( if (itemScanIsQr(binding.scanInput.text.toString())) { - var myQr = itemScanned(JSONObject(binding.scanInput.text.toString())) + var myQr = ItemScanned(JSONObject(binding.scanInput.text.toString())) when (myQr.table) { "saleGroup" -> { diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/collection/fragment/CollectionFragmentPicker.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/collection/fragment/CollectionFragmentPicker.kt index e867188a..7aeb2c1e 100644 --- a/app/src/main/java/es/verdnatura/presentation/view/feature/collection/fragment/CollectionFragmentPicker.kt +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/collection/fragment/CollectionFragmentPicker.kt @@ -380,7 +380,7 @@ class CollectionFragmentPicker( if (itemScanIsQr(binding.scanInput.text.toString())) { - var myQr = itemScanned(JSONObject(binding.scanInput.text.toString())) + var myQr = ItemScanned(JSONObject(binding.scanInput.text.toString())) when (myQr.table) { "saleGroup" -> { diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/collection/fragment/CollectionFragmentPickerNew.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/collection/fragment/CollectionFragmentPickerNew.kt index 07b1e0e0..59bbf845 100644 --- a/app/src/main/java/es/verdnatura/presentation/view/feature/collection/fragment/CollectionFragmentPickerNew.kt +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/collection/fragment/CollectionFragmentPickerNew.kt @@ -16,6 +16,7 @@ import android.view.View import android.view.WindowManager import android.view.inputmethod.EditorInfo import android.view.inputmethod.InputMethodManager +import android.widget.EditText import android.widget.ImageView import android.widget.Toast import androidx.annotation.RequiresApi @@ -53,7 +54,6 @@ class CollectionFragmentPickerNew( var type: String = SACADOR ) : BaseFragment(CollectionViewModel::class) { - private lateinit var dataMessageSalix: DataMessageSalix private var sales: List = listOf() private var salesParent: List = listOf() private var saleAdapter: SaleAdapterNew? = null @@ -122,32 +122,13 @@ class CollectionFragmentPickerNew( override fun onCreate(savedInstanceState: Bundle?) { - mperror = MediaPlayer.create((activity as MainActivity), R.raw.error) mpok = MediaPlayer.create((activity as MainActivity), R.raw.ok) - viewModel.collectionTicketGetSalix( collection.collectionFk, print = false ) - - /* if (collection.tickets.isEmpty()) { - viewModel.collectionTicketGet( - collection.collectionFk, - getDataInt(SECTORFK), - print = "0", - type - ) - - } else { - viewModel.collectionTicketGetLocal( - collection.collectionFk, - getDataInt(SECTORFK), - print = "0", - type - ) - }*/ super.onCreate(savedInstanceState) } @@ -250,12 +231,6 @@ class CollectionFragmentPickerNew( collection.collectionFk, print = false ) - /* viewModel.collectionTicketGet( - collection.collectionFk, - getDataInt(SECTORFK), - print = "0", - type - )*/ } @@ -267,6 +242,8 @@ class CollectionFragmentPickerNew( if (sales[indice].saleGroupFk != null && sales[indice].saleGroupFk == saleGroupScanned.toInt()) { println("Sacador saleGroup ${sales[indice].itemShelvingSaleFk}") + + //Sera el nuevo procedimiento confirmarSAleGroup viewModel.confirmItemShelvingReserved( sales[indice].itemShelvingSaleFk, sales[indice].reservedQuantity, @@ -276,7 +253,6 @@ class CollectionFragmentPickerNew( saleGroupScanned.toInt() )*/ return true - mpok!!.start() } @@ -376,7 +352,7 @@ class CollectionFragmentPickerNew( if (itemScanIsQr(binding.scanInput.text.toString())) { - var myQr = itemScanned(JSONObject(binding.scanInput.text.toString())) + var myQr = ItemScanned(JSONObject(binding.scanInput.text.toString())) when (myQr.table) { "saleGroup" -> { @@ -617,11 +593,11 @@ class CollectionFragmentPickerNew( ) } }) - placementSuppleyList.observe(viewLifecycleOwner, Observer { - binding.splashProgress.visibility = View.GONE - if (!goBack) printShelvingResult(it) - goBack = false - }) + /* placementSuppleyList.observe(viewLifecycleOwner, Observer { + binding.splashProgress.visibility = View.GONE + if (!goBack) printShelvingResult(it) + goBack = false + })*/ item.observe(viewLifecycleOwner, Observer { binding.splashProgress.visibility = View.GONE @@ -646,12 +622,7 @@ class CollectionFragmentPickerNew( if (!goBack) { - /* sendSalixMessage( - item = dataMessageSalix.item, - ticketFk = dataMessageSalix.ticket, - quantity = dataMessageSalix.quantity, - salePerson = dataMessageSalix.personSale - )*/ + // TODO()→ LLAMAR Al procedimiento bySale o viewModel.collectionTicketGet( collection.collectionFk, @@ -660,7 +631,7 @@ class CollectionFragmentPickerNew( type ) - // //Log.i("VERDNATURA:","La collection es ${collection.collectionFk}") + } } // } @@ -739,7 +710,6 @@ class CollectionFragmentPickerNew( responseSaleMistakeAdd.observe(viewLifecycleOwner, Observer { - if (!goBack) { if (it.isError) { ma.messageWithSound(it.errorMessage, isError = true, true) @@ -776,15 +746,6 @@ class CollectionFragmentPickerNew( goMistakeBack = true }) - - mistakeList.observe(viewLifecycleOwner, Observer { - binding.splashProgress.visibility = View.GONE - /*sergio:se quita y se pone esta comprobacion porque si no aparece de nuevo otra vez al volver atrás */ - - if (!goMistakeBack) - showMistakeList(it.list) - goMistakeBack = true - }) //sergio: para si hay algun ticket por revisar antes de parkinear responseCollectionUnchecked.observe(viewLifecycleOwner, Observer { @@ -815,7 +776,7 @@ class CollectionFragmentPickerNew( customDialog.show() } else { viewModel.parking( - ticketFk = tickets[0], + ticketFk = tickets[0].toInt(), parking = ticketScanTxt ) } @@ -1000,14 +961,9 @@ class CollectionFragmentPickerNew( } } - println("Sacador esta vacia las sales: ${salesList.isEmpty()}") - for (s in salesList) { - // println("Sacador la saleeeee es ${s.saleFk} cantidad: ${s.saleQuantity} y ${s.pickingOrder}") - } + sales = salesList.sortedWith(compareBy { it.pickingOrder }.thenBy { it.itemFk }) - for (s in sales) { - // println("Sacador la sale es ${s.saleFk} cantidad: ${s.saleQuantity} y ${s.pickingOrder}") - } + //quitar comentarios FALTA AGRUPAR LAS PREVIAS myGroupList = groupSaleGroup(salesList).sortedWith(compareBy { it.pickingOrder }.thenBy { it.itemFk }) @@ -1037,8 +993,6 @@ class CollectionFragmentPickerNew( }, object : OnSaleClickSaleListener { override fun onSaleClick(mysale: Sale) { - println("Sacador onSaleClickListener") - sales.forEachIndexed { index, sale -> println("Sacador la sale es ${sale.saleFk}") @@ -1066,11 +1020,6 @@ class CollectionFragmentPickerNew( }, object : OnMistakeClickListener { override fun onMistakeClickListener(sale: SaleVO) { - binding.splashProgress.visibility = View.VISIBLE - viewModel.mistakeType() - mistakeSale = sale - goMistakeBack = false - } }, object : OnPackingClickSaleListener { @@ -1086,9 +1035,6 @@ class CollectionFragmentPickerNew( }, object : OnTicketClickSaleListener { override fun onTicketClickListener(sale: Sale) { - if (type == CONTROLADOR) { - //var ticketFk = sale.ticketFk - var entryPoint = Gson().toJson( mutableMapOf( "entryPoint" to sale.ticketFk, @@ -1100,7 +1046,6 @@ class CollectionFragmentPickerNew( title = getString(R.string.titleWebViewer), ), entryPoint = entryPoint ) - } } }, type = type ) @@ -1113,7 +1058,6 @@ class CollectionFragmentPickerNew( setTotalLines() setStoredPosition(true) setScrollListener(lm!!) - printObservations(observations) } @@ -1161,7 +1105,7 @@ class CollectionFragmentPickerNew( //Si no es previa ni está cogiendo nada se comprueba si es un parking if (txtscan.contains("-")) { viewModel.parking( - ticketFk = collection.collectionFk.toString(), + ticketFk = collection.collectionFk, parking = txtscan ) } else { @@ -1170,69 +1114,7 @@ class CollectionFragmentPickerNew( } } - /* - var index = 0 - var isBreak = false - var isOk = false - goBack = false - goBack2 = false - if (type == SACADOR) { - isOk = markPrevia(txtscan) - for (saleVO in sales) { - if (isOk) break - - if (saleVO.semaphore != "2" && saleVO.semaphore != "1") { - //if (saleVO.isPrepared != "1" && saleVO.isPreviousPrepared != "1") { - //2- Por carro - if (saleVO.placements != null) { - var shelvingIndex = 0 - for (placementVO in saleVO.placements) { - // para comprobar si es igual a una matricula - if (placementVO.shelving != null && placementVO.visible != null && txtscan.uppercase() == placementVO.shelving.uppercase() && placementVO.visible != "(0)") { - if (mpok != null) mpok!!.start() - isOk = true - //////Log.i("VERDNATURA:","encontrado producto") - showShelving(index, shelvingIndex) - //nuevo - var mySale = sales[index].saleFk - for (indice in myGroupList.indices) { - - if (!myGroupList[indice].isParent && myGroupList[indice].saleFk == mySale) { - d("VERDNATURA::", "la pos del index de la sale es" + indice) - storedBackPosition = indice - // setListPosition(storedBackPosition,false) - } - } - - isBreak = true - break - } - shelvingIndex += 1 - } - if (isBreak) break - } - } - index += 1 - } - if (!isOk) { - if (txtscan.contains("-")) { - if (tickets.size > 0) { - - - viewModel.parking( - ticketFk = tickets[0], - parking = txtscan - ) - - } - } else { - if (mperror != null) mperror!!.start() - } - - } - } - */ } private fun findSale(txtscan: String, position: Int, sale: Sale) { @@ -1243,16 +1125,16 @@ class CollectionFragmentPickerNew( if (sale.code!!.uppercase() == txtscan.uppercase()) { mpok!!.start() - //showShelving(position) + showShelving(position) - binding.splashProgress.visibility = View.VISIBLE + /* binding.splashProgress.visibility = View.VISIBLE viewModel.itemPlacementSupplyAiming( itemFk = sales[position].itemFk, quantity = sales[position].reservedQuantity, shelvingFk = sales[position].code!! - ) + )*/ /* viewModel.confirmItemShelvingReserved( sale.itemShelvingSaleFk, sale.reservedQuantity!!, @@ -1282,7 +1164,7 @@ class CollectionFragmentPickerNew( //nuevo tema agrupacion sales checkStateParent() - // var mySale = sales[position].saleFk Ordenar setPosition + // var mySale = sales[position].saleFk Ordenar setPosition var mySale = sales[position].itemShelvingSaleFk for (indice in myGroupList.indices) { if (!myGroupList[indice].isParent && myGroupList[indice].itemShelvingSaleFk == mySale) { @@ -1369,7 +1251,7 @@ class CollectionFragmentPickerNew( private fun setListPosition(position: Int, isFromBack: Boolean) { d("VERDNATURA::", "Vamos a la pos" + storedBackPosition) - if (storedPosition == 0 && storedBackPosition == 0) { // se inicia lista, se busca porqué item vamos. + if (storedPosition == 0 && storedBackPosition == 0) { // se inicia lista, se busca porqué item vamos. for (indice in myGroupList.indices) { if (myGroupList[indice].isPicked == 0) { //storedPosition = indice @@ -1474,56 +1356,24 @@ class CollectionFragmentPickerNew( //SHELVINGS private fun showShelving(position: Int) { storedPosition = position - binding.splashProgress.visibility = View.VISIBLE - try { - var quantityGet = - (sales[position].reservedQuantity!!) - - viewModel.itemPlacementSupplyAiming( - itemFk = sales[position].itemFk, - quantity = quantityGet, - shelvingFk = sales[position].code!! - - ) - } catch (e: Exception) { - } + printShelvingResult(position) } - @RequiresApi(Build.VERSION_CODES.O) - private fun printShelvingResult(placementSupplyListVO: PlacementSupplyListVO) { + private fun printShelvingResult(pos: Int) { customDialogList.getEditTextTwo().inputType = InputType.TYPE_CLASS_TEXT + customDialogList.getEditText().setRawInputType(InputType.TYPE_CLASS_NUMBER) + + var shelving = myGroupList[pos].code + var item = myGroupList[pos].itemFk + var longName = myGroupList[pos].longName + var totalReserved = myGroupList[pos].reservedQuantity + var itemShelvingFk = myGroupList[pos].itemShelvingSaleFk - var shelving = "" - var item = "" - var longName = "" - var total = "0" - var itemShelvingFk = 0 - if (!placementSupplyListVO.list.isEmpty()) { - var placement: PlacementSupplyVO? = null - placementSupplyListVO.list.forEach { placementVO -> - if (placementVO.stock != "0" && placement == null) - placement = placementVO - } - if (placement != null) { - shelving = placement!!.shelving - item = placement!!.itemFk - longName = placement!!.longName - total = placement!!.total - itemShelvingFk = placement!!.itemShelvingFk - } - } - listPlacementSupply = ArrayList() - placementSupplyListVO.list.forEach { - if (it.stock != "0") - listPlacementSupply.add(BarcodeVO(code = it.proposal)) - //////Log.i("VERDNATURA:","Array de placementsupply") - } try { // Log.i("VERDNATURA:","Pulso COGER-1") - // customDialogList.getEditTextTwo().setRawInputType(InputType.TYPE_CLASS_NUMBER) - customDialogList.setTitle("$shelving($item) $total de $longName").setOkButton( + customDialogList.setTitle("$shelving($item) $totalReserved de $longName").setOkButton( getString( R.string.take ) @@ -1539,10 +1389,21 @@ class CollectionFragmentPickerNew( "more" ).toString() ) + var quantityToReserve = customDialogList.getValue().toInt() - if (isNumber(customDialogList.getValue()) && isNumber(total) && customDialogList.getValue() - .toInt() > total.toInt() + if (quantityToReserve > totalReserved) { + customDialogList.setValue(totalReserved.toString()) + getString(R.string.quantityHigh).toast(requireContext()) + } else { + showQuestionUbicationEmpty(pos) + } + + + + if (isNumber(customDialogList.getValue()) && customDialogList.getValue() + .toInt() > totalReserved ) { + customDialogList.setValue(totalReserved.toString()) getString(R.string.quantityHigh).toast(requireContext()) } else if (isNumber(customDialogList.getValue())) { originalItemScan = customDialogList.getValueTwo().toLong() @@ -1602,7 +1463,7 @@ class CollectionFragmentPickerNew( scanRequest() hideKeyboards() customDialogList.dismiss() - }.setHintValue(getString(R.string.quantitySelect)).setValue(total) + }.setHintValue(getString(R.string.quantitySelect)).setValue(totalReserved.toString()) .setHintValueTwo(getString(R.string.scanItem)) .setValueTwo("").show() } catch (e: Exception) { @@ -1646,7 +1507,7 @@ class CollectionFragmentPickerNew( if (customDialogList.getValueTwo().isNotEmpty()) { try { if (isNumber(customDialogList.getValue()) && customDialogList.getValue() - .toInt() > total.toInt() + .toInt() > totalReserved.toInt() ) { getString(R.string.quantityHigh).toast(requireContext()) } else if (isNumber(customDialogList.getValue())) { @@ -1696,13 +1557,13 @@ class CollectionFragmentPickerNew( listPlacementSupply, object : OnBarcodeRowClickListener { override fun onBarcodeRowClickListener(item: BarcodeVO) { - placementSupplyListVO.list.forEach { + /*placementSupplyListVO.list.forEach { if (it.proposal == item.code) { customDialogList.setValue(it.total) total = it.total itemShelvingFk = it.itemShelvingFk } - } + }*/ } }, showDelete = false @@ -1774,20 +1635,20 @@ class CollectionFragmentPickerNew( } - private fun showQuestionUbicationEmpty(position: Int) { + private fun showQuestionUbicationEmpty(position: Int, quantity: Int = 0) { customDialogThreeButtonsQuantity - .setTitle("Cambio de cantidad a 0") + .setTitle("Cambio de cantidad a $quantity") .setDescription("¿Hay unidades del artículo ${sales[position].itemFk} en el carro escaneado?") .setValue("") .setCustomDialogValue(View.GONE) customDialogThreeButtonsQuantity.setOkButtonAdd("SI") { scanRequest() customDialogThreeButtonsQuantity.dismiss() - markLine(storedPosition, 0, false) + markLine(storedPosition, quantity, false) }.setOkButtonTwo("NO") { scanRequest() customDialogThreeButtonsQuantity.dismiss() - markLine(storedPosition, 0, true) + markLine(storedPosition, quantity, true) } .setKoButton("CANCELAR") { scanRequest() @@ -1975,9 +1836,6 @@ class CollectionFragmentPickerNew( getString(R.string.Coleccióncompleta).toast(this.context, Toast.LENGTH_SHORT) saleAdapter!!.notifyDataSetChanged() - if (!goBack) - ticketCollection_setUsedShelves() - goBack = false changeTicketState() @@ -1986,131 +1844,6 @@ class CollectionFragmentPickerNew( } - private fun ticketCollection_setUsedShelves() { - - - if (type.equals("CHECKER") && (isMarking && (getData(SECTORDESCRIP).uppercase() != getString( - R.string.sectorALGEMESI - ) && getData(SECTORDESCRIP).uppercase() != getString( - R.string.sectorALGEMESINEW - ) - )) - ) { - - - customDialogInput.setTitle(getString(R.string.shlevesNumber)) - .setDescription(getString(R.string.shlevesNumberTicket)) - .setOkButton(getString(R.string.accept)) { - if (!customDialogInput.getValue().isNullOrEmpty()) { - - binding.splashProgress.visibility = View.VISIBLE - viewModel.ticketCollection_setUsedShelves( - ticketFk = collection.collectionFk, - usedShelves = customDialogInput.getValue().toInt() - ) - hideKeyboards() - // showKeyboards() - - } - customDialogInput.setValue("") - customDialogInput.dismiss() - showKeyboards() - }.setKoButton(getString(R.string.cancel)) { - customDialogInput.dismiss() - showKeyboards() - }.setValue("").show() - - customDialogInput.setInputText(InputType.TYPE_CLASS_NUMBER) - // customDialogInput.currentFocus - customDialogInput.setFocusText() - showKeyboards() - - customDialogInput.getEditText().setOnEditorActionListener { v, actionId, event -> - if (actionId == EditorInfo.IME_ACTION_SEARCH || actionId == EditorInfo.IME_ACTION_DONE || actionId == 0) { - if (!customDialogInput.getValue().isNullOrEmpty()) { - - binding.splashProgress.visibility = View.VISIBLE - viewModel.ticketCollection_setUsedShelves( - ticketFk = collection.collectionFk, - usedShelves = customDialogInput.getValue().toInt() - ) - hideKeyboards() - } - customDialogInput.setValue("") - scanRequest() - customDialogInput.dismiss() - hideKeyboards() - return@setOnEditorActionListener true - } - false - } - - - } - - - } - - private fun item_updatePackingShelve(itemFk: Int) { - - - isMarking = false - customDialogInput.setTitle(getString(R.string.packetNumberShelves)) - .setDescription(getString(R.string.packetIndicate)) - .setOkButton(getString(R.string.accept)) { - if (!customDialogInput.getValue().isNullOrEmpty()) { - - binding.splashProgress.visibility = View.VISIBLE - viewModel.item_updatePackingShelve( - vSelf = itemFk, - vPacking = customDialogInput.getValue().toInt() - ) - hideKeyboards() - //showKeyboards() - - } - customDialogInput.setValue("") - customDialogInput.dismiss() - // hideKeyboards() - showKeyboards() - }.setKoButton(getString(R.string.cancel)) { - - customDialogInput.dismiss() - //hideKeyboards() - showKeyboards() - }.setValue("").show() - - customDialogInput.setInputText(InputType.TYPE_CLASS_NUMBER) - customDialogInput.currentFocus - customDialogInput.setFocusText() - showKeyboards() - - customDialogInput.getEditText().setOnEditorActionListener { v, actionId, event -> - if (actionId == EditorInfo.IME_ACTION_SEARCH || actionId == EditorInfo.IME_ACTION_DONE || actionId == 0) { - if (!customDialogInput.getValue().isNullOrEmpty()) { - - binding.splashProgress.visibility = View.VISIBLE - viewModel.item_updatePackingShelve( - vSelf = itemFk, - vPacking = customDialogInput.getValue().toInt() - ) - - } - customDialogInput.setValue("") - scanRequest() - customDialogInput.dismiss() - hideKeyboards() - return@setOnEditorActionListener true - } - false - } - - } - - private fun showBottomNavigation(visibilitiy: Int) { - //requireActivity().main_bottom_navigation.visibility = visibilitiy - } - //FALTAS / BASURA / SPLIT @@ -2124,13 +1857,13 @@ class CollectionFragmentPickerNew( if (customDialogThreeButtons.getValue().toInt() == 0) { showQuestionUbicationEmpty(position) } else { - println("Sacador reservedQuantity ${sales[position].reservedQuantity}") - println("Sacador item ${sales[position].itemFk}") + println("Sacador reservedQuantity ${myGroupList[position].reservedQuantity}") + println("Sacador item ${myGroupList[position].itemFk}") println("Sacador cantidad introducida ${customDialogThreeButtons.getValue()}") if (customDialogThreeButtons.getValue() - .toInt() != sales[position].reservedQuantity + .toInt() != myGroupList[position].reservedQuantity ) { markLine(position, customDialogThreeButtons.getValue().toInt(), false) } else { @@ -2191,33 +1924,36 @@ class CollectionFragmentPickerNew( //OTROS private fun showScanner(index: Int, sale: Sale) { customDialogInput.getEditText().inputType = InputType.TYPE_CLASS_TEXT - customDialogInput.setTitle("" + sale.itemFk) + customDialogInput.setTitle(""+sale.itemFk) .setDescription(getString(R.string.scanWagonForItem)) .setOkButton(getString(R.string.accept)) { if (!customDialogInput.getValue().isNullOrEmpty()) { findSale(customDialogInput.getValue(), index, sale) } - customDialogInput.setValue("") - scanRequest() - customDialogInput.dismiss() - hideKeyboards() + closeCustomDialog(binding.scanInput, customDialogInput) }.setKoButton(getString(R.string.cancel)) { - customDialogInput.dismiss() + closeCustomDialog(binding.scanInput, customDialogInput) }.setValue("").show() - customDialogInput.getEditText().requestFocus() + + customDialogInput.getEditText().setOnEditorActionListener { v, actionId, event -> if (actionId == EditorInfo.IME_ACTION_SEARCH || actionId == EditorInfo.IME_ACTION_DONE || actionId == 0) { if (!customDialogInput.getValue().isNullOrEmpty()) { findSale(customDialogInput.getValue(), index, sale) } - customDialogInput.setValue("") - scanRequest() - customDialogInput.dismiss() - hideKeyboards() - return@setOnEditorActionListener true + closeCustomDialog(binding.scanInput, customDialogInput) + return@setOnEditorActionListener false } false } + customDialogInput.getEditText().requestFocus() + } + + private fun closeCustomDialog(scanInput: EditText, customDialogInput: CustomDialogInput) { + requireContext().hideKeyboard(customDialogInput.getEditText()) + scanInput.requestFocus() + customDialogInput.dismiss() + scanInput.requestFocus() } @@ -2261,52 +1997,6 @@ class CollectionFragmentPickerNew( } - private fun showMistakeList(list: List) { - - customDialogInput.dismiss() - binding.splashProgress.visibility = View.GONE - listPlacementSupply = ArrayList() - list.forEach { - listPlacementSupply.add(BarcodeVO(code = it.description)) - } - - customDialogList.setTitle(getString(R.string.errorCause)) - customDialogList.hideTextInput() - .setKoButton(getString(R.string.cancel)) { - scanRequest() - hideKeyboards() - listPlacementSupply.clear() - customDialogList.dismiss() - - }.show() - - - placementSupplyAdapter = - BarcodeAdapter(listPlacementSupply, object : OnBarcodeRowClickListener { - override fun onBarcodeRowClickListener(item: BarcodeVO) { - list.forEach { - if (it.description == item.code) { - - viewModel.saleMistakeAdd( - saleFk = mistakeSale?.saleFk!!, - typeFk = it.id - ) - - - getString(R.string.errorRegistered).toast(requireContext()) - customDialogList.dismiss() - } - } - - } - }, showDelete = false) - - customDialogList.getRecyclerView().adapter = placementSupplyAdapter - - customDialogList.getRecyclerView().layoutManager = - LinearLayoutManager(requireContext(), LinearLayoutManager.VERTICAL, false) - } - fun isNumber(num: String): Boolean { var numberInt = 0 try { diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/collection/fragment/CollectionFragmentPreChecker.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/collection/fragment/CollectionFragmentPreChecker.kt index 24aa3496..d682ddb3 100644 --- a/app/src/main/java/es/verdnatura/presentation/view/feature/collection/fragment/CollectionFragmentPreChecker.kt +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/collection/fragment/CollectionFragmentPreChecker.kt @@ -382,7 +382,7 @@ class CollectionFragmentPreChecker( if (itemScanIsQr(binding.scanInput.text.toString())) { - var myQr = itemScanned(JSONObject(binding.scanInput.text.toString())) + var myQr = ItemScanned(JSONObject(binding.scanInput.text.toString())) when (myQr.table) { "saleGroup" -> { @@ -393,6 +393,7 @@ class CollectionFragmentPreChecker( findSale(binding.scanInput.text.toString()) } } + "buy" -> binding.scanInput.setText(myQr.more) "parking" -> { @@ -403,7 +404,7 @@ class CollectionFragmentPreChecker( if (at.saleGroupFk != saleGroup) { viewModel.parking( ticketFk = at.saleGroupFk.toInt(), - parking = myQr.more + parking = myQr.more!! ) saleGroup = at.saleGroupFk } @@ -626,12 +627,12 @@ class CollectionFragmentPreChecker( if (!goBack) { - /* sendSalixMessage( - item = dataMessageSalix.item, - ticketFk = dataMessageSalix.ticket, - quantity = dataMessageSalix.quantity, - salePerson = dataMessageSalix.personSale - )*/ + /* sendSalixMessage( + item = dataMessageSalix.item, + ticketFk = dataMessageSalix.ticket, + quantity = dataMessageSalix.quantity, + salePerson = dataMessageSalix.personSale + )*/ viewModel.collectionTicketGet( collection.collectionFk, getDataInt(SECTORFK), @@ -1053,12 +1054,12 @@ class CollectionFragmentPreChecker( markLine(positionCollectionSplit, type) saleAdapter!!.notifyDataSetChanged() - /* val ticket = - "[" + sales[positionCollectionSplit].ticketFk + "](https://salix.verdnatura.es/#!/ticket/" + sales[positionCollectionSplit].ticketFk + "/summary)" - val message = - getString(R.string.splitSent) + sales[positionCollectionSplit].itemFk + getString(R.string.fromTicket) + ticket + /* val ticket = + "[" + sales[positionCollectionSplit].ticketFk + "](https://salix.verdnatura.es/#!/ticket/" + sales[positionCollectionSplit].ticketFk + "/summary)" + val message = + getString(R.string.splitSent) + sales[positionCollectionSplit].itemFk + getString(R.string.fromTicket) + ticket - sendSalixMessageNew(message, sales[positionCollectionSplit].salePersonFk)*/ + sendSalixMessageNew(message, sales[positionCollectionSplit].salePersonFk)*/ } @@ -1089,22 +1090,22 @@ class CollectionFragmentPreChecker( return salePerson } - /* private fun sendSalixMessage( - item: String, - ticketFk: Int, - quantity: String, - salePerson: String - ) { - val ticket = - "[" + ticketFk + "](https://salix.verdnatura.es/#!/ticket/" + ticketFk + "/summary)" - val message = - getString(R.string.itemAdded) + item + getString(R.string.with) + quantity + getString(R.string.unityTicket) + ticket + /* private fun sendSalixMessage( + item: String, + ticketFk: Int, + quantity: String, + salePerson: String + ) { + val ticket = + "[" + ticketFk + "](https://salix.verdnatura.es/#!/ticket/" + ticketFk + "/summary)" + val message = + getString(R.string.itemAdded) + item + getString(R.string.with) + quantity + getString(R.string.unityTicket) + ticket - viewModel.sendChekingPresence( - workerId = salePerson, - message = message - ) - }*/ + viewModel.sendChekingPresence( + workerId = salePerson, + message = message + ) + }*/ //CREATE LIST private fun createCollectionList() { @@ -1502,19 +1503,19 @@ class CollectionFragmentPreChecker( if (sales[position].isPrepared == "1") { sales[position].pickedQuantity = sales[position].quantity!! } - // checkStateParent() + // checkStateParent() } else if (type == CONTROLADOR) { sales[position].isControlled = if (sales[position].isControlled == "1") "0" else "1" //En primera instancia coge el primer elemento hijo para realizar la copia y según se va interactuando con las sales ya se actualiza el // estado del padre - // checkStateParent() + // checkStateParent() } if (type == PRECHECKER) { sales[position].isPreControlled = if (sales[position].isPreControlled == "1") "0" else "1" - // checkStateParent() + // checkStateParent() } @@ -2277,48 +2278,20 @@ class CollectionFragmentPreChecker( customDialogInput.setTitle(getString(R.string.shlevesNumber)) .setDescription(getString(R.string.shlevesNumberTicket)) .setOkButton(getString(R.string.accept)) { - if (!customDialogInput.getValue().isNullOrEmpty()) { - - binding.splashProgress.visibility = VISIBLE - viewModel.ticketCollection_setUsedShelves( - ticketFk = collection.collectionFk, - usedShelves = customDialogInput.getValue().toInt() - ) - hideKeyboards() - // showKeyboards() - - } - customDialogInput.setValue("") - customDialogInput.dismiss() - showKeyboards() - //hideKeyboards() - //showKeyboards() + customDialogSetUsed() }.setKoButton(getString(R.string.cancel)) { customDialogInput.dismiss() - // hideKeyboards() + showKeyboards() }.setValue("").show() customDialogInput.setInputText(TYPE_CLASS_NUMBER) - // customDialogInput.currentFocus customDialogInput.setFocusText() showKeyboards() customDialogInput.getEditText().setOnEditorActionListener { v, actionId, event -> if (actionId == EditorInfo.IME_ACTION_SEARCH || actionId == EditorInfo.IME_ACTION_DONE || actionId == 0) { - if (!customDialogInput.getValue().isNullOrEmpty()) { - - binding.splashProgress.visibility = VISIBLE - viewModel.ticketCollection_setUsedShelves( - ticketFk = collection.collectionFk, - usedShelves = customDialogInput.getValue().toInt() - ) - hideKeyboards() - } - customDialogInput.setValue("") - scanRequest() - customDialogInput.dismiss() - hideKeyboards() + customDialogSetUsed() return@setOnEditorActionListener true } false @@ -2330,6 +2303,22 @@ class CollectionFragmentPreChecker( } + private fun customDialogSetUsed() { + if (!customDialogInput.getValue().isNullOrEmpty()) { + + binding.splashProgress.visibility = VISIBLE + viewModel.ticketCollection_setUsedShelves( + ticketFk = collection.collectionFk, + usedShelves = customDialogInput.getValue().toInt() + ) + hideKeyboards() + } + customDialogInput.setValue("") + scanRequest() + customDialogInput.dismiss() + hideKeyboards() + } + private fun item_updatePackingShelve(itemFk: Int) { @@ -2337,25 +2326,11 @@ class CollectionFragmentPreChecker( customDialogInput.setTitle(getString(R.string.packetNumberShelves)) .setDescription(getString(R.string.packetIndicate)) .setOkButton(getString(R.string.accept)) { - if (!customDialogInput.getValue().isNullOrEmpty()) { + customDialogInputPacking(itemFk) - binding.splashProgress.visibility = VISIBLE - viewModel.item_updatePackingShelve( - vSelf = itemFk, - vPacking = customDialogInput.getValue().toInt() - ) - hideKeyboards() - //showKeyboards() - - } - customDialogInput.setValue("") - customDialogInput.dismiss() - // hideKeyboards() - showKeyboards() }.setKoButton(getString(R.string.cancel)) { customDialogInput.dismiss() - //hideKeyboards() showKeyboards() }.setValue("").show() @@ -2366,19 +2341,7 @@ class CollectionFragmentPreChecker( customDialogInput.getEditText().setOnEditorActionListener { v, actionId, event -> if (actionId == EditorInfo.IME_ACTION_SEARCH || actionId == EditorInfo.IME_ACTION_DONE || actionId == 0) { - if (!customDialogInput.getValue().isNullOrEmpty()) { - - binding.splashProgress.visibility = VISIBLE - viewModel.item_updatePackingShelve( - vSelf = itemFk, - vPacking = customDialogInput.getValue().toInt() - ) - - } - customDialogInput.setValue("") - scanRequest() - customDialogInput.dismiss() - hideKeyboards() + customDialogInputPacking(itemFk) return@setOnEditorActionListener true } false @@ -2386,8 +2349,20 @@ class CollectionFragmentPreChecker( } - private fun showBottomNavigation(visibilitiy: Int) { - //requireActivity().main_bottom_navigation.visibility = visibilitiy + private fun customDialogInputPacking(itemFk: Int) { + if (!customDialogInput.getValue().isNullOrEmpty()) { + + binding.splashProgress.visibility = VISIBLE + viewModel.item_updatePackingShelve( + vSelf = itemFk, + vPacking = customDialogInput.getValue().toInt() + ) + + } + customDialogInput.setValue("") + scanRequest() + customDialogInput.dismiss() + hideKeyboards() } //FALTAS / BASURA / SPLIT @@ -2501,6 +2476,7 @@ class CollectionFragmentPreChecker( sales[positionIncreaseQuantity].originalQuantity = quantityIncrease } + private fun increaseQuantity(position: Int, quantity: Int) { positionIncreaseQuantity = position quantityIncrease = quantity @@ -2548,26 +2524,14 @@ class CollectionFragmentPreChecker( customDialogInput.setTitle("" + sale.itemFk) .setDescription(getString(R.string.scanWagonForItem)) .setOkButton(getString(R.string.accept)) { - if (!customDialogInput.getValue().isNullOrEmpty()) { - findSale(customDialogInput.getValue(), index) - } - customDialogInput.setValue("") - scanRequest() - customDialogInput.dismiss() - hideKeyboards() + customDialogActionFind(index) }.setKoButton(getString(R.string.cancel)) { customDialogInput.dismiss() }.setValue("").show() customDialogInput.getEditText().requestFocus() customDialogInput.getEditText().setOnEditorActionListener { v, actionId, event -> if (actionId == EditorInfo.IME_ACTION_SEARCH || actionId == EditorInfo.IME_ACTION_DONE || actionId == 0) { - if (!customDialogInput.getValue().isNullOrEmpty()) { - findSale(customDialogInput.getValue(), index) - } - customDialogInput.setValue("") - scanRequest() - customDialogInput.dismiss() - hideKeyboards() + customDialogActionFind(index) return@setOnEditorActionListener true } false @@ -2575,6 +2539,17 @@ class CollectionFragmentPreChecker( } + private fun customDialogActionFind(index: Int) { + + if (!customDialogInput.getValue().isNullOrEmpty()) { + findSale(customDialogInput.getValue(), index) + } + customDialogInput.setValue("") + scanRequest() + customDialogInput.dismiss() + hideKeyboards() + } + private fun showErrorMessage(text: String) { customDialog.setTitle(getString(R.string.errorMarkLine)).setDescription(text) .setKoButton(getString(R.string.close)) { diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/controlador/fragment/ControladorFragment.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/controlador/fragment/ControladorFragment.kt index 7d9eafca..2ef76517 100644 --- a/app/src/main/java/es/verdnatura/presentation/view/feature/controlador/fragment/ControladorFragment.kt +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/controlador/fragment/ControladorFragment.kt @@ -19,7 +19,6 @@ class ControladorFragment : private var goBack: Boolean = false private var onCollectionSelectedListener: OnCollectionSelectedListener? = null override fun getLayoutId(): Int = R.layout.fragment_general_black - //private lateinit var customDialog: CustomDialog companion object { fun newInstance() = ControladorFragment() @@ -55,12 +54,10 @@ class ControladorFragment : binding.scanInput.requestFocus() binding.scanInput.setOnEditorActionListener { v, actionId, event -> if (actionId == EditorInfo.IME_ACTION_SEARCH || actionId == EditorInfo.IME_ACTION_DONE || actionId == 0 || actionId == 5) { - // d("Action id "+actionId) goBack = false if (!binding.scanInput.text.isNullOrEmpty()) { binding.splashProgress.visibility = VISIBLE - //sergio: para ver si ha marcado dos veces el mismo ticket. El laser falla binding.scanInput.setText(textScanned_filterDouble(binding.scanInput.text!!.toString())) @@ -86,10 +83,6 @@ class ControladorFragment : binding.splashProgress.visibility = View.GONE if (it.isError) { ma.messageWithSound(it.errorMessage, isError = true, isPlayed = false) - /*customDialog.setTitle(getString(R.string.error)).setDescription(it.errorMessage) - .setOkButton(getString(R.string.accept)) { - customDialog.dismiss() - }.show()*/ } else { if (!goBack) navigateToCollectionList(it) diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/controlvehiculo/fragment/ControlVehiculoFragment.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/controlvehiculo/fragment/ControlVehiculoFragment.kt index 1b74f384..2d23991a 100644 --- a/app/src/main/java/es/verdnatura/presentation/view/feature/controlvehiculo/fragment/ControlVehiculoFragment.kt +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/controlvehiculo/fragment/ControlVehiculoFragment.kt @@ -137,13 +137,8 @@ class ControlVehiculoFragment( customDialogInput.setTitle(getString(R.string.vehiclecontrol)).setDescription(description) .setOkButton(getString(R.string.accept)) { if (customDialogInput.getValue().isNotEmpty()) { - // "$description ${customDialogInput.getValue()} OK".toast(requireContext()) insertControlTimeVehicle(customDialogInput.getValue(), action) } - customDialogInput.setValue("") - scanRequest() - customDialogInput.dismiss() - hideKeyboards() } .setKoButton(getString(R.string.cancel)) { @@ -160,13 +155,8 @@ class ControlVehiculoFragment( if (actionId == EditorInfo.IME_ACTION_SEARCH || actionId == EditorInfo.IME_ACTION_DONE || actionId == 0) { if (customDialogInput.getValue().isNotEmpty()) { - insertControlTimeVehicle(customDialogInput.getValue(), action) } - customDialogInput.setValue("") - scanRequest() - customDialogInput.dismiss() - hideKeyboards() return@setOnEditorActionListener true } false @@ -204,6 +194,10 @@ class ControlVehiculoFragment( ma.openFragmentPickers(true) } + customDialogInput.setValue("") + scanRequest() + customDialogInput.dismiss() + hideKeyboards() } private fun scanRequest() { diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/delivery/fragments/LogExpeditionFragment.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/delivery/fragments/LogExpeditionFragment.kt index 78cb02cf..7a9dcc71 100644 --- a/app/src/main/java/es/verdnatura/presentation/view/feature/delivery/fragments/LogExpeditionFragment.kt +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/delivery/fragments/LogExpeditionFragment.kt @@ -125,7 +125,7 @@ class LogExpeditionFragment( binding.mainToolbar.toolbarTitle.text = """${getString(R.string.expedition)} ${binding.scanInput.text}""" } catch (ex: Exception) { - "Error al escanear expedición".toast(context, Toast.LENGTH_SHORT) + getString(R.string.errorScanExpedition).toast(context, Toast.LENGTH_SHORT) } } diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/diadeventa/fragment/DayOfSaleFragment.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/diadeventa/fragment/DayOfSaleFragment.kt index 2b8eeea7..9247ebd7 100644 --- a/app/src/main/java/es/verdnatura/presentation/view/feature/diadeventa/fragment/DayOfSaleFragment.kt +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/diadeventa/fragment/DayOfSaleFragment.kt @@ -86,7 +86,6 @@ class DayOfSaleFragment( if (actionId == EditorInfo.IME_ACTION_SEARCH || actionId == EditorInfo.IME_ACTION_DONE || actionId == 0 || actionId == 5) { if (!binding.scanInput.text.toString().isNullOrEmpty()) { getItemsSaleDate(binding.scanInput.text.toString()) - itemScan = binding.scanInput.text.toString() } binding.scanInput.setText("") diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/inventario/fragment/InventaryParkingFragment.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/inventario/fragment/InventaryParkingFragment.kt index af0ae98f..9771808e 100644 --- a/app/src/main/java/es/verdnatura/presentation/view/feature/inventario/fragment/InventaryParkingFragment.kt +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/inventario/fragment/InventaryParkingFragment.kt @@ -612,9 +612,6 @@ class InventaryParkingFragment( private fun createListInventoryParking( ) { - println("El filtro es " + filterActivated) - println("El filtro shelving es " + positionShelvingChecking) - println("El filtro shelving guardado " + shelvingSaved) adapter = InventoryParkingAdapter( (if (filterActivated) { @@ -630,7 +627,7 @@ class InventaryParkingFragment( } else { myListInventory } - }) as List, + }), onPasillerosItemClickListener = pasillerosItemClickListener!!, onVisibleInventoryClickListener = object : OnVisibleInventoryClickListener { override fun onVisibleInventoryClickListener(item: ItemInventoryParking) { diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/paletizador/fragment/CmrExpeditionPalletFragment.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/paletizador/fragment/CmrExpeditionPalletFragment.kt index 919700ee..36c1fc5f 100644 --- a/app/src/main/java/es/verdnatura/presentation/view/feature/paletizador/fragment/CmrExpeditionPalletFragment.kt +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/paletizador/fragment/CmrExpeditionPalletFragment.kt @@ -5,7 +5,7 @@ import android.view.inputmethod.EditorInfo import es.verdnatura.R import es.verdnatura.databinding.FragmentExpeditionscanSorterBinding import es.verdnatura.presentation.base.BaseFragment -import es.verdnatura.presentation.common.itemScanned +import es.verdnatura.presentation.common.ItemScanned import es.verdnatura.presentation.view.component.CustomDialogInputTwoValues import org.json.JSONObject @@ -18,8 +18,8 @@ class CmrExpeditionPalletFragment( override fun getLayoutId(): Int = R.layout.fragment_expeditionscan_sorter private lateinit var customDialogList: CustomDialogInputTwoValues private var itemScaned: String = "" - private var dataScanned: itemScanned? = null - private var dataScannedTwo: itemScanned? = null + private var dataScanned: ItemScanned? = null + private var dataScannedTwo: ItemScanned? = null companion object { fun newInstance(title: String) = CmrExpeditionPalletFragment(title) @@ -111,23 +111,11 @@ class CmrExpeditionPalletFragment( ma.hideKeyboard(customDialogList.getEditText()) customDialogList.getEditText().setOnEditorActionListener { _, actionId, _ -> if (actionId == EditorInfo.IME_ACTION_SEARCH || actionId == EditorInfo.IME_ACTION_DONE || actionId == 0 || actionId == 5 || actionId == 6) { - // var action = true if (customDialogList.getValue().isNotEmpty()) { dataScanned = itemScan(customDialogList.getValue()) - if (dataScanned == null) { - // action = false - /*ma.messageWithSound( - getString(R.string.errorPalletCmrNotScanned), - isError = true, - isPlayed = true, - titleWithError = getString(R.string.warning), - isToasted = true - ) - customDialogList.setValue("")*/ - - } else { - // action = false + if (dataScanned != null) { + customDialogList.setValue(dataScanned!!.id.toString()) customDialogList.setHint(true) if (dataScanned!!.table == "cmr") { @@ -158,28 +146,6 @@ class CmrExpeditionPalletFragment( customDialogList.getValueTwo().toInt() ) - /* var messageLabel = "" - when (dataScanned!!.table) { - "cmr" -> { - messageLabel = "CMR" - } - "expeditionPallet" -> { - messageLabel = "Pallet" - } - } - - ma.messageWithSound( - String.format( - getString(R.string.labelPalletOrCmrNotValid), - messageLabel - ), - isError = true, - isPlayed = true, - titleWithError = getString(R.string.warning), - isToasted = true - ) - customDialogList.setValueTwo("")*/ - } else { if (dataScanned != null) { @@ -189,7 +155,7 @@ class CmrExpeditionPalletFragment( getString(R.string.errorSameType), isError = true, isPlayed = true, - titleWithError = "Aviso", + titleWithError = getString(R.string.info), isToasted = true ) customDialogList.setValueTwo("") @@ -226,10 +192,10 @@ class CmrExpeditionPalletFragment( } -private fun itemScan(value: String): itemScanned? { +private fun itemScan(value: String): ItemScanned? { return try { - val valueScanned = itemScanned(JSONObject(value)) + val valueScanned = ItemScanned(JSONObject(value)) if (valueScanned.table == "cmr" || valueScanned.table == "expeditionPallet") { valueScanned diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/paletizador/fragment/ExpeditionPalletFragment.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/paletizador/fragment/ExpeditionPalletFragment.kt index 4e2f4bcf..567c8669 100644 --- a/app/src/main/java/es/verdnatura/presentation/view/feature/paletizador/fragment/ExpeditionPalletFragment.kt +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/paletizador/fragment/ExpeditionPalletFragment.kt @@ -79,12 +79,13 @@ class ExpeditionPalletFragment( itemExpeditionTruckVO!!.ETD.toString() + " " + if (itemExpeditionTruckVO!!.Destino.isNullOrBlank()) { itemExpeditionTruckVO!!.description - }else{ + } else { itemExpeditionTruckVO!!.Destino } setToolBar() setEvents() - viewModel.expeditionPallet_List(itemExpeditionTruckVO!!.truckFk + viewModel.expeditionPallet_List( + itemExpeditionTruckVO!!.truckFk ) super.init() @@ -111,7 +112,7 @@ class ExpeditionPalletFragment( if (item == iconReload) { binding.splashProgress.visibility = View.VISIBLE viewModel.expeditionPallet_List( - itemExpeditionTruckVO!!.truckFk + itemExpeditionTruckVO!!.truckFk ) } else if (item == iconPlus) { expeditionScanAdd() @@ -154,15 +155,8 @@ class ExpeditionPalletFragment( } else { - if (it.response == "0") { - - //"Rutas iguales ${it.response}".toast(requireActivity()) - ////Log.i("VERDNATURA:","Rutas iguales") - } if (it.response == "1") { mperror?.start() - // "Resultado llamada $it.response".toast(requireActivity()) - ////Log.i("VERDNATURA:","Rutas distintas") } } @@ -190,7 +184,7 @@ class ExpeditionPalletFragment( private fun expeditionScanAdd() { binding.splashProgress.visibility = View.VISIBLE viewModel.expeditionScanAdd( - vPalletFk = 0, vTruckFk = itemExpeditionTruckVO!!.truckFk + vPalletFk = 0, vTruckFk = itemExpeditionTruckVO!!.truckFk ) } @@ -231,14 +225,14 @@ class ExpeditionPalletFragment( }.setKoButton(getString(R.string.close)) { - ma.hideKeyboard(customDialogList.getEditText()) - binding.splashProgress.visibility = View.VISIBLE - viewModel.expeditionPallet_List( - itemExpeditionTruckVO!!.truckFk - ) - listExpeditions = ArrayList() - customDialogList.dismiss() - }.setValue("").show() + ma.hideKeyboard(customDialogList.getEditText()) + binding.splashProgress.visibility = View.VISIBLE + viewModel.expeditionPallet_List( + itemExpeditionTruckVO!!.truckFk + ) + listExpeditions = ArrayList() + customDialogList.dismiss() + }.setValue("").show() customDialogList.getEditText().requestFocus() ma.hideKeyboard(customDialogList.getEditText()) @@ -247,7 +241,7 @@ class ExpeditionPalletFragment( if (actionId == EditorInfo.IME_ACTION_SEARCH || actionId == EditorInfo.IME_ACTION_DONE || actionId == 0 || actionId == 5) { if (!customDialogList.getValue().isNullOrEmpty()) { try { - // val numExpedition = customDialogList.getValue().toDouble() + if (customDialogList.getValue().length >= 7) { listExpeditions.add(0, BarcodeVO(code = customDialogList.getValue())) customDialogList.setDescription(getString(R.string.total) + listExpeditions.size) @@ -255,7 +249,6 @@ class ExpeditionPalletFragment( it.list.get(0).palletFk, customDialogList.getValue().toInt() ) - ////Log.i("VERDNATURA:"," palletizando ${it.list.get(0).palletFk} expedi: ${customDialogList.getValue()}") viewModel.checkRouteExpeditionScanPut( it.list[0].palletFk, customDialogList.getValue().toInt() diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/paletizador/fragment/ExpeditionScanFragment.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/paletizador/fragment/ExpeditionScanFragment.kt index 97468e17..48dbbf1a 100644 --- a/app/src/main/java/es/verdnatura/presentation/view/feature/paletizador/fragment/ExpeditionScanFragment.kt +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/paletizador/fragment/ExpeditionScanFragment.kt @@ -83,7 +83,7 @@ class ExpeditionScanFragment( setToolBar() setEvents() viewModel.expeditionScanList( - itemPalletVO!!.Pallet + itemPalletVO!!.Pallet ) super.init() } @@ -185,7 +185,7 @@ class ExpeditionScanFragment( .setOkButton(getString(R.string.delete)) { binding.splashProgress.visibility = View.VISIBLE viewModel.expeditionScanDel( - itemExpeditionScan.id + itemExpeditionScan.id ) customDialogTwoButtons.dismiss() }.setKoButton(getString(R.string.cancel)) { @@ -226,27 +226,28 @@ class ExpeditionScanFragment( onComprobarPalletViewClickListener!!.onComprobarPalletViewClickListener( itemExpeditionTruckVO!!, - ItemPalletVO(Pallet = it.list.get(0).palletFk)) + ItemPalletVO(Pallet = it.list.get(0).palletFk) + ) } else { customDialog.setTitle(getString(R.string.info)) .setDescription(getString(R.string.expeditionsError)).setOkButton( - getString( - R.string.ok - ) - ) { - customDialog.dismiss() - }.show() + getString( + R.string.ok + ) + ) { + customDialog.dismiss() + }.show() } customDialogList.dismiss() }.setKoButton(getString(R.string.close)) { - ma.hideKeyboard(customDialogList.getEditText()) - listExpeditions = ArrayList() - customDialogList.dismiss() - }.setValue("").show() + ma.hideKeyboard(customDialogList.getEditText()) + listExpeditions = ArrayList() + customDialogList.dismiss() + }.setValue("").show() customDialogList.getEditText().requestFocus() ma.hideKeyboard(customDialogList.getEditText()) @@ -254,19 +255,22 @@ class ExpeditionScanFragment( customDialogList.getEditText().setOnEditorActionListener { v, actionId, event -> if (actionId == EditorInfo.IME_ACTION_SEARCH || actionId == EditorInfo.IME_ACTION_DONE || actionId == 0 || actionId == 5) { if (!customDialogList.getValue().isNullOrEmpty()) { + try { + listExpeditions.add(BarcodeVO(code = customDialogList.getValue())) + viewModel.expeditionScanPut( + it.list[0].palletFk, + customDialogList.getValue().toInt() + ) + checkRouteExpeditionScanPut( + it.list[0].palletFk, + customDialogList.getValue().toInt() + ) - listExpeditions.add(BarcodeVO(code = customDialogList.getValue())) - viewModel.expeditionScanPut( - it.list.get(0).palletFk, - customDialogList.getValue().toInt() - ) + expeditionAdapter!!.notifyDataSetChanged() + } catch (ex: Exception) { + getString(R.string.errorInput) + } - checkRouteExpeditionScanPut( - it.list.get(0).palletFk, - customDialogList.getValue().toInt() - ) - - expeditionAdapter!!.notifyDataSetChanged() } customDialogList.setValue("") diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/paletizador/fragment/ExpeditionTruckListFragment.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/paletizador/fragment/ExpeditionTruckListFragment.kt index bf93c761..5f25636d 100644 --- a/app/src/main/java/es/verdnatura/presentation/view/feature/paletizador/fragment/ExpeditionTruckListFragment.kt +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/paletizador/fragment/ExpeditionTruckListFragment.kt @@ -126,9 +126,8 @@ class ExpeditionTruckListFragment : BaseFragment(ParkingViewModel::class) { @@ -76,14 +75,9 @@ class ParkingFragment (var menuOrigin:String): BaseFragment if (actionId == EditorInfo.IME_ACTION_SEARCH || actionId == EditorInfo.IME_ACTION_DONE || actionId == 0 || actionId == 5) { try { - isScanned = event != null && event.action == KeyEvent.ACTION_DOWN && event.keyCode == KeyEvent.KEYCODE_ENTER + isScanned = + event != null && event.action == KeyEvent.ACTION_DOWN && event.keyCode == KeyEvent.KEYCODE_ENTER customDialogList.setValueTwo( itemScanValue( @@ -957,26 +958,14 @@ class EndSacadorFragment( customDialogInput.setTitle("" + sale.itemFk) .setDescription(getString(R.string.scanWagonForItem)) .setOkButton(getString(R.string.accept)) { - if (!customDialogInput.getValue().isNullOrEmpty()) { - findSale(customDialogInput.getValue(), index) - } - customDialogInput.setValue("") - scanRequest() - customDialogInput.dismiss() - hideKeyboards() + customDialogInputAction(index) }.setKoButton(getString(R.string.cancel)) { customDialogInput.dismiss() }.setValue("").show() customDialogInput.getEditText().requestFocus() customDialogInput.getEditText().setOnEditorActionListener { v, actionId, event -> if (actionId == EditorInfo.IME_ACTION_SEARCH || actionId == EditorInfo.IME_ACTION_DONE || actionId == 0) { - if (!customDialogInput.getValue().isNullOrEmpty()) { - findSale(customDialogInput.getValue(), index) - } - customDialogInput.setValue("") - scanRequest() - customDialogInput.dismiss() - hideKeyboards() + customDialogInputAction(index) return@setOnEditorActionListener true } false @@ -984,18 +973,14 @@ class EndSacadorFragment( } - //OPTIONS - private fun print() { - /* viewModel.collectionStickerPrint( - usuario = user, - password = password, - collectionFk = ticket, - sectorFk = sectorFk,"collectionSticker_print" - ) - ////Log.i("VERDNATURA:","La collection es $ticket, sectorFk $sectorFk, user $user i pass $password") - (getString(R.string.Imprimiendo) + SectorDescription).toast(requireContext())*/ - - + private fun customDialogInputAction(index: Int) { + if (!customDialogInput.getValue().isNullOrEmpty()) { + findSale(customDialogInput.getValue(), index) + customDialogInput.setValue("") + scanRequest() + customDialogInput.dismiss() + hideKeyboards() + } } //OTROS diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/qr/QrFragment.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/qr/QrFragment.kt index 081cd0ae..7d1909d4 100644 --- a/app/src/main/java/es/verdnatura/presentation/view/feature/qr/QrFragment.kt +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/qr/QrFragment.kt @@ -72,7 +72,6 @@ class QrFragment( ma.hideKeyboard(binding.scanInput) return@setOnEditorActionListener true } - // false } diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/reubication/fragment/ReubicationCollectionFragment.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/reubication/fragment/ReubicationCollectionFragment.kt index 029048b0..16d1bcec 100644 --- a/app/src/main/java/es/verdnatura/presentation/view/feature/reubication/fragment/ReubicationCollectionFragment.kt +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/reubication/fragment/ReubicationCollectionFragment.kt @@ -164,23 +164,7 @@ class ReubicationCollectionFragment( .setValue(itemReubication.quantity.toString()) .setOkButton(getString(R.string.leaveItem)) { - - if (customDialogInputTwoValues.getValueTwo().isNotEmpty()) { - binding.splashProgress.visibility = VISIBLE - viewModel.itemShelving_merge( - itemReubication.id, - customDialogInputTwoValues.getValueTwo().uppercase() - ) - } else { - ma.messageWithSound( - getString(R.string.returnScan), - true, - true, - isToasted = true - ) - } - customDialogInputTwoValues.setValueTwo("") - customDialogInputTwoValues.dismiss() + customDialogMerge(itemReubication) }.setKoButton(getString(R.string.cancel)) { binding.splashProgress.visibility = GONE @@ -188,23 +172,13 @@ class ReubicationCollectionFragment( scanRequest() customDialogInputTwoValues.dismiss() }.show() - //} + customDialogInputTwoValues.getEditTextTwo() .setOnEditorActionListener { v, actionId, event -> if (actionId == EditorInfo.IME_ACTION_SEARCH || actionId == EditorInfo.IME_ACTION_DONE || actionId == 0) { - if (customDialogInputTwoValues.getValueTwo().isNotEmpty()) { + customDialogMerge(itemReubication) - binding.splashProgress.visibility = VISIBLE - viewModel.itemShelving_merge( - itemReubication.id, - customDialogInputTwoValues.getValueTwo().uppercase() - ) - } - customDialogInputTwoValues.setValue("") - scanRequest() - customDialogInputTwoValues.dismiss() - //hideKeyboards() return@setOnEditorActionListener true } false @@ -214,6 +188,28 @@ class ReubicationCollectionFragment( } + private fun customDialogMerge(itemReubication: Reubication) { + if (customDialogInputTwoValues.getValueTwo().isNotEmpty()) { + binding.splashProgress.visibility = VISIBLE + viewModel.itemShelving_merge( + itemReubication.id, + customDialogInputTwoValues.getValueTwo().uppercase() + ) + } else { + ma.messageWithSound( + getString(R.string.returnScan), + true, + true, + isToasted = true + ) + } + customDialogInputTwoValues.setValue("") + customDialogInputTwoValues.setValueTwo("") + customDialogInputTwoValues.dismiss() + scanRequest() + + } + private fun scanRequest() { binding.scanInput.requestFocus() diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/sacador/fragment/SacadorFragment.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/sacador/fragment/SacadorFragment.kt index 2dafec5f..b5897219 100644 --- a/app/src/main/java/es/verdnatura/presentation/view/feature/sacador/fragment/SacadorFragment.kt +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/sacador/fragment/SacadorFragment.kt @@ -64,9 +64,11 @@ class SacadorFragment( "PREPARED" -> { viewModel.collectionGetSalix() } + "PREITEMPICKER" -> { viewModel.sectorCollection_get() } + else -> { binding.splashProgress.visibility = View.GONE } @@ -126,6 +128,7 @@ class SacadorFragment( } + iconVehicleIn.drawable -> ma.onVehicleSelected(SacadorFragment.TAG) iconPrint.drawable -> { @@ -145,32 +148,19 @@ class SacadorFragment( customDialogInput.setDescription(getString(R.string.printPreviousGroup)) .setValue("") .setOkButton(getString(R.string.print)) { - try { - if (customDialogInput.getValue().isNotEmpty() - ) { - print() - } - } catch (ex: Exception) { - getString(R.string.errorInput) - } - customDialogInput.setValue("") - + printAction() }.setKoButton(getString(R.string.cancel)) { customDialogInput.dismiss() }.show() customDialogInput.setFocusText() - customDialogInput.setFocusText() ma.hideKeyboard(customDialogInput.getEditText()) customDialogInput.getEditText().setOnEditorActionListener { _, actionId, _ -> if (actionId == EditorInfo.IME_ACTION_SEARCH || actionId == EditorInfo.IME_ACTION_DONE || actionId == 0 || actionId == 5 || actionId == 6) { - if (customDialogInput.getValue().isNotEmpty() - ) { - print() - } + printAction() return@setOnEditorActionListener true } @@ -180,15 +170,23 @@ class SacadorFragment( } - private fun print() { - if (ma.havePrinter()) { - viewModel.ticket_printLabelPrevious(customDialogInput.getValue().toInt()) - (getString(R.string.Imprimiendo) + getData(PRINTERNAME)).toast( - requireContext() - ) - } else { - getString(R.string.selectPrinter).toast(requireContext()) + private fun printAction() { + try { + if (customDialogInput.getValue().isNotEmpty() + ) { + if (ma.havePrinter()) { + viewModel.ticket_printLabelPrevious(customDialogInput.getValue().toInt()) + (getString(R.string.Imprimiendo) + getData(PRINTERNAME)).toast( + requireContext() + ) + } else { + getString(R.string.selectPrinter).toast(requireContext()) + } + } + } catch (ex: Exception) { + getString(R.string.errorInput) } + customDialogInput.setValue("") } private fun setEvents() { @@ -216,7 +214,7 @@ class SacadorFragment( } else { if (goBack) { - if (!it.response.isNullOrBlank())addCollectionToList(it.response.toInt()) + if (!it.response.isNullOrBlank()) addCollectionToList(it.response.toInt()) } } goBack = false diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/smarttag/adapter/SmartTagAdapter.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/smarttag/adapter/BufferAdapter.kt similarity index 94% rename from app/src/main/java/es/verdnatura/presentation/view/feature/smarttag/adapter/SmartTagAdapter.kt rename to app/src/main/java/es/verdnatura/presentation/view/feature/smarttag/adapter/BufferAdapter.kt index a213532f..391326c5 100644 --- a/app/src/main/java/es/verdnatura/presentation/view/feature/smarttag/adapter/SmartTagAdapter.kt +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/smarttag/adapter/BufferAdapter.kt @@ -1,7 +1,5 @@ package es.verdnatura.presentation.view.feature.smarttag.adapter -import es.verdnatura.presentation.view.feature.smarttag.model.SmartTag - import android.view.LayoutInflater import android.view.View @@ -9,13 +7,14 @@ import android.view.ViewGroup import androidx.recyclerview.widget.RecyclerView import es.verdnatura.databinding.ItemSmarttagRowBinding import es.verdnatura.presentation.common.OnSmartTagRowClickListener +import es.verdnatura.presentation.view.feature.smarttag.model.SmartTag -class SmartTagAdapter( +class BufferAdapter( private val items: List, private val OnSmartTagRowClickListener: OnSmartTagRowClickListener, private var showDelete: Boolean = true -): RecyclerView.Adapter () { +): RecyclerView.Adapter () { override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ItemHolder { diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/ubicador/fragment/AutomaticAddItemFragment.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/ubicador/fragment/AutomaticAddItemFragment.kt index 5b014ad8..0ee3fc4d 100644 --- a/app/src/main/java/es/verdnatura/presentation/view/feature/ubicador/fragment/AutomaticAddItemFragment.kt +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/ubicador/fragment/AutomaticAddItemFragment.kt @@ -76,7 +76,6 @@ class AutomaticAddItemFragment( if (!binding.editMatricula.text.toString().isNullOrEmpty()) { contador += 1 setSubtitle() - // binding.editMatricula.setText(textScanned_filterDouble(binding.editMatricula.text.toString())) try { listItems.add( 0, ItemEscanerVO( diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/ubicador/fragment/AutomaticAddItemFragmentTEST.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/ubicador/fragment/AutomaticAddItemFragmentTEST.kt index 4b00712b..3406558a 100644 --- a/app/src/main/java/es/verdnatura/presentation/view/feature/ubicador/fragment/AutomaticAddItemFragmentTEST.kt +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/ubicador/fragment/AutomaticAddItemFragmentTEST.kt @@ -1,8 +1,6 @@ package es.verdnatura.presentation.view.feature.ubicador.fragment -import android.view.KeyEvent import android.view.View -import android.view.inputmethod.EditorInfo import androidx.lifecycle.Observer import androidx.recyclerview.widget.LinearLayoutManager import es.verdnatura.R @@ -10,9 +8,7 @@ import es.verdnatura.databinding.FragmentAutomaticAddItemBinding import es.verdnatura.presentation.base.BaseFragment import es.verdnatura.presentation.common.OnAutomaticItemClickListener import es.verdnatura.presentation.common.itemScanValue -import es.verdnatura.presentation.view.feature.ubicador.adapter.AutomaticAdapter import es.verdnatura.presentation.view.feature.ubicador.adapter.AutomaticAdapterTEST -import es.verdnatura.presentation.view.feature.ubicador.model.ItemEscanerVO import java.lang.Boolean.TRUE @@ -74,7 +70,6 @@ class AutomaticAddItemFragmentTEST( binding.editMatricula.setOnEditorActionListener { v, actionId, event -> if (actionId == 0 || actionId == 5 || actionId == 6 ) { - var l1= System.currentTimeMillis() if (!binding.editMatricula.text.toString().isNullOrEmpty()) { try { listItems.add( @@ -95,8 +90,6 @@ class AutomaticAddItemFragmentTEST( ma.messageWithSound(ex.message.toString(), true, true) } } - var l2=System.currentTimeMillis() - println("Lectura diferencia:${l2-l1}") binding.editMatricula.setText("") ma.hideKeyboard(binding.editMatricula) return@setOnEditorActionListener true diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/ubicador/fragment/UbicadorFragment.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/ubicador/fragment/UbicadorFragment.kt index f2aca137..bcd3eb6d 100644 --- a/app/src/main/java/es/verdnatura/presentation/view/feature/ubicador/fragment/UbicadorFragment.kt +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/ubicador/fragment/UbicadorFragment.kt @@ -251,11 +251,6 @@ class UbicadorFragment( binding.editMatricula.text.toString() ) } else { - - /*Tarea#5109*/ - /*viewModel.getIdFromCode( - code = binding.editMatricula.text.toString() - )*/ try { binding.splashProgress.visibility = VISIBLE viewModel.getIdFromCode( @@ -321,16 +316,8 @@ class UbicadorFragment( R.string.parking ) ) { - viewModel.shelvingPark( - shelvingFk, - customDialogInput.getValue() - ) - parking = customDialogInput.getValue() - binding.mainToolbar.toolbarTitle.text = - shelvingFk.uppercase() + getString(R.string.pUppercase) + parking + getString( - R.string.label - ) + etiquetas - customDialogInput.dismiss() + customDialogActionParking() + }.setKoButton(getString(R.string.cancel)) { customDialogInput.dismiss() }.show() @@ -346,17 +333,7 @@ class UbicadorFragment( customDialogInput.getEditText() .setOnEditorActionListener { v, actionId, event -> if (actionId == EditorInfo.IME_ACTION_SEARCH || actionId == EditorInfo.IME_ACTION_DONE || actionId == 0) { - viewModel.shelvingPark( - shelvingFk, - customDialogInput.getValue() - ) - customDialogInput.dismiss() - parking = customDialogInput.getValue() - binding.mainToolbar.toolbarTitle.text = - shelvingFk.uppercase() + getString(R.string.pUppercase) + parking + getString( - R.string.label - ) + etiquetas - + customDialogActionParking() return@setOnEditorActionListener true } @@ -372,14 +349,7 @@ class UbicadorFragment( .setValue("") .setOkButton(getString(R.string.save)) { if (!customDialogInput.getValue().isNullOrBlank()) { - viewModel.shelvingChangeSalix( - shelvingFk, customDialogInput.getValue() - ) - shelvingFk = customDialogInput.getValue() - binding.mainToolbar.toolbarTitle.text = - shelvingFk.uppercase() + getString(R.string.pUppercase) + parking + getString( - R.string.label - ) + etiquetas + customDialogActionChange() } else { getString(R.string.errorShelving).toast( requireContext() @@ -400,18 +370,7 @@ class UbicadorFragment( customDialogInput.getEditText() .setOnEditorActionListener { v, actionId, event -> if (actionId == EditorInfo.IME_ACTION_SEARCH || actionId == EditorInfo.IME_ACTION_DONE || actionId == 0) { - - viewModel.shelvingChangeSalix( - shelvingFk, - customDialogInput.getValue() - ) - shelvingFk = customDialogInput.getValue() - binding.mainToolbar.toolbarTitle.text = - shelvingFk.uppercase() + getString(R.string.pUppercase) + parking + getString( - R.string.label - ) + etiquetas - - customDialogInput.dismiss() + customDialogActionChange() return@setOnEditorActionListener true } false @@ -451,6 +410,31 @@ class UbicadorFragment( } } + private fun customDialogActionParking() { + viewModel.shelvingPark( + shelvingFk, + customDialogInput.getValue() + ) + parking = customDialogInput.getValue() + binding.mainToolbar.toolbarTitle.text = + shelvingFk.uppercase() + getString(R.string.pUppercase) + parking + getString( + R.string.label + ) + etiquetas + customDialogInput.dismiss() + } + + private fun customDialogActionChange() { + viewModel.shelvingChangeSalix( + shelvingFk, customDialogInput.getValue() + ) + shelvingFk = customDialogInput.getValue() + binding.mainToolbar.toolbarTitle.text = + shelvingFk.uppercase() + getString(R.string.pUppercase) + parking + getString( + R.string.label + ) + etiquetas + customDialog.dismiss() + } + private fun checkUbications(itemScanned: Int) { itemScannedScreen = itemScanned val listInt: ArrayList = ArrayList() @@ -1019,19 +1003,7 @@ class UbicadorFragment( .setDescription(getString(R.string.selectDestiny) + item.item) .setValue("") .setOkButton(getString(R.string.transfer)) { - if (customDialogInput.getValue().isNotEmpty()) { - binding.splashProgress.visibility = VISIBLE - viewModel.itemShelvingTransfer( - item.id, - customDialogInput.getValue() - ) - listItems.remove(item) - adapter!!.notifyDataSetChanged() - customDialogInput.dismiss() - } else { - getString(R.string.wagonIncorrect).toast(requireContext()) - - } + customDialogInputAction(item) }.setKoButton(getString(R.string.cancel)) { customDialogInput.dismiss() @@ -1041,13 +1013,7 @@ class UbicadorFragment( customDialogInput.getEditText() .setOnEditorActionListener { v, actionId, event -> if (actionId == EditorInfo.IME_ACTION_SEARCH || actionId == EditorInfo.IME_ACTION_DONE || actionId == 0) { - viewModel.itemShelvingTransfer( - item.id, - customDialogInput.getValue() - ) - listItems.remove(item) - adapter!!.notifyDataSetChanged() - customDialogInput.dismiss() + customDialogInputAction(item) return@setOnEditorActionListener true } false @@ -1087,5 +1053,21 @@ class UbicadorFragment( customDialogTwoButtons.dismiss() }.show() } + + private fun customDialogInputAction(item:ItemUbicadorVO) { + if (customDialogInput.getValue().isNotEmpty()) { + binding.splashProgress.visibility = VISIBLE + viewModel.itemShelvingTransfer( + item.id, + customDialogInput.getValue() + ) + listItems.remove(item) + adapter!!.notifyDataSetChanged() + customDialogInput.dismiss() + } else { + getString(R.string.wagonIncorrect).toast(requireContext()) + + } + } }