From 317aae62868c81716b851cb848c52d6b496c6978 Mon Sep 17 00:00:00 2001 From: Sergio De la torre Date: Tue, 12 Mar 2024 07:32:12 +0100 Subject: [PATCH] refs #4021 feat:packaging --- .../es/verdnatura/domain/ConstAndValues.kt | 1 + .../java/es/verdnatura/domain/SalixService.kt | 34 +++- .../presentation/common/UIExtensions.kt | 11 ++ .../packaging/fragment/ObservFragment.kt | 48 +++-- .../fragment/PackagingCountFragment.kt | 30 +-- .../fragment/PackagingSummaryFragment.kt | 20 +- .../PackagingViewModel/SupplierViewModel.kt | 174 ++++++++++++------ .../packaging/fragment/SupplierFragment.kt | 116 +++++++----- .../pasillero/fragment/PasilleroViewModel.kt | 7 +- .../layout/fragment_automatic_add_item.xml | 2 +- .../res/layout/fragment_packaging_obs.xml | 6 +- app/src/main/res/layout/fragment_web.xml | 4 +- app/src/main/res/layout/item_image_row.xml | 2 +- .../main/res/layout/item_itemsupplier_row.xml | 2 +- app/src/main/res/values-es/strings.xml | 4 +- app/src/main/res/values-fr/strings.xml | 2 +- app/src/main/res/values-pt/strings.xml | 2 +- app/src/main/res/values/strings.xml | 2 +- 18 files changed, 305 insertions(+), 162 deletions(-) diff --git a/app/src/main/java/es/verdnatura/domain/ConstAndValues.kt b/app/src/main/java/es/verdnatura/domain/ConstAndValues.kt index 36c646ad..a443f024 100644 --- a/app/src/main/java/es/verdnatura/domain/ConstAndValues.kt +++ b/app/src/main/java/es/verdnatura/domain/ConstAndValues.kt @@ -37,6 +37,7 @@ object ConstAndValues { const val WORKFORMSELECTED = "workFormSelected" const val SUPPLIERID = "SUPPLIERID" const val SUPPLIERNAME = "SUPPLIERNAME" + const val ENTRYID = "ENTRYID" const val ITEMPACKING = "itemPackingType" const val ITEMPACKINGFK = "itemPackingTypeFk" const val BUYER = "buyernickname" diff --git a/app/src/main/java/es/verdnatura/domain/SalixService.kt b/app/src/main/java/es/verdnatura/domain/SalixService.kt index a4eaf801..687f27fd 100644 --- a/app/src/main/java/es/verdnatura/domain/SalixService.kt +++ b/app/src/main/java/es/verdnatura/domain/SalixService.kt @@ -42,6 +42,8 @@ import es.verdnatura.presentation.view.feature.main.model.WorkerActionSalix import es.verdnatura.presentation.view.feature.packaging.model.EntrySalix import es.verdnatura.presentation.view.feature.packaging.model.ItemSupplier import es.verdnatura.presentation.view.feature.packaging.model.Supplier +import es.verdnatura.presentation.view.feature.packaging.model.notificationQueue +import es.verdnatura.presentation.view.feature.packaging.model.obervationEntry import es.verdnatura.presentation.view.feature.paletizador.model.ItemExpeditionScanVO import es.verdnatura.presentation.view.feature.paletizador.model.ItemExpeditionTruckVO import es.verdnatura.presentation.view.feature.paletizador.model.ItemPalletVO @@ -50,13 +52,31 @@ import es.verdnatura.presentation.view.feature.paletizador.model.ItemScanVO import es.verdnatura.presentation.view.feature.presacador.model.PreSacadorItemVO import es.verdnatura.presentation.view.feature.reubication.model.Reubication import es.verdnatura.presentation.view.feature.sacador.model.CollectionTicket -import es.verdnatura.presentation.view.feature.packaging.model.* import es.verdnatura.presentation.view.feature.sacador.model.CollectionVO +import es.verdnatura.presentation.view.feature.sacador.model.MistakeTypeVO +import es.verdnatura.presentation.view.feature.sacador.model.PlacementSupplyVO +import es.verdnatura.presentation.view.feature.sacador.model.TicketStateSalix +import es.verdnatura.presentation.view.feature.ubicador.model.ItemUbicador +import es.verdnatura.presentation.view.feature.ubicador.model.ItemUbicadorVO import es.verdnatura.presentation.view.feature.workermistake.model.DepartmentMistake +import es.verdnatura.presentation.view.feature.workermistake.model.ExpeditionMistakeSalix +import es.verdnatura.presentation.view.feature.workermistake.model.MistakeType +import es.verdnatura.presentation.view.feature.workermistake.model.SaleMistakeSalix +import es.verdnatura.presentation.view.feature.workermistake.model.WorkerFromMistake +import es.verdnatura.presentation.view.feature.workermistake.model.WorkerMistakeSalix import okhttp3.MultipartBody -import org.json.JSONObject import retrofit2.Call -import retrofit2.http.* +import retrofit2.http.Body +import retrofit2.http.DELETE +import retrofit2.http.GET +import retrofit2.http.Multipart +import retrofit2.http.PATCH +import retrofit2.http.POST +import retrofit2.http.PUT +import retrofit2.http.Part +import retrofit2.http.Path +import retrofit2.http.Query +import retrofit2.http.QueryMap interface SalixService { @@ -749,8 +769,9 @@ interface SalixService { ): Call //DE MOMENTO NO FUNCIONA, SE QUERÍA AÑADIR POR INSERTIGNORE - @POST("Operators/add") + @POST("Operators") fun operatorAdd( + @Body params: Any ): Call @POST("DeviceLogs") @@ -796,8 +817,10 @@ interface SalixService { @GET("Suppliers")//REVISADA fun getSuppliers( + //@Query("filter") filter:String="""{"fields":{"id":true,"name":true}}""" //@Body params:JSONObject=JSONObject("""filter"={"fields":{"id":true,"name":true},"include":[{"relation":"contacts","scope":{"fields":["email"],"order":"id DESC","limit":1,"where":{"email":{"neq":null}}}}]}""") - /* @Query("filter") filter:String="{\"fields\":{\"id\":true,\"name\":true},\"include\":[{\"relation\":\"contacts\"," + + @Query("filter") filter:String = """{"fields":{"id":true,"name":true},"order":"name ASC","where":{"isActive":1,"name":{"neq":null}}, "include":[{"relation":"contacts","scope":{"fields":["email"],"where":{"email":{"neq":null}}}}]}""" + /* @Query("filter") filter:String="{\"fields\":{\"id\":true,\"name\":true},\"include\":[{\"relation\":\"contacts\"," + "\"scope\":{" + "\"fields\":[\"email\"],\"order\":\"id DESC\",\"limit\":1," + "\"where\":{ \"email\":{\"neq\":null } }}}]})"*/ @@ -833,6 +856,7 @@ interface SalixService { ): Call + @PATCH("Entries/{entryId}")//REVISADA fun entry_updateObserv( @Path("entryId") entryId:Int, diff --git a/app/src/main/java/es/verdnatura/presentation/common/UIExtensions.kt b/app/src/main/java/es/verdnatura/presentation/common/UIExtensions.kt index 4623352c..622b96f4 100644 --- a/app/src/main/java/es/verdnatura/presentation/common/UIExtensions.kt +++ b/app/src/main/java/es/verdnatura/presentation/common/UIExtensions.kt @@ -217,3 +217,14 @@ fun PackageManager.getPackageInfoCompat(packageName: String, flags: Int = 0): Pa } else { @Suppress("DEPRECATION") getPackageInfo(packageName, flags) } + +fun convertToDateString(date: String?): String? { + + if (date.isNullOrEmpty()) { + return date + } + val formatoEntrada = SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'") // Formato de entrada + val formatoSalida = SimpleDateFormat("yyyy-MM-dd") // Formato de salida + val fechaDate = formatoEntrada.parse(date) // Convertir fecha de String a objeto Date + return formatoSalida.format(fechaDate) // Convertir fecha a String con formato deseado +} diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/packaging/fragment/ObservFragment.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/packaging/fragment/ObservFragment.kt index 88c73db0..6dd87e7a 100644 --- a/app/src/main/java/es/verdnatura/presentation/view/feature/packaging/fragment/ObservFragment.kt +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/packaging/fragment/ObservFragment.kt @@ -13,6 +13,11 @@ import com.esafirm.imagepicker.features.registerImagePicker import com.esafirm.imagepicker.model.Image import es.verdnatura.R import es.verdnatura.databinding.FragmentPackagingObsBinding +import es.verdnatura.domain.ConstAndValues.ENTRYID +import es.verdnatura.domain.ConstAndValues.ENTRYNUMBERIMAGES +import es.verdnatura.domain.ConstAndValues.ENTRYOBSERVATIONS +import es.verdnatura.domain.ConstAndValues.ENTRYTYPE +import es.verdnatura.domain.ConstAndValues.SUPPLIERNAME import es.verdnatura.presentation.base.BaseFragment import es.verdnatura.presentation.common.* import es.verdnatura.presentation.view.component.CustomDialog @@ -20,7 +25,7 @@ import es.verdnatura.presentation.view.component.CustomDialogList import es.verdnatura.presentation.view.feature.packaging.adapter.ListImageAdapter import es.verdnatura.presentation.view.feature.packaging.fragment.PackagingViewModel.PackagingViewModel import es.verdnatura.presentation.view.feature.pasillero.model.PasillerosItemVO - +import kotlinx.coroutines.runBlocking @Suppress("UNUSED_ANONYMOUS_PARAMETER") class ObservFragment( @@ -58,7 +63,11 @@ class ObservFragment( private fun setToolBar() { - binding.mainToolbar.toolbarTitle.text = getData("ENTRYTYPE") + ": " + getData("SUPPLIERNAME") + binding.mainToolbar.toolbarTitle.text = buildString { + append(mobileApplication.dataStoreApp.readDataStoreKey(ENTRYTYPE)) + append(": ") + append(mobileApplication.dataStoreApp.readDataStoreKey(SUPPLIERNAME)) + } val listIcons: ArrayList = ArrayList() val iconNext = ImageView(context) @@ -72,16 +81,14 @@ class ObservFragment( override fun onOptionsItemSelected(item: Drawable) { when (item) { iconNext.drawable -> { - saveData( - "ENTRYNUMBERIMAGES", - if (listImages.isNullOrEmpty()) "0" else { - listImages!!.size.toString() - } - ) - saveData("ENTRYOBSERVATIONS",binding.observations.text.toString() ) - - viewModel.entry_updateObserv(getDataInt("ENTRYID"),binding.observations.text.toString()) - + runBlocking { + mobileApplication.dataStoreApp.editDataStoreKey(ENTRYNUMBERIMAGES, + if (listImages.isNullOrEmpty()) 0 else { + listImages!!.size + } ) + mobileApplication.dataStoreApp.editDataStoreKey(ENTRYOBSERVATIONS,binding.observations.text.toString()) + } + viewModel.entry_updateObserv(mobileApplication.dataStoreApp.readDataStoreKey(ENTRYID),binding.observations.text.toString()) ma.onPasillerosItemClickListener( PasillerosItemVO(title = getString(R.string.titlePackagingSummary)), getString(R.string.titlePackagingSummary) @@ -158,10 +165,21 @@ class ObservFragment( adapterListImage = ListImageAdapter(list, object : OnImageUpdateClickListener { - + //http://localhost:3000/api/Entries/1/uploadFile?warehouseId=1&companyId=442&dmsTypeId=21&reference=1&description + // ="Example description"&hasFile=false (tiene que ser de tipo Multipart y llevar adjunto un fichero) override fun OnImageUpdateClickListener(item: Any) { - d("VERDNATURA::", "Seleccionado update" + (item as Image).name) - } + println("a subir imagen") + /* viewModel.entry_uploadPhotoSalix( + warehouseId = mobileApplication.dataStoreApp.readDataStoreKey( + WAREHOUSEFK), + companyId = 442, + dmsTypeId = 21, + reference = mobileApplication.dataStoreApp.readDataStoreKey(ENTRYID).toString(), + description = "Entry id", + hasFile = false, + file= MultipartBody.Part + )*/ + } }, object : OnImageTrashClickListener { override fun OnImageTrashClickListener(item: Any) { d("VERDNATURA::", "Seleccionado trash" + (item as Image).name) diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/packaging/fragment/PackagingCountFragment.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/packaging/fragment/PackagingCountFragment.kt index 1efb4478..2f4c2e6a 100644 --- a/app/src/main/java/es/verdnatura/presentation/view/feature/packaging/fragment/PackagingCountFragment.kt +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/packaging/fragment/PackagingCountFragment.kt @@ -40,9 +40,9 @@ class PackagingCountFragment( override fun init() { - binding.splashProgress.visibility = View.VISIBLE + // binding.splashProgress.visibility = View.VISIBLE viewModel.getItemsPackaging( - getDataInt("SUPPLIERID"), getDataInt("ENTRYID") + mobileApplication.dataStoreApp.readDataStoreKey("SUPPLIERID"), mobileApplication.dataStoreApp.readDataStoreKey("ENTRYID") ) customDialogInput = CustomDialogInput(requireContext()) customDialog = CustomDialog(requireContext()) @@ -55,7 +55,8 @@ class PackagingCountFragment( private fun setToolBar() { binding.mainToolbar.toolbarTitle.text = - "${getData("ENTRYTYPE")}: ${getData("SUPPLIERNAME")}" + "${mobileApplication.dataStoreApp.readDataStoreKey("ENTRYTYPE")}:" + + " ${mobileApplication.dataStoreApp.readDataStoreKey("SUPPLIERNAME")}" val listIcons: ArrayList = ArrayList() val iconNext = ImageView(context) @@ -100,20 +101,19 @@ class PackagingCountFragment( entryAdd.observe(viewLifecycleOwner) { if (it.isError) { - binding.splashProgress.visibility = View.INVISIBLE + //binding.splashProgress.visibility = View.INVISIBLE ma.messageWithSound(it.errorMessage, true, true) } else { ma.messageWithSound(it.errorMessage, false, true) - binding.splashProgress.visibility = View.VISIBLE + //binding.splashProgress.visibility = View.VISIBLE viewModel.getItemsPackaging( - getDataInt("SUPPLIERID"), getDataInt("ENTRYID") - ) + mobileApplication.dataStoreApp.readDataStoreKey("SUPPLIERID"), mobileApplication.dataStoreApp.readDataStoreKey("ENTRYID")) } } itemSupplierList.observe(viewLifecycleOwner) { - binding.splashProgress.visibility = View.GONE + //binding.splashProgress.visibility = View.GONE adapteritemsupplier = ItemSupplierAdapter(it.list, object : OnImageUpdateClickListener { @@ -152,17 +152,17 @@ class PackagingCountFragment( customDialogInput.setTitle(getString(R.string.quantityReviewed)) .setDescription(getString(R.string.Indicanuevacantidad)) .setOkButton(getString(R.string.accept)) { - if (!customDialogInput.getValue().isEmpty()) { + if (customDialogInput.getValue().isNotEmpty()) { requireActivity().hideKeyboard() } - binding.splashProgress.visibility = View.VISIBLE + //binding.splashProgress.visibility = View.VISIBLE viewModel.entry_addFromBuy( - getDataInt("ENTRYID"), item = item.id!!.toInt(), - (if (getData("ENTRYTYPE") == "Rec") { + mobileApplication.dataStoreApp.readDataStoreKey("ENTRYID"), item = item.id!!.toInt(), + (if (mobileApplication.dataStoreApp.readDataStoreKey("ENTRYTYPE") == "Rec") { (item.printedStickers.plus(customDialogInput.getValue().toInt())) } else { - item.printedStickers.plus(customDialogInput.getValue().toInt() * -1) + item.printedStickers.plus(customDialogInput.getValue().toInt()) }) as Number ) customDialog.cancel() @@ -190,9 +190,9 @@ class PackagingCountFragment( ) { customDialog.cancel() customDialog.dismiss() - binding.splashProgress.visibility = View.VISIBLE + //binding.splashProgress.visibility = View.VISIBLE viewModel.entry_addFromBuy( - getDataInt("ENTRYID"), item = item.id!!.toInt(), + mobileApplication.dataStoreApp.readDataStoreKey("ENTRYID"), item = item.id!!.toInt(), 0 ) } diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/packaging/fragment/PackagingSummaryFragment.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/packaging/fragment/PackagingSummaryFragment.kt index 35791e47..a48f894e 100644 --- a/app/src/main/java/es/verdnatura/presentation/view/feature/packaging/fragment/PackagingSummaryFragment.kt +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/packaging/fragment/PackagingSummaryFragment.kt @@ -7,6 +7,12 @@ import android.widget.ImageView import androidx.recyclerview.widget.LinearLayoutManager import es.verdnatura.R import es.verdnatura.databinding.FragmentPackagingSummaryBinding +import es.verdnatura.domain.ConstAndValues.ENTRYID +import es.verdnatura.domain.ConstAndValues.ENTRYNUMBERIMAGES +import es.verdnatura.domain.ConstAndValues.ENTRYOBSERVATIONS +import es.verdnatura.domain.ConstAndValues.ENTRYTYPE +import es.verdnatura.domain.ConstAndValues.SUPPLIERID +import es.verdnatura.domain.ConstAndValues.SUPPLIERNAME import es.verdnatura.presentation.base.BaseFragment import es.verdnatura.presentation.common.* import es.verdnatura.presentation.view.component.CustomDialog @@ -34,12 +40,12 @@ class PackagingSummaryFragment( override fun init() { customDialog = CustomDialog(requireContext()) - binding.totalImages.text = getData("ENTRYNUMBERIMAGES") - binding.observations.text = getData("ENTRYOBSERVATIONS") + binding.totalImages.text = mobileApplication.dataStoreApp.readDataStoreKey(ENTRYNUMBERIMAGES).toString() + binding.observations.text = mobileApplication.dataStoreApp.readDataStoreKey(ENTRYOBSERVATIONS) binding.splashProgress.visibility = View.VISIBLE viewModel.getItemsPackaging( - getDataInt("SUPPLIERID"), getDataInt("ENTRYID") + mobileApplication.dataStoreApp.readDataStoreKey(SUPPLIERID), mobileApplication.dataStoreApp.readDataStoreKey(ENTRYID) ) ma.hideBottomNavigation(View.GONE) @@ -51,7 +57,11 @@ class PackagingSummaryFragment( private fun setToolBar() { - binding.mainToolbar.toolbarTitle.text = getData("ENTRYTYPE") + ": " + getData("SUPPLIERNAME") + binding.mainToolbar.toolbarTitle.text = buildString { + append(mobileApplication.dataStoreApp.readDataStoreKey(ENTRYTYPE)) + append(": ") + append(mobileApplication.dataStoreApp.readDataStoreKey(SUPPLIERNAME)) + } val listIcons: ArrayList = ArrayList() val iconConfirm = ImageView(context) @@ -113,7 +123,7 @@ class PackagingSummaryFragment( R.string.accept ) ) { - viewModel.notificationQueues("modified-entry",getDataInt(USERFK),"""{"url":"${getData("base_urlSalix")}/#!/entry/${getDataInt("ENTRYID")}/summary"}""") + viewModel.notificationQueues("modified-entry",mobileApplication.userId!!,"""{"url":"${mobileApplication.dataStoreApp.readDataStoreKey("base_urlSalix")}/#!/entry/${mobileApplication.dataStoreApp.readDataStoreKey("ENTRYID")}/summary"}""") customDialog.dismiss() } diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/packaging/fragment/PackagingViewModel/SupplierViewModel.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/packaging/fragment/PackagingViewModel/SupplierViewModel.kt index 5ef4988b..82d7f3f1 100644 --- a/app/src/main/java/es/verdnatura/presentation/view/feature/packaging/fragment/PackagingViewModel/SupplierViewModel.kt +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/packaging/fragment/PackagingViewModel/SupplierViewModel.kt @@ -3,20 +3,26 @@ package es.verdnatura.presentation.view.feature.packaging.fragment.PackagingView import android.content.Context import androidx.lifecycle.LiveData import androidx.lifecycle.MutableLiveData -import androidx.lifecycle.Transformations +import androidx.lifecycle.map import es.verdnatura.domain.SilexCallback import es.verdnatura.presentation.base.BaseViewModel import es.verdnatura.presentation.base.getMessageFromAllResponse import es.verdnatura.presentation.base.nameofFunction import es.verdnatura.presentation.common.Event import es.verdnatura.presentation.common.ResponseItemVO -import es.verdnatura.presentation.view.feature.packaging.model.* +import es.verdnatura.presentation.view.feature.packaging.model.EntryList +import es.verdnatura.presentation.view.feature.packaging.model.EntrySalix +import es.verdnatura.presentation.view.feature.packaging.model.ItemSupplier +import es.verdnatura.presentation.view.feature.packaging.model.Supplier +import es.verdnatura.presentation.view.feature.packaging.model.SupplierList +import es.verdnatura.presentation.view.feature.packaging.model.itemSupplierList +import es.verdnatura.presentation.view.feature.packaging.model.notificationQueue +import es.verdnatura.presentation.view.feature.packaging.model.obervationEntry import okhttp3.MultipartBody import retrofit2.Response class PackagingViewModel(val context: Context) : BaseViewModel(context) { - private val _itemSupplierList by lazy { MutableLiveData() } val itemSupplierList: LiveData get() = _itemSupplierList @@ -45,7 +51,8 @@ class PackagingViewModel(val context: Context) : BaseViewModel(context) { val response: LiveData get() = _response - val loadEntryAdd = Transformations.map(_entryAdd) { Event(it) } + val loadEntryAdd: LiveData> = _entryAdd.map { Event(it) } + //val loadEntryAdd = Transformations.map(_entryAdd) { Event(it) } fun getSuppliers() { salix.getSuppliers() @@ -87,6 +94,38 @@ class PackagingViewModel(val context: Context) : BaseViewModel(context) { }) } + //http://localhost:3000/api/Entries/1/uploadFile?warehouseId=1&companyId=442&dmsTypeId=21&reference=1&description="Example description"&hasFile=false (tiene que ser de tipo Multipart y llevar adjunto un fichero) + fun uploadFile(entry: EntrySalix) { + salix.add_entry(entry) + .enqueue(object : + SilexCallback(context) { + override fun onError(t: Throwable) { + _entry.value = EntrySalix( + isError = true, + errorMessage = getMessageFromAllResponse( + nameofFunction(this), + t.message!! + ) + ) + } + + override fun onSuccess(response: Response) { + if (response.body() != null) { + _entry.value = response.body() + } else { + _entry.value = EntrySalix( + isError = true, + errorMessage = getMessageFromAllResponse( + nameofFunction(this), + response.message() + ) + ) + } + + } + }) + } + fun getEntries_fromSupplier(supplier: Int) { salix.getEntries_fromSupplier("""{"where": {"supplierFk": "$supplier"},"limit":5, "order":"created DESC"}""") .enqueue(object : @@ -159,7 +198,7 @@ class PackagingViewModel(val context: Context) : BaseViewModel(context) { }) } - fun entry_addSalix(entry: EntrySalix) { + fun entry_addSalix(entry: EntrySalix) { salix.add_entry(entry) .enqueue(object : SilexCallback(context) { @@ -191,7 +230,7 @@ class PackagingViewModel(val context: Context) : BaseViewModel(context) { } fun entry_updateObserv(entryId: Int, observation: String) { - salix.entry_updateObserv(entryId,obervationEntry(observation)) + salix.entry_updateObserv(entryId, obervationEntry(observation)) .enqueue(object : SilexCallback(context) { override fun onError(t: Throwable) { @@ -221,22 +260,41 @@ class PackagingViewModel(val context: Context) : BaseViewModel(context) { }) } - fun entry_uploadPhotoSalix(id: Number, warehouseId: Number, companyId: Number, dmsTypeId: Number, reference: String, description: String, hasFile: Boolean, file: MultipartBody.Part) { - salix.uploadEntryPhoto(id, warehouseId, companyId, dmsTypeId, reference, description, hasFile, file) - .enqueue(object : SilexCallback(context){}) + fun entry_uploadPhotoSalix( + idEntry:Number, + warehouseId: Number, + companyId: Number, + dmsTypeId: Number, + reference: String, + description: String, + hasFile: Boolean, + file: MultipartBody.Part + ) { + salix.uploadEntryPhoto( + idEntry, + warehouseId, + companyId, + dmsTypeId, + reference, + description, + hasFile, + file + ) + .enqueue(object : SilexCallback(context) {}) } fun entry_addFromBuy(id: Number, item: Number, printedStickers: Number) { salix.addFromBuy(id, item, printedStickers) - .enqueue(object : SilexCallback(context){override fun onError(t: Throwable) { - _entryAdd.value = EntrySalix( - isError = true, - errorMessage = getMessageFromAllResponse( - nameofFunction(this), - t.message!! + .enqueue(object : SilexCallback(context) { + override fun onError(t: Throwable) { + _entryAdd.value = EntrySalix( + isError = true, + errorMessage = getMessageFromAllResponse( + nameofFunction(this), + t.message!! + ) ) - ) - } + } override fun onSuccess(response: Response) { if (response.body() != null) { @@ -254,32 +312,35 @@ class PackagingViewModel(val context: Context) : BaseViewModel(context) { } }) } + fun notificationQueues(notification: String, workerfk: Int, bodyUrl: String) { - salix.notificationQueues(notificationQueue(notification,workerfk,bodyUrl)) - .enqueue(object : SilexCallback(context){override fun onError(t: Throwable) { - _response.value = ResponseItemVO( - isError = true, - errorMessage = getMessageFromAllResponse( - nameofFunction(this), - t.message!! + salix.notificationQueues(notificationQueue(notification, workerfk, bodyUrl)) + .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 = true, - errorMessage = getMessageFromAllResponse( - nameofFunction(this), - response.message() - ) + isError = true, + errorMessage = getMessageFromAllResponse( + nameofFunction(this), + response.message() ) + ) } }) } - fun entry_addFromPackaging(supplier: Number,isPackaging: Boolean) { + + fun entry_addFromPackaging(supplier: Int, isPackaging: Boolean) { salix.addFromPackaging(supplier, isPackaging) .enqueue(object : SilexCallback(context) { override fun onError(t: Throwable) { @@ -308,34 +369,35 @@ class PackagingViewModel(val context: Context) : BaseViewModel(context) { } }) } - fun getItemsPackaging(supplierId: Int,entryId: Int) { - salix.getItemsPackaging(supplierId, entryId) - .enqueue(object : SilexCallback>(context){ - override fun onError(t: Throwable) { - val listError: ArrayList = ArrayList() - listError.add( - ItemSupplier( - isError = true, - errorMessage = getMessageFromAllResponse( - nameofFunction(this), - t.message!! - ) + + fun getItemsPackaging(supplierId: Int, entryId: Int) { + salix.getItemsPackaging(supplierId, entryId) + .enqueue(object : SilexCallback>(context) { + override fun onError(t: Throwable) { + val listError: ArrayList = ArrayList() + listError.add( + ItemSupplier( + isError = true, + errorMessage = getMessageFromAllResponse( + nameofFunction(this), + t.message!! ) ) + ) + _itemSupplierList.value = itemSupplierList(listError) + } + + override fun onSuccess(response: Response>) { + if (response.body() != null) { + _itemSupplierList.value = + response.body()?.let { itemSupplierList(it) } + } else { + val listError: ArrayList = ArrayList() + listError.add(ItemSupplier(null, null)) _itemSupplierList.value = itemSupplierList(listError) } + } - override fun onSuccess(response: Response>) { - if (response.body() != null) { - _itemSupplierList.value = - response.body()?.let { itemSupplierList(it) } - } else { - val listError: ArrayList = ArrayList() - listError.add(ItemSupplier(null, null)) - _itemSupplierList.value = itemSupplierList(listError) - } - } - - }) + }) } } diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/packaging/fragment/SupplierFragment.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/packaging/fragment/SupplierFragment.kt index ec6f8740..190ac3e8 100644 --- a/app/src/main/java/es/verdnatura/presentation/view/feature/packaging/fragment/SupplierFragment.kt +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/packaging/fragment/SupplierFragment.kt @@ -17,7 +17,7 @@ import es.verdnatura.presentation.view.feature.packaging.model.EntrySalix import es.verdnatura.presentation.view.feature.packaging.model.Supplier import es.verdnatura.presentation.view.feature.pasillero.model.PasillerosItemVO import ir.mirrajabi.searchdialog.SimpleSearchDialogCompat - +import kotlinx.coroutines.runBlocking @Suppress("UNUSED_ANONYMOUS_PARAMETER") class SupplierFragment( @@ -34,8 +34,6 @@ class SupplierFragment( private val entries = ArrayList() private lateinit var customDialog: CustomDialog - - companion object { fun newInstance(entryPoint: String) = SupplierFragment(entryPoint) } @@ -54,7 +52,6 @@ class SupplierFragment( val drawableId: Int = R.drawable.background_test // Reemplaza "mi_drawable" con el nombre de tu recurso Drawable - /* val uri: Uri = Uri.parse( ContentResolver.SCHEME_ANDROID_RESOURCE + "://" + context!!.resources.getResourcePackageName(drawableId) + '/' + @@ -64,24 +61,23 @@ class SupplierFragment( val rutaAbsoluta: String = uri.toString()*/ - -/* - val file = File("/storage/emulated/0/Android/data/es.verdnatura.sfusion/files/Pictures/test.png") - val filePart = MultipartBody.Part.createFormData( - "file", - file.name, - RequestBody.create(MediaType.parse("image/png"), file) - ) - viewModel.entry_uploadPhotoSalix( - 1, - 1, - 442, - 21, - "1", - "Example description", - false, - file = filePart - )*/ + /* + val file = File("/storage/emulated/0/Android/data/es.verdnatura.sfusion/files/Pictures/test.png") + val filePart = MultipartBody.Part.createFormData( + "file", + file.name, + RequestBody.create(MediaType.parse("image/png"), file) + ) + viewModel.entry_uploadPhotoSalix( + 1, + 1, + 442, + 21, + "1", + "Example description", + false, + file = filePart + )*/ // viewModel.entry_addFromBuy(8,1,100) super.onCreate(savedInstanceState) } @@ -103,10 +99,19 @@ class SupplierFragment( null, suppliers ) { baseSearchDialogCompat, nombre, position -> - binding.filterSupplier.setText((nombre.getName())) + binding.filterSupplier.text = (nombre.getName()) + println("nombreSupplier"+nombre.getName()) binding.radiobuttonTypePackaging.visibility = View.VISIBLE - saveData("SUPPLIERNAME", nombre.getName()) - saveDataInt("SUPPLIERID", nombre.getId().toInt()) + runBlocking { + mobileApplication.dataStoreApp.editDataStoreKey( + "SUPPLIERNAME", + nombre.getName() + ) + mobileApplication.dataStoreApp.editDataStoreKey( + "SUPPLIERID", + nombre.getId().toInt() + ) + } viewModel.getEntries_fromSupplier(nombre.getId().toInt()) baseSearchDialogCompat.dismiss() }.show() @@ -133,11 +138,15 @@ class SupplierFragment( binding.radiobuttonTypePackaging.setOnCheckedChangeListener { buttonView, isChecked -> when (isChecked) { R.id.radioButtonRec -> { - saveData("ENTRYTYPE", "Rec") + runBlocking { + mobileApplication.dataStoreApp.editDataStoreKey("ENTRYTYPE", "Rec") + } } - R.id.radioButtonDev -> { - saveData("ENTRYTYPE", "Dev") + R.id.radioButtonDev -> { + runBlocking { + mobileApplication.dataStoreApp.editDataStoreKey("ENTRYTYPE", "Dev") + } } } @@ -161,7 +170,12 @@ class SupplierFragment( if (nombre.getName() == getString(R.string.newEntry)) { addEntry() } else { - saveDataInt("ENTRYID", nombre.getId().toInt()) + runBlocking { + mobileApplication.dataStoreApp.editDataStoreKey( + "ENTRYID", + nombre.getId().toInt() + ) + } ma.onPasillerosItemClickListener( PasillerosItemVO(title = getString(R.string.titlePackagingCount)), getString(R.string.titlePackagingCount) @@ -173,7 +187,6 @@ class SupplierFragment( } - override fun observeViewModel() { with(viewModel) { supplierList.observe(viewLifecycleOwner) { @@ -199,7 +212,13 @@ class SupplierFragment( ma.messageWithSound(it.errorMessage, true, false) } else { - saveDataInt("ENTRYID", it.id!!.toInt()) + runBlocking { + mobileApplication.dataStoreApp.editDataStoreKey( + "ENTRYID", + it.id!!.toInt() + ) + } + ma.onPasillerosItemClickListener( PasillerosItemVO(title = getString(R.string.titlePackagingCount)), it.id!!.toString() @@ -209,20 +228,18 @@ class SupplierFragment( } } + /* entryAdd.observe(viewLifecycleOwner) { + if (it.isError) { + ma.messageWithSound(it.errorMessage, true, false) - - /* entryAdd.observe(viewLifecycleOwner) { - if (it.isError) { - ma.messageWithSound(it.errorMessage, true, false) - - } else { - saveDataInt("ENTRYID", it.id!!.toInt()) - ma.onPasillerosItemClickListener( - PasillerosItemVO(title = getString(R.string.titlePackagingCount)), - it.id!!.toString() - ) - } - }*/ + } else { + saveDataInt("ENTRYID", it.id!!.toInt()) + ma.onPasillerosItemClickListener( + PasillerosItemVO(title = getString(R.string.titlePackagingCount)), + it.id!!.toString() + ) + } + }*/ entry.observe(viewLifecycleOwner) { binding.splashProgress.visibility = View.GONE @@ -230,7 +247,10 @@ class SupplierFragment( ma.messageWithSound(it.errorMessage, true, false) } else { - saveDataInt("ENTRYID", it.id!!.toInt()) + runBlocking { + mobileApplication.dataStoreApp.editDataStoreKey("ENTRYID", it.id!!.toInt()) + } + ma.onPasillerosItemClickListener( PasillerosItemVO(title = getString(R.string.titlePackagingCount)), getString(R.string.titlePackagingCount) @@ -240,7 +260,6 @@ class SupplierFragment( } } - private fun createSupplierList(list: List) { suppliers.clear() list.forEach { supplier -> @@ -287,8 +306,8 @@ class SupplierFragment( customDialog.dismiss() binding.splashProgress.visibility = View.VISIBLE viewModel.entry_addFromPackaging( - getDataInt("SUPPLIERID"), - getData("ENTRYTYPE") == "Rec" + mobileApplication.dataStoreApp.readDataStoreKey("SUPPLIERID"), + mobileApplication.dataStoreApp.readDataStoreKey("ENTRYTYPE") == "Rec" ) } @@ -297,7 +316,6 @@ class SupplierFragment( customDialog.cancel() customDialog.dismiss() - } .show() } diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/pasillero/fragment/PasilleroViewModel.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/pasillero/fragment/PasilleroViewModel.kt index c8a35ac0..f4bebf4f 100644 --- a/app/src/main/java/es/verdnatura/presentation/view/feature/pasillero/fragment/PasilleroViewModel.kt +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/pasillero/fragment/PasilleroViewModel.kt @@ -438,10 +438,9 @@ class PasilleroViewModel(context: Context) : BaseViewModel(context) { ) ) -*/ //#tarea4021 - _pasillerositem.add( + /* _pasillerositem.add( PasillerosItemVO( 6, R.drawable.ic_packaging_entries, @@ -449,7 +448,7 @@ class PasilleroViewModel(context: Context) : BaseViewModel(context) { R.string.titlePackaging, contextApp.getString(R.string.titlePackagingDescrip) ) - ) + )*/ _pasillerositem.add( PasillerosItemVO( 6, @@ -458,7 +457,7 @@ class PasilleroViewModel(context: Context) : BaseViewModel(context) { R.string.titlePhotos, contextApp.getString(R.string.titlePhotos) ) - + ) _pasillerositem.add( PasillerosItemVO( 50, diff --git a/app/src/main/res/layout/fragment_automatic_add_item.xml b/app/src/main/res/layout/fragment_automatic_add_item.xml index 39ec720f..bbb0b6bc 100644 --- a/app/src/main/res/layout/fragment_automatic_add_item.xml +++ b/app/src/main/res/layout/fragment_automatic_add_item.xml @@ -54,8 +54,8 @@ android:id="@+id/button_finalizar" style="@style/DefaultButton" android:layout_width="match_parent" + android:layout_height="wrap_content" android:layout_marginStart="16dp" - android:layout_marginTop="16dp" android:layout_marginEnd="16dp" android:layout_weight="1" android:background="@drawable/btn_orange" diff --git a/app/src/main/res/layout/fragment_packaging_obs.xml b/app/src/main/res/layout/fragment_packaging_obs.xml index b7b3b2d0..84b3f5ed 100644 --- a/app/src/main/res/layout/fragment_packaging_obs.xml +++ b/app/src/main/res/layout/fragment_packaging_obs.xml @@ -39,7 +39,7 @@ android:textColor="#FFF" android:textSize="18dp" android:drawableEnd="@drawable/ic_add_black_24dp" - android:visibility="gone" + android:visibility="visible" app:layout_constraintStart_toEndOf="@+id/observations" app:layout_constraintTop_toBottomOf="@+id/observations" /> @@ -72,7 +72,7 @@ android:id="@+id/listImagesRecycler" android:layout_width="match_parent" android:layout_height="550dp" - android:visibility="gone" + android:visibility="visible" app:layout_constraintStart_toEndOf="@+id/textImages" app:layout_constraintTop_toBottomOf="@+id/textImages" tools:listitem="@layout/item_image_row" diff --git a/app/src/main/res/layout/fragment_web.xml b/app/src/main/res/layout/fragment_web.xml index 93ae3965..6893f618 100644 --- a/app/src/main/res/layout/fragment_web.xml +++ b/app/src/main/res/layout/fragment_web.xml @@ -4,6 +4,7 @@ @@ -21,7 +22,8 @@ android:id="@+id/webView" android:layout_width="match_parent" android:layout_height="match_parent" - android:layout_marginTop="0dp" /> + android:layout_marginTop="0dp" + /> \ No newline at end of file diff --git a/app/src/main/res/layout/item_image_row.xml b/app/src/main/res/layout/item_image_row.xml index 8734a188..56d4e97d 100644 --- a/app/src/main/res/layout/item_image_row.xml +++ b/app/src/main/res/layout/item_image_row.xml @@ -54,7 +54,7 @@ android:gravity="center_vertical" android:scaleType="centerCrop" android:src="@drawable/ic_history_black_24dp" - android:visibility="gone" /> + android:visibility="visible" /> Coger Causa del error registrado Falta seleccionar impresora - Observaciones + Observaciones: Escanea matrícula para ver histórico Escanea matrícula del vehículo Escanea matrícula para dejar vehículo @@ -738,8 +738,6 @@ Imágenes adjuntas: Añadir… ¿Estás seguro que quieres parkinear la matricula %1$s? Tienes material mas antiguo en otra ubicación. - - Revisión del carro Cantidad revisada a sumar/restar del total Vas a borrar la cantidad de la compra de la entrada Cantidad a revisar diff --git a/app/src/main/res/values-fr/strings.xml b/app/src/main/res/values-fr/strings.xml index e1e4a7f3..6030af92 100644 --- a/app/src/main/res/values-fr/strings.xml +++ b/app/src/main/res/values-fr/strings.xml @@ -246,7 +246,7 @@ Coger Causa del error registrado Falta seleccionar impresora - Observaciones + Observaciones: Escanea matrícula para ver histórico Escanea matrícula del vehículo Escanea matrícula para dejar vehículo diff --git a/app/src/main/res/values-pt/strings.xml b/app/src/main/res/values-pt/strings.xml index 2585d6f4..5cdef72c 100644 --- a/app/src/main/res/values-pt/strings.xml +++ b/app/src/main/res/values-pt/strings.xml @@ -246,7 +246,7 @@ Coger Causa del error registrado Falta seleccionar impresora - Observaciones + Observaciones: Escanea matrícula para ver histórico Escanea matrícula del vehículo Escanea matrícula para dejar vehículo diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 5a5a03d3..f0ebd69c 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -281,7 +281,7 @@ Take Cause of error registered Select printer - Observations + Observations: Scan plate for looking historical Scan vehicle plate "Scan plate to take off "