From 9e2d2f167e65d34016b07f1a40da8dc2fce38d19 Mon Sep 17 00:00:00 2001 From: Sergio De la torre Date: Fri, 19 Apr 2024 09:43:08 +0200 Subject: [PATCH] refs #6921 feat:dropOffNotes --- .../delivery/adapters/TicketAdapter.kt | 2 +- .../delivery/fragments/TicketsFragment.kt | 68 ++++++++++++++++--- .../delivery/viewmodels/DeliveryViewModel.kt | 18 +++++ 3 files changed, 77 insertions(+), 11 deletions(-) diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/delivery/adapters/TicketAdapter.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/delivery/adapters/TicketAdapter.kt index badb9833..ae23657e 100644 --- a/app/src/main/java/es/verdnatura/presentation/view/feature/delivery/adapters/TicketAdapter.kt +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/delivery/adapters/TicketAdapter.kt @@ -76,7 +76,7 @@ class TicketAdapter( fun bind(item: ClientTicketSalix) { binding.apply { - if (!item.ticketObservation.isNullOrEmpty()) { + if (!item.observationDelivery.isNullOrEmpty() && !item.observationDelivery!!.toString().contains("null")){ note.setColorFilter( ContextCompat.getColor( note.context, R.color.verdnatura_white diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/delivery/fragments/TicketsFragment.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/delivery/fragments/TicketsFragment.kt index 1a038dd3..a82d3135 100644 --- a/app/src/main/java/es/verdnatura/presentation/view/feature/delivery/fragments/TicketsFragment.kt +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/delivery/fragments/TicketsFragment.kt @@ -2,7 +2,6 @@ package es.verdnatura.presentation.view.feature.delivery.fragments import android.Manifest import android.app.Activity -import android.app.AlertDialog import android.app.TimePickerDialog import android.content.Intent import android.content.pm.PackageManager @@ -317,7 +316,7 @@ class TicketsFragment( ticket.id, ticket.packages, ticket.ipt, - ticket.ticketObservation, + ticket.observationDelivery, ticket.cmrFk ) } @@ -425,6 +424,7 @@ class TicketsFragment( val customDialogInput = CustomDialogInputNotes(requireContext()) customDialogInput.setTitle(getString(R.string.notes)) + //customDialogInput.setDescription(itemClient.observationDelivery.toString()) val adapter: GeneralAdapter val itemsNotes: List = listOf( @@ -449,6 +449,21 @@ class TicketsFragment( customDialogInput.getRecyclerView().layoutManager = LinearLayoutManager(requireContext(), LinearLayoutManager.VERTICAL, false) customDialogInput.setOkButton(getString(R.string.save)) { + //tarea 6921 + /*if (itemClient.observationDropOff == null) { + viewModel.addNotesFromDropOff( + TicketObservation( + ticketFk = itemClient.id, + description = customDialogInput.getValue(), + observationTypeFk = 10 + ) + ) + } else { + viewModel.updateNotesFromDropOff( + itemClient.id, + description = customDialogInput.getValue() + ) + }*/ viewModel.addNotes(itemClient.tickets, customDialogInput.getValue()) customDialogInput.dismiss() }.setKoButton(getString(R.string.cancel)) { @@ -459,15 +474,48 @@ class TicketsFragment( } - private fun showNotes(item: ClientTicketSalix) { + fun showNotes(clientClicked: ClientTicketSalix) { + val ticketNotes: MutableList = mutableListOf() + //Tarea 6275 + if (!clientClicked.observationDelivery.isNullOrBlank()) { - val alertDialog = AlertDialog.Builder(requireContext()).create() - alertDialog.setTitle(getString(R.string.info)) - alertDialog.setMessage(item.ticketObservation) - alertDialog.setButton( - AlertDialog.BUTTON_NEUTRAL, getString(R.string.close) - ) { dialog, _ -> dialog.dismiss() } - alertDialog.show() + ticketNotes.add( + GeneralItem( + text = "Reparto:${clientClicked.observationDelivery}", + code = "" + ) + ) + } + if (!clientClicked.observationDropOff.isNullOrBlank()) { + + ticketNotes.add( + GeneralItem( + text = "Repartidor:${clientClicked.observationDropOff}", + code = "" + ) + ) + } + + customDialogList.setValueVisibility(View.GONE) + customDialogList.setTitle(getString(R.string.ticketNotes)).setKoButton( + getString( + R.string.cancel + ) + ) { + customDialogList.dismiss() + }.hideDialog().show() + + val listPhonesAdapter = GeneralAdapter(ticketNotes, object : OnGeneralItemRowClickListener { + override fun OnGeneralItemRowClickListener(item: GeneralItem) { + + customDialogList.dismiss() + } + + }) + + customDialogList.getRecyclerView().adapter = listPhonesAdapter + customDialogList.getRecyclerView().layoutManager = + LinearLayoutManager(requireContext(), LinearLayoutManager.VERTICAL, false) } diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/delivery/viewmodels/DeliveryViewModel.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/delivery/viewmodels/DeliveryViewModel.kt index 23253e5f..7422d355 100644 --- a/app/src/main/java/es/verdnatura/presentation/view/feature/delivery/viewmodels/DeliveryViewModel.kt +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/delivery/viewmodels/DeliveryViewModel.kt @@ -24,6 +24,7 @@ import es.verdnatura.presentation.view.feature.delivery.model.RouteDeliveryList import es.verdnatura.presentation.view.feature.delivery.model.RouteInfo import es.verdnatura.presentation.view.feature.delivery.model.RouteList import es.verdnatura.presentation.view.feature.delivery.model.Ticket +import es.verdnatura.presentation.view.feature.delivery.model.TicketObservation import okhttp3.MediaType import okhttp3.MultipartBody import okhttp3.RequestBody @@ -328,6 +329,23 @@ class DeliveryViewModel(val context: Context) : BaseViewModel(context) { arrayListOf(listTickets[0].Id, note).formatWithQuotes() ).enqueue(object : SalixCallback(context) {}) } + fun addNotesFromDropOff( + ticketObservation: TicketObservation + + ) { + salix.addNoteFromDropOff( + ticketObservation + ).enqueue(object : SalixCallback(context) {}) + } + fun updateNotesFromDropOff( + ticketFK:Long, description:String + + ) { + salix.updateNoteFromDropOff( + where ="""{"ticketFk" : $ticketFK,"observationTypeFk":10}""" , params= hashMapOf("description" to description) + ).enqueue(object : SalixCallback(context) {}) + } + fun imageUpload( warehouseId: Number,