refs #6786 inventaryParking

This commit is contained in:
Sergio De la torre 2024-02-02 08:32:17 +01:00
parent 9589279fa2
commit 54bff16431
2 changed files with 36 additions and 10 deletions

View File

@ -40,10 +40,12 @@ class InventoryParkingAdapter(
fun getListItems(): List<ItemInventoryParking> { fun getListItems(): List<ItemInventoryParking> {
return items return items
} }
fun setItems(newItems: List<ItemInventoryParking>) { fun setItems(newItems: List<ItemInventoryParking>) {
items = newItems items = newItems
notifyDataSetChanged() // Notificar al adaptador que los datos han cambiado notifyDataSetChanged() // Notificar al adaptador que los datos han cambiado
} }
fun sortBy(fieldSort: String) { fun sortBy(fieldSort: String) {
when (fieldSort) { when (fieldSort) {
"sector" -> { "sector" -> {
@ -136,6 +138,7 @@ class InventoryParkingAdapter(
} }
if (item.isChecked != null) { if (item.isChecked != null) {
println("item ${item.itemFk} checked ${item.isChecked} ")
when (item.isChecked!!.toInt()) { when (item.isChecked!!.toInt()) {
@ -146,6 +149,14 @@ class InventoryParkingAdapter(
) )
) )
else -> {
itemRowLayout.setBackgroundColor(
ContextCompat.getColor(
visibleText.context,
R.color.verdnatura_black_5
)
)
}
} }
} else { } else {

View File

@ -335,7 +335,12 @@ class InventaryParkingFragment(
private fun setEvents() { private fun setEvents() {
binding.mainToolbar.backButton.setOnClickListener { binding.mainToolbar.backButton.setOnClickListener {
isBack = true isBack = true
requireActivity().onBackPressed() if (shelvingSaved.isNullOrBlank()) {
requireActivity().onBackPressed()
} else {
resetChecking()
}
} }
binding.inventorySwipe.setOnRefreshListener { binding.inventorySwipe.setOnRefreshListener {
@ -371,7 +376,7 @@ class InventaryParkingFragment(
binding.editMatricula.setText( binding.editMatricula.setText(
itemScanValue( itemScanValue(
binding.editMatricula.text.toString(), "buy", "more" binding.editMatricula.text.toString(), "buy", "more"
).toString() ).toString().uppercase()
) )
} catch (ex: Exception) { } catch (ex: Exception) {
ex.message!!.toast(requireContext()) ex.message!!.toast(requireContext())
@ -379,14 +384,14 @@ class InventaryParkingFragment(
} }
positionShelvingChecking = myListInventory.indexOfFirst { item -> positionShelvingChecking = myListInventory.indexOfFirst { item ->
item.shelvingFk == binding.editMatricula.text.toString() item.shelvingFk.uppercase() == binding.editMatricula.text.toString()
} }
if (positionShelvingChecking != -1) { if (positionShelvingChecking != -1) {
shelvingSaved = myListInventory[positionShelvingChecking].shelvingFk shelvingSaved = myListInventory[positionShelvingChecking].shelvingFk.uppercase()
} }
var allChecked = if (positionShelvingChecking != -1) { var allChecked = if (positionShelvingChecking != -1) {
myListInventory.filter { it.shelvingFk == myListInventory[positionShelvingChecking].shelvingFk } myListInventory.filter { it.shelvingFk.uppercase() == myListInventory[positionShelvingChecking].shelvingFk.uppercase() }
.all { item -> .all { item ->
item.isChecked != null && item.isChecked!! > 0 item.isChecked != null && item.isChecked!! > 0
} }
@ -399,7 +404,7 @@ class InventaryParkingFragment(
getString(R.string.plateChecked), false, true, "", isToasted = true getString(R.string.plateChecked), false, true, "", isToasted = true
) )
chageListAdapter(listIcons) chageListAdapter(listIcons)
adapter!!.setItems(myListInventory.filter { it.shelvingFk == myListInventory[positionShelvingChecking].shelvingFk }) adapter!!.setItems(myListInventory.filter { it.shelvingFk.uppercase() == myListInventory[positionShelvingChecking].shelvingFk.uppercase() })
positionShelvingChecking = -1 positionShelvingChecking = -1
positionItemChecking = -1 positionItemChecking = -1
shelvingSaved = "" shelvingSaved = ""
@ -448,9 +453,19 @@ class InventaryParkingFragment(
} }
private fun resetChecking() {
chageListAdapter(listIcons)
positionShelvingChecking = -1
positionItemChecking = -1
shelvingSaved = ""
binding.editMatricula.hint = getString(R.string.scanShelving)
binding.textinputlayoutMatricula.hint = getString(R.string.scanShelving)
callGetInventory(parkingFrom, parkingTo)
}
private fun checkItem(itemCode: String) { private fun checkItem(itemCode: String) {
positionItemChecking = myListInventory.indexOfFirst { item -> positionItemChecking = myListInventory.indexOfFirst { item ->
item.itemFk == itemCode.toInt() && item.shelvingFk == myListInventory[positionShelvingChecking].shelvingFk && item.isChecked == null item.itemFk == itemCode.toInt() && item.shelvingFk.uppercase() == myListInventory[positionShelvingChecking].shelvingFk.uppercase() && item.isChecked == null
} }
@ -473,7 +488,7 @@ class InventaryParkingFragment(
binding.editMatricula.hint = getString(R.string.scanShelving) binding.editMatricula.hint = getString(R.string.scanShelving)
var allChecked = var allChecked =
myListInventory.filter { it.shelvingFk == myListInventory[positionShelvingChecking].shelvingFk } myListInventory.filter { it.shelvingFk.uppercase() == myListInventory[positionShelvingChecking].shelvingFk.uppercase() }
.all { item -> .all { item ->
item.isChecked != null && item.isChecked!! > 0 item.isChecked != null && item.isChecked!! > 0
} }
@ -541,14 +556,14 @@ class InventaryParkingFragment(
adapter = InventoryParkingAdapter((if (filterActivated) { adapter = InventoryParkingAdapter((if (filterActivated) {
if (!shelvingSaved.isNullOrEmpty()) { if (!shelvingSaved.isNullOrEmpty()) {
myListInventory.filter { (it.isChecked == null || it.isChecked == 0) && it.shelvingFk == shelvingSaved } myListInventory.filter { (it.isChecked == null || it.isChecked == 0) && it.shelvingFk.uppercase() == shelvingSaved.uppercase() }
} else { } else {
myListInventory.filter { it.isChecked == null || it.isChecked == 0 } myListInventory.filter { it.isChecked == null || it.isChecked == 0 }
} }
} else { } else {
if (!shelvingSaved.isNullOrEmpty()) { if (!shelvingSaved.isNullOrEmpty()) {
myListInventory.filter { it.shelvingFk == shelvingSaved } myListInventory.filter { it.shelvingFk.uppercase() == shelvingSaved.uppercase() }
} else { } else {
myListInventory myListInventory
} }