refs #6531 feat:last tickets

This commit is contained in:
Sergio De la torre 2024-02-27 09:46:34 +01:00
parent 3afe9de1c9
commit 9818b0babe
1 changed files with 47 additions and 40 deletions

View File

@ -10,6 +10,7 @@ import es.verdnatura.databinding.FragmentGeneralBlackBinding
import es.verdnatura.domain.ConstAndValues
import es.verdnatura.presentation.base.BaseFragment
import es.verdnatura.presentation.common.OnCollectionSelectedListener
import es.verdnatura.presentation.view.component.CustomDialog
import es.verdnatura.presentation.view.feature.collection.fragment.CollectionViewModel
import es.verdnatura.presentation.view.feature.sacador.model.CollectionVO
@ -60,46 +61,52 @@ class ControladorFragment :
binding.splashProgress.visibility = VISIBLE
binding.scanInput.setText(textScanned_filterDouble(binding.scanInput.text!!.toString()))
//Tarea 6458 descomentar si ok
/* collectionViewModel = CollectionViewModel(mobileApplication)
collectionViewModel!!.ticketState(binding.scanInput.text.toString().toInt())
collectionViewModel!!.responseTicketState.observe(
viewLifecycleOwner,
Observer { it ->
binding.splashProgress.visibility = View.GONE
if ((it.code == "ON_CHECKING" || it.code == "CHECKED") && it.user.id != mobileApplication.userId) {
var customDialogWarning = CustomDialog(requireContext())
customDialogWarning.setTitle(getString(R.string.info))
customDialogWarning.setDescription(
if (it.code == "ON_CHECKING") {
getString(R.string.checkingByUser, it.user.username)
} else {
getString(R.string.checkedByUser, it.user.username)
}
)
.setOkButton(getString(R.string.aware)) {
customDialogWarning.dismiss()
binding.splashProgress.visibility= VISIBLE
viewModel.collectionTicketGet(
sectorFk = mobileApplication.dataStoreApp.readDataStoreKey(
ConstAndValues.SECTORFK
),
collectionFk = binding.scanInput.text.toString().toInt(),
print = "0",
type = ConstAndValues.CONTROLADOR
)
}.show()
customDialogWarning.currentFocus
} else {*/
viewModel.collectionTicketGet(
sectorFk = mobileApplication.dataStoreApp.readDataStoreKey(
ConstAndValues.SECTORFK
),
collectionFk = binding.scanInput.text.toString().toInt(),
print = "0",
type = ConstAndValues.CONTROLADOR
)
// }
//})
collectionViewModel = CollectionViewModel(mobileApplication)
collectionViewModel!!.ticketState(binding.scanInput.text.toString().toInt())
collectionViewModel!!.responseTicketState.observe(
viewLifecycleOwner,
Observer { it ->
binding.splashProgress.visibility = View.GONE
if ((it.code == "ON_CHECKING" || it.code == "CHECKED") && it.user.id != mobileApplication.userId) {
var customDialogWarning = CustomDialog(requireContext())
customDialogWarning.setTitle(getString(R.string.info))
customDialogWarning.setDescription(
if (it.code == "ON_CHECKING") {
getString(R.string.checkingByUser, it.user.username)
} else {
getString(R.string.checkedByUser, it.user.username)
}
)
.setOkButton(getString(R.string.aware)) {
customDialogWarning.dismiss()
binding.splashProgress.visibility = VISIBLE
viewModel.collectionTicketGet(
sectorFk = mobileApplication.dataStoreApp.readDataStoreKey(
ConstAndValues.SECTORFK
),
collectionFk = binding.scanInput.text.toString()
.toInt(),
print = "0",
type = ConstAndValues.CONTROLADOR
)
}.setKoButton(getString(R.string.cancel)){
binding.scanInput.setText("")
binding.scanInput.requestFocus()
customDialogWarning.dismiss()
}.show()
customDialogWarning.currentFocus
} else {
viewModel.collectionTicketGet(
sectorFk = mobileApplication.dataStoreApp.readDataStoreKey(
ConstAndValues.SECTORFK
),
collectionFk = binding.scanInput.text.toString().toInt(),
print = "0",
type = ConstAndValues.CONTROLADOR
)
}
})
}