From 6c58e8012fa31e1d1fe455fca0402d0aee6d152e Mon Sep 17 00:00:00 2001 From: Sergio De la torre Date: Mon, 27 Mar 2023 10:20:59 +0200 Subject: [PATCH] refs #4731 print --- .idea/workspace.xml | 18 +- app/beta/release/output-metadata.json | 20 ++ app/build.gradle | 6 +- .../es/verdnatura/domain/VerdnaturaService.kt | 6 + .../collection/fragment/CollectionFragment.kt | 11 +- .../fragment/InitPreSacadorFragment.kt | 314 ++++++++++-------- .../fragment/PreSacadorViewModel.kt | 44 ++- app/src/main/res/values-es/strings.xml | 2 + app/src/main/res/values/strings.xml | 2 + 9 files changed, 265 insertions(+), 158 deletions(-) create mode 100644 app/beta/release/output-metadata.json diff --git a/.idea/workspace.xml b/.idea/workspace.xml index 5a2f9291..a93b6fe9 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -83,10 +83,16 @@ - + + - + + + + + + - @@ -781,7 +787,7 @@ - diff --git a/app/beta/release/output-metadata.json b/app/beta/release/output-metadata.json new file mode 100644 index 00000000..ea2c93bd --- /dev/null +++ b/app/beta/release/output-metadata.json @@ -0,0 +1,20 @@ +{ + "version": 3, + "artifactType": { + "type": "APK", + "kind": "Directory" + }, + "applicationId": "es.verdnatura.sfusion", + "variantName": "betaRelease", + "elements": [ + { + "type": "SINGLE", + "filters": [], + "attributes": [], + "versionCode": 174, + "versionName": "23.10.2Beta", + "outputFile": "app-beta-release.apk" + } + ], + "elementType": "File" +} \ No newline at end of file diff --git a/app/build.gradle b/app/build.gradle index e5db4c8a..d63f7cd0 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -13,9 +13,9 @@ android { applicationId "es.verdnatura" minSdkVersion 24 //21 targetSdkVersion 33 - versionCode 172 - versionName = "23.10Beta" - //versionName = "23.8Beta" versionCode 170 + versionCode 174 + versionName = "23.10.2Beta" + //versionName = "23.10Beta" versionCode 172 testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" } diff --git a/app/src/main/java/es/verdnatura/domain/VerdnaturaService.kt b/app/src/main/java/es/verdnatura/domain/VerdnaturaService.kt index 8dfe4925..fc06fdfb 100644 --- a/app/src/main/java/es/verdnatura/domain/VerdnaturaService.kt +++ b/app/src/main/java/es/verdnatura/domain/VerdnaturaService.kt @@ -165,6 +165,12 @@ interface VerdnaturaService { ): Call> + @POST("almacennew/ticket_printLabelPrevious") //NO SALIX + fun ticket_printLabelPrevious( + @Body vararg params: Any + ): + Call + @POST("almacennew/collection_assign")//NO SALIX fun collection_assign( ): diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/collection/fragment/CollectionFragment.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/collection/fragment/CollectionFragment.kt index aef9192a..602ff362 100644 --- a/app/src/main/java/es/verdnatura/presentation/view/feature/collection/fragment/CollectionFragment.kt +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/collection/fragment/CollectionFragment.kt @@ -1120,7 +1120,7 @@ class CollectionFragment( sales = salesList.sortedWith(compareBy({ it.saleOrder })) myGroupList = groupSaleGroup(salesList).sortedWith(compareBy({ it.saleOrder })) - if (type == CONTROLADOR) { + if (type == CONTROLADOR || type == PRECHECKER) { sales = salesList.sortedWith(compareBy({ it.picked })) myGroupList = groupSaleGroup(salesList).sortedWith(compareBy({ it.picked })) @@ -1918,7 +1918,8 @@ class CollectionFragment( } private fun setStoredPosition(isFromBack: Boolean) { - if (type == SACADOR) { + /* if (type == SACADOR) { + for (indice in myGroupList.indices) { if (myGroupList[indice].isPrepared == "0") { storedPosition = if (indice != 0) { @@ -1928,8 +1929,8 @@ class CollectionFragment( } break } - } - } + }*/ + setListPosition(storedPosition, isFromBack) } @@ -2842,7 +2843,7 @@ class CollectionFragment( mySale.totalSales = value.size //total líneas mySale.isParent = true value as MutableList - mySale.sonSales = value as MutableList + mySale.sonSales = value.sortedWith(compareBy { it.picked }) as MutableList mySale.line1 = "Previa :${mySale.saleGroupFk}" mySale.line2 = "Líneas: ${value.size}" diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/presacador/fragment/InitPreSacadorFragment.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/presacador/fragment/InitPreSacadorFragment.kt index 3d0ea325..8f11fad1 100644 --- a/app/src/main/java/es/verdnatura/presentation/view/feature/presacador/fragment/InitPreSacadorFragment.kt +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/presacador/fragment/InitPreSacadorFragment.kt @@ -3,7 +3,6 @@ package es.verdnatura.presentation.view.feature.presacador.fragment import android.content.Context import android.graphics.drawable.Drawable import android.os.Build -import android.util.Log.d import android.view.View import android.widget.ImageView import androidx.lifecycle.Observer @@ -11,179 +10,222 @@ import androidx.recyclerview.widget.LinearLayoutManager import es.verdnatura.R import es.verdnatura.databinding.FragmentSacadorBinding import es.verdnatura.domain.ConstAndValues.PREITEMPICKER +import es.verdnatura.domain.toast import es.verdnatura.presentation.base.BaseFragment import es.verdnatura.presentation.common.OnCollectionSelectedListener import es.verdnatura.presentation.common.OnOptionsSelectedListener import es.verdnatura.presentation.common.ToolBarAdapterTooltip import es.verdnatura.presentation.view.component.CustomDialog -import es.verdnatura.presentation.view.feature.presacador.adapter.PreCollectionAdapter +import es.verdnatura.presentation.view.component.CustomDialogInput import es.verdnatura.presentation.view.feature.sacador.adapter.CollectionAdapter import es.verdnatura.presentation.view.feature.sacador.model.CollectionVO -class InitPreSacadorFragment ( - var entrypoint:String = "" +class InitPreSacadorFragment( + var entrypoint: String = "" ) : - BaseFragment(PreSacadorViewModel::class) { + BaseFragment(PreSacadorViewModel::class) { - private var onCollectionSelectedListener: OnCollectionSelectedListener? = null - private var goBack: Boolean = false - private var goBack2: Boolean = false - private lateinit var customDialog: CustomDialog - private var collectionsList: ArrayList = ArrayList() - private var adapter: CollectionAdapter? = null + private var onCollectionSelectedListener: OnCollectionSelectedListener? = null + private var goBack: Boolean = false + private var goBack2: Boolean = false + private lateinit var customDialog: CustomDialog + private var collectionsList: ArrayList = ArrayList() + private var adapter: CollectionAdapter? = null + private lateinit var customDialogInput: CustomDialogInput - companion object { - fun newInstance(entryPoint:String) = InitPreSacadorFragment(entryPoint) + companion object { + fun newInstance(entryPoint: String) = InitPreSacadorFragment(entryPoint) + } + + override fun onAttach(context: Context) { + super.onAttach(context) + if (context is OnCollectionSelectedListener) onCollectionSelectedListener = context + } + + override fun getLayoutId(): Int = R.layout.fragment_sacador + + override fun init() { + + customDialog = CustomDialog(requireContext()) + customDialogInput = CustomDialogInput(requireContext()) + binding.splashProgress.visibility = View.VISIBLE + binding.splashProgressTwo.visibility = View.GONE + setToolBar() + setEvents() + viewModel.sectorCollection_get() + super.init() + + } + + override fun onPause() { + goBack = true + goBack2 = true + super.onPause() + } + + private fun setToolBar() { + + ma.hideBottomNavigation(View.VISIBLE) + binding.mainToolbar.toolbarTitle.text = entrypoint + binding.mainToolbar.backButton.setOnClickListener { + ma.onBackPressed() } - override fun onAttach(context: Context) { - super.onAttach(context) - if (context is OnCollectionSelectedListener) onCollectionSelectedListener = context - } + val listIcons: ArrayList = ArrayList() + val iconAdd = ImageView(context) + val iconPrint = ImageView(context) + iconPrint.setImageResource(R.drawable.ic_print_black_24dp) + iconAdd.setImageResource(R.drawable.ic_add_black_24dp) + iconPrint.setImageResource(R.drawable.ic_print_black_24dp) - override fun getLayoutId(): Int = R.layout.fragment_sacador - - override fun init() { - customDialog = CustomDialog(requireContext()) - binding.splashProgress.visibility = View.VISIBLE - binding.splashProgressTwo.visibility = View.GONE - setToolBar() - setEvents() - viewModel.sectorCollection_get() - super.init() + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { + + iconAdd.tooltipText = getTooltip(R.drawable.ic_add_black_24dp) + // Tarea 4731 + // iconPrint.tooltipText = getTooltip(R.drawable.ic_print_black_24dp) } - override fun onPause() { - goBack = true - goBack2 = true - super.onPause() - } - private fun setToolBar() { + listIcons.add(iconAdd) + listIcons.add(iconPrint) - ma.hideBottomNavigation(View.VISIBLE) - binding.mainToolbar.toolbarTitle.text=entrypoint - binding.mainToolbar.backButton.setOnClickListener{ - ma.onBackPressed() - } - - val listIcons: ArrayList = ArrayList() - val iconAdd = ImageView(context) - iconAdd.setImageResource(R.drawable.ic_add_black_24dp) - - - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { - - iconAdd.tooltipText=getTooltip(R.drawable.ic_add_black_24dp) - - } - - - listIcons.add(iconAdd) - - binding.mainToolbar.toolbarIcons.adapter = ToolBarAdapterTooltip(listIcons, object : OnOptionsSelectedListener { + binding.mainToolbar.toolbarIcons.adapter = + ToolBarAdapterTooltip(listIcons, object : OnOptionsSelectedListener { override fun onOptionsItemSelected(item: Drawable) { - when(item){ + when (item) { iconAdd.drawable -> { binding.splashProgress.visibility = View.VISIBLE viewModel.sectorCollection_new(getDataInt(SECTORFK)) } + iconPrint.drawable -> { + showPrintPrevious() + } } } }) - binding.mainToolbar.toolbarIcons.layoutManager = - LinearLayoutManager(requireContext(), LinearLayoutManager.HORIZONTAL, false) - } + binding.mainToolbar.toolbarIcons.layoutManager = + LinearLayoutManager(requireContext(), LinearLayoutManager.HORIZONTAL, false) + } - private fun setEvents() { - binding.sacadorSwipe.setOnRefreshListener { - viewModel.sectorCollection_get() - binding.sacadorSwipe.isRefreshing = false - } - } + private fun showPrintPrevious() { + customDialogInput.setInputText() + customDialogInput.setTitle(getString(R.string.printTicket)) + customDialogInput.setDescription(getString(R.string.printPreviousGroup)) + .setValue("") + .setOkButton(getString(R.string.print)) { + try { + binding.splashProgress.visibility = View.VISIBLE + viewModel.ticket_printLabelPrevious(customDialogInput.getValue().toInt()) + (getString(R.string.Imprimiendo) + getData(PRINTERNAME)).toast( + requireContext()) + } catch (ex: Exception) { - - override fun observeViewModel() { - - with(viewModel) { - - collectionList.observe(viewLifecycleOwner, Observer { - if (!goBack2) binding.splashProgress.visibility = View.GONE - createCollectionList(it.list) - binding.splashProgress.visibility = View.GONE - goBack2 = false - }) - - response.observe(viewLifecycleOwner, Observer { - binding.splashProgressTwo.visibility = View.GONE - binding.splashProgress.visibility = View.GONE - if (it.isError) { - ma.messageWithSound(it.errorMessage,true,false) - - } else { - if (goBack) addCollectionToList(it.response.toInt()) - } - goBack = false - //sergio:para asegurarnos que aparece en pantalla. En mi movil personal y trabajo no hacia falta. - //viewModel.PrecollectionGetSalix(token=getData(TOKEN)) - }) - responseNew.observe(viewLifecycleOwner, Observer { - binding.splashProgressTwo.visibility = View.GONE - binding.splashProgress.visibility = View.GONE - if (it.isError) { - ma.messageWithSound(getString(R.string.errorCollectionNew)+ it.errorMessage,true,false) - - } else { - //if (goBack) - viewModel.sectorCollection_get() - } - goBack = false - //sergio:para asegurarnos que aparece en pantalla. En mi movil personal y trabajo no hacia falta. - //viewModel.PrecollectionGetSalix(token=getData(TOKEN)) - }) - } - } - - private fun createCollectionList(collections: List) { - collectionsList = ArrayList() - collections.forEach { - collectionsList.add(it) - } - val lm = LinearLayoutManager(requireContext(), LinearLayoutManager.VERTICAL, false) - adapter = CollectionAdapter(collectionsList, onCollectionSelectedListener!!,PREITEMPICKER) - binding.fragmentSacadorCollections.layoutManager = lm - binding.fragmentSacadorCollections.adapter = adapter - - } - - private fun addCollectionToList(collection: Int) { - var isNew = true - collectionsList.forEach { - if (it.collectionFk == collection) { - isNew = false } - } - if (isNew) { - collectionsList.add(CollectionVO(collectionFk = collection, created = getString(R.string.newCreated))) - adapter?.notifyDataSetChanged() - } else { - customDialog.setTitle(getString(R.string.info)) - .setDescription(getString(R.string.collectionPending) + collection) - .setOkButton(getString(R.string.accept)) { - customDialog.dismiss() - }.show() - } - //sergio:para asegurarnos que se actualiza pantalla. - adapter?.notifyDataSetChanged() + customDialogInput.dismiss() + + }.setKoButton(getString(R.string.cancel)) { + customDialogInput.dismiss() + }.show() + customDialogInput.setFocusText() + } + + private fun setEvents() { + binding.sacadorSwipe.setOnRefreshListener { + viewModel.sectorCollection_get() + binding.sacadorSwipe.isRefreshing = false } + } + override fun observeViewModel() { + + with(viewModel) { + + collectionList.observe(viewLifecycleOwner, Observer { + if (!goBack2) binding.splashProgress.visibility = View.GONE + createCollectionList(it.list) + binding.splashProgress.visibility = View.GONE + goBack2 = false + }) + + response.observe(viewLifecycleOwner, Observer { + binding.splashProgressTwo.visibility = View.GONE + binding.splashProgress.visibility = View.GONE + if (it.isError) { + ma.messageWithSound(it.errorMessage, true, false) + + } else { + if (goBack) addCollectionToList(it.response.toInt()) + } + goBack = false + //sergio:para asegurarnos que aparece en pantalla. En mi movil personal y trabajo no hacia falta. + //viewModel.PrecollectionGetSalix(token=getData(TOKEN)) + }) + responseNew.observe(viewLifecycleOwner, Observer { + binding.splashProgressTwo.visibility = View.GONE + binding.splashProgress.visibility = View.GONE + if (it.isError) { + ma.messageWithSound( + getString(R.string.errorCollectionNew) + it.errorMessage, + true, + false + ) + + } else { + //if (goBack) + viewModel.sectorCollection_get() + } + goBack = false + //sergio:para asegurarnos que aparece en pantalla. En mi movil personal y trabajo no hacia falta. + //viewModel.PrecollectionGetSalix(token=getData(TOKEN)) + }) + } + } + + private fun createCollectionList(collections: List) { + collectionsList = ArrayList() + collections.forEach { + collectionsList.add(it) + } + val lm = LinearLayoutManager(requireContext(), LinearLayoutManager.VERTICAL, false) + adapter = CollectionAdapter(collectionsList, onCollectionSelectedListener!!, PREITEMPICKER) + binding.fragmentSacadorCollections.layoutManager = lm + binding.fragmentSacadorCollections.adapter = adapter } + + private fun addCollectionToList(collection: Int) { + var isNew = true + collectionsList.forEach { + if (it.collectionFk == collection) { + isNew = false + } + } + if (isNew) { + collectionsList.add( + CollectionVO( + collectionFk = collection, + created = getString(R.string.newCreated) + ) + ) + adapter?.notifyDataSetChanged() + } else { + customDialog.setTitle(getString(R.string.info)) + .setDescription(getString(R.string.collectionPending) + collection) + .setOkButton(getString(R.string.accept)) { + customDialog.dismiss() + }.show() + } + //sergio:para asegurarnos que se actualiza pantalla. + adapter?.notifyDataSetChanged() + } + + +} diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/presacador/fragment/PreSacadorViewModel.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/presacador/fragment/PreSacadorViewModel.kt index 635c71df..2ab5a970 100644 --- a/app/src/main/java/es/verdnatura/presentation/view/feature/presacador/fragment/PreSacadorViewModel.kt +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/presacador/fragment/PreSacadorViewModel.kt @@ -71,9 +71,9 @@ class PreSacadorViewModel(val context: Context) : BaseViewModel(context) { val responseSalixMessage: LiveData get() = _responseSalixMessage - /* private val _responseMissingTrash by lazy { MutableLiveData() } - val responseMissingTrash: LiveData - get() = _responseMissingTrash*/ + /* private val _responseMissingTrash by lazy { MutableLiveData() } + val responseMissingTrash: LiveData + get() = _responseMissingTrash*/ private val _responseItemShelvingUpdate by lazy { MutableLiveData() } val responseItemShelvingUpdate: LiveData @@ -456,6 +456,25 @@ class PreSacadorViewModel(val context: Context) : BaseViewModel(context) { } + fun ticket_printLabelPrevious(saleGroup: Int) { + + silex.ticket_printLabelPrevious(saleGroup).enqueue(object : SilexCallback(context) { + override fun onError(t: Throwable) { + _response.value = ResponseItemVO( + isError = true, + errorMessage = getMessageFromAllResponse(nameofFunction(this), t.message!!) + ) + } + + override fun onSuccess(response: Response) { + _response.value = + ResponseItemVO(isError = false, response = response.message()!!) + } + }) + + } + + fun sectorCollection_get() { silex.sectorCollection_get().enqueue(object : @@ -466,7 +485,10 @@ class PreSacadorViewModel(val context: Context) : BaseViewModel(context) { CollectionVO( 0, isError = true, - errorMessage = getMessageFromAllResponse(nameofFunction(this), t.message!!) + errorMessage = getMessageFromAllResponse( + nameofFunction(this), + t.message!! + ) ) ) _collectionList.value = CollectionListVO(listError) @@ -622,9 +644,9 @@ class PreSacadorViewModel(val context: Context) : BaseViewModel(context) { fun saleTracking_updateIsChecked( vSaleFk: Int, vIsChecked: Boolean, - vIsScanned:Boolean? + vIsScanned: Boolean? ) { - silex.saleTracking_updateIsChecked(vSaleFk, vIsChecked,vIsScanned) + silex.saleTracking_updateIsChecked(vSaleFk, vIsChecked, vIsScanned) .enqueue( object : SilexCallback(context) { @@ -665,7 +687,10 @@ class PreSacadorViewModel(val context: Context) : BaseViewModel(context) { _responseItemShelvingUpdate.value = ResponseItemVO( isError = true, - errorMessage = getMessageFromAllResponse(nameofFunction(this), t.message!!) + errorMessage = getMessageFromAllResponse( + nameofFunction(this), + t.message!! + ) ) } @@ -691,7 +716,10 @@ class PreSacadorViewModel(val context: Context) : BaseViewModel(context) { override fun onError(t: Throwable) { _responseSplit.value = ResponseItemVO( isError = true, - errorMessage = getMessageFromAllResponse(nameofFunction(this), t.message!!) + errorMessage = getMessageFromAllResponse( + nameofFunction(this), + t.message!! + ) ) } diff --git a/app/src/main/res/values-es/strings.xml b/app/src/main/res/values-es/strings.xml index 3307bd48..a7e63e28 100644 --- a/app/src/main/res/values-es/strings.xml +++ b/app/src/main/res/values-es/strings.xml @@ -546,5 +546,7 @@ Va a eliminar para Autoconsumo la cantidad del artículo: " Tickets:" No es posible actualizar. Problema con la descarga de la app + Introduce el número de previa a imprimir + Imprimir diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 79d9335d..cbe3a343 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -81,6 +81,7 @@ Indicate the new quantity and the action you want to take with the rest. Garbage Indicates new quantity + Indicates previous number for printing Complete collection Parking Shelving Parking @@ -426,6 +427,7 @@ Wagoons Without printer Label printers + Print Label type Vehicle control User without permissions to perform the action