From c014dbfd2d60a58eea2590932d4dcf48cd8a7722 Mon Sep 17 00:00:00 2001 From: Sergio De la torre Date: Thu, 27 Jul 2023 13:07:34 +0200 Subject: [PATCH] refs #5891 inventoryParking --- .../presentation/base/BaseFragment.kt | 4 + .../adapter/InventoryParkingAdapter.kt | 5 +- .../fragment/InventaryParkingFragment.kt | 508 +++++++++++------- .../inventario/fragment/InventaryViewModel.kt | 124 ++++- .../inventario/model/ItemInventaryVO.kt | 32 +- .../main/res/drawable/ic_eye_inventory.xml | 6 + .../main/res/drawable/ic_filter_inventory.xml | 9 + .../res/layout/item_inventory_parking_row.xml | 5 +- 8 files changed, 459 insertions(+), 234 deletions(-) create mode 100644 app/src/main/res/drawable/ic_eye_inventory.xml create mode 100644 app/src/main/res/drawable/ic_filter_inventory.xml diff --git a/app/src/main/java/es/verdnatura/presentation/base/BaseFragment.kt b/app/src/main/java/es/verdnatura/presentation/base/BaseFragment.kt index a9e0188e..2a742649 100644 --- a/app/src/main/java/es/verdnatura/presentation/base/BaseFragment.kt +++ b/app/src/main/java/es/verdnatura/presentation/base/BaseFragment.kt @@ -228,6 +228,10 @@ abstract class BaseFragment(viewModelCla R.drawable.expedition_find -> getString(R.string.showLogExpedition) R.drawable.ic_info_refresh -> getString(R.string.udpateRoutes) R.drawable.ic_info_delivery -> getString(R.string.info) + R.drawable.ic_filter_inventory -> getString(R.string.filterNoReview) + R.drawable.ic_remove_checks->getString(R.string.resetReviewItems) + R.drawable.ic_eye_inventory -> getString(R.string.inventoryShowParking) + else -> { "" } diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/inventario/adapter/InventoryParkingAdapter.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/inventario/adapter/InventoryParkingAdapter.kt index bf3b8772..961da294 100644 --- a/app/src/main/java/es/verdnatura/presentation/view/feature/inventario/adapter/InventoryParkingAdapter.kt +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/inventario/adapter/InventoryParkingAdapter.kt @@ -40,7 +40,10 @@ class InventoryParkingAdapter( fun getListItems(): List { return items } - + fun setItems(newItems: List) { + items = newItems + notifyDataSetChanged() // Notificar al adaptador que los datos han cambiado + } fun sortBy(fieldSort: String) { when (fieldSort) { "sector" -> { 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 1393926c..3cba20fd 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 @@ -11,6 +11,7 @@ import android.view.View.VISIBLE import android.view.inputmethod.EditorInfo import android.widget.ImageView import androidx.annotation.RequiresApi +import androidx.core.content.ContextCompat import androidx.lifecycle.Observer import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.RecyclerView @@ -18,6 +19,7 @@ import com.google.gson.JsonArray import com.google.gson.JsonObject import es.verdnatura.R import es.verdnatura.databinding.FragmentInventoryParkingBinding +import es.verdnatura.domain.notNull import es.verdnatura.domain.toast import es.verdnatura.presentation.base.BaseFragment import es.verdnatura.presentation.common.* @@ -62,6 +64,9 @@ class InventaryParkingFragment( private var positionShelvingChecking: Int = -1 private var positionItemChecking: Int = -1 private var scrollPosition = 0 + private var parkingFrom = "" + private var parkingTo = "" + private var filterActivated = false companion object { fun newInstance(title: String) = @@ -71,12 +76,17 @@ class InventaryParkingFragment( override fun getLayoutId(): Int = R.layout.fragment_inventory_parking override fun onPause() { - val layoutManager = - binding.inventoryParkingRecyclerview.layoutManager as LinearLayoutManager - scrollPosition = layoutManager.findFirstVisibleItemPosition() + try { + val layoutManager = + binding.inventoryParkingRecyclerview.layoutManager as LinearLayoutManager + scrollPosition = layoutManager.findFirstVisibleItemPosition() + }catch (exception:Exception){ + + } - super.onPause() isBack = true + super.onPause() + } @@ -98,6 +108,9 @@ class InventaryParkingFragment( setEvents() setViews() setToolBar() + if (!isBack) { + setParkingFromTo() + } super.init() } @@ -127,19 +140,22 @@ class InventaryParkingFragment( val iconReset = ImageView(context) iconReset.setImageResource(R.drawable.ic_remove_checks) + val iconFilter = ImageView(context) + iconFilter.setImageResource(R.drawable.ic_filter_inventory) + val iconParkingFrom = ImageView(context) - iconParkingFrom.setImageResource(R.drawable.ic_eye_ui) + iconParkingFrom.setImageResource(R.drawable.ic_eye_inventory) if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { - iconParkingFrom.tooltipText = getTooltip(R.drawable.ic_eye_ui) + iconParkingFrom.tooltipText = getTooltip(R.drawable.ic_eye_inventory) iconReload.tooltipText = getTooltip(R.drawable.ic_autorenew_black_24dp) iconAdd.tooltipText = getString(R.string.addItemShelving) iconReset.tooltipText = getTooltip(R.drawable.ic_remove_checks) + iconFilter.tooltipText = getTooltip(R.drawable.ic_filter_inventory) } listIcons.add(iconParkingFrom) - //listIcons.add(iconAdd) - //listIcons.add(iconReload) + listIcons.add(iconFilter) listIcons.add(iconReset) @@ -148,22 +164,41 @@ class InventaryParkingFragment( override fun onOptionsItemSelected(item: Drawable) { when (item) { - iconAdd.drawable -> { - // adapter!!.sortBy("sector") - } - iconReload.drawable -> { + iconFilter.drawable -> { + try { + filterActivated = !filterActivated + adapter!!.setItems( + if (filterActivated) { + myListInventory.filter { it.isChecked == null || it.isChecked == 0 } + } else { + myListInventory + } + ) + iconFilter.drawable.setTint( + ContextCompat.getColor( + context!!, + if (filterActivated) R.color.verdnatura_pumpkin_orange else R.color.verdnatura_white + ) + ) + + } catch (ex: Exception) { + } - // adapter!!.sortBy("buyer") } iconReset.drawable -> { - showResetShelving() + if (!myListInventory.isNullOrEmpty()) { + binding.textinputlayoutMatricula.visibility = VISIBLE + showResetShelving() + } else { + "La lista del inventario está vacía".toast(requireContext()) + } } iconParkingFrom.drawable -> { - binding.textinputlayoutMatricula.visibility = VISIBLE + setParkingFromTo() } @@ -175,6 +210,10 @@ class InventaryParkingFragment( LinearLayoutManager(requireContext(), LinearLayoutManager.HORIZONTAL, false) } + private fun filterList() { + TODO("Not yet implemented") + } + private fun showResetShelving() { customDialogInput.setFocusText() customDialogInput.setInputText(InputType.TYPE_CLASS_TEXT) @@ -217,7 +256,10 @@ class InventaryParkingFragment( filter.add("id", JsonObject().apply { add("inq", inqValues) }) binding.splashProgress.visibility = VISIBLE - viewModel.itemShelvingsUpdate(filter, ItemShelvingChecked(null)) + viewModel.itemShelvingsUpdate( + filter, + ItemShelvingChecked(null, mobileApplication.userId!!) + ) } ma.hideKeyboard(customDialogInput.getEditText()) customDialogInput.setValue("") @@ -227,30 +269,34 @@ class InventaryParkingFragment( } private fun setParkingFromTo() { - + binding.textinputlayoutMatricula.visibility = VISIBLE customDialogList.setTitle(getString(R.string.selectParkingsCheckin)) customDialogList.setDescription(getString(R.string.selectParkingsFrom)) - .setOkButton( - getString(R.string.review) - ) { - ma.hideKeyboard(customDialogList.getEditText()) + /* .setOkButton( + getString(R.string.review) + ) { + ma.hideKeyboard(customDialogList.getEditText()) - if (listParkings.size == 1) { - viewModel.ItemListInventoryParking( - listParkings.first().code!!, - customDialogList.getValue() - ) - ma.hideKeyboard(customDialogList.getEditText()) - listParkings.clear() - customDialogList.dismiss() - binding.editMatricula.requestFocus() - } else { - listParkings.add(0, BarcodeVO(code = customDialogList.getValue())) - } + if (listParkings.size == 2) { + + callGetInventory( + listParkings.first().code!!.uppercase(), + customDialogList.getValue().uppercase() + ) + + ma.hideKeyboard(customDialogList.getEditText()) + listParkings.clear() + customDialogList.dismiss() + binding.editMatricula.requestFocus() + } else { + listParkings.add(0, BarcodeVO(code = customDialogList.getValue())) + customDialogList.setValue("") + customDialogList.setDescription(getString(R.string.selectParkingsTo)) + } - }.setKoButton(getString(R.string.cancel)) { + }*/.setKoButton(getString(R.string.cancel)) { ma.hideKeyboard(customDialogList.getEditText()) listParkings = ArrayList() customDialogList.dismiss() @@ -265,15 +311,18 @@ class InventaryParkingFragment( try { if (listParkings.size == 1) { - viewModel.ItemListInventoryParking( - listParkings.first().code!!, - customDialogList.getValue() + callGetInventory( + listParkings.first().code!!.uppercase(), + customDialogList.getValue().uppercase() ) + + ma.hideKeyboard(customDialogList.getEditText()) listParkings.clear() customDialogList.dismiss() binding.editMatricula.requestFocus() } else { + customDialogList.setDescription(getString(R.string.selectParkingsTo)) listParkings.add(0, BarcodeVO(code = customDialogList.getValue())) } @@ -306,10 +355,22 @@ class InventaryParkingFragment( } + private fun callGetInventory(parkingFromScan: String, parkingToScan: String) { + binding.splashProgress.visibility = VISIBLE + parkingFrom = parkingFromScan + parkingTo = parkingToScan + viewModel.getInventoryParking( + parkingFromScan, + parkingToScan + ) + binding.mainToolbar.toolbarTitle.text = "$parkingFrom → $parkingTo" + } + @RequiresApi(Build.VERSION_CODES.O) @SuppressLint("SetTextI18n") private fun setEvents() { binding.mainToolbar.backButton.setOnClickListener { + isBack = true requireActivity().onBackPressed() } @@ -320,9 +381,21 @@ class InventaryParkingFragment( if (!binding.editMatricula.text.toString().isEmpty()) { - if (positionShelvingChecking == -1) { + try { + binding.editMatricula.setText( + itemScanValue( + binding.editMatricula.text.toString(), + "buy", + "more" + ).toString() + ) + } catch (ex: Exception) { + ex.message!!.toast(requireContext()) + + } + positionShelvingChecking = myListInventory.indexOfFirst { item -> item.shelvingFk == binding.editMatricula.text.toString() } @@ -339,49 +412,76 @@ class InventaryParkingFragment( binding.editMatricula.hint = getString(R.string.scanItemForChecking) } } else { + try { - positionItemChecking = myListInventory.indexOfFirst { item -> - item.itemFk == binding.editMatricula.text.toString() - .toInt() && item.shelvingFk == myListInventory[positionShelvingChecking].shelvingFk && item.isChecked == null - } - } catch (ex: Exception) { - ma.messageWithSound("", true, true, "", null) - } - if (positionItemChecking == -1) { - ma.messageWithSound( - getString(R.string.itemNotFoundScanAgain), - true, - true, - "", - true + + viewModel.getIdFromCodeSalix( + code = itemScanValue( + binding.editMatricula.text.toString(), + "buy", + "more" + ).toString() ) - positionShelvingChecking = -1 - binding.editMatricula.hint = getString(R.string.scanShelvingAgain) - } else { - try { - /* binding.splashProgress.visibility = VISIBLE - viewModel.itemShelvingUpdate( - myListInventory.get(positionItemChecking).id, - ItemShelvingChecked(true) - )*/ - myListInventory[positionItemChecking].isChecked = 1 - adapter!!.notifyDataSetChanged() - binding.editMatricula.hint = getString(R.string.scanShelving) - /* viewModel.getIdFromCode( - code = itemScanValue( - binding.editMatricula.text.toString(), - "buy", - "more" - ).toString() - )*/ - } catch (Ex: Exception) { - ma.messageWithSound(Ex.message.toString(), true, true) - } + /* binding.editMatricula.setText( + itemScanValue( + binding.editMatricula.text.toString(), + "buy", + "more" + ).toString() + )*/ + + /* positionItemChecking = myListInventory.indexOfFirst { item -> + item.itemFk == binding.editMatricula.text.toString() + .toInt() && item.shelvingFk == myListInventory[positionShelvingChecking].shelvingFk && item.isChecked == null + }*/ + } catch (ex: Exception) { + ma.messageWithSound(ex.message!!, true, true, "", null) } + //fun checkItem al obterner el code de Salix + + /* if (positionItemChecking == -1) { + ma.messageWithSound( + getString(R.string.itemNotFoundScanAgain), + true, + true, + "", + true + ) + positionShelvingChecking = -1 + binding.editMatricula.hint = getString(R.string.scanShelvingAgain) + } else { + + try { + binding.splashProgress.visibility = VISIBLE + + //SE pone en el response + viewModel.itemShelvingUpdate( + myListInventory[positionItemChecking].id, + ItemShelvingChecked(true, mobileApplication.userId!!) + ) + myListInventory[positionItemChecking].isChecked = 1 + adapter!!.notifyDataSetChanged() + binding.editMatricula.hint = getString(R.string.scanShelving) + positionItemChecking = -1 + positionShelvingChecking = -1 + + /* viewModel.getIdFromCodeSalix( + code = itemScanValue( + binding.editMatricula.text.toString(), + "buy", + "more" + ).toString())*/ + + } catch (Ex: Exception) { + ma.messageWithSound(Ex.message.toString(), true, true) + } + + }*/ + } binding.editMatricula.setText("") ma.hideKeyboard(binding.editMatricula) @@ -391,125 +491,51 @@ class InventaryParkingFragment( return@setOnEditorActionListener false } - binding.parkingImg.setOnClickListener { - customDialogInput.setTitle(getString(R.string.parkingShelving)).setValue("") - .setOkButton( - getString( - R.string.parking - ) - ) { - - parking = customDialogInput.getValue() - binding.mainToolbar.toolbarTitle.text = - shelvingFk.uppercase() + getString(R.string.pUppercase) + parking + getString( - R.string.label - ) + etiquetas - customDialogInput.dismiss() - }.setKoButton(getString(R.string.cancel)) { - customDialogInput.dismiss() - }.show() - - customDialogInput.getEditText().requestFocus() - ma.hideKeyboard(customDialogInput.getEditText()) - - customDialogInput.getEditText() - .setOnEditorActionListener { v, actionId, event -> - if (actionId == EditorInfo.IME_ACTION_SEARCH || actionId == EditorInfo.IME_ACTION_DONE || actionId == 0) { - - customDialogInput.dismiss() - parking = customDialogInput.getValue() - binding.mainToolbar.toolbarTitle.text = - shelvingFk.uppercase() + getString(R.string.pUppercase) + parking + getString( - R.string.label - ) + etiquetas - - - return@setOnEditorActionListener true - } - false - } - - } - - binding.editImg.setOnClickListener { - customDialogInput.setTitle(getString(R.string.changeShelving)).setValue("") - .setOkButton(getString(R.string.save)) { - - shelvingFk = customDialogInput.getValue() - binding.mainToolbar.toolbarTitle.text = - shelvingFk.uppercase() + getString(R.string.pUppercase) + parking + getString( - R.string.label - ) + etiquetas - if (mpok != null) mpok!!.start() - customDialogInput.dismiss() - }.setKoButton(getString(R.string.cancel)) { - customDialogInput.dismiss() - }.show() - - customDialogInput.getEditText().requestFocus() - ma.hideKeyboard(customDialogInput.getEditText()) - - customDialogInput.getEditText() - .setOnEditorActionListener { v, actionId, event -> - if (actionId == EditorInfo.IME_ACTION_SEARCH || actionId == EditorInfo.IME_ACTION_DONE || actionId == 0) { - - shelvingFk = customDialogInput.getValue() - binding.mainToolbar.toolbarTitle.text = - shelvingFk.uppercase() + getString(R.string.pUppercase) + parking + getString( - R.string.label - ) + etiquetas - if (mpok != null) mpok!!.start() - customDialogInput.dismiss() - return@setOnEditorActionListener true - } - false - } - - } - - binding.deleteImg.setOnClickListener { - customDialog.setTitle(getString(R.string.empty)) - .setDescription(getString(R.string.operationNoReturn)) - .setOkButton(getString(R.string.empty)) { - - listItems.forEach { - it.stickers = "0" - it.visible = "0" - } - if (adapter != null) { - adapter!!.notifyDataSetChanged() - } - customDialog.dismiss() - }.setKoButton(getString(R.string.cancel)) { - customDialog.dismiss() - }.show() - - - } } - private fun checkUbications(itemScanned: Int) { - itemScannedScreen = itemScanned - val listInt: ArrayList = ArrayList() + private fun checkItem(itemCode: String) { - if (listItems.filter { it.item == itemScanned }.isEmpty()) { - listInt.add(itemScanned) + positionItemChecking = myListInventory.indexOfFirst { item -> + item.itemFk == itemCode + .toInt() && item.shelvingFk == myListInventory[positionShelvingChecking].shelvingFk && item.isChecked == null + } + + + if (positionItemChecking == -1) { + ma.messageWithSound( + getString(R.string.itemNotFoundScanAgain), + true, + true, + "", + true + ) + positionShelvingChecking = -1 + binding.editMatricula.hint = getString(R.string.scanShelvingAgain) } else { - listItems.sortedBy { it.isChecked }.forEachIndexed { index, item -> - if (item.item == itemScanned) { - item.checked = true - listInt.add(item.item) - ma.messageWithSound("", false, true, "", false) - } + + try { + binding.splashProgress.visibility = VISIBLE + + //SE pone en el response + viewModel.itemShelvingUpdate( + myListInventory[positionItemChecking].id, + ItemShelvingChecked(true, mobileApplication.userId!!) + ) + myListInventory[positionItemChecking].isChecked = 1 + adapter!!.notifyDataSetChanged() + binding.editMatricula.hint = getString(R.string.scanShelving) + positionItemChecking = -1 + positionShelvingChecking = -1 + + + } catch (ex: Exception) { + } - } - - - adapter!!.notifyDataSetChanged() } + private fun setTooltips() { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { binding.editImg.tooltipText = getTooltip(R.drawable.ic_mode_edit_black_24dp) @@ -532,40 +558,95 @@ class InventaryParkingFragment( with(viewModel) { /* loadInventaryParkingList.observe(viewLifecycleOwner) { event -> - event.getContentIfNotHandled().notNull { - binding.splashProgress.visibility = GONE - if (it.list[0].isError) { - ma.messageWithSound( - it.list[0].errorMessage, - it.list[0].isError, - false - ) + event.getContentIfNotHandled().notNull { + binding.splashProgress.visibility = GONE + if (it.list[0].isError) { + ma.messageWithSound( + it.list[0].errorMessage, + it.list[0].isError, + false + ) - } else { - myListInventory = it.list as MutableList - createListInventoryParking(myListInventory) + } else { + myListInventory = it.list as MutableList + createListInventoryParking(myListInventory) - } - } - }*/ + } + } + }*/ inventoryListParking.observe(viewLifecycleOwner, Observer { binding.splashProgress.visibility = GONE - binding.splashProgress.visibility = GONE - if (it.list[0].isError) { - ma.messageWithSound( - it.list[0].errorMessage, - it.list[0].isError, - false - ) - } else { - myListInventory = it.list as MutableList - createListInventoryParking(myListInventory) + if (it.list.isNotEmpty()) { + if (it.list[0].isError) { + ma.messageWithSound( + it.list[0].errorMessage, + it.list[0].isError, + false + ) + } else { + myListInventory = it.list as MutableList + createListInventoryParking(myListInventory) + customDialogInput.dismiss() + binding.textinputlayoutMatricula.visibility = VISIBLE + binding.editMatricula.requestFocus() + + } } }) + /* loadInventaryParkingList.observe(viewLifecycleOwner) { event -> + event.getContentIfNotHandled().notNull { + binding.splashProgress.visibility = GONE + try { + + + if (it.list.isNotEmpty()) { + if (it.list[0].isError) { + ma.messageWithSound( + it.list[0].errorMessage, + it.list[0].isError, + false + ) + + } else { + myListInventory = it.list as MutableList + createListInventoryParking(myListInventory) + + } + }}catch ( + ex:Exception + ){ + ex.message!!.toast(requireContext()) + } + } + }*/ + + loadReponseCode.observe(viewLifecycleOwner) { event -> + event.getContentIfNotHandled().notNull { + binding.splashProgress.visibility = GONE + if (it.isError) { + ma.messageWithSound(it.errorMessage, it.isError, true) + + } else { + checkItem(it.response) + + } + } + } + + /* responseCode.observe(viewLifecycleOwner, Observer { + binding.splashProgress.visibility = GONE + if (it.isError) { + ma.messageWithSound(it.errorMessage, it.isError, true) + + } else { + checkItem(it.response) + + } + })*/ response.observe(viewLifecycleOwner, Observer { binding.splashProgress.visibility = GONE if (it.isError) { @@ -573,6 +654,11 @@ class InventaryParkingFragment( } else { ma.messageWithSound("", it.isError, true, isToasted = false) + callGetInventory( + parkingFrom, + parkingTo + ) + } }) @@ -587,7 +673,11 @@ class InventaryParkingFragment( ) { adapter = InventoryParkingAdapter( - myListInventory, + if (filterActivated) { + myListInventory.filter { it.isChecked == null || it.isChecked == 0 } + } else { + myListInventory + }, onPasillerosItemClickListener = pasillerosItemClickListener!!, onVisibleInventoryClickListener = object : OnVisibleInventoryClickListener { override fun onVisibleInventoryClickListener(item: ItemInventoryParking) { diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/inventario/fragment/InventaryViewModel.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/inventario/fragment/InventaryViewModel.kt index 784c7c57..de93c2cd 100644 --- a/app/src/main/java/es/verdnatura/presentation/view/feature/inventario/fragment/InventaryViewModel.kt +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/inventario/fragment/InventaryViewModel.kt @@ -63,6 +63,13 @@ class InventaryViewModel(val context: Context) : BaseViewModel(context) { val loadInventaryParkingList = Transformations.map(_inventoryListParking) { Event(it) } + + private val _responseCode by lazy { MutableLiveData() } + val responseCode: LiveData + get() = _responseCode + + val loadReponseCode = Transformations.map(_responseCode) { Event(it) } + //sergio para obtener comprador fun itemShelvingBuyerGet() { silex.itemShelvingBuyerGet().enqueue(object : @@ -166,6 +173,7 @@ class InventaryViewModel(val context: Context) : BaseViewModel(context) { }) } + fun itemShelvingsUpdate( where: JsonObject, params: Any, @@ -190,6 +198,7 @@ class InventaryViewModel(val context: Context) : BaseViewModel(context) { }) } + fun itemTrash( itemFk: Int, warehouseFk: Int, @@ -423,7 +432,54 @@ class InventaryViewModel(val context: Context) : BaseViewModel(context) { }) } - fun ItemListInventoryParking( + fun getInventoryParking( + vParkingFrom: String, + vParkingTo: String + ) { + + salix.getInventoryParking(vParkingFrom, vParkingTo) + .enqueue(object : + SilexCallback>(context) { + override fun onError(t: Throwable) { + val listError: ArrayList = ArrayList() + listError.add( + ItemInventoryParking( + isError = true, + errorMessage = getMessageFromAllResponse( + nameofFunction(this), + t.message!! + ), + ) + ) + _inventoryListParking.value = InventoryParkingList(listError) + + } + + override fun onSuccess(response: Response>) { + + if (response.body() != null) { + _inventoryListParking.value = + response.body()?.let { InventoryParkingList(it) } + + }else{ + val listError: ArrayList = ArrayList() + listError.add( + ItemInventoryParking( + isError = false, + errorMessage = getMessageFromAllResponse( + nameofFunction(this), + response.message() + ), + ) + ) + _inventoryListParking.value = InventoryParkingList(listError) + } + } + + }) + } + + fun ItemListInventoryParking_( vParkingFrom: String, vParkingTo: String ) { @@ -487,8 +543,18 @@ class InventaryViewModel(val context: Context) : BaseViewModel(context) { 2 ), ItemInventoryParking( - 5, 33, "F-01-3", "ZLZ", 2912, "HEL Tropical Red", 2, 37, "Jose Alarcan Gomex", - "http://verdnatura.es/vn-image-data/catalog/1600x900/002912", 0, 0 + 5, + 33, + "F-01-3", + "ZLZ", + 2912, + "HEL Tropical Red", + 2, + 37, + "Jose Alarcan Gomex", + "http://verdnatura.es/vn-image-data/catalog/1600x900/002912", + 0, + 0 ), ItemInventoryParking( 6, @@ -519,16 +585,36 @@ class InventaryViewModel(val context: Context) : BaseViewModel(context) { 0 ), ItemInventoryParking( - 8, 34, "F-01-4", "JXU", 50001, "Monstera I", 130, 37, "Jose Alarcan Gomex", - "http://verdnatura.es/vn-image-data/catalog/1600x900/50001", 0, 2 + 8, + 34, + "F-01-4", + "JXU", + 50001, + "Monstera I", + 130, + 37, + "Jose Alarcan Gomex", + "http://verdnatura.es/vn-image-data/catalog/1600x900/50001", + 0, + 2 ), ItemInventoryParking( - 9, 34, "F-01-4", "JXU", 50004, "Monstera IV", 240, 37, "Jose Alarcan Gomex", - "http://verdnatura.es/vn-image-data/catalog/1600x900/50003", 0, 2 + 9, + 34, + "F-01-4", + "JXU", + 50004, + "Monstera IV", + 240, + 37, + "Jose Alarcan Gomex", + "http://verdnatura.es/vn-image-data/catalog/1600x900/50003", + 0, + 2 ) ) ) - _inventoryListParking.value = myList + // _inventoryListParking.value = myList /*silex.itemShelving_inventory(vParkingFromFk, vParkingToFk) .enqueue(object : @@ -595,4 +681,26 @@ class InventaryViewModel(val context: Context) : BaseViewModel(context) { }) } + + fun getIdFromCodeSalix(code: String) { + salix.barcodes_toitem(code) + .enqueue(object : SilexCallback(context) { + override fun onError(t: Throwable) { + _responseCode.value = ResponseItemVO( + isError = true, + errorMessage = getMessageFromAllResponse(nameofFunction(this), t.message!!) + ) + } + + override fun onSuccess(response: Response) { + _responseCode.value = + ResponseItemVO( + isError = false, + response = if (response.body() == null) "" else { + response.body()!! + } + ) + } + }) + } } diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/inventario/model/ItemInventaryVO.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/inventario/model/ItemInventaryVO.kt index b36a6137..c9b1d0ce 100644 --- a/app/src/main/java/es/verdnatura/presentation/view/feature/inventario/model/ItemInventaryVO.kt +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/inventario/model/ItemInventaryVO.kt @@ -18,27 +18,31 @@ class InventaryListVO( ) class ItemShelvingVisible( - val visible: Int + var visible: Int ) + class ItemShelvingChecked( - val isChecked: Boolean? + var isChecked: Boolean?, + var userFk : Int ) + data class ItemInventoryParking( - val id: Long, - val pickingOrder: Int, - val parking: String, - val shelvingFk: String, - val itemFk: Int, - val longName: String, - val visible: Int, - val sectorFk: Int, - val buyer: String, - val urlImage: String, - var isChecked:Int?, - val priority: Int, + var id: Long = 0, + var pickingOrder: Int = 0, + var parking: String = "", + var shelvingFk: String = "", + var itemFk: Int = 0, + var longName: String = "", + var visible: Int = 0, + var sectorFk: Int = 0, + var buyer: String = "", + var urlImage: String = "", + var isChecked: Int? = null, + var priority: Int = 0, var isError: Boolean = false, var errorMessage: String = "", ) + class InventoryParkingList( var list: List = listOf() ) diff --git a/app/src/main/res/drawable/ic_eye_inventory.xml b/app/src/main/res/drawable/ic_eye_inventory.xml new file mode 100644 index 00000000..fd64899e --- /dev/null +++ b/app/src/main/res/drawable/ic_eye_inventory.xml @@ -0,0 +1,6 @@ + + + diff --git a/app/src/main/res/drawable/ic_filter_inventory.xml b/app/src/main/res/drawable/ic_filter_inventory.xml new file mode 100644 index 00000000..ba2a74ce --- /dev/null +++ b/app/src/main/res/drawable/ic_filter_inventory.xml @@ -0,0 +1,9 @@ + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/item_inventory_parking_row.xml b/app/src/main/res/layout/item_inventory_parking_row.xml index 3ee1d9f1..5567adab 100644 --- a/app/src/main/res/layout/item_inventory_parking_row.xml +++ b/app/src/main/res/layout/item_inventory_parking_row.xml @@ -26,7 +26,7 @@ android:orientation="horizontal" android:paddingLeft="@dimen/pasilleros_margin_main_menu" android:paddingTop="@dimen/inventory_item" - android:paddingRight="@dimen/pasilleros_margin_main_menu" + android:paddingRight="@dimen/inventory_item" android:paddingBottom="@dimen/inventory_item"> @@ -134,7 +135,7 @@ android:id="@+id/layer_visible" android:layout_width="match_parent" android:layout_height="match_parent" - android:layout_weight="8" + android:layout_weight="6" android:orientation="vertical">