refs #6982 feat:pickerHelper

This commit is contained in:
Sergio De la torre 2024-04-04 11:57:30 +02:00
parent 2be1c44f83
commit 1260fcaa20
8 changed files with 271 additions and 462 deletions

View File

@ -168,7 +168,7 @@ interface OnCollectionSelectedListener {
}
interface OnCollectionTicketSelectedListener {
fun onCollectionSelected(collection: CollectionTicket, type: String)
fun onCollectionSelected(collection: CollectionTicket, type: String, hasPicking:Boolean = false)
}
interface OnQuantityClickListener {

View File

@ -28,11 +28,22 @@ import es.verdnatura.domain.ConstAndValues.BASEURLSALIX
import es.verdnatura.domain.ConstAndValues.CONTROLADOR
import es.verdnatura.domain.ConstAndValues.PRINTERNAME
import es.verdnatura.domain.ConstAndValues.SACADOR
import es.verdnatura.domain.ConstAndValues.SECTORFK
import es.verdnatura.domain.notNull
import es.verdnatura.domain.toast
import es.verdnatura.presentation.base.BaseFragment
import es.verdnatura.presentation.common.*
import es.verdnatura.presentation.common.ItemScanned
import es.verdnatura.presentation.common.OnBarcodeRowClickListener
import es.verdnatura.presentation.common.OnMistakeClickListener
import es.verdnatura.presentation.common.OnOptionsSelectedListener
import es.verdnatura.presentation.common.OnPackingClickSaleListener
import es.verdnatura.presentation.common.OnPasillerosItemClickListener
import es.verdnatura.presentation.common.OnQuantityClickSaleListener
import es.verdnatura.presentation.common.OnSaleClickSaleListener
import es.verdnatura.presentation.common.OnTicketClickSaleListener
import es.verdnatura.presentation.common.ToolBarAdapterTooltip
import es.verdnatura.presentation.common.hideKeyboard
import es.verdnatura.presentation.common.itemScanIsQr
import es.verdnatura.presentation.common.itemScanValue
import es.verdnatura.presentation.view.component.CustomDialog
import es.verdnatura.presentation.view.component.CustomDialogInput
import es.verdnatura.presentation.view.component.CustomDialogList
@ -44,12 +55,16 @@ import es.verdnatura.presentation.view.feature.collection.adapter.SaleAdapterNew
import es.verdnatura.presentation.view.feature.collection.mapper.map
import es.verdnatura.presentation.view.feature.main.activity.MainActivity
import es.verdnatura.presentation.view.feature.pasillero.model.PasillerosItemVO
import es.verdnatura.presentation.view.feature.sacador.model.*
import es.verdnatura.presentation.view.feature.sacador.model.CollectionTicket
import es.verdnatura.presentation.view.feature.sacador.model.Sale
import es.verdnatura.presentation.view.feature.sacador.model.SaleVO
import org.json.JSONObject
@Suppress("UNUSED_ANONYMOUS_PARAMETER")
class CollectionFragmentPickerNew(
var collection: CollectionTicket, var type: String = SACADOR
var collection: CollectionTicket,
var type: String = SACADOR,
var hasPickingOrder: Boolean = false
) : BaseFragment<FragmentCollectionNewBinding, CollectionViewModel>(
CollectionViewModel::class
) {
@ -91,8 +106,12 @@ class CollectionFragmentPickerNew(
private lateinit var myGroupList: List<Sale>
companion object {
fun newInstance(collection: CollectionTicket, type: String) =
CollectionFragmentPickerNew(collection, type)
fun newInstance(
collection: CollectionTicket,
type: String,
hasPickingOrder: Boolean = false
) =
CollectionFragmentPickerNew(collection, type, hasPickingOrder)
}
override fun onAttach(context: Context) {
@ -127,9 +146,11 @@ class CollectionFragmentPickerNew(
binding.splashProgress.visibility = View.VISIBLE
setEvents()
setToolBar()
if (collection.tickets.isNotEmpty()) {
createCollectionList()
}
super.init()
}
@ -183,7 +204,7 @@ class CollectionFragmentPickerNew(
override fun onOptionsItemSelected(item: Drawable) {
when (item) {
iconViewCollection.drawable -> getCollection()
//iconViewCollection.drawable -> getCollection()
iconPrint.drawable -> print()
iconAdd.drawable -> addItem()
iconWorker.drawable -> showUser()
@ -227,26 +248,26 @@ class CollectionFragmentPickerNew(
return false
}
private fun getCollection() {
binding.splashProgress.visibility = View.VISIBLE
if (!buttonPushedGetCollection) {
viewModel.collection_get(
collection.collectionFk,
mobileApplication.dataStoreApp.readDataStoreKey(SECTORFK),
print = "0",
type
)
buttonPushedGetCollection = true
} else {
viewModel.collectionTicketGetSalix(
lastScanned,
print = false
/* private fun getCollection() {
binding.splashProgress.visibility = View.VISIBLE
if (!buttonPushedGetCollection) {
viewModel.collection_get(
collection.collectionFk,
mobileApplication.dataStoreApp.readDataStoreKey(SECTORFK),
print = "0",
type
)
buttonPushedGetCollection = true
} else {
viewModel.collectionTicketGetSalix(
lastScanned,
print = false
)
buttonPushedGetCollection = false
}
lastScanned = collection.collectionFk
}
)
buttonPushedGetCollection = false
}
lastScanned = collection.collectionFk
}*/
private fun scanRequest() {
binding.scanInput.requestFocus()
@ -412,10 +433,12 @@ class CollectionFragmentPickerNew(
})*/
responseExistsItemShelvingSale.observe(viewLifecycleOwner, Observer {
if (!goBack) {
if (it.exists){
markLine(it.position, it.quantity,true)
}else{
"Actualizando las líneas porque la reserva está modificada".toast(requireContext())
if (it.exists) {
markLine(it.position, it.quantity, true)
} else {
"Actualizando las líneas porque la reserva está modificada".toast(
requireContext()
)
viewModel.collectionTicketGetSalix(collection.collectionFk, false)
}
}
@ -584,12 +607,21 @@ class CollectionFragmentPickerNew(
tickets = ArrayList()
var observations = ""
val myPickingFrom = mobileApplication.dataStoreApp.readDataStoreKey<Int>("PICKING_FROM")
val myPickingTo = mobileApplication.dataStoreApp.readDataStoreKey<Int>("PICKING_TO")
collection.tickets.forEach { ticket ->
if (!observations.isNullOrEmpty()) observations =
observations + " " + ticket.observations
ticket.sales.forEach { sale ->
salesList.add(sale)
if (hasPickingOrder) {
if (sale.pickingOrder != null && sale.pickingOrder in myPickingFrom..myPickingTo) {
salesList.add(sale)
}
} else {
salesList.add(sale)
}
}
}
@ -650,7 +682,7 @@ class CollectionFragmentPickerNew(
showScanner(index, sale)
} else {
println("Sacador **** desmarcar")
unMarkLine(index, sales[index])
unMarkLine(index, myGroupList[index])
}
}
@ -864,22 +896,28 @@ class CollectionFragmentPickerNew(
R.string.sure
)
).setOkButton(getString(R.string.unmark)) {
sale.isPicked = 0
saleAdapter!!.notifyDataSetChanged()
var mySale = sale.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
}
if (!sale.isParent && sale.reservedQuantity == 0 && sale.originalQuantity != sale.saleQuantity) {
"No es posible desmarcar. Hablar con responsable almacén".toast(requireContext())
} else {
/* saleAdapter!!.notifyDataSetChanged()
var mySale = sale.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
}
}*/
storedBackPosition = position
setListPosition(position, false)
viewModel.itemShelvingSaleUnpicked(myGroupList[position].itemShelvingSaleFk)
sale.isPicked = 0
positionUnmarked = position
setTotalLines()
scanRequest()
}
storedBackPosition = position
setListPosition(position, false)
viewModel.itemShelvingSaleUnpicked(sales[position].itemShelvingSaleFk)
println("itemshelvingSale ${sales[position].itemShelvingSaleFk}")
positionUnmarked = position
setTotalLines()
scanRequest()
customDialog.dismiss()
}.setKoButton(getString(R.string.cancel)) {
scanRequest()
@ -953,8 +991,16 @@ class CollectionFragmentPickerNew(
var quantityToReserve = customDialogList.getValue().toInt()
if (quantityToReserve < totalReserved) {
customDialogList.dismiss()
showQuestionUbicationEmpty(position, quantityToReserve)
if (customDialogList.getValueTwo() in sales[position].Barcodes || customDialogList.getValueTwo() == sales[position].itemFk.toString()) {
customDialogList.dismiss()
showQuestionUbicationEmpty(position, quantityToReserve)
} else {
ma.messageWithSound(
message = "Indique el item correctamente", isError =
true, isPlayed = true, isToasted = false
)
}
}
if (quantityToReserve > totalReserved) {
@ -1025,7 +1071,8 @@ class CollectionFragmentPickerNew(
}
private fun showQuestionUbicationEmpty(position: Int, quantity: Int = 0) {
customDialogThreeButtonsQuantity.setTitle("Cambio de cantidad a $quantity")
customDialogThreeButtonsQuantity.setTitle("Cambio de cantidad a $quantity del artículo ${sales[position].itemFk}")
.setDescription("¿Quedan unidades del artículo ${sales[position].itemFk} en el carro escaneado?")
.setValue("").setCustomDialogValue(View.GONE)
customDialogThreeButtonsQuantity.setOkButtonAdd("SI") {
@ -1038,9 +1085,15 @@ class CollectionFragmentPickerNew(
}.setOkButtonTwo("NO") {
scanRequest()
customDialogThreeButtonsQuantity.dismiss()
if (quantity == 0){
viewModel.itemShelvingSaleExists(myGroupList[position].itemShelvingSaleFk, position, quantity)
}else{markLine(position, quantity, true)}
if (quantity == 0) {
viewModel.itemShelvingSaleExists(
myGroupList[position].itemShelvingSaleFk,
position,
quantity
)
} else {
markLine(position, quantity, true)
}
//markLine(position, quantity, true)
}.setKoButton("CANCELAR") {
scanRequest()

View File

@ -850,6 +850,7 @@ class MainActivity : BaseActivity<ActivityMainBinding>(), OnPasillerosItemClickL
getString(R.string.tickets) -> {
addFragmentOnTop(TicketsFragment.newInstance(item.title, entryPoint))
}
getString(R.string.pickerHelper) -> {
addFragmentOnTop(PickerHelperFragment.newInstance(item.title))
}
@ -981,9 +982,13 @@ class MainActivity : BaseActivity<ActivityMainBinding>(), OnPasillerosItemClickL
}
override fun onCollectionSelected(collection: CollectionTicket, type: String) {
override fun onCollectionSelected(
collection: CollectionTicket,
type: String,
hasPicking: Boolean
) {
addFragmentOnTop(CollectionFragmentPickerNew.newInstance(collection, type))
addFragmentOnTop(CollectionFragmentPickerNew.newInstance(collection, type, hasPicking))
}

View File

@ -3,46 +3,37 @@ package es.verdnatura.presentation.view.feature.sacador.fragment
import android.annotation.SuppressLint
import android.content.Context
import android.graphics.drawable.Drawable
import android.os.Build
import android.text.InputType
import android.view.View.GONE
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
import com.google.gson.JsonArray
import com.google.gson.JsonObject
import es.verdnatura.R
import es.verdnatura.databinding.FragmentInventoryParkingBinding
import es.verdnatura.databinding.FragmentGeneralBlackBinding
import es.verdnatura.domain.ConstAndValues
import es.verdnatura.domain.toast
import es.verdnatura.presentation.base.BaseFragment
import es.verdnatura.presentation.common.OnBarcodeRowClickListener
import es.verdnatura.presentation.common.OnMoreClickListener
import es.verdnatura.presentation.common.OnCollectionTicketSelectedListener
import es.verdnatura.presentation.common.OnOptionsSelectedListener
import es.verdnatura.presentation.common.OnPasillerosItemClickListener
import es.verdnatura.presentation.common.OnVisibleInventoryClickListener
import es.verdnatura.presentation.common.ToolBarAdapterTooltip
import es.verdnatura.presentation.common.itemScanValue
import es.verdnatura.presentation.view.component.CustomDialogInput
import es.verdnatura.presentation.view.component.CustomDialogList
import es.verdnatura.presentation.view.feature.articulo.adapter.BarcodeAdapter
import es.verdnatura.presentation.view.feature.articulo.model.BarcodeVO
import es.verdnatura.presentation.view.feature.inventario.adapter.InventoryParkingAdapter
import es.verdnatura.presentation.view.feature.inventario.model.ItemInventoryParking
import es.verdnatura.presentation.view.feature.ubicador.model.ItemUbicadorVO
import es.verdnatura.presentation.view.feature.sacador.model.CollectionTicket
import kotlinx.coroutines.runBlocking
@Suppress("UNUSED_ANONYMOUS_PARAMETER")
class PickerHelperFragment(
var title: String = "",
) : BaseFragment<FragmentInventoryParkingBinding, SacadorViewModel>(
var title: String = ""
) : BaseFragment<FragmentGeneralBlackBinding, SacadorViewModel>(
SacadorViewModel::class
) {
private var onCollectionSelectedListener: OnCollectionTicketSelectedListener? = null
private var adapter: InventoryParkingAdapter? = null
private lateinit var customDialogInput: CustomDialogInput
private lateinit var customDialogList: CustomDialogList
private var pasillerosItemClickListener: OnPasillerosItemClickListener? = null
private var isBack = false
@ -62,56 +53,47 @@ class PickerHelperFragment(
fun newInstance(title: String) = PickerHelperFragment(title)
}
override fun getLayoutId(): Int = R.layout.fragment_inventory_parking
override fun getLayoutId(): Int = R.layout.fragment_general_black
override fun onPause() {
try {
val layoutManager =
binding.inventoryParkingRecyclerview.layoutManager as LinearLayoutManager
scrollPosition = layoutManager.findFirstVisibleItemPosition()
} catch (exception: Exception) {
}
isBack = true
super.onPause()
}
override fun onAttach(context: Context) {
if (context is OnPasillerosItemClickListener) pasillerosItemClickListener = context
super.onAttach(context)
if (context is OnCollectionTicketSelectedListener) onCollectionSelectedListener = context
}
@RequiresApi(Build.VERSION_CODES.O)
override fun init() {
customDialogInput = CustomDialogInput(requireContext())
customDialogList = CustomDialogList(requireContext())
ma.hideBottomNavigation(GONE)
binding.mainToolbar.toolbarTitle.text = title
setEvents()
setViews()
setToolBar()
if (!isBack) {
setParkingFromTo()
}
checkParkingsToPicker()
super.init()
}
private fun setViews() {
binding.inventoryParkingRecyclerview.addOnScrollListener(object :
RecyclerView.OnScrollListener() {
override fun onScrolled(recyclerView: RecyclerView, dx: Int, dy: Int) {
scrollPosition =
(recyclerView.layoutManager as LinearLayoutManager).findFirstVisibleItemPosition()
super.onScrolled(recyclerView, dx, dy)
}
})
private fun checkParkingsToPicker() {
val parkingFrom = mobileApplication.dataStoreApp.readDataStoreKey<String>("PARKING_FROM")
val parkingTo = mobileApplication.dataStoreApp.readDataStoreKey<String>("PARKING_TO")
if (parkingTo.isNotBlank()) {
binding.mainToolbar.toolbarTitle.text =
getString(R.string.parkingForPicking, parkingFrom, parkingTo)
} else {
showSettingsHelper(
)
}
}
@RequiresApi(Build.VERSION_CODES.O)
private fun setToolBar() {
val iconAdd = ImageView(context)
@ -129,25 +111,15 @@ class PickerHelperFragment(
val iconParkingFrom = ImageView(context)
iconParkingFrom.setImageResource(R.drawable.ic_eye_inventory)
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
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)
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)
}
if (listIcons.isEmpty()) {
listIcons.add(iconParkingFrom)
listIcons.add(iconFilter)
listIcons.add(iconReset)
} else {
listIcons.clear()
listIcons.add(iconParkingFrom)
listIcons.add(iconFilter)
listIcons.add(iconReset)
}
listIcons.add(iconReset)
listIcons.add(iconParkingFrom)
binding.mainToolbar.toolbarIcons.adapter =
ToolBarAdapterTooltip(listIcons, object : OnOptionsSelectedListener {
@ -155,123 +127,58 @@ class PickerHelperFragment(
when (item) {
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) {
}
}
iconReset.drawable -> {
if (!myListInventory.isNullOrEmpty()) {
binding.textinputlayoutMatricula.visibility = VISIBLE
showResetShelving()
} else {
getString(R.string.listInventoryEmpty).toast(requireContext())
}
showResetShelving()
}
iconParkingFrom.drawable -> {
setParkingFromTo()
showSettingsHelper()
}
}
}
})
chageListAdapter(listIcons.filter { it != iconReset })
binding.mainToolbar.toolbarIcons.layoutManager =
LinearLayoutManager(requireContext(), LinearLayoutManager.HORIZONTAL, false)
}
private fun chageListAdapter(filterList: List<ImageView>, removeReset: Boolean = false) {
if (!removeReset) {
(binding.mainToolbar.toolbarIcons.adapter as ToolBarAdapterTooltip).setItemsList(
filterList
)
} else {
(binding.mainToolbar.toolbarIcons.adapter as ToolBarAdapterTooltip).setItemsList(
filterList.filter {
it.drawable.constantState?.equals(
context?.getDrawable(
R.drawable.ic_remove_checks
)?.constantState
) != true
})
}
}
private fun showResetShelving() {
customDialogInput.setFocusText()
customDialogInput.setInputText(InputType.TYPE_CLASS_TEXT)
customDialogInput.setTitle(getString(R.string.checkItemShelvingDescrip))
.setDescription(getString(R.string.checkItemShelvingSelect))
.setOkButton(getString(R.string.cancel)) {
customDialogInput.dismiss()
}.setKoButton(getString(R.string.ok)) {
checkSelvingsForUpdate(customDialogInput.getValue())
}.show()
customDialogInput.getEditText().setOnEditorActionListener { _, actionId, _ ->
if (actionId == EditorInfo.IME_ACTION_SEARCH || actionId == EditorInfo.IME_ACTION_DONE || actionId == 0 || actionId == 5) {
if (customDialogInput.getValue().isNotEmpty()) {
checkSelvingsForUpdate(customDialogInput.getValue())
}
return@setOnEditorActionListener true
}
false
binding.mainToolbar.toolbarTitle.text = title
runBlocking {
mobileApplication.dataStoreApp.editDataStoreKey(
"PARKING_FROM", ""
)
mobileApplication.dataStoreApp.editDataStoreKey(
"PICKING_FROM", 0
)
mobileApplication.dataStoreApp.editDataStoreKey(
"PARKING_TO", ""
)
mobileApplication.dataStoreApp.editDataStoreKey(
"PICKING_TO", 0
)
}
showSettingsHelper()
}
private fun checkSelvingsForUpdate(shelvingInput: String) {
private fun showSettingsHelper() {
val filter = JsonObject()
val inqValues = JsonArray()
for (item in myListInventory) {
if (item.shelvingFk == shelvingInput) {
inqValues.add(item.id)
}
}
if (inqValues.size() == 0) {
ma.messageWithSound("", true, true, "", null)
} else {
filter.add("id", JsonObject().apply { add("inq", inqValues) })
/* viewModel.itemShelvingsReset(
filter, ItemShelvingChecked(null, mobileApplication.userId!!)
)*/
}
ma.hideKeyboard(customDialogInput.getEditText())
customDialogInput.setValue("")
customDialogInput.dismiss()
binding.editMatricula.requestFocus()
customDialogList.setTitle(
"Parkings del almacén"
)
customDialogList.setDescription(
}
private fun setParkingFromTo() {
binding.textinputlayoutMatricula.visibility = VISIBLE
customDialogList.setTitle("Parkings del almacén")
customDialogList.setDescription("Indica los parkings por los que voy a sacar")
"Indica los parkings por los que voy a estar sacando"
)
.setKoButton(getString(R.string.cancel)) {
ma.hideKeyboard(customDialogList.getEditText())
listParkings = ArrayList()
customDialogList.dismiss()
ma.onMyBackPressed()
}.setValue("").show()
customDialogList.getEditText().requestFocus()
@ -282,26 +189,35 @@ class PickerHelperFragment(
if (customDialogList.getValue().isNotEmpty()) {
try {
if (listParkings.size == 2) {
callGetInventory(
listParkings.first().code!!.uppercase(),
customDialogList.getValue().uppercase()
)
when (listParkings.size) {
0 -> {
listParkings.add(0, BarcodeVO(code = customDialogList.getValue()))
viewModel.getPickingOrder(customDialogList.getValue())
}
1 -> {
listParkings.add(
0,
BarcodeVO(code = customDialogList.getValue())
)
viewModel.getPickingOrder(customDialogList.getValue())
}
else -> {
listParkings.clear()
customDialogList.dismiss()
}
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()))
}
} catch (e: Exception) {
ma.messageWithSound(e.message.toString(), true, true, "", true)
ma.messageWithSound(e.message.toString(), isError = true, isPlayed = true)
}
listWagonsAdapter!!.notifyItemInserted(listParkings.size - 1)
listWagonsAdapter!!.notifyItemChanged(0)
}
customDialogList.setValue("")
ma.hideKeyboard(customDialogList.getEditText())
@ -311,7 +227,8 @@ class PickerHelperFragment(
}
listWagonsAdapter = BarcodeAdapter(
listParkings, object : OnBarcodeRowClickListener {
listParkings,
object : OnBarcodeRowClickListener {
override fun onBarcodeRowClickListener(item: BarcodeVO) {
}
@ -324,130 +241,32 @@ class PickerHelperFragment(
}
private fun callGetInventory(parkingFromScan: String, parkingToScan: String) {
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.scanInput.visibility = VISIBLE
binding.scanInput.setHint(getString(R.string.scanCollection))
binding.mainToolbar.backButton.setOnClickListener {
isBack = true
if (shelvingSaved.isNullOrBlank()) {
ma.onMyBackPressed()
} else {
resetChecking()
}
ma.onMyBackPressed()
}
binding.inventorySwipe.setOnRefreshListener {
positionShelvingChecking = -1
positionItemChecking = -1
shelvingSaved = ""
/* viewModel.getInventoryParking(
parkingFrom, parkingTo
)*/
binding.editMatricula.hint = getString(R.string.scanShelving)
chageListAdapter(listIcons.filter {
it.drawable.constantState?.equals(
context?.getDrawable(
R.drawable.ic_remove_checks
)?.constantState
) != true
})
binding.inventorySwipe.isRefreshing = false
}
binding.editMatricula.requestFocus()
binding.editMatricula.setOnEditorActionListener { v, actionId, event ->
binding.scanInput.requestFocus()
binding.scanInput.setOnEditorActionListener { v, actionId, event ->
if (actionId == EditorInfo.IME_ACTION_SEARCH || actionId == EditorInfo.IME_ACTION_DONE || actionId == 0 || actionId == 5) {
if (!binding.editMatricula.text.toString().isEmpty()) {
if (binding.scanInput.text.toString().isNotEmpty()) {
if (positionShelvingChecking == -1) {
try {
navigateToCollectionList(binding.scanInput.text.toString().toInt())
try {
binding.editMatricula.setText(
itemScanValue(
binding.editMatricula.text.toString(), "buy", "more"
).toString().uppercase()
)
} catch (ex: Exception) {
ex.message!!.toast(requireContext())
}
positionShelvingChecking = myListInventory.indexOfFirst { item ->
item.shelvingFk.uppercase() == binding.editMatricula.text.toString()
}
if (positionShelvingChecking != -1) {
shelvingSaved = myListInventory[positionShelvingChecking].shelvingFk.uppercase()
}
var allChecked = if (positionShelvingChecking != -1) {
myListInventory.filter { it.shelvingFk.uppercase() == myListInventory[positionShelvingChecking].shelvingFk.uppercase() }
.all { item ->
item.isChecked != null && item.isChecked!! > 0
}
} else {
false
}
if (allChecked) {
ma.messageWithSound(
getString(R.string.plateChecked), false, true, "", isToasted = true
)
chageListAdapter(listIcons)
adapter!!.setItems(myListInventory.filter { it.shelvingFk.uppercase() == myListInventory[positionShelvingChecking].shelvingFk.uppercase() })
positionShelvingChecking = -1
positionItemChecking = -1
shelvingSaved = ""
binding.editMatricula.hint = getString(R.string.scanShelving)
binding.textinputlayoutMatricula.hint = getString(R.string.scanShelving)
} else {
if (positionShelvingChecking == -1) {
ma.messageWithSound(
getString(R.string.shelvingNotFound), true, true, "", true
)
} else {
chageListAdapter(listIcons)
adapter!!.setItems(myListInventory.filter { it.shelvingFk == myListInventory[positionShelvingChecking].shelvingFk })
binding.editMatricula.hint = getString(R.string.scanItemForChecking)
binding.textinputlayoutMatricula.hint =
getString(R.string.scanItemForChecking)
}
}
} else {
try {
/* viewModel.getIdFromCodeSalix(
code = itemScanValue(
binding.editMatricula.text.toString(), "buy", "more"
).toString()
)*/
} catch (ex: Exception) {
ma.messageWithSound(ex.message!!, true, true, "", null)
}
} catch (ex: Exception) {
ex.message!!.toast(requireContext())
}
binding.editMatricula.setText("")
ma.hideKeyboard(binding.editMatricula)
binding.scanInput.setText("")
ma.hideKeyboard(binding.scanInput)
}
return@setOnEditorActionListener true
}
@ -456,55 +275,12 @@ class PickerHelperFragment(
}
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) {
positionItemChecking = myListInventory.indexOfFirst { item ->
item.itemFk == itemCode.toInt() && item.shelvingFk.uppercase() == myListInventory[positionShelvingChecking].shelvingFk.uppercase() && 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 {
try {
/* viewModel.itemShelvingUpdate(
myListInventory[positionItemChecking].id,
ItemShelvingChecked(true, mobileApplication.userId!!)
)*/
myListInventory[positionItemChecking].isChecked = 1
adapter!!.notifyDataSetChanged()
binding.editMatricula.hint = getString(R.string.scanShelving)
var allChecked =
myListInventory.filter { it.shelvingFk.uppercase() == myListInventory[positionShelvingChecking].shelvingFk.uppercase() }
.all { item ->
item.isChecked != null && item.isChecked!! > 0
}
if (allChecked) {
shelvingSaved = ""
}
positionItemChecking = -1
positionShelvingChecking = -1
} catch (ex: Exception) {
}
}
private fun navigateToCollectionList(collectionFk: Int) {
onCollectionSelectedListener!!.onCollectionSelected(
CollectionTicket(collectionFk = collectionFk),
ConstAndValues.PREPARED,
true
)
}
@SuppressLint("SetTextI18n")
@ -512,87 +288,54 @@ class PickerHelperFragment(
with(viewModel) {
response.observe(viewLifecycleOwner) {
if (!it.isError && it.response.isNotBlank()) {
runBlocking {
when (listParkings.size) {
1 -> {
mobileApplication.dataStoreApp.editDataStoreKey(
"PARKING_FROM",
listParkings.first().code.toString()
)
mobileApplication.dataStoreApp.editDataStoreKey(
"PICKING_FROM",
it.response.toInt()
)
}
response.observe(viewLifecycleOwner, Observer {
chageListAdapter(listIcons, true)
callGetInventory(
parkingFrom, parkingTo
)
2 -> {
mobileApplication.dataStoreApp.editDataStoreKey(
"PARKING_TO",
listParkings.first().code.toString()
)
mobileApplication.dataStoreApp.editDataStoreKey(
"PICKING_TO",
it.response.toInt()
)
binding.mainToolbar.toolbarTitle.text =
getString(R.string.parkingForPicking, listParkings[1].code,listParkings[0].code)
listParkings.clear()
customDialogList.dismiss()
})
}
else -> {
//listParkings.clear()
// customDialogList.dismiss()
// showSettingsHelper()
ma.messageWithSound(
"Parking no encontrado",
isError = true,
isPlayed = true
)
}
}
}
}
}
}
}
private fun createListInventoryParking(
) {
adapter = InventoryParkingAdapter((if (filterActivated) {
if (!shelvingSaved.isNullOrEmpty()) {
myListInventory.filter { (it.isChecked == null || it.isChecked == 0) && it.shelvingFk.uppercase() == shelvingSaved.uppercase() }
} else {
myListInventory.filter { it.isChecked == null || it.isChecked == 0 }
}
} else {
if (!shelvingSaved.isNullOrEmpty()) {
myListInventory.filter { it.shelvingFk.uppercase() == shelvingSaved.uppercase() }
} else {
myListInventory
}
}),
onPasillerosItemClickListener = pasillerosItemClickListener!!,
onVisibleInventoryClickListener = object : OnVisibleInventoryClickListener {
override fun onVisibleInventoryClickListener(item: ItemInventoryParking) {
changeVisible(item)
}
},
onMoreClickListener = object : OnMoreClickListener {
override fun onMoreClickListener(item: ItemUbicadorVO) {
}
})
binding.inventoryParkingRecyclerview.adapter = adapter
binding.inventoryParkingRecyclerview.layoutManager = LinearLayoutManager(
requireContext(), LinearLayoutManager.VERTICAL, false
)
}
private fun changeVisible(item: ItemInventoryParking) {
customDialogInput.setInputText(InputType.TYPE_CLASS_NUMBER)
customDialogInput.setTitle(getString(R.string.quantity))
customDialogInput.setDescription(getString(R.string.quantityVisible)).setValue(item.visible.toString())
.setOkButton(getString(R.string.modify)) {
try {
if (customDialogInput.getValue().toInt() >= 0) {
/*viewModel.itemShelvingUpdate(
item.id, if (customDialogInput.getValue().toInt() == 0) {
ItemShelvingVisibleZero(customDialogInput.getValue().toInt(), true)
} else {
ItemShelvingVisible(customDialogInput.getValue().toInt())
}
)*/
} else {
throw Exception("")
}
} catch (err: Exception) {
(getString(R.string.errorQuantity).toast(requireContext()))
}
customDialogInput.setValue("")
customDialogInput.dismiss()
}.setKoButton(getString(R.string.cancel)) {
customDialogInput.dismiss()
}.show()
customDialogInput.setFocusText()
}
}

View File

@ -753,6 +753,8 @@
<string name="attachImage">"Imágenes: "</string>
<string name="pickerHelper">Sacadores asistente</string>
<string name="pickerHelperDescrip">Permite sacar parte de la colección</string>
<string name="parkingForPicking">P:%1$s→%2$s</string>
<string name="scanCollection">Escanea colección</string>
</resources>

View File

@ -753,5 +753,7 @@
<string name="attachImage">"Imágenes: "</string>
<string name="pickerHelper">Sacadores asistente</string>
<string name="pickerHelperDescrip">Permite sacar parte de la colección</string>
<string name="parkingForPicking">P:%1$s→%2$s</string>
<string name="scanCollection">Escanea colección</string>
</resources>

View File

@ -753,5 +753,7 @@
<string name="attachImage">"Imágenes: "</string>
<string name="pickerHelper">Sacadores asistente</string>
<string name="pickerHelperDescrip">Permite sacar parte de la colección</string>
<string name="parkingForPicking">P:%1$s→%2$s</string>
<string name="scanCollection">Escanea colección</string>
</resources>

View File

@ -753,5 +753,7 @@
<string name="attachImage">Imágenes: </string>
<string name="pickerHelper">Sacadores asistente</string>
<string name="pickerHelperDescrip">Permite sacar parte de la colección</string>
<string name="parkingForPicking">P:%1$s→%2$s</string>
<string name="scanCollection">Escanea colección</string>
</resources>