From c264406f0e2ac9e20c2b6c513da636c1cb18aba0 Mon Sep 17 00:00:00 2001 From: Sergio De la torre Date: Tue, 9 Jan 2024 08:47:16 +0100 Subject: [PATCH] refs #6275 feat: back to Salix --- .../main/java/es/verdnatura/db/database.kt | 8 +- .../java/es/verdnatura/domain/SalixService.kt | 4 +- .../delivery/activity/SignedActivity.kt | 17 ++-- .../delivery/adapters/TicketAdapter.kt | 13 ++- .../delivery/fragments/LoadUnloadFragment.kt | 8 +- .../delivery/fragments/RoutesFragment.kt | 39 ++++---- .../delivery/fragments/SummaryFragment.kt | 46 ++++++---- .../delivery/fragments/TicketsFragment.kt | 90 +++++++++---------- .../feature/delivery/model/ClientTicket.kt | 3 +- .../delivery/viewmodels/DeliveryViewModel.kt | 29 +++--- app/src/main/res/layout/item_ticket_row.xml | 10 +-- 11 files changed, 145 insertions(+), 122 deletions(-) diff --git a/app/src/main/java/es/verdnatura/db/database.kt b/app/src/main/java/es/verdnatura/db/database.kt index 43ea43c9..8d72773d 100644 --- a/app/src/main/java/es/verdnatura/db/database.kt +++ b/app/src/main/java/es/verdnatura/db/database.kt @@ -4,7 +4,7 @@ import android.content.Context import androidx.room.* import com.google.gson.Gson import com.google.gson.reflect.TypeToken -import es.verdnatura.presentation.view.feature.delivery.model.ClientTicket +import es.verdnatura.presentation.view.feature.delivery.model.ClientTicketSalix import es.verdnatura.presentation.view.feature.delivery.model.ExpeditionInfoLoadUnload import es.verdnatura.presentation.view.feature.delivery.model.ExpeditionInfoPending import es.verdnatura.presentation.view.feature.delivery.model.MyLocation @@ -17,7 +17,7 @@ import java.util.Date // Clase que representa la base de datos @Database( - entities = [ExpeditionInfoLoadUnload::class, ExpeditionInfoPending::class, SignedTickets::class, RouteInfo::class, ClientTicket::class, RouteLoaded::class], + entities = [ExpeditionInfoLoadUnload::class, ExpeditionInfoPending::class, SignedTickets::class, RouteInfo::class, ClientTicketSalix::class, RouteLoaded::class], version = 1 ) @TypeConverters(MapTypeConverter::class) @@ -114,10 +114,10 @@ interface RoutesDao { @Dao interface ClientTicketDao { @Query("SELECT * FROM clientTickets ") - suspend fun getAll(): List + suspend fun getAll(): List @Insert(onConflict = OnConflictStrategy.REPLACE) - suspend fun insert(routes: List) + suspend fun insert(routes: List) @Query("DELETE FROM clientTickets ") suspend fun delete() diff --git a/app/src/main/java/es/verdnatura/domain/SalixService.kt b/app/src/main/java/es/verdnatura/domain/SalixService.kt index 31c48b00..379389e9 100644 --- a/app/src/main/java/es/verdnatura/domain/SalixService.kt +++ b/app/src/main/java/es/verdnatura/domain/SalixService.kt @@ -15,7 +15,7 @@ import es.verdnatura.presentation.view.feature.calidad.model.BuyerVO import es.verdnatura.presentation.view.feature.collection.SalixSaleQuantity import es.verdnatura.presentation.view.feature.collection.listSaleSalix import es.verdnatura.presentation.view.feature.controlvehiculo.fragment.model.DeviceId -import es.verdnatura.presentation.view.feature.delivery.model.ClientTicket +import es.verdnatura.presentation.view.feature.delivery.model.ClientTicketSalix import es.verdnatura.presentation.view.feature.delivery.model.DeliveryInfo import es.verdnatura.presentation.view.feature.delivery.model.ExpeditionInfoLoadUnload import es.verdnatura.presentation.view.feature.delivery.model.ExpeditionInfoLog @@ -129,7 +129,7 @@ interface SalixService { @GET("Routes/getTickets") fun getTickets( @Query("filter") filter: Any, - ): Call> + ): Call> @GET("Routes/getByWorker") fun getRoutes( diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/delivery/activity/SignedActivity.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/delivery/activity/SignedActivity.kt index 38ac09db..f7e3b747 100644 --- a/app/src/main/java/es/verdnatura/presentation/view/feature/delivery/activity/SignedActivity.kt +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/delivery/activity/SignedActivity.kt @@ -1,7 +1,6 @@ package es.verdnatura.presentation.view.feature.delivery.activity import android.Manifest -import android.content.DialogInterface import android.content.pm.PackageManager import android.graphics.Bitmap import android.location.Location @@ -21,7 +20,7 @@ import es.verdnatura.presentation.base.BaseActivity import es.verdnatura.presentation.base.LocationUpdateCallback import es.verdnatura.presentation.base.database import es.verdnatura.presentation.view.component.CustomDialog -import es.verdnatura.presentation.view.feature.delivery.model.ClientTicket +import es.verdnatura.presentation.view.feature.delivery.model.ClientTicketSalix import es.verdnatura.presentation.view.feature.delivery.model.MyLocation import es.verdnatura.presentation.view.feature.delivery.model.SignedTickets import es.verdnatura.presentation.view.feature.delivery.viewmodels.DeliveryViewModel @@ -44,7 +43,7 @@ class SignedActivity : BaseActivity(), LocationUpdateCallba private lateinit var fusedLocationClient: com.google.android.gms.location.FusedLocationProviderClient private var lastLocationCurrent: MyLocation = MyLocation(0.0, 0.0) private lateinit var ticketsSet: HashSet - private lateinit var clientTicket: ClientTicket + private lateinit var clientTicket: ClientTicketSalix private lateinit var db: DeliveryDatabase override fun init() { @@ -53,7 +52,7 @@ class SignedActivity : BaseActivity(), LocationUpdateCallba "ticket" -> { binding.mainToolbar.toolbarTitle.text = getString(R.string.sign) - clientTicket = intent.extras!!.getSerializable("clientTicketList") as ClientTicket + clientTicket = intent.extras!!.getSerializable("clientTicketList") as ClientTicketSalix setViews(clientTicket) setLocation() } @@ -91,12 +90,12 @@ class SignedActivity : BaseActivity(), LocationUpdateCallba this.longitude = lastLocationCurrent.Longitude } val locationClient = Location("").apply { - this.latitude = clientTicket.Latitude ?: 0.0 - this.longitude = clientTicket.Longitude ?: 0.0 + this.latitude = clientTicket.latitude ?: 0.0 + this.longitude = clientTicket.longitude ?: 0.0 } - if (clientTicket.Latitude != null && clientTicket.Longitude != null) { + if (clientTicket.latitude != null && clientTicket.longitude != null) { if (locationCurrent.distanceTo(locationClient) > 100 ) { val customDialogDistance = CustomDialog(this) @@ -154,11 +153,11 @@ class SignedActivity : BaseActivity(), LocationUpdateCallba } - private fun setViews(clientTicketList: ClientTicket) { + private fun setViews(clientTicketList: ClientTicketSalix) { if (clientTicketList != null) { - binding.nameAddress.text = clientTicketList.ClientName + binding.nameAddress.text = clientTicketList.nickname ticketsSet = HashSet() var sum = 0 for (exp in clientTicketList.tickets) { 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 c8950217..0e9872e4 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 @@ -11,11 +11,10 @@ import es.verdnatura.R import es.verdnatura.databinding.ItemTicketRowBinding import es.verdnatura.presentation.common.OnItemButtonCMRRowClickListener import es.verdnatura.presentation.common.OnItemButtonTicketRowClickListener -import es.verdnatura.presentation.view.feature.delivery.model.ClientTicket - +import es.verdnatura.presentation.view.feature.delivery.model.ClientTicketSalix class TicketAdapter( - private var items: MutableList, + private var items: MutableList, private val onItemButtonTicketRowClickListener: OnItemButtonTicketRowClickListener, private val onItemButtonCMRRowClickListener: OnItemButtonCMRRowClickListener @@ -33,7 +32,7 @@ class TicketAdapter( ) } - fun setHeaders(list: MutableList): MutableList { + fun setHeaders(list: MutableList): MutableList { /* var prevCreated = "" for (route in list) { @@ -45,7 +44,7 @@ class TicketAdapter( return list } - fun updateList(newList: MutableList) { + fun updateList(newList: MutableList) { items = newList notifyDataSetChanged() } @@ -89,10 +88,10 @@ class TicketAdapter( val binding: ItemTicketRowBinding ) : RecyclerView.ViewHolder(binding.root) { private val res = binding.root.context.resources - fun bind(item: ClientTicket) { + fun bind(item: ClientTicketSalix) { binding.apply { - if (!item.Note.isNullOrEmpty()) { + if (!item.ticketObservation.isNullOrEmpty()) { note.setColorFilter( ContextCompat.getColor( note.context, diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/delivery/fragments/LoadUnloadFragment.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/delivery/fragments/LoadUnloadFragment.kt index ffa52254..6d30fffe 100644 --- a/app/src/main/java/es/verdnatura/presentation/view/feature/delivery/fragments/LoadUnloadFragment.kt +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/delivery/fragments/LoadUnloadFragment.kt @@ -313,7 +313,13 @@ class LoadUnloadFragment( if (binding.mainToolbar.switchButton.isChecked) { counterCalls = 1 binding.splashProgress.visibility = View.VISIBLE - viewModel.expeditionState_add(myList.filter { it.code == state }, state) + val pendingExpeditionSend = myList.map { l -> + ExpeditionSalix( + expeditionFk = l.id, + stateCode = l.code + ) + } + viewModel.expeditionStateAddSalix( hashMapOf("expeditions" to pendingExpeditionSend.filter { it.stateCode == state })) } else { updateCount(myList, state) } diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/delivery/fragments/RoutesFragment.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/delivery/fragments/RoutesFragment.kt index aa6d2dc2..8d1f6c2e 100644 --- a/app/src/main/java/es/verdnatura/presentation/view/feature/delivery/fragments/RoutesFragment.kt +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/delivery/fragments/RoutesFragment.kt @@ -24,6 +24,7 @@ import es.verdnatura.presentation.base.database import es.verdnatura.presentation.common.* import es.verdnatura.presentation.view.feature.delivery.adapters.RouteAdapter import es.verdnatura.presentation.view.feature.delivery.model.ExpeditionInfoLoadUnload +import es.verdnatura.presentation.view.feature.delivery.model.ExpeditionSalix import es.verdnatura.presentation.view.feature.delivery.model.RouteInfo import es.verdnatura.presentation.view.feature.delivery.model.RouteLoaded import es.verdnatura.presentation.view.feature.delivery.viewmodels.DeliveryViewModel @@ -64,6 +65,7 @@ class RoutesFragment( } private fun pendingOperations() { + db = database(requireContext().applicationContext) if (mobileApplication.hasNetwork) { lifecycleScope.launch { @@ -75,31 +77,35 @@ class RoutesFragment( val pendingExpedition = db.expedicionDao().getAllPendingExpeditions() - if (pendingExpedition.filter { it.code == "DELIVERED" }.isNotEmpty()) { - viewModel.expeditionState_add( - pendingExpedition.filter { it.code == "DELIVERED" }, - "DELIVERED" + + val pendingExpeditionSend = pendingExpedition.map { l -> + ExpeditionSalix( + expeditionFk = l.id, + stateCode = l.code ) } - if (pendingExpedition.filter { it.code == "ON DELIVERY" }.isNotEmpty()) { - viewModel.expeditionState_add( - pendingExpedition.filter { it.code == "ON DELIVERY" }, - "ON DELIVERY" + if (pendingExpeditionSend.filter{ it.stateCode == "DELIVERED" }.isNotEmpty()) { + viewModel.expeditionStateAddSalix( + hashMapOf("expeditions" to pendingExpeditionSend.filter{ it.stateCode == "DELIVERED" }) ) } - if (pendingExpedition.filter { it.code == "LOST" }.isNotEmpty()) { - viewModel.expeditionState_add( - pendingExpedition.filter { it.code == "LOST" }, - "LOST" + if (pendingExpeditionSend.filter{ it.stateCode == "ON DELIVERY" }.isNotEmpty()) { + viewModel.expeditionStateAddSalix( + hashMapOf("expeditions" to pendingExpeditionSend.filter{ it.stateCode == "ON DELIVERY" }) ) } - if (pendingExpedition.filter { it.code == "FOUND" }.isNotEmpty()) { - viewModel.expeditionState_add( - pendingExpedition.filter { it.code == "FOUND" }, - "FOUND" + if (pendingExpeditionSend.filter{ it.stateCode == "LOST" }.isNotEmpty()) { + viewModel.expeditionStateAddSalix( + hashMapOf("expeditions" to pendingExpeditionSend.filter{ it.stateCode == "LOST" }) ) } + if (pendingExpeditionSend.filter{ it.stateCode == "FOUND" }.isNotEmpty()) { + viewModel.expeditionStateAddSalix( + hashMapOf("expeditions" to pendingExpeditionSend.filter{ it.stateCode == "FOUND" }) + ) + } + } db.routesDao().deleteLoaded(toDateString(Date())) myListRouteLoaded = db.routesDao().getAllLoaded() @@ -132,6 +138,7 @@ class RoutesFragment( return callBackEndPoint } + @RequiresApi(Build.VERSION_CODES.O) private fun setToolBar() { ma.hideBottomNavigation(View.GONE) diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/delivery/fragments/SummaryFragment.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/delivery/fragments/SummaryFragment.kt index 832bd399..24109b4e 100644 --- a/app/src/main/java/es/verdnatura/presentation/view/feature/delivery/fragments/SummaryFragment.kt +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/delivery/fragments/SummaryFragment.kt @@ -21,10 +21,10 @@ import es.verdnatura.presentation.common.* import es.verdnatura.presentation.view.feature.delivery.adapters.ExpeditionSummaryAdapter import es.verdnatura.presentation.view.feature.delivery.model.ExpeditionInfoLoadUnload import es.verdnatura.presentation.view.feature.delivery.model.ExpeditionInfoSummary +import es.verdnatura.presentation.view.feature.delivery.model.ExpeditionSalix import es.verdnatura.presentation.view.feature.delivery.viewmodels.DeliveryViewModel import es.verdnatura.presentation.view.feature.pasillero.model.PasillerosItemVO - class SummaryFragment( var title: String = "", var state: String = "", @@ -46,7 +46,6 @@ class SummaryFragment( private var isScanning = false private var positionSelected = -1 - companion object { fun newInstance(title: String, state: String, route: Int) = SummaryFragment(title, state, route) @@ -126,7 +125,7 @@ class SummaryFragment( } iconExit.drawable -> { - requireActivity().finish() + requireActivity().finish() } } @@ -158,14 +157,27 @@ class SummaryFragment( state: String, address: Int ) { - + val listExpedition = list.filter { it.addressFk == address }.map { l -> + ExpeditionSalix( + expeditionFk = l.id, + stateCode = if (l.code == state) { + state + } else { + "FOUND" + } + ) + } if (list.filter { it.addressFk == address } .filter { it.code == state }.size == list.filter { it.addressFk == address }.size) { - binding.splashProgress.visibility = View.VISIBLE - callBack(viewModel.expeditionState_add(list.filter { it.addressFk == address } - .filter { it.code == state }, state)) counterCalls = 1 + callBack( + viewModel.expeditionStateAddSalix( + hashMapOf("expeditions" to listExpedition.filter { it.stateCode == state }) + ) + ) + /* callBack(viewModel.expeditionState_add(list.filter { it.addressFk == address } + .filter { it.code == state }, state))*/ isScanning = false } else { @@ -175,13 +187,18 @@ class SummaryFragment( alertDialog.setButton( android.app.AlertDialog.BUTTON_POSITIVE, getString(R.string.save) ) { dialog, which -> - counterCalls = 2 + binding.splashProgress.visibility = View.VISIBLE - viewModel.expeditionState_add(list.filter { it.addressFk == address } - .filter { it.code == state }, state) - viewModel.expeditionState_add(list.filter { it.addressFk == address } - .filter { it.code != state }, "LOST") + + counterCalls = 1 + viewModel.expeditionStateAddSalix(hashMapOf("expeditions" to listExpedition.filter { it.stateCode == state })) + + /* + viewModel.expeditionState_add(list.filter { it.addressFk == address } + .filter { it.code == state }, state) + viewModel.expeditionState_add(list.filter { it.addressFk == address } + .filter { it.code != state }, "LOST")*/ } alertDialog.setButton( android.app.AlertDialog.BUTTON_NEUTRAL, getString(R.string.find) @@ -191,7 +208,6 @@ class SummaryFragment( alertDialog.show() } - } private fun openAppDelivery() { @@ -271,7 +287,6 @@ class SummaryFragment( updateCount(myList, state) } - } @RequiresApi(Build.VERSION_CODES.O) @@ -382,7 +397,6 @@ class SummaryFragment( } - private fun createList(list: MutableList) { myList = list @@ -399,7 +413,6 @@ class SummaryFragment( } } - private fun updateCount(list: MutableList, state: String) { val countMarked = list.filter { it.addressFk == addressFkSelected }.filter { it.code == state }.size @@ -424,5 +437,4 @@ class SummaryFragment( } } - } \ No newline at end of file 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 945da8c6..a50e93b3 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 @@ -31,7 +31,7 @@ import es.verdnatura.presentation.common.* import es.verdnatura.presentation.view.component.CustomDialogInputNotes import es.verdnatura.presentation.view.component.CustomDialogList import es.verdnatura.presentation.view.feature.delivery.adapters.TicketAdapter -import es.verdnatura.presentation.view.feature.delivery.model.ClientTicket +import es.verdnatura.presentation.view.feature.delivery.model.ClientTicketSalix import es.verdnatura.presentation.view.feature.delivery.model.ExpeditionInfoLoadUnload import es.verdnatura.presentation.view.feature.delivery.model.RouteInfo import es.verdnatura.presentation.view.feature.delivery.model.Ticket @@ -52,7 +52,7 @@ class TicketsFragment( private var adapter: TicketAdapter? = null private var pasillerosItemClickListener: OnPasillerosItemClickListener? = null - private lateinit var myListClientTicket: MutableList + private lateinit var myListClientTicket: MutableList private var showSigned = false private var showSettings = false private lateinit var db: DeliveryDatabase @@ -84,7 +84,7 @@ class TicketsFragment( binding.mainToolbar.toolbarSubtitle.text = if (::myListClientTicket.isInitialized) { - myListClientTicket.filter { it.Signed == 1 }.size.toString() + "/" + myListClientTicket.size + myListClientTicket.filter { it.signed == 1 }.size.toString() + "/" + myListClientTicket.size } else { "0/0" } @@ -170,9 +170,9 @@ class TicketsFragment( if (::myListClientTicket.isInitialized) { adapter!!.updateList( if (showSigned) { - myListClientTicket.filter { it.Signed == 1 } as MutableList + myListClientTicket.filter { it.signed == 1 } as MutableList } else { - myListClientTicket.filter { it.Signed == 0 } as MutableList + myListClientTicket.filter { it.signed == 0 } as MutableList }) } changeColorIcon(iconSigned.drawable, showSigned) @@ -359,9 +359,9 @@ class TicketsFragment( } - private fun createLisTickets(list: MutableList, getSaved: Boolean = false) { + private fun createLisTickets(list: MutableList, getSaved: Boolean = false) { - var myListClientTicketAux: MutableList = mutableListOf() + var myListClientTicketAux: MutableList = mutableListOf() lifecycleScope.launch { withContext(Dispatchers.IO) { @@ -371,17 +371,17 @@ class TicketsFragment( .toMutableList() } else { myListClientTicketAux = - list.distinctBy { it.Address } as MutableList + list.distinctBy { it.addressFk } as MutableList for (clientTicket in myListClientTicketAux) { - val addressId = clientTicket.Address - val ticketsForClient = list.filter { it.Address == addressId } + val addressId = clientTicket.addressFk + val ticketsForClient = list.filter { it.addressFk == addressId } val mappedTickets = ticketsForClient.map { ticket -> Ticket( - ticket.Id, - ticket.Packages, - ticket.PackingType, - ticket.Note, + ticket.id, + ticket.packages, + ticket.ipt, + ticket.ticketObservation, ticket.cmrFk ) } @@ -399,16 +399,16 @@ class TicketsFragment( myListClientTicket = myListClientTicketAux val myListFiltered = if (showSigned) { - myListClientTicket.filter { it.Signed == 1 } + myListClientTicket.filter { it.signed == 1 } } else { - myListClientTicket.filter { it.Signed == 0 } + myListClientTicket.filter { it.signed == 0 } } adapter = TicketAdapter( - myListFiltered as MutableList, + myListFiltered as MutableList, object : OnItemButtonTicketRowClickListener { override fun onItemButtonTicketRowClickListener( - item: ClientTicket, + item: ClientTicketSalix, action: String ) { when (action) { @@ -417,12 +417,12 @@ class TicketsFragment( val entryPoint = Gson().toJson( mutableMapOf( "route" to route.id.toString(), - "address" to item.Address + "address" to item.addressFk ) ) ma.onPasillerosItemClickListener( PasillerosItemVO(title = getString(R.string.titleUnLoadTruck)), - entryPoint, myListClientTicket.filter { it.Id == item.Id } + entryPoint, myListClientTicket.filter { it.id == item.id } ) } @@ -486,7 +486,7 @@ class TicketsFragment( } } - private fun addNotes(itemClient: ClientTicket) { + private fun addNotes(itemClient: ClientTicketSalix) { val customDialogInput = CustomDialogInputNotes(requireContext()) customDialogInput.setTitle("Notas") @@ -526,11 +526,11 @@ class TicketsFragment( } - private fun showNotes(item: ClientTicket) { + private fun showNotes(item: ClientTicketSalix) { val alertDialog = AlertDialog.Builder(requireContext()).create() alertDialog.setTitle(getString(R.string.info)) - alertDialog.setMessage(item.Note) + alertDialog.setMessage(item.ticketObservation) alertDialog.setButton( AlertDialog.BUTTON_NEUTRAL, getString(R.string.close) ) { dialog, _ -> dialog.dismiss() } @@ -546,28 +546,28 @@ class TicketsFragment( } } - fun showPhones(clientClicked: ClientTicket) { + fun showPhones(clientClicked: ClientTicketSalix) { val phones: MutableList = mutableListOf() //Tarea 6275 - /*if (clientClicked.clientPhone!=null){ + if (clientClicked.clientPhone!=null){ phones.add( GeneralItem( - text = "${getString(R.string.Cliente)}:$clientClicked.clientPhone", - code =clientClicked.clientMobile + text = "${getString(R.string.Cliente)}:${clientClicked.clientPhone}", + code =clientClicked.clientMobile.toString() )) } - if (clientClicked.addressMobile!=null){ + if (clientClicked.clientMobile!=null){ phones.add( GeneralItem( - text = "${getString(R.string.Cliente)}:$clientClicked.addressPhone", - code =clientClicked.addressMobile + text = "${getString(R.string.Cliente)}:${clientClicked.clientMobile}", + code =clientClicked.clientMobile.toString() )) } if (clientClicked.addressPhone!=null){ phones.add( GeneralItem( - text = "${getString(R.string.Cliente)}:$clientClicked.addressPhone", - code =clientClicked.addressPhone + text = "${getString(R.string.Cliente)}:${clientClicked.addressPhone}", + code =clientClicked.addressPhone.toString() )) } if (!clientClicked.salePersonPhone.isNullOrEmpty()) @@ -577,9 +577,9 @@ class TicketsFragment( code = clientClicked.salePersonPhone.toString() ) - )*/ + ) - if (clientClicked.Phones != null && clientClicked.Phones!!.isNotEmpty()) { + /* if (clientClicked.Phones != null && clientClicked.Phones!!.isNotEmpty()) { for (t in clientClicked.Phones!!) { phones.add( GeneralItem( @@ -597,7 +597,7 @@ class TicketsFragment( code = clientClicked.SalePersonPhone.toString() ) - ) + )*/ customDialogList.setValueVisibility(View.GONE) customDialogList.setTitle(getString(R.string.phones)) .setKoButton( @@ -645,22 +645,22 @@ class TicketsFragment( } - fun goMaps(item: ClientTicket) { + fun goMaps(item: ClientTicketSalix) { if (isGoogleMapsInstalled()) { val uri: String - if (item.Latitude != null) { - uri = "geo:${item.Latitude},${item.Longitude}?q=" + item.ClientName + - " " + item.AddressName + - " " + item.City + - " " + item.PostalCode + if (item.latitude != null) { + uri = "geo:${item.latitude},${item.longitude}?q=" + item.nickname + + " " + item.street + + " " + item.city + + " " + item.postalCode } else { - uri = "geo:0,0?q=" + item.ClientName + - " " + item.AddressName + - " " + item.City + - " " + item.PostalCode + uri = "geo:0,0?q=" + item.nickname + + " " + item.street + + " " + item.city + + " " + item.postalCode } val locationIntent = Intent(Intent.ACTION_VIEW, Uri.parse(uri)) startActivity(locationIntent) diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/delivery/model/ClientTicket.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/delivery/model/ClientTicket.kt index e96c098e..cda53256 100644 --- a/app/src/main/java/es/verdnatura/presentation/view/feature/delivery/model/ClientTicket.kt +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/delivery/model/ClientTicket.kt @@ -7,7 +7,7 @@ import es.verdnatura.db.MapTypeConverter import java.io.Serializable class ClientTicketList( - var list: MutableList = mutableListOf() + var list: MutableList = mutableListOf() ) @Entity(tableName = "clientTickets") @@ -38,6 +38,7 @@ data class ClientTicket( ) : Serializable //Tarea 6275 +@Entity(tableName = "clientTickets") data class ClientTicketSalix( @PrimaryKey var id: Long, var clientFk: Int, 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 26022a07..a427c926 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 @@ -11,8 +11,8 @@ import es.verdnatura.domain.formatWithQuotes import es.verdnatura.presentation.base.BaseViewModel import es.verdnatura.presentation.common.Event import es.verdnatura.presentation.common.ResponseItemVO -import es.verdnatura.presentation.view.feature.delivery.model.ClientTicket import es.verdnatura.presentation.view.feature.delivery.model.ClientTicketList +import es.verdnatura.presentation.view.feature.delivery.model.ClientTicketSalix import es.verdnatura.presentation.view.feature.delivery.model.DeliveryInfo import es.verdnatura.presentation.view.feature.delivery.model.ExpeditionInfoList import es.verdnatura.presentation.view.feature.delivery.model.ExpeditionInfoLoadUnload @@ -217,8 +217,7 @@ class DeliveryViewModel(val context: Context) : BaseViewModel(context) { } - fun expeditionState_add(expeditions: Any?, state: String) { - + /* fun expeditionState_add(expeditions: Any?, state: String) { silex.expeditionState_add(expeditions, state) .enqueue(object : SilexCallback(context) { override fun onSuccess(response: Response) { @@ -235,7 +234,7 @@ class DeliveryViewModel(val context: Context) : BaseViewModel(context) { } }) - } + }*/ fun expeditionStateAddSalix(expeditions: Any) { @@ -282,8 +281,8 @@ class DeliveryViewModel(val context: Context) : BaseViewModel(context) { route: Int ) { //Tarea 6275 - //salix.routeGetExpeditionSummary(route) - silex.route_getExpeditionSummary(route) + salix.routeGetExpeditionSummary(route) + // silex.route_getExpeditionSummary(route) .enqueue(object : SalixCallback>(context) { override fun onSuccess(response: Response>) { @@ -308,9 +307,9 @@ class DeliveryViewModel(val context: Context) : BaseViewModel(context) { workerFk: Int ) { //Redmine 6028 falta que le pongan el email y PR - //salix.getRoutes() - silex.getRoutes(workerFk) - .enqueue(object : SilexCallback>(context) { + salix.getRoutes() + // silex.getRoutes(workerFk) + .enqueue(object : SalixCallback>(context) { override fun onSuccess(response: Response>) { @@ -335,10 +334,10 @@ class DeliveryViewModel(val context: Context) : BaseViewModel(context) { routeId: Long ) { //Tarea 6275 - // salix.getTickets("""{"id":$routeId}""") - silex.getTickets(routeId) - .enqueue(object : SalixCallback>(context) { - override fun onSuccess(response: Response>) { + salix.getTickets("""{"id":$routeId}""") + // silex.getTickets(routeId) + .enqueue(object : SalixCallback>(context) { + override fun onSuccess(response: Response>) { _clientTicketList.value = response.body()?.let { ClientTicketList(it) } } @@ -369,7 +368,7 @@ class DeliveryViewModel(val context: Context) : BaseViewModel(context) { }) } - fun addNote( + /* fun addNote( ticketFk: Int ) { silex.addNotes(ticketFk) @@ -386,7 +385,7 @@ class DeliveryViewModel(val context: Context) : BaseViewModel(context) { } }) - } + }*/ fun routeUpdate( route: RouteInfo diff --git a/app/src/main/res/layout/item_ticket_row.xml b/app/src/main/res/layout/item_ticket_row.xml index af311b88..5f3c2f78 100644 --- a/app/src/main/res/layout/item_ticket_row.xml +++ b/app/src/main/res/layout/item_ticket_row.xml @@ -7,7 +7,7 @@ + type="es.verdnatura.presentation.view.feature.delivery.model.ClientTicketSalix" /> @@ -113,7 +113,7 @@ android:id="@+id/textView24" android:layout_width="match_parent" android:layout_height="wrap_content" - android:text="@{item.addressName}" + android:text="@{item.street}" android:textAllCaps="true" android:textColor="@color/colorPrimary" tools:text="C/ Les flors,1"/>