feat: refs#7823 selectPrinterFreely
This commit is contained in:
parent
31c715c40d
commit
16b84ce2ec
|
@ -31,4 +31,13 @@ class WorkerActivityUseCase(private val salixService: SalixService) {
|
||||||
fun addWorkerActivity(workerActionSalix: WorkerActionSalix): Call<Any> {
|
fun addWorkerActivity(workerActionSalix: WorkerActionSalix): Call<Any> {
|
||||||
return salixService.workerActivityAdd(workerActionSalix)
|
return salixService.workerActivityAdd(workerActionSalix)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class OperatorUseCase(private val salixService: SalixService) {
|
||||||
|
fun updateOperator(workerFk: Number, update: HashMap<String, Number>): Call<Unit> {
|
||||||
|
return salixService.updateOperator(
|
||||||
|
id = workerFk,
|
||||||
|
params = update
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -4,13 +4,18 @@ import android.app.AlertDialog
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.text.InputType
|
import android.text.InputType
|
||||||
import android.view.View
|
import android.view.View
|
||||||
|
import android.view.inputmethod.EditorInfo
|
||||||
import es.verdnatura.R
|
import es.verdnatura.R
|
||||||
import es.verdnatura.domain.toast
|
import es.verdnatura.domain.toast
|
||||||
|
import es.verdnatura.presentation.view.component.CustomDialogInput
|
||||||
import es.verdnatura.presentation.view.component.CustomDialogList
|
import es.verdnatura.presentation.view.component.CustomDialogList
|
||||||
|
|
||||||
class PrinterDialogManager(private val context: Context) {
|
class PrinterDialogManager(private val context: Context) {
|
||||||
fun showPrintDialog(
|
fun showPrintDialog(
|
||||||
item: Long, itemName: String, onPrintClick: (Long, String, Int?, Int) -> Unit
|
item: Long,
|
||||||
|
itemName: String,
|
||||||
|
onPrintClick: (Long, String, Int?, Int) -> Unit,
|
||||||
|
onPrintChange: (String) -> Unit
|
||||||
) {
|
) {
|
||||||
val customDialogList = CustomDialogList(context)
|
val customDialogList = CustomDialogList(context)
|
||||||
customDialogList.getEditText().setRawInputType(InputType.TYPE_CLASS_NUMBER)
|
customDialogList.getEditText().setRawInputType(InputType.TYPE_CLASS_NUMBER)
|
||||||
|
@ -23,7 +28,9 @@ class PrinterDialogManager(private val context: Context) {
|
||||||
}.setOkTwoButton(context.getString(R.string.printBarcode)) {
|
}.setOkTwoButton(context.getString(R.string.printBarcode)) {
|
||||||
handlePrintClick(item, customDialogList, onPrintClick, "barcode")
|
handlePrintClick(item, customDialogList, onPrintClick, "barcode")
|
||||||
customDialogList.dismiss()
|
customDialogList.dismiss()
|
||||||
|
//Tarea 7823
|
||||||
|
/*}.setOkThreeButton(context.getString(R.string.changePrinter)) {
|
||||||
|
readQrPrinter(onPrintChange)*/
|
||||||
}.setKoButton(context.getString(R.string.cancel)) {
|
}.setKoButton(context.getString(R.string.cancel)) {
|
||||||
customDialogList.dismiss()
|
customDialogList.dismiss()
|
||||||
}.setHintValueThree(context.getString(R.string.labelNumber))
|
}.setHintValueThree(context.getString(R.string.labelNumber))
|
||||||
|
@ -32,6 +39,29 @@ class PrinterDialogManager(private val context: Context) {
|
||||||
customDialogList.getFocusThree()
|
customDialogList.getFocusThree()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun readQrPrinter(onPrintChange: (String) -> Unit) {
|
||||||
|
val customDialogInput = CustomDialogInput(context)
|
||||||
|
|
||||||
|
customDialogInput.setTitle(context.getString(R.string.changePrinter))
|
||||||
|
.setDescription(context.getString(R.string.scanQrPrinter))
|
||||||
|
.setOkButton(context.getString(R.string.save)) {
|
||||||
|
onPrintChange(customDialogInput.getValue())
|
||||||
|
customDialogInput.dismiss()
|
||||||
|
|
||||||
|
}.setKoButton(context.getString(R.string.cancel)) {
|
||||||
|
customDialogInput.dismiss()
|
||||||
|
}.setValue("").show()
|
||||||
|
customDialogInput.getEditText().requestFocus()
|
||||||
|
customDialogInput.getEditText().setOnEditorActionListener { _, actionId, _ ->
|
||||||
|
if (actionId == EditorInfo.IME_ACTION_SEARCH || actionId == EditorInfo.IME_ACTION_DONE || actionId == 0) {
|
||||||
|
onPrintChange(customDialogInput.getValue())
|
||||||
|
customDialogInput.dismiss()
|
||||||
|
return@setOnEditorActionListener true
|
||||||
|
}
|
||||||
|
false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private fun handlePrintClick(
|
private fun handlePrintClick(
|
||||||
item: Long,
|
item: Long,
|
||||||
customDialogList: CustomDialogList,
|
customDialogList: CustomDialogList,
|
||||||
|
|
|
@ -16,7 +16,8 @@ import es.verdnatura.domain.toast
|
||||||
class SearchableAdapter(
|
class SearchableAdapter(
|
||||||
private var listElements: MutableList<NameWithId>,
|
private var listElements: MutableList<NameWithId>,
|
||||||
private var context: Context,
|
private var context: Context,
|
||||||
private val onItemClick: (NameWithId) -> Unit,
|
private val listColorElements: List<Int> = listOf(),
|
||||||
|
private val onItemClick: (NameWithId) -> Unit
|
||||||
) : RecyclerView.Adapter<SearchableAdapter.NameViewHolder>() {
|
) : RecyclerView.Adapter<SearchableAdapter.NameViewHolder>() {
|
||||||
|
|
||||||
private var listElementsFiltered = listElements.toMutableList()
|
private var listElementsFiltered = listElements.toMutableList()
|
||||||
|
@ -48,6 +49,13 @@ class SearchableAdapter(
|
||||||
} catch (ex: Exception) {
|
} catch (ex: Exception) {
|
||||||
ex.message?.toast(context)
|
ex.message?.toast(context)
|
||||||
}
|
}
|
||||||
|
if (listColorElements.isNotEmpty()) {
|
||||||
|
if (nameWithId.id in listColorElements) {
|
||||||
|
nameText.setTextColor(Color.BLACK)
|
||||||
|
} else {
|
||||||
|
nameText.setTextColor(Color.GRAY)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -96,6 +96,13 @@ class CustomDialogList(context: Context) : Dialog(context, R.style.DialogTheme)
|
||||||
return this
|
return this
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun setOkThreeButton(text: String, onButtonClicked: () -> Unit): CustomDialogList {
|
||||||
|
binding.customDialogButtonOkThree.visibility = View.VISIBLE
|
||||||
|
binding.customDialogButtonOkThree.text = text
|
||||||
|
binding.customDialogButtonOkThree.setOnClickListener { onButtonClicked() }
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
|
||||||
fun setKoButton(text: String, onButtonClicked: () -> Unit): CustomDialogList {
|
fun setKoButton(text: String, onButtonClicked: () -> Unit): CustomDialogList {
|
||||||
binding.customDialogButtonKo.visibility = View.VISIBLE
|
binding.customDialogButtonKo.visibility = View.VISIBLE
|
||||||
binding.customDialogButtonKo.text = text
|
binding.customDialogButtonKo.text = text
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package es.verdnatura.presentation.view.feature.ajustes.fragment
|
package es.verdnatura.presentation.view.feature.ajustes.fragment
|
||||||
|
|
||||||
|
import android.annotation.SuppressLint
|
||||||
import android.app.AlertDialog
|
import android.app.AlertDialog
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import android.content.pm.PackageInfo
|
import android.content.pm.PackageInfo
|
||||||
|
@ -86,46 +87,77 @@ class AjustesFragment :
|
||||||
super.init()
|
super.init()
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setSearchable(listNames: MutableList<NameWithId>) {
|
private fun setSearchable(
|
||||||
|
listNames: MutableList<NameWithId>,
|
||||||
|
type: String = "sector",
|
||||||
|
listColorsElements: List<Int> = listOf()
|
||||||
|
) {
|
||||||
val adapter =
|
val adapter =
|
||||||
SearchableAdapter(
|
SearchableAdapter(
|
||||||
listElements = listNames,
|
listElements = listNames,
|
||||||
context = requireContext()
|
context = requireContext(),
|
||||||
|
listColorElements = listColorsElements,
|
||||||
) { elementSelected ->
|
) { elementSelected ->
|
||||||
sectorListVO.forEach {
|
when (type) {
|
||||||
if (it.id == elementSelected.id) {
|
"sector" -> {
|
||||||
runBlocking {
|
sectorListVO.forEach {
|
||||||
mobileApplication.dataStoreApp.editDataStoreKey(
|
if (it.id == elementSelected.id) {
|
||||||
PRINTERNAME, getString(R.string.noprinter)
|
runBlocking {
|
||||||
)
|
mobileApplication.dataStoreApp.editDataStoreKey(
|
||||||
mobileApplication.dataStoreApp.editDataStoreKey(PRINTERFK, -1)
|
PRINTERNAME, getString(R.string.noprinter)
|
||||||
mobileApplication.dataStoreApp.editDataStoreKey(
|
)
|
||||||
SECTORDESCRIP, it.description
|
mobileApplication.dataStoreApp.editDataStoreKey(PRINTERFK, -1)
|
||||||
)
|
mobileApplication.dataStoreApp.editDataStoreKey(
|
||||||
mobileApplication.dataStoreApp.editDataStoreKey(
|
SECTORDESCRIP, it.description
|
||||||
SECTORFK, it.id
|
)
|
||||||
)
|
mobileApplication.dataStoreApp.editDataStoreKey(
|
||||||
it.warehouseFk?.let { it1 ->
|
SECTORFK, it.id
|
||||||
mobileApplication.dataStoreApp.editDataStoreKey(
|
)
|
||||||
WAREHOUSEFK, it1
|
it.warehouseFk?.let { it1 ->
|
||||||
|
mobileApplication.dataStoreApp.editDataStoreKey(
|
||||||
|
WAREHOUSEFK, it1
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
viewModel.settingsItem[0].sectorFk = it.id
|
||||||
|
viewModel.settingsItem[0].selected = it.description
|
||||||
|
viewModel.workerUpdateOperatorSalix(
|
||||||
|
"sector", mobileApplication.userId!!, it.id, null
|
||||||
)
|
)
|
||||||
|
settingsAdapter!!.notifyItemChanged(0)
|
||||||
|
return@forEach
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
viewModel.settingsItem[0].sectorFk = it.id
|
}
|
||||||
viewModel.settingsItem[0].selected = it.description
|
|
||||||
viewModel.workerUpdateOperatorSalix(
|
"printer" -> {
|
||||||
"sector", mobileApplication.userId!!, it.id, null
|
println("selected $elementSelected")
|
||||||
)
|
val printer = printersList.find { it.name == elementSelected.name }
|
||||||
settingsAdapter!!.notifyItemChanged(0)
|
println("selected printer $elementSelected")
|
||||||
return@forEach
|
if (printer != null) {
|
||||||
|
if (printer.sector?.backupPrinterFk == printer.id) {
|
||||||
|
showWarningPrinter(printer.name, printer.id)
|
||||||
|
} else {
|
||||||
|
savePrinter(printer.name, printer.id)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
printersList.clear()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
val searchView =
|
||||||
|
binding.searchableRecyclerView.findViewById<androidx.appcompat.widget.SearchView>(
|
||||||
|
R.id.search_view
|
||||||
|
)
|
||||||
|
searchView?.setQuery("", false)
|
||||||
binding.searchableRecyclerView.visibility = View.GONE
|
binding.searchableRecyclerView.visibility = View.GONE
|
||||||
}
|
}
|
||||||
|
|
||||||
binding.searchableRecyclerView.setAdapter(adapter, listNames)
|
binding.searchableRecyclerView.setAdapter(adapter, listNames)
|
||||||
binding.searchableRecyclerView.visibility = View.VISIBLE
|
binding.searchableRecyclerView.visibility = View.VISIBLE
|
||||||
binding.searchableRecyclerView.setSearchHint(getString(R.string.sectorSearch))
|
binding.searchableRecyclerView.setSearchHint(
|
||||||
|
if (type == "sector") getString(R.string.sectorSearch) else
|
||||||
|
getString(R.string.printerSearch)
|
||||||
|
)
|
||||||
ma.hideKeyboard(binding.searchableRecyclerView)
|
ma.hideKeyboard(binding.searchableRecyclerView)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -148,7 +180,7 @@ class AjustesFragment :
|
||||||
listIcons.add(iconInfo)
|
listIcons.add(iconInfo)
|
||||||
listIcons.add(iconLogout)
|
listIcons.add(iconLogout)
|
||||||
// listIcons.add(iconPhone)
|
// listIcons.add(iconPhone)
|
||||||
// listIcons.add(iconSettings)
|
//listIcons.add(iconSettings)
|
||||||
|
|
||||||
binding.mainToolbar.toolbarIcons.adapter =
|
binding.mainToolbar.toolbarIcons.adapter =
|
||||||
ToolBarAdapterTooltip(listIcons, object : OnOptionsSelectedListener {
|
ToolBarAdapterTooltip(listIcons, object : OnOptionsSelectedListener {
|
||||||
|
@ -216,13 +248,20 @@ class AjustesFragment :
|
||||||
"phoneNumber",
|
"phoneNumber",
|
||||||
"sip:651353889@pbx.verdnatura.es"
|
"sip:651353889@pbx.verdnatura.es"
|
||||||
)
|
)
|
||||||
|
|
||||||
/* intentIncoming.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT)
|
/* intentIncoming.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT)
|
||||||
startActivity(intentIncoming)*/
|
startActivity(intentIncoming)*/
|
||||||
val intent = Intent("org.linphone.CALLING")
|
val intent = Intent("org.linphone.CALLING")
|
||||||
|
intent.setClassName(
|
||||||
|
"org.linphone.incomingcall",
|
||||||
|
"org.linphone.incomingcall.IncomingCallActivity"
|
||||||
|
)
|
||||||
intent.putExtra("server", "pbx.verdnatura.es")
|
intent.putExtra("server", "pbx.verdnatura.es")
|
||||||
intent.putExtra("username", "1007")
|
intent.putExtra("username", "1007")
|
||||||
intent.putExtra("password", "delatorre.1234")
|
intent.putExtra("password", "*******")
|
||||||
intent.putExtra("phoneNumber", "sip:651353889@pbx.verdnatura.es")
|
intent.putExtra("phoneNumber", "sip:651353889@pbx.verdnatura.es")
|
||||||
|
intent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT)
|
||||||
|
startActivity(intent)
|
||||||
requireContext().sendBroadcast(intent)
|
requireContext().sendBroadcast(intent)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -375,20 +414,53 @@ class AjustesFragment :
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
loadPrintersList.observe(viewLifecycleOwner) { event ->
|
loadPrintersList.observe(viewLifecycleOwner) { event ->
|
||||||
event.getContentIfNotHandled().notNull { it ->
|
event.getContentIfNotHandled()?.let { it ->
|
||||||
|
|
||||||
if (it.list.isNotEmpty()) {
|
if (it.list.isNotEmpty()) {
|
||||||
val listPrinters: ArrayList<String> = ArrayList()
|
val listPrinters: ArrayList<String> = ArrayList()
|
||||||
it.list.forEach {
|
printersList.clear()
|
||||||
listPrinters.add(it.name)
|
|
||||||
|
|
||||||
|
printersList.addAll(it.list.sortedWith(compareBy(
|
||||||
|
{ printer ->
|
||||||
|
when {
|
||||||
|
printer.sector?.id == mobileApplication.dataStoreApp.readDataStoreKey<Int>(
|
||||||
|
SECTORFK
|
||||||
|
) -> 0
|
||||||
|
|
||||||
|
printer.sector?.id != null -> 1
|
||||||
|
else -> 2
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{ printer -> printer.name }
|
||||||
|
)))
|
||||||
|
|
||||||
|
printersList.forEach { printer ->
|
||||||
|
listPrinters.add(printer.name)
|
||||||
}
|
}
|
||||||
|
|
||||||
val array = arrayOfNulls<String>(listPrinters.size)
|
val array = arrayOfNulls<String>(listPrinters.size)
|
||||||
printersList = it.list
|
|
||||||
showDialogForAll(listPrinters.toArray(array), messagePrinter ?: "")
|
showDialogForAll(listPrinters.toArray(array), messagePrinter ?: "")
|
||||||
|
//Tarea7823
|
||||||
|
/* val listColorsElements = printersList.mapIndexed { _, printer ->
|
||||||
|
if (printer.sector?.id == mobileApplication.dataStoreApp.readDataStoreKey<Int>(
|
||||||
|
SECTORFK
|
||||||
|
)
|
||||||
|
) printer.id else null
|
||||||
|
}.filterNotNull()
|
||||||
|
|
||||||
|
setSearchable(printersList.map {
|
||||||
|
NameWithId(
|
||||||
|
id = it.id,
|
||||||
|
name = it.name
|
||||||
|
)
|
||||||
|
} as MutableList<NameWithId>,
|
||||||
|
type = "printer",
|
||||||
|
listColorsElements = listColorsElements)*/
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
viewModel.settingsItem[2].selected = getString(R.string.noprinter)
|
viewModel.settingsItem[2].selected = getString(R.string.noprinter)
|
||||||
settingsAdapter!!.notifyItemChanged(2)
|
settingsAdapter?.notifyItemChanged(2)
|
||||||
customDialog.setTitle(getString(R.string.printers))
|
customDialog.setTitle(getString(R.string.printers))
|
||||||
.setDescription(getString(R.string.Noprinters))
|
.setDescription(getString(R.string.Noprinters))
|
||||||
.setOkButton(getString(R.string.Close)) {
|
.setOkButton(getString(R.string.Close)) {
|
||||||
|
@ -396,7 +468,6 @@ class AjustesFragment :
|
||||||
handleUserCall()
|
handleUserCall()
|
||||||
}.show()
|
}.show()
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
loadTrainList.observe(viewLifecycleOwner) { event ->
|
loadTrainList.observe(viewLifecycleOwner) { event ->
|
||||||
|
@ -421,14 +492,19 @@ class AjustesFragment :
|
||||||
super.observeViewModel()
|
super.observeViewModel()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressLint("NotifyDataSetChanged")
|
||||||
private fun getUserData() {
|
private fun getUserData() {
|
||||||
|
|
||||||
loginViewModel = LoginViewModel(requireActivity().applicationContext)
|
loginViewModel = LoginViewModel(requireActivity().applicationContext)
|
||||||
handleUserCall()
|
handleUserCall()
|
||||||
loginViewModel.handleUserResponse.observe(this@AjustesFragment) { iti ->
|
loginViewModel.handleUserResponse.observe(this@AjustesFragment) { iti ->
|
||||||
runBlocking { mobileApplication.dataStoreApp.saveWorkerData(iti) }
|
runBlocking {
|
||||||
|
mobileApplication.dataStoreApp.saveWorkerData(iti)
|
||||||
|
setSettings()
|
||||||
|
binding.setttingsItems.adapter!!.notifyDataSetChanged()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
setSettings()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun handleUserCall() {
|
private fun handleUserCall() {
|
||||||
|
@ -496,12 +572,26 @@ class AjustesFragment :
|
||||||
val positionPrinterEmergency =
|
val positionPrinterEmergency =
|
||||||
printersList.indexOfFirst { printer -> printer.sector?.backupPrinterFk == printer.id }
|
printersList.indexOfFirst { printer -> printer.sector?.backupPrinterFk == printer.id }
|
||||||
|
|
||||||
if (position == positionPrinterEmergency) {
|
val positions = printersList.mapIndexed { index, printer ->
|
||||||
textView.setTextColor(Color.RED)
|
if (printer.sector?.id == mobileApplication.dataStoreApp.readDataStoreKey<Int>(
|
||||||
} else {
|
SECTORFK
|
||||||
textView.setTextColor(Color.BLACK)
|
)
|
||||||
}
|
) index else null
|
||||||
|
}.filterNotNull()
|
||||||
|
|
||||||
|
when (position) {
|
||||||
|
positionPrinterEmergency -> {
|
||||||
|
textView.setTextColor(Color.RED)
|
||||||
|
}
|
||||||
|
|
||||||
|
in positions -> {
|
||||||
|
textView.setTextColor(Color.BLACK)
|
||||||
|
}
|
||||||
|
|
||||||
|
else -> {
|
||||||
|
textView.setTextColor(Color.GRAY)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return view
|
return view
|
||||||
}
|
}
|
||||||
|
|
|
@ -160,6 +160,10 @@ class AjustesViewModel(val context: Context) : BaseViewModel(context) {
|
||||||
salix.getprinters(
|
salix.getprinters(
|
||||||
"""{"fields":["id","name","sectorFk"],"where":{"sectorFk":$sectorFk,"isLabeler":{"neq":false}},"include": [ { "relation": "sector", "scope": { "fields": ["backupPrinterFk"]}}]}"""
|
"""{"fields":["id","name","sectorFk"],"where":{"sectorFk":$sectorFk,"isLabeler":{"neq":false}},"include": [ { "relation": "sector", "scope": { "fields": ["backupPrinterFk"]}}]}"""
|
||||||
).enqueue(object : SalixCallback<MutableList<Printers>>(context) {
|
).enqueue(object : SalixCallback<MutableList<Printers>>(context) {
|
||||||
|
//Tarea 7823
|
||||||
|
/* salix.getprinters(
|
||||||
|
"""{"fields":["id","name","sectorFk"],"where":{"isLabeler":{"neq":false}},"include": [ { "relation": "sector", "scope": { "fields": ["backupPrinterFk"]}}]}"""
|
||||||
|
).enqueue(object : SalixCallback<MutableList<Printers>>(context) {*/
|
||||||
override fun onSuccess(response: Response<MutableList<Printers>>) {
|
override fun onSuccess(response: Response<MutableList<Printers>>) {
|
||||||
_printerList.value = response.body()?.let { PrintersList(it) }
|
_printerList.value = response.body()?.let { PrintersList(it) }
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,6 +25,7 @@ import es.verdnatura.presentation.common.OnOptionsSelectedListener
|
||||||
import es.verdnatura.presentation.common.PrinterDialogManager
|
import es.verdnatura.presentation.common.PrinterDialogManager
|
||||||
import es.verdnatura.presentation.common.ToolBarAdapterTooltip
|
import es.verdnatura.presentation.common.ToolBarAdapterTooltip
|
||||||
import es.verdnatura.presentation.common.hideKeyboard
|
import es.verdnatura.presentation.common.hideKeyboard
|
||||||
|
import es.verdnatura.presentation.common.itemScanIsQr
|
||||||
import es.verdnatura.presentation.common.itemScanValue
|
import es.verdnatura.presentation.common.itemScanValue
|
||||||
import es.verdnatura.presentation.common.loadUrl
|
import es.verdnatura.presentation.common.loadUrl
|
||||||
import es.verdnatura.presentation.composable.ImageViewActivityComposable
|
import es.verdnatura.presentation.composable.ImageViewActivityComposable
|
||||||
|
@ -133,10 +134,30 @@ class ItemCardFragment(
|
||||||
val printerDialogManager = PrinterDialogManager(requireContext())
|
val printerDialogManager = PrinterDialogManager(requireContext())
|
||||||
printerDialogManager.showPrintDialog(
|
printerDialogManager.showPrintDialog(
|
||||||
buyToPrint ?: itemInfoG!!.id.toLong(),
|
buyToPrint ?: itemInfoG!!.id.toLong(),
|
||||||
itemInfoG?.longName ?: ""
|
itemInfoG?.longName ?: "",
|
||||||
) { id, labelType, copies, packing ->
|
onPrintClick = { id, labelType, copies, packing ->
|
||||||
printItem(id, labelType, copies, packing)
|
printItem(id, labelType, copies, packing)
|
||||||
}
|
},
|
||||||
|
onPrintChange = { text ->
|
||||||
|
if (itemScanIsQr(text)) {
|
||||||
|
|
||||||
|
viewModel.operatorUpdate(
|
||||||
|
workerFk = mobileApplication.userId!!,
|
||||||
|
labelerFK = itemScanValue(
|
||||||
|
text,
|
||||||
|
arrayOf("printer"),
|
||||||
|
"id"
|
||||||
|
).toString().toLong()
|
||||||
|
)
|
||||||
|
} else {
|
||||||
|
ma.messageWithSound(
|
||||||
|
getString(R.string.qrPrinterNotvalid),
|
||||||
|
isPlayed = true,
|
||||||
|
isError = true,
|
||||||
|
isToasted = false
|
||||||
|
)
|
||||||
|
}
|
||||||
|
})
|
||||||
} else ma.messageWithSound(
|
} else ma.messageWithSound(
|
||||||
getString(R.string.errorPrintBuy),
|
getString(R.string.errorPrintBuy),
|
||||||
isError = true,
|
isError = true,
|
||||||
|
@ -273,7 +294,7 @@ class ItemCardFragment(
|
||||||
}
|
}
|
||||||
binding.itemcardImage.setOnClickListener {
|
binding.itemcardImage.setOnClickListener {
|
||||||
|
|
||||||
//JETPACKCOMPOSE
|
//JETPACKCOMPOSE
|
||||||
// val i = Intent(activity, ImageViewActivity::class.java)
|
// val i = Intent(activity, ImageViewActivity::class.java)
|
||||||
val i = Intent(activity, ImageViewActivityComposable::class.java)
|
val i = Intent(activity, ImageViewActivityComposable::class.java)
|
||||||
i.putExtra(getString(R.string.url), urlLarge)
|
i.putExtra(getString(R.string.url), urlLarge)
|
||||||
|
|
|
@ -8,6 +8,7 @@ import es.verdnatura.domain.SalixCallback
|
||||||
import es.verdnatura.domain.formatWithQuotes
|
import es.verdnatura.domain.formatWithQuotes
|
||||||
import es.verdnatura.domain.userCases.GetItemFromBarcodeUseCase
|
import es.verdnatura.domain.userCases.GetItemFromBarcodeUseCase
|
||||||
import es.verdnatura.domain.userCases.GetItemPrintItemUseCase
|
import es.verdnatura.domain.userCases.GetItemPrintItemUseCase
|
||||||
|
import es.verdnatura.domain.userCases.OperatorUseCase
|
||||||
import es.verdnatura.presentation.base.BaseViewModel
|
import es.verdnatura.presentation.base.BaseViewModel
|
||||||
import es.verdnatura.presentation.common.Event
|
import es.verdnatura.presentation.common.Event
|
||||||
import es.verdnatura.presentation.common.ItemBarCodeSalix
|
import es.verdnatura.presentation.common.ItemBarCodeSalix
|
||||||
|
@ -27,6 +28,7 @@ class ItemCardViewModel(var context: Context) : BaseViewModel(context) {
|
||||||
|
|
||||||
private val getItemFromBarcodeUseCase = GetItemFromBarcodeUseCase(salix)
|
private val getItemFromBarcodeUseCase = GetItemFromBarcodeUseCase(salix)
|
||||||
private val printItemUseCase = GetItemPrintItemUseCase(salix)
|
private val printItemUseCase = GetItemPrintItemUseCase(salix)
|
||||||
|
private val operatorUseCase = OperatorUseCase(salix)
|
||||||
|
|
||||||
private val _itemCard by lazy { MutableLiveData<ItemCardVO>() }
|
private val _itemCard by lazy { MutableLiveData<ItemCardVO>() }
|
||||||
val itemCard: LiveData<ItemCardVO>
|
val itemCard: LiveData<ItemCardVO>
|
||||||
|
@ -69,6 +71,14 @@ class ItemCardViewModel(var context: Context) : BaseViewModel(context) {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun operatorUpdate(workerFk: Number, labelerFK: Number) {
|
||||||
|
|
||||||
|
operatorUseCase.updateOperator(workerFk = workerFk, hashMapOf("labelerFk" to labelerFK))
|
||||||
|
.enqueue(object : SalixCallback<Unit>(context) {
|
||||||
|
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
fun printItem(
|
fun printItem(
|
||||||
reportName: String,
|
reportName: String,
|
||||||
printerFk: Int,
|
printerFk: Int,
|
||||||
|
|
|
@ -37,6 +37,7 @@ import es.verdnatura.presentation.common.OnVisibleClickListener6869
|
||||||
import es.verdnatura.presentation.common.PrinterDialogManager
|
import es.verdnatura.presentation.common.PrinterDialogManager
|
||||||
import es.verdnatura.presentation.common.ToolBarAdapterTooltip
|
import es.verdnatura.presentation.common.ToolBarAdapterTooltip
|
||||||
import es.verdnatura.presentation.common.hideKeyboard
|
import es.verdnatura.presentation.common.hideKeyboard
|
||||||
|
import es.verdnatura.presentation.common.itemScanIsQr
|
||||||
import es.verdnatura.presentation.common.itemScanValue
|
import es.verdnatura.presentation.common.itemScanValue
|
||||||
import es.verdnatura.presentation.view.component.CustomDialog
|
import es.verdnatura.presentation.view.component.CustomDialog
|
||||||
import es.verdnatura.presentation.view.component.CustomDialogInput
|
import es.verdnatura.presentation.view.component.CustomDialogInput
|
||||||
|
@ -650,8 +651,11 @@ class UbicadorFragment : BaseFragment<FragmentUbicadorBinding, UbicadorViewModel
|
||||||
|
|
||||||
if (it.list.isNotEmpty()) {
|
if (it.list.isNotEmpty()) {
|
||||||
customDialogOlder = CustomDialog(requireContext())
|
customDialogOlder = CustomDialog(requireContext())
|
||||||
|
|
||||||
val oldList = it.list.filter { item ->
|
val oldList = it.list.filter { item ->
|
||||||
item.itemCreated!!.contains("old", ignoreCase = true)
|
item.itemCreated!!.contains("old", ignoreCase = true)
|
||||||
|
}.distinctBy { item ->
|
||||||
|
"${item.itemFk}:${item.code}:${item.parkingFk}"
|
||||||
}.map { item ->
|
}.map { item ->
|
||||||
val itemFk = item.itemFk
|
val itemFk = item.itemFk
|
||||||
val shelvingFk = item.code
|
val shelvingFk = item.code
|
||||||
|
@ -663,10 +667,12 @@ class UbicadorFragment : BaseFragment<FragmentUbicadorBinding, UbicadorViewModel
|
||||||
created
|
created
|
||||||
)!!
|
)!!
|
||||||
)
|
)
|
||||||
"$itemFk:${shelvingFk?.uppercase()}→${parkingCode}:(${formattedCreated}"
|
"$itemFk:${shelvingFk?.uppercase()}→${parkingCode}(${formattedCreated})"
|
||||||
}
|
}
|
||||||
val newList = it.list.filter { item ->
|
val newList = it.list.filter { item ->
|
||||||
item.itemCreated!!.contains("new", ignoreCase = true)
|
item.itemCreated!!.contains("new", ignoreCase = true)
|
||||||
|
}.distinctBy { item ->
|
||||||
|
"${item.itemFk}:${item.code}:${item.parkingFk}"
|
||||||
}.map { item ->
|
}.map { item ->
|
||||||
val itemFk = item.itemFk
|
val itemFk = item.itemFk
|
||||||
val shelvingFk = item.code
|
val shelvingFk = item.code
|
||||||
|
@ -678,7 +684,7 @@ class UbicadorFragment : BaseFragment<FragmentUbicadorBinding, UbicadorViewModel
|
||||||
created
|
created
|
||||||
)!!
|
)!!
|
||||||
)
|
)
|
||||||
"$itemFk:${shelvingFk?.uppercase()}→${parkingCode}:(${formattedCreated})"
|
"$itemFk:${shelvingFk?.uppercase()}→${parkingCode}(${formattedCreated})"
|
||||||
}
|
}
|
||||||
|
|
||||||
val resultStringOld = oldList.joinToString(separator = "\n")
|
val resultStringOld = oldList.joinToString(separator = "\n")
|
||||||
|
@ -1187,36 +1193,57 @@ class UbicadorFragment : BaseFragment<FragmentUbicadorBinding, UbicadorViewModel
|
||||||
.setOkButtonThree(getString(R.string.print)) {
|
.setOkButtonThree(getString(R.string.print)) {
|
||||||
val printerDialogManager = PrinterDialogManager(requireContext())
|
val printerDialogManager = PrinterDialogManager(requireContext())
|
||||||
printerDialogManager.showPrintDialog(
|
printerDialogManager.showPrintDialog(
|
||||||
item.item.id, item.description ?: ""
|
item.item.id,
|
||||||
) { id, labelType, packing, copies ->
|
item.description ?: "",
|
||||||
|
onPrintClick = { id, labelType, packing, copies ->
|
||||||
|
|
||||||
if (item.buyFk == null) {
|
if (item.buyFk == null) {
|
||||||
viewModel.buyUltimate(
|
viewModel.buyUltimate(
|
||||||
itemFk = item.id,
|
itemFk = item.id,
|
||||||
warehouseFk = mobileApplication.dataStoreApp.readDataStoreKey(
|
warehouseFk = mobileApplication.dataStoreApp.readDataStoreKey(
|
||||||
WAREHOUSEFK
|
WAREHOUSEFK
|
||||||
),
|
),
|
||||||
dated = LocalDate.now().format(
|
dated = LocalDate.now().format(
|
||||||
DateTimeFormatter.ofPattern("yyyy-dd-MM")
|
DateTimeFormatter.ofPattern("yyyy-dd-MM")
|
||||||
),
|
),
|
||||||
reportName = "LabelBuy",
|
reportName = "LabelBuy",
|
||||||
printerFk = mobileApplication.dataStoreApp.readDataStoreKey<Int>(
|
printerFk = mobileApplication.dataStoreApp.readDataStoreKey<Int>(
|
||||||
ConstAndValues.PRINTERFK
|
ConstAndValues.PRINTERFK
|
||||||
),
|
),
|
||||||
userFk = mobileApplication.userId!!,
|
userFk = mobileApplication.userId!!,
|
||||||
priority = "normal",
|
priority = "normal",
|
||||||
copies = copies,
|
copies = copies,
|
||||||
labelType = labelType,
|
labelType = labelType,
|
||||||
packing = packing
|
packing = packing
|
||||||
)
|
)
|
||||||
customDialogTwoButtons.dismiss()
|
customDialogTwoButtons.dismiss()
|
||||||
} else {
|
} else {
|
||||||
printItem(
|
printItem(
|
||||||
item.buyFk, labelType, packing, copies
|
item.buyFk, labelType, packing, copies
|
||||||
)
|
)
|
||||||
customDialogTwoButtons.dismiss()
|
customDialogTwoButtons.dismiss()
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
|
onPrintChange = { text ->
|
||||||
|
if (itemScanIsQr(text)) {
|
||||||
|
viewModel.operatorUpdate(
|
||||||
|
workerFk = mobileApplication.userId!!,
|
||||||
|
labelerFK = itemScanValue(
|
||||||
|
text,
|
||||||
|
arrayOf("printer"),
|
||||||
|
"id"
|
||||||
|
).toString().toLong()
|
||||||
|
)
|
||||||
|
} else {
|
||||||
|
ma.messageWithSound(
|
||||||
|
getString(R.string.qrPrinterNotvalid),
|
||||||
|
isPlayed = true,
|
||||||
|
isError = true,
|
||||||
|
isToasted = false
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
})
|
||||||
customDialogInput.getEditText().requestFocus()
|
customDialogInput.getEditText().requestFocus()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -12,6 +12,7 @@ import es.verdnatura.domain.formatWithQuotes
|
||||||
import es.verdnatura.domain.userCases.GetItemFromBarcodeUseCase
|
import es.verdnatura.domain.userCases.GetItemFromBarcodeUseCase
|
||||||
import es.verdnatura.domain.userCases.GetItemPrintItemUseCase
|
import es.verdnatura.domain.userCases.GetItemPrintItemUseCase
|
||||||
import es.verdnatura.domain.userCases.NotiticationUseCase
|
import es.verdnatura.domain.userCases.NotiticationUseCase
|
||||||
|
import es.verdnatura.domain.userCases.OperatorUseCase
|
||||||
import es.verdnatura.presentation.base.BaseViewModel
|
import es.verdnatura.presentation.base.BaseViewModel
|
||||||
import es.verdnatura.presentation.common.Action
|
import es.verdnatura.presentation.common.Action
|
||||||
import es.verdnatura.presentation.common.Event
|
import es.verdnatura.presentation.common.Event
|
||||||
|
@ -39,6 +40,7 @@ class UbicadorViewModel(val context: Context) : BaseViewModel(context) {
|
||||||
private val getItemFromBarcodeUseCase = GetItemFromBarcodeUseCase(salix)
|
private val getItemFromBarcodeUseCase = GetItemFromBarcodeUseCase(salix)
|
||||||
private val printItemUseCase = GetItemPrintItemUseCase(salix)
|
private val printItemUseCase = GetItemPrintItemUseCase(salix)
|
||||||
private val notificationUseCase = NotiticationUseCase(salix)
|
private val notificationUseCase = NotiticationUseCase(salix)
|
||||||
|
private val operatorUseCase = OperatorUseCase(salix)
|
||||||
|
|
||||||
private val _responseUbicator by lazy { MutableLiveData<Boolean>() }
|
private val _responseUbicator by lazy { MutableLiveData<Boolean>() }
|
||||||
val responseUbicator: LiveData<Boolean>
|
val responseUbicator: LiveData<Boolean>
|
||||||
|
@ -711,4 +713,11 @@ class UbicadorViewModel(val context: Context) : BaseViewModel(context) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun operatorUpdate(workerFk: Number, labelerFK: Number) {
|
||||||
|
|
||||||
|
operatorUseCase.updateOperator(workerFk = workerFk, hashMapOf("labelerFk" to labelerFK))
|
||||||
|
.enqueue(object : SalixCallback<Unit>(context) {
|
||||||
|
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -131,6 +131,15 @@
|
||||||
tools:text="@string/delete"
|
tools:text="@string/delete"
|
||||||
tools:visibility="visible" />
|
tools:visibility="visible" />
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/custom_dialog_button_ok_three"
|
||||||
|
style="@style/DefaultButton.NormalButton"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_marginTop="@dimen/default_layout_margin"
|
||||||
|
android:visibility="gone"
|
||||||
|
tools:text="@string/delete"
|
||||||
|
tools:visibility="visible" />
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
android:id="@+id/custom_dialog_button_ko"
|
android:id="@+id/custom_dialog_button_ko"
|
||||||
style="@style/DefaultButton.TransparentButton"
|
style="@style/DefaultButton.TransparentButton"
|
||||||
|
|
|
@ -927,6 +927,10 @@
|
||||||
<string name="organize">Ordenar</string>
|
<string name="organize">Ordenar</string>
|
||||||
<string name="descripOrganize">Escanea carro que vas a ordenar.\nAcuérdate de volver a pulsar el icono cuando termines de ordenar</string>
|
<string name="descripOrganize">Escanea carro que vas a ordenar.\nAcuérdate de volver a pulsar el icono cuando termines de ordenar</string>
|
||||||
<string name="activityOrganize">Al pulsar tu actividad será : Ordenar carro</string>
|
<string name="activityOrganize">Al pulsar tu actividad será : Ordenar carro</string>
|
||||||
|
<string name="printerSearch">Escribe impresora</string>
|
||||||
|
<string name="changePrinter">Cambiar Impresora</string>
|
||||||
|
<string name="qrPrinterNotvalid">QR para impresora no válido</string>
|
||||||
|
<string name="scanQrPrinter">Escanea etiqueta qr de la impresora</string>
|
||||||
|
|
||||||
|
|
||||||
</resources>
|
</resources>
|
||||||
|
|
|
@ -927,5 +927,9 @@
|
||||||
<string name="organize">Ordenar</string>
|
<string name="organize">Ordenar</string>
|
||||||
<string name="descripOrganize">Escanea carro que vas a ordenar.\nAcuérdate de volver a pulsar el icono cuando termines de ordenar</string>
|
<string name="descripOrganize">Escanea carro que vas a ordenar.\nAcuérdate de volver a pulsar el icono cuando termines de ordenar</string>
|
||||||
<string name="activityOrganize">Al pulsar tu actividad será : Ordenar carro</string>
|
<string name="activityOrganize">Al pulsar tu actividad será : Ordenar carro</string>
|
||||||
|
<string name="printerSearch">Escribe impresora</string>
|
||||||
|
<string name="changePrinter">Cambiar Impresora</string>
|
||||||
|
<string name="qrPrinterNotvalid">QR para impresora no válido</string>
|
||||||
|
<string name="scanQrPrinter">Escanea etiqueta qr de la impresora</string>
|
||||||
|
|
||||||
</resources>
|
</resources>
|
||||||
|
|
|
@ -927,5 +927,9 @@
|
||||||
<string name="organize">Ordenar</string>
|
<string name="organize">Ordenar</string>
|
||||||
<string name="descripOrganize">Escanea carro que vas a ordenar.\nAcuérdate de volver a pulsar el icono cuando termines de ordenar</string>
|
<string name="descripOrganize">Escanea carro que vas a ordenar.\nAcuérdate de volver a pulsar el icono cuando termines de ordenar</string>
|
||||||
<string name="activityOrganize">Al pulsar tu actividad será : Ordenar carro</string>
|
<string name="activityOrganize">Al pulsar tu actividad será : Ordenar carro</string>
|
||||||
|
<string name="printerSearch">Escribe impresora</string>
|
||||||
|
<string name="changePrinter">Cambiar Impresora</string>
|
||||||
|
<string name="qrPrinterNotvalid">QR para impresora no válido</string>
|
||||||
|
<string name="scanQrPrinter">Escanea etiqueta qr de la impresora</string>
|
||||||
|
|
||||||
</resources>
|
</resources>
|
||||||
|
|
|
@ -930,5 +930,9 @@
|
||||||
<string name="organize">Ordenar</string>
|
<string name="organize">Ordenar</string>
|
||||||
<string name="descripOrganize">Escanea carro que vas a ordenar.\nAcuérdate de volver a pulsar el icono cuando termines de ordenar</string>
|
<string name="descripOrganize">Escanea carro que vas a ordenar.\nAcuérdate de volver a pulsar el icono cuando termines de ordenar</string>
|
||||||
<string name="activityOrganize">Al pulsar tu actividad será : Ordenar carro</string>
|
<string name="activityOrganize">Al pulsar tu actividad será : Ordenar carro</string>
|
||||||
|
<string name="printerSearch">Escribe impresora</string>
|
||||||
|
<string name="changePrinter">Cambiar Impresora</string>
|
||||||
|
<string name="qrPrinterNotvalid">QR para impresora no válido</string>
|
||||||
|
<string name="scanQrPrinter">Escanea etiqueta qr de la impresora</string>
|
||||||
|
|
||||||
</resources>
|
</resources>
|
||||||
|
|
Loading…
Reference in New Issue