refs #5891 inventoryParking

This commit is contained in:
Sergio De la torre 2023-07-27 13:07:34 +02:00
parent e4fc2cdc6e
commit c014dbfd2d
8 changed files with 459 additions and 234 deletions

View File

@ -228,6 +228,10 @@ abstract class BaseFragment<T : ViewDataBinding, V : BaseViewModel>(viewModelCla
R.drawable.expedition_find -> getString(R.string.showLogExpedition) R.drawable.expedition_find -> getString(R.string.showLogExpedition)
R.drawable.ic_info_refresh -> getString(R.string.udpateRoutes) R.drawable.ic_info_refresh -> getString(R.string.udpateRoutes)
R.drawable.ic_info_delivery -> getString(R.string.info) 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 -> { else -> {
"" ""
} }

View File

@ -40,7 +40,10 @@ class InventoryParkingAdapter(
fun getListItems(): List<ItemInventoryParking> { fun getListItems(): List<ItemInventoryParking> {
return items return items
} }
fun setItems(newItems: List<ItemInventoryParking>) {
items = newItems
notifyDataSetChanged() // Notificar al adaptador que los datos han cambiado
}
fun sortBy(fieldSort: String) { fun sortBy(fieldSort: String) {
when (fieldSort) { when (fieldSort) {
"sector" -> { "sector" -> {

View File

@ -11,6 +11,7 @@ import android.view.View.VISIBLE
import android.view.inputmethod.EditorInfo import android.view.inputmethod.EditorInfo
import android.widget.ImageView import android.widget.ImageView
import androidx.annotation.RequiresApi import androidx.annotation.RequiresApi
import androidx.core.content.ContextCompat
import androidx.lifecycle.Observer import androidx.lifecycle.Observer
import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView import androidx.recyclerview.widget.RecyclerView
@ -18,6 +19,7 @@ import com.google.gson.JsonArray
import com.google.gson.JsonObject import com.google.gson.JsonObject
import es.verdnatura.R import es.verdnatura.R
import es.verdnatura.databinding.FragmentInventoryParkingBinding import es.verdnatura.databinding.FragmentInventoryParkingBinding
import es.verdnatura.domain.notNull
import es.verdnatura.domain.toast import es.verdnatura.domain.toast
import es.verdnatura.presentation.base.BaseFragment import es.verdnatura.presentation.base.BaseFragment
import es.verdnatura.presentation.common.* import es.verdnatura.presentation.common.*
@ -62,6 +64,9 @@ class InventaryParkingFragment(
private var positionShelvingChecking: Int = -1 private var positionShelvingChecking: Int = -1
private var positionItemChecking: Int = -1 private var positionItemChecking: Int = -1
private var scrollPosition = 0 private var scrollPosition = 0
private var parkingFrom = ""
private var parkingTo = ""
private var filterActivated = false
companion object { companion object {
fun newInstance(title: String) = fun newInstance(title: String) =
@ -71,12 +76,17 @@ class InventaryParkingFragment(
override fun getLayoutId(): Int = R.layout.fragment_inventory_parking override fun getLayoutId(): Int = R.layout.fragment_inventory_parking
override fun onPause() { override fun onPause() {
val layoutManager = try {
binding.inventoryParkingRecyclerview.layoutManager as LinearLayoutManager val layoutManager =
scrollPosition = layoutManager.findFirstVisibleItemPosition() binding.inventoryParkingRecyclerview.layoutManager as LinearLayoutManager
scrollPosition = layoutManager.findFirstVisibleItemPosition()
}catch (exception:Exception){
}
super.onPause()
isBack = true isBack = true
super.onPause()
} }
@ -98,6 +108,9 @@ class InventaryParkingFragment(
setEvents() setEvents()
setViews() setViews()
setToolBar() setToolBar()
if (!isBack) {
setParkingFromTo()
}
super.init() super.init()
} }
@ -127,19 +140,22 @@ class InventaryParkingFragment(
val iconReset = ImageView(context) val iconReset = ImageView(context)
iconReset.setImageResource(R.drawable.ic_remove_checks) iconReset.setImageResource(R.drawable.ic_remove_checks)
val iconFilter = ImageView(context)
iconFilter.setImageResource(R.drawable.ic_filter_inventory)
val iconParkingFrom = ImageView(context) 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) { 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) iconReload.tooltipText = getTooltip(R.drawable.ic_autorenew_black_24dp)
iconAdd.tooltipText = getString(R.string.addItemShelving) iconAdd.tooltipText = getString(R.string.addItemShelving)
iconReset.tooltipText = getTooltip(R.drawable.ic_remove_checks) iconReset.tooltipText = getTooltip(R.drawable.ic_remove_checks)
iconFilter.tooltipText = getTooltip(R.drawable.ic_filter_inventory)
} }
listIcons.add(iconParkingFrom) listIcons.add(iconParkingFrom)
//listIcons.add(iconAdd) listIcons.add(iconFilter)
//listIcons.add(iconReload)
listIcons.add(iconReset) listIcons.add(iconReset)
@ -148,22 +164,41 @@ class InventaryParkingFragment(
override fun onOptionsItemSelected(item: Drawable) { override fun onOptionsItemSelected(item: Drawable) {
when (item) { 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 -> { iconReset.drawable -> {
showResetShelving() if (!myListInventory.isNullOrEmpty()) {
binding.textinputlayoutMatricula.visibility = VISIBLE
showResetShelving()
} else {
"La lista del inventario está vacía".toast(requireContext())
}
} }
iconParkingFrom.drawable -> { iconParkingFrom.drawable -> {
binding.textinputlayoutMatricula.visibility = VISIBLE
setParkingFromTo() setParkingFromTo()
} }
@ -175,6 +210,10 @@ class InventaryParkingFragment(
LinearLayoutManager(requireContext(), LinearLayoutManager.HORIZONTAL, false) LinearLayoutManager(requireContext(), LinearLayoutManager.HORIZONTAL, false)
} }
private fun filterList() {
TODO("Not yet implemented")
}
private fun showResetShelving() { private fun showResetShelving() {
customDialogInput.setFocusText() customDialogInput.setFocusText()
customDialogInput.setInputText(InputType.TYPE_CLASS_TEXT) customDialogInput.setInputText(InputType.TYPE_CLASS_TEXT)
@ -217,7 +256,10 @@ class InventaryParkingFragment(
filter.add("id", JsonObject().apply { add("inq", inqValues) }) filter.add("id", JsonObject().apply { add("inq", inqValues) })
binding.splashProgress.visibility = VISIBLE binding.splashProgress.visibility = VISIBLE
viewModel.itemShelvingsUpdate(filter, ItemShelvingChecked(null)) viewModel.itemShelvingsUpdate(
filter,
ItemShelvingChecked(null, mobileApplication.userId!!)
)
} }
ma.hideKeyboard(customDialogInput.getEditText()) ma.hideKeyboard(customDialogInput.getEditText())
customDialogInput.setValue("") customDialogInput.setValue("")
@ -227,30 +269,34 @@ class InventaryParkingFragment(
} }
private fun setParkingFromTo() { private fun setParkingFromTo() {
binding.textinputlayoutMatricula.visibility = VISIBLE
customDialogList.setTitle(getString(R.string.selectParkingsCheckin)) customDialogList.setTitle(getString(R.string.selectParkingsCheckin))
customDialogList.setDescription(getString(R.string.selectParkingsFrom)) customDialogList.setDescription(getString(R.string.selectParkingsFrom))
.setOkButton( /* .setOkButton(
getString(R.string.review) getString(R.string.review)
) { ) {
ma.hideKeyboard(customDialogList.getEditText()) ma.hideKeyboard(customDialogList.getEditText())
if (listParkings.size == 1) { if (listParkings.size == 2) {
viewModel.ItemListInventoryParking(
listParkings.first().code!!, callGetInventory(
customDialogList.getValue() listParkings.first().code!!.uppercase(),
) customDialogList.getValue().uppercase()
ma.hideKeyboard(customDialogList.getEditText()) )
listParkings.clear()
customDialogList.dismiss() ma.hideKeyboard(customDialogList.getEditText())
binding.editMatricula.requestFocus() listParkings.clear()
} else { customDialogList.dismiss()
listParkings.add(0, BarcodeVO(code = customDialogList.getValue())) 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()) ma.hideKeyboard(customDialogList.getEditText())
listParkings = ArrayList() listParkings = ArrayList()
customDialogList.dismiss() customDialogList.dismiss()
@ -265,15 +311,18 @@ class InventaryParkingFragment(
try { try {
if (listParkings.size == 1) { if (listParkings.size == 1) {
viewModel.ItemListInventoryParking( callGetInventory(
listParkings.first().code!!, listParkings.first().code!!.uppercase(),
customDialogList.getValue() customDialogList.getValue().uppercase()
) )
ma.hideKeyboard(customDialogList.getEditText()) ma.hideKeyboard(customDialogList.getEditText())
listParkings.clear() listParkings.clear()
customDialogList.dismiss() customDialogList.dismiss()
binding.editMatricula.requestFocus() binding.editMatricula.requestFocus()
} else { } else {
customDialogList.setDescription(getString(R.string.selectParkingsTo))
listParkings.add(0, BarcodeVO(code = customDialogList.getValue())) 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) @RequiresApi(Build.VERSION_CODES.O)
@SuppressLint("SetTextI18n") @SuppressLint("SetTextI18n")
private fun setEvents() { private fun setEvents() {
binding.mainToolbar.backButton.setOnClickListener { binding.mainToolbar.backButton.setOnClickListener {
isBack = true
requireActivity().onBackPressed() requireActivity().onBackPressed()
} }
@ -320,9 +381,21 @@ class InventaryParkingFragment(
if (!binding.editMatricula.text.toString().isEmpty()) { if (!binding.editMatricula.text.toString().isEmpty()) {
if (positionShelvingChecking == -1) { 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 -> positionShelvingChecking = myListInventory.indexOfFirst { item ->
item.shelvingFk == binding.editMatricula.text.toString() item.shelvingFk == binding.editMatricula.text.toString()
} }
@ -339,49 +412,76 @@ class InventaryParkingFragment(
binding.editMatricula.hint = getString(R.string.scanItemForChecking) binding.editMatricula.hint = getString(R.string.scanItemForChecking)
} }
} else { } else {
try { try {
positionItemChecking = myListInventory.indexOfFirst { item ->
item.itemFk == binding.editMatricula.text.toString() viewModel.getIdFromCodeSalix(
.toInt() && item.shelvingFk == myListInventory[positionShelvingChecking].shelvingFk && item.isChecked == null code = itemScanValue(
} binding.editMatricula.text.toString(),
} catch (ex: Exception) { "buy",
ma.messageWithSound("", true, true, "", null) "more"
} ).toString()
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
viewModel.itemShelvingUpdate(
myListInventory.get(positionItemChecking).id,
ItemShelvingChecked(true)
)*/
myListInventory[positionItemChecking].isChecked = 1
adapter!!.notifyDataSetChanged()
binding.editMatricula.hint = getString(R.string.scanShelving)
/* viewModel.getIdFromCode( /* binding.editMatricula.setText(
code = itemScanValue( itemScanValue(
binding.editMatricula.text.toString(), binding.editMatricula.text.toString(),
"buy", "buy",
"more" "more"
).toString() ).toString()
)*/ )*/
} catch (Ex: Exception) {
ma.messageWithSound(Ex.message.toString(), true, true)
}
/* 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("") binding.editMatricula.setText("")
ma.hideKeyboard(binding.editMatricula) ma.hideKeyboard(binding.editMatricula)
@ -391,125 +491,51 @@ class InventaryParkingFragment(
return@setOnEditorActionListener false 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) { private fun checkItem(itemCode: String) {
itemScannedScreen = itemScanned
val listInt: ArrayList<Int> = ArrayList()
if (listItems.filter { it.item == itemScanned }.isEmpty()) { positionItemChecking = myListInventory.indexOfFirst { item ->
listInt.add(itemScanned) 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 { } else {
listItems.sortedBy { it.isChecked }.forEachIndexed { index, item ->
if (item.item == itemScanned) { try {
item.checked = true binding.splashProgress.visibility = VISIBLE
listInt.add(item.item)
ma.messageWithSound("", false, true, "", false) //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() { private fun setTooltips() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
binding.editImg.tooltipText = getTooltip(R.drawable.ic_mode_edit_black_24dp) binding.editImg.tooltipText = getTooltip(R.drawable.ic_mode_edit_black_24dp)
@ -532,40 +558,95 @@ class InventaryParkingFragment(
with(viewModel) { with(viewModel) {
/* loadInventaryParkingList.observe(viewLifecycleOwner) { event -> /* loadInventaryParkingList.observe(viewLifecycleOwner) { event ->
event.getContentIfNotHandled().notNull { event.getContentIfNotHandled().notNull {
binding.splashProgress.visibility = GONE binding.splashProgress.visibility = GONE
if (it.list[0].isError) { if (it.list[0].isError) {
ma.messageWithSound( ma.messageWithSound(
it.list[0].errorMessage, it.list[0].errorMessage,
it.list[0].isError, it.list[0].isError,
false false
) )
} else { } else {
myListInventory = it.list as MutableList<ItemInventoryParking> myListInventory = it.list as MutableList<ItemInventoryParking>
createListInventoryParking(myListInventory) createListInventoryParking(myListInventory)
} }
} }
}*/ }*/
inventoryListParking.observe(viewLifecycleOwner, Observer { inventoryListParking.observe(viewLifecycleOwner, Observer {
binding.splashProgress.visibility = GONE 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 { if (it.list.isNotEmpty()) {
myListInventory = it.list as MutableList<ItemInventoryParking> if (it.list[0].isError) {
createListInventoryParking(myListInventory) ma.messageWithSound(
it.list[0].errorMessage,
it.list[0].isError,
false
)
} else {
myListInventory = it.list as MutableList<ItemInventoryParking>
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<ItemInventoryParking>
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 { response.observe(viewLifecycleOwner, Observer {
binding.splashProgress.visibility = GONE binding.splashProgress.visibility = GONE
if (it.isError) { if (it.isError) {
@ -573,6 +654,11 @@ class InventaryParkingFragment(
} else { } else {
ma.messageWithSound("", it.isError, true, isToasted = false) ma.messageWithSound("", it.isError, true, isToasted = false)
callGetInventory(
parkingFrom,
parkingTo
)
} }
}) })
@ -587,7 +673,11 @@ class InventaryParkingFragment(
) { ) {
adapter = InventoryParkingAdapter( adapter = InventoryParkingAdapter(
myListInventory, if (filterActivated) {
myListInventory.filter { it.isChecked == null || it.isChecked == 0 }
} else {
myListInventory
},
onPasillerosItemClickListener = pasillerosItemClickListener!!, onPasillerosItemClickListener = pasillerosItemClickListener!!,
onVisibleInventoryClickListener = object : OnVisibleInventoryClickListener { onVisibleInventoryClickListener = object : OnVisibleInventoryClickListener {
override fun onVisibleInventoryClickListener(item: ItemInventoryParking) { override fun onVisibleInventoryClickListener(item: ItemInventoryParking) {

View File

@ -63,6 +63,13 @@ class InventaryViewModel(val context: Context) : BaseViewModel(context) {
val loadInventaryParkingList = Transformations.map(_inventoryListParking) { Event(it) } val loadInventaryParkingList = Transformations.map(_inventoryListParking) { Event(it) }
private val _responseCode by lazy { MutableLiveData<ResponseItemVO>() }
val responseCode: LiveData<ResponseItemVO>
get() = _responseCode
val loadReponseCode = Transformations.map(_responseCode) { Event(it) }
//sergio para obtener comprador //sergio para obtener comprador
fun itemShelvingBuyerGet() { fun itemShelvingBuyerGet() {
silex.itemShelvingBuyerGet().enqueue(object : silex.itemShelvingBuyerGet().enqueue(object :
@ -166,6 +173,7 @@ class InventaryViewModel(val context: Context) : BaseViewModel(context) {
}) })
} }
fun itemShelvingsUpdate( fun itemShelvingsUpdate(
where: JsonObject, where: JsonObject,
params: Any, params: Any,
@ -190,6 +198,7 @@ class InventaryViewModel(val context: Context) : BaseViewModel(context) {
}) })
} }
fun itemTrash( fun itemTrash(
itemFk: Int, itemFk: Int,
warehouseFk: 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<List<ItemInventoryParking>>(context) {
override fun onError(t: Throwable) {
val listError: ArrayList<ItemInventoryParking> = ArrayList()
listError.add(
ItemInventoryParking(
isError = true,
errorMessage = getMessageFromAllResponse(
nameofFunction(this),
t.message!!
),
)
)
_inventoryListParking.value = InventoryParkingList(listError)
}
override fun onSuccess(response: Response<List<ItemInventoryParking>>) {
if (response.body() != null) {
_inventoryListParking.value =
response.body()?.let { InventoryParkingList(it) }
}else{
val listError: ArrayList<ItemInventoryParking> = ArrayList()
listError.add(
ItemInventoryParking(
isError = false,
errorMessage = getMessageFromAllResponse(
nameofFunction(this),
response.message()
),
)
)
_inventoryListParking.value = InventoryParkingList(listError)
}
}
})
}
fun ItemListInventoryParking_(
vParkingFrom: String, vParkingFrom: String,
vParkingTo: String vParkingTo: String
) { ) {
@ -487,8 +543,18 @@ class InventaryViewModel(val context: Context) : BaseViewModel(context) {
2 2
), ),
ItemInventoryParking( ItemInventoryParking(
5, 33, "F-01-3", "ZLZ", 2912, "HEL Tropical Red", 2, 37, "Jose Alarcan Gomex", 5,
"http://verdnatura.es/vn-image-data/catalog/1600x900/002912", 0, 0 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( ItemInventoryParking(
6, 6,
@ -519,16 +585,36 @@ class InventaryViewModel(val context: Context) : BaseViewModel(context) {
0 0
), ),
ItemInventoryParking( ItemInventoryParking(
8, 34, "F-01-4", "JXU", 50001, "Monstera I", 130, 37, "Jose Alarcan Gomex", 8,
"http://verdnatura.es/vn-image-data/catalog/1600x900/50001", 0, 2 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( ItemInventoryParking(
9, 34, "F-01-4", "JXU", 50004, "Monstera IV", 240, 37, "Jose Alarcan Gomex", 9,
"http://verdnatura.es/vn-image-data/catalog/1600x900/50003", 0, 2 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) /*silex.itemShelving_inventory(vParkingFromFk, vParkingToFk)
.enqueue(object : .enqueue(object :
@ -595,4 +681,26 @@ class InventaryViewModel(val context: Context) : BaseViewModel(context) {
}) })
} }
fun getIdFromCodeSalix(code: String) {
salix.barcodes_toitem(code)
.enqueue(object : SilexCallback<String>(context) {
override fun onError(t: Throwable) {
_responseCode.value = ResponseItemVO(
isError = true,
errorMessage = getMessageFromAllResponse(nameofFunction(this), t.message!!)
)
}
override fun onSuccess(response: Response<String>) {
_responseCode.value =
ResponseItemVO(
isError = false,
response = if (response.body() == null) "" else {
response.body()!!
}
)
}
})
}
} }

View File

@ -18,27 +18,31 @@ class InventaryListVO(
) )
class ItemShelvingVisible( class ItemShelvingVisible(
val visible: Int var visible: Int
) )
class ItemShelvingChecked( class ItemShelvingChecked(
val isChecked: Boolean? var isChecked: Boolean?,
var userFk : Int
) )
data class ItemInventoryParking( data class ItemInventoryParking(
val id: Long, var id: Long = 0,
val pickingOrder: Int, var pickingOrder: Int = 0,
val parking: String, var parking: String = "",
val shelvingFk: String, var shelvingFk: String = "",
val itemFk: Int, var itemFk: Int = 0,
val longName: String, var longName: String = "",
val visible: Int, var visible: Int = 0,
val sectorFk: Int, var sectorFk: Int = 0,
val buyer: String, var buyer: String = "",
val urlImage: String, var urlImage: String = "",
var isChecked:Int?, var isChecked: Int? = null,
val priority: Int, var priority: Int = 0,
var isError: Boolean = false, var isError: Boolean = false,
var errorMessage: String = "", var errorMessage: String = "",
) )
class InventoryParkingList( class InventoryParkingList(
var list: List<ItemInventoryParking> = listOf() var list: List<ItemInventoryParking> = listOf()
) )

View File

@ -0,0 +1,6 @@
<vector android:height="24dp"
android:viewportHeight="50"
android:viewportWidth="50"
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="#FFF" android:pathData="M25,18.2c-3.8,0 -6.8,3.1 -6.8,6.8s3.1,6.8 6.8,6.8s6.8,-3.1 6.8,-6.8S28.8,18.2 25,18.2M25,36.4c-6.3,0 -11.4,-5.1 -11.4,-11.4S18.7,13.6 25,13.6S36.4,18.7 36.4,25S31.3,36.4 25,36.4M25,8C13.6,8 3.9,15 0,25c3.9,10 13.6,17 25,17S46.1,35 50,25C46.1,15 36.4,8 25,8z"/>
</vector>

View File

@ -0,0 +1,9 @@
<!-- drawable/filter_outline.xml -->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:tint="#FFF"
android:height="24dp"
android:width="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path android:fillColor="#FFFFFF" android:pathData="M15,19.88C15.04,20.18 14.94,20.5 14.71,20.71C14.32,21.1 13.69,21.1 13.3,20.71L9.29,16.7C9.06,16.47 8.96,16.16 9,15.87V10.75L4.21,4.62C3.87,4.19 3.95,3.56 4.38,3.22C4.57,3.08 4.78,3 5,3V3H19V3C19.22,3 19.43,3.08 19.62,3.22C20.05,3.56 20.13,4.19 19.79,4.62L15,10.75V19.88M7.04,5L11,10.06V15.58L13,17.58V10.05L16.96,5H7.04Z" />
</vector>

View File

@ -26,7 +26,7 @@
android:orientation="horizontal" android:orientation="horizontal"
android:paddingLeft="@dimen/pasilleros_margin_main_menu" android:paddingLeft="@dimen/pasilleros_margin_main_menu"
android:paddingTop="@dimen/inventory_item" android:paddingTop="@dimen/inventory_item"
android:paddingRight="@dimen/pasilleros_margin_main_menu" android:paddingRight="@dimen/inventory_item"
android:paddingBottom="@dimen/inventory_item"> android:paddingBottom="@dimen/inventory_item">
<LinearLayout <LinearLayout
@ -122,6 +122,7 @@
android:maxLines="1" android:maxLines="1"
android:text="@{item.buyer}" android:text="@{item.buyer}"
android:textColor="@color/verdnatura_white" android:textColor="@color/verdnatura_white"
android:visibility="gone"
android:textSize="@dimen/h8" /> android:textSize="@dimen/h8" />
</LinearLayout> </LinearLayout>
</LinearLayout> </LinearLayout>
@ -134,7 +135,7 @@
android:id="@+id/layer_visible" android:id="@+id/layer_visible"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_weight="8" android:layout_weight="6"
android:orientation="vertical"> android:orientation="vertical">
<TextView <TextView