refs #6921 feat:dropOffNotes

This commit is contained in:
Sergio De la torre 2024-04-19 09:43:08 +02:00
parent 5f39620f69
commit 9e2d2f167e
3 changed files with 77 additions and 11 deletions

View File

@ -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

View File

@ -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<GeneralItem> = 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<GeneralItem> = 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)
}

View File

@ -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<Any>(context) {})
}
fun addNotesFromDropOff(
ticketObservation: TicketObservation
) {
salix.addNoteFromDropOff(
ticketObservation
).enqueue(object : SalixCallback<Any>(context) {})
}
fun updateNotesFromDropOff(
ticketFK:Long, description:String
) {
salix.updateNoteFromDropOff(
where ="""{"ticketFk" : $ticketFK,"observationTypeFk":10}""" , params= hashMapOf("description" to description)
).enqueue(object : SalixCallback<Any>(context) {})
}
fun imageUpload(
warehouseId: Number,