diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index 890125aa..cbd2dee9 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -4,75 +4,71 @@
+
-
-
-
+
+
-
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/java/es/verdnatura/dataStore/DataStoreLocal.kt b/app/src/main/java/es/verdnatura/dataStore/DataStoreLocal.kt
index 2d030d39..45ef7c9c 100644
--- a/app/src/main/java/es/verdnatura/dataStore/DataStoreLocal.kt
+++ b/app/src/main/java/es/verdnatura/dataStore/DataStoreLocal.kt
@@ -20,6 +20,7 @@ import es.verdnatura.domain.ConstAndValues.BASE_URL_SALIX
import es.verdnatura.domain.ConstAndValues.ENTRYID
import es.verdnatura.domain.ConstAndValues.ENTRYOBSERVATIONORIGINAL
import es.verdnatura.domain.ConstAndValues.ENTRYOBSERVATIONS
+import es.verdnatura.domain.ConstAndValues.ITEMPACKING
import es.verdnatura.domain.ConstAndValues.NUMBEROFWAGONS
import es.verdnatura.domain.ConstAndValues.PRINTERFK
import es.verdnatura.domain.ConstAndValues.PRINTERFKDEFAULT
@@ -28,6 +29,7 @@ import es.verdnatura.domain.ConstAndValues.RESERVATIONMODE
import es.verdnatura.domain.ConstAndValues.SECTORDESCRIP
import es.verdnatura.domain.ConstAndValues.SECTORFK
import es.verdnatura.domain.ConstAndValues.SECTORFKDEFAULT
+import es.verdnatura.domain.ConstAndValues.SECTORISONRESERVATIONMODE
import es.verdnatura.domain.ConstAndValues.SUPPLIERID
import es.verdnatura.domain.ConstAndValues.SUPPLIERNAME
import es.verdnatura.domain.ConstAndValues.TRAINNAME
@@ -36,6 +38,7 @@ import es.verdnatura.domain.ConstAndValues.WAREHOUSEFKDEFAULT
import es.verdnatura.domain.ConstAndValues.WORKFORMSELECTED
import es.verdnatura.presentation.view.feature.login.model.OperatorSalix
import es.verdnatura.presentation.view.feature.login.model.WorkForms
+import es.verdnatura.presentation.view.feature.login.model.WorkerData
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.first
import kotlinx.coroutines.flow.map
@@ -98,10 +101,90 @@ class DataStoreLocal(var mobileApplication: MobileApplication) {
editDataStoreKey(
NUMBEROFWAGONS, operator.numberOfWagons
)
+
editDataStoreKey(
- RESERVATIONMODE, operator.isOnReservationMode
+ ITEMPACKING,
+ if (operator.itemPackingTypeFk != null) operator.itemPackingTypeFk.toString() else ""
)
+
+ editDataStoreKey(
+ RESERVATIONMODE, operator.isOnReservationMode
+ )
+
+ }
+
+ //Tarea 6868
+ suspend fun saveWorkerData(operator: WorkerData) {
+
+ editDataStoreKey(
+ SECTORFK, if (operator.sector != null) {
+ operator.sector.id
+ } else {
+ SECTORFKDEFAULT
+ }
+ )
+
+ if (operator.sector?.isOnReservationMode != null) {
+ editDataStoreKey(
+ SECTORISONRESERVATIONMODE,
+ operator.sector.isOnReservationMode
+ )
+ } else {
+ mobileApplication.dataStore.edit { preferences ->
+ preferences.remove(stringPreferencesKey(SECTORISONRESERVATIONMODE))
+ }
+ }
+ editDataStoreKey(
+ WAREHOUSEFK, if (operator.sector != null) {
+ operator.sector.warehouseFk
+ } else {
+ WAREHOUSEFKDEFAULT
+ }
+ )
+ editDataStoreKey(
+ SECTORDESCRIP, if (operator.sector != null) {
+ operator.sector.description
+ } else {
+ mobileApplication.getString(R.string.Sinsector)
+ }
+ )
+
+ editDataStoreKey(
+ PRINTERFK, if (operator.printer != null) {
+ operator.printer.id
+ } else {
+ PRINTERFKDEFAULT
+ }
+ )
+ editDataStoreKey(
+ PRINTERNAME, if (operator.printer != null) {
+ operator.printer.name
+ } else {
+ mobileApplication.getString(R.string.printerWithout)
+ }
+ )
+
+ editDataStoreKey(
+ TRAINNAME, if (operator.train != null) {
+ operator.train.name
+ } else {
+ ""
+ }
+ )
+ editDataStoreKey(
+ NUMBEROFWAGONS, operator.numberOfWagons
+ )
+ editDataStoreKey(
+ RESERVATIONMODE, operator.isOnReservationMode
+ )
+
+ }
+
+ suspend fun isPreferenceExists(key: String): Boolean {
+ val preferencesKey = booleanPreferencesKey(key)
+ val preferences = mobileApplication.dataStore.data.first()
+ return preferences.contains(preferencesKey)
}
inline fun readDataStoreKey(key: String): T {
diff --git a/app/src/main/java/es/verdnatura/di/viewModelModule.kt b/app/src/main/java/es/verdnatura/di/viewModelModule.kt
index cf2a7d8a..c56efb00 100644
--- a/app/src/main/java/es/verdnatura/di/viewModelModule.kt
+++ b/app/src/main/java/es/verdnatura/di/viewModelModule.kt
@@ -7,7 +7,9 @@ import es.verdnatura.presentation.view.feature.buffer.fragment.BufferFragmentVie
import es.verdnatura.presentation.view.feature.buscaritem.fragment.BuscarItemViewModel
import es.verdnatura.presentation.view.feature.category.ChangeCategoryViewModel
import es.verdnatura.presentation.view.feature.claim.fragment.ubication.ClaimViewModel
+import es.verdnatura.presentation.view.feature.collection.fragment.CollectionCheckerViewModel
import es.verdnatura.presentation.view.feature.collection.fragment.CollectionViewModel
+import es.verdnatura.presentation.view.feature.collection.fragment.CollectionViewModelCheckerPreviosNew
import es.verdnatura.presentation.view.feature.controlvehiculo.fragment.ControlVehiculoViewModel
import es.verdnatura.presentation.view.feature.delivery.viewmodels.DeliveryViewModel
import es.verdnatura.presentation.view.feature.diadeventa.fragment.DayOfSaleViewModel
@@ -137,6 +139,12 @@ val viewModelModule = module {
viewModel {
CollectionViewModel(androidContext())
}
+ viewModel {
+ CollectionViewModelCheckerPreviosNew(androidContext())
+ }
+ viewModel {
+ CollectionCheckerViewModel(androidContext())
+ }
viewModel {
ParkingViewModel(androidContext())
diff --git a/app/src/main/java/es/verdnatura/domain/ConstAndValues.kt b/app/src/main/java/es/verdnatura/domain/ConstAndValues.kt
index ee166162..7f38a4be 100644
--- a/app/src/main/java/es/verdnatura/domain/ConstAndValues.kt
+++ b/app/src/main/java/es/verdnatura/domain/ConstAndValues.kt
@@ -12,13 +12,13 @@ object ConstAndValues {
const val SERIALNUMBER = "SERIALNUMBER"
const val ON_CHECKING = "ON_CHECKING"
const val PRECHECKER = "PRECHECKER"
- const val PRECHECKERNEW = "PRECHECKERNEW"
const val MAINACTIVITY = "MAIN"
const val VERTICKET = "SHOWTICKET"
const val SECTORFKDEFAULT = -1
const val PRINTERFKDEFAULT = -1
const val WAREHOUSEFKDEFAULT = 60
const val SECTORFK = "sectorFk"
+ const val SECTORISONRESERVATIONMODE = "sectorIsOnReservationMode"
const val TAG = "VERDNATURA::"
const val USERFK = "userFk"
const val USER = "user"
@@ -27,6 +27,7 @@ object ConstAndValues {
const val TTL = "ttl"
const val TOKENCREATED = "tokenCreated"
const val SECTORDESCRIP = "sectordescrip"
+ const val HOLDPOSITION = "holdPosition"
const val NUMBEROFWAGONS = "operatorNumberOfWagons"
const val PRINTERNAME = "printername"
const val PRINTERFK = "printerFk"
@@ -67,11 +68,6 @@ object ConstAndValues {
const val LIMITRECORDSSHELVINGLOG = 50
const val RESERVATIONMODE = "operatorReservationMode"
const val MODELWORKERTYPEACTIVITY = "APP"
- val ACTIONNAMES = listOf(
- "STOP",
- "ON_CHECKING",
- "Delivery"
- )
}
diff --git a/app/src/main/java/es/verdnatura/domain/SalixService.kt b/app/src/main/java/es/verdnatura/domain/SalixService.kt
index fd3d14ff..b8652197 100644
--- a/app/src/main/java/es/verdnatura/domain/SalixService.kt
+++ b/app/src/main/java/es/verdnatura/domain/SalixService.kt
@@ -3,6 +3,7 @@ package es.verdnatura.domain
import com.google.gson.JsonObject
import es.verdnatura.presentation.common.ExpeditionPrintOut
import es.verdnatura.presentation.common.ItemBarCodeSalix
+import es.verdnatura.presentation.common.ItemShelving
import es.verdnatura.presentation.common.PackingSiteSalix
import es.verdnatura.presentation.common.SaleTrackingSalix
import es.verdnatura.presentation.common.TicketState
@@ -36,8 +37,6 @@ import es.verdnatura.presentation.view.feature.inventario.model.ItemInventaryVO
import es.verdnatura.presentation.view.feature.inventario.model.ItemInventoryParking
import es.verdnatura.presentation.view.feature.login.model.AccessConfigSalix
import es.verdnatura.presentation.view.feature.login.model.DataUserSalix
-import es.verdnatura.presentation.view.feature.login.model.LoginApp
-import es.verdnatura.presentation.view.feature.login.model.LoginAppData
import es.verdnatura.presentation.view.feature.login.model.LoginDevice
import es.verdnatura.presentation.view.feature.login.model.LoginSalixVO
import es.verdnatura.presentation.view.feature.login.model.NameWorker
@@ -45,6 +44,7 @@ import es.verdnatura.presentation.view.feature.login.model.OperatorAdd
import es.verdnatura.presentation.view.feature.login.model.OperatorSalix
import es.verdnatura.presentation.view.feature.login.model.RenewToken
import es.verdnatura.presentation.view.feature.login.model.VersionApp
+import es.verdnatura.presentation.view.feature.login.model.WorkerData
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.NotificationQueue
@@ -105,8 +105,8 @@ interface SalixService {
@POST("Devices/handleUser")
fun handleUser(
- @Body params: LoginApp
- ): Call
+ @Body params: MutableMap
+ ): Call
@GET("VnUsers/getCurrentUserData")
fun getCurrentUserData(
@@ -218,6 +218,12 @@ interface SalixService {
@Query("schema") schema: String = "vn", @Query("params") params: Any? = null
): Call
+ @POST("Applications/itemShelvingSale_deleteAdded/execute-proc")
+ fun itemShelvingSaleDeleteAdded(
+ @Query("schema") schema: String = "vn",
+ @Query("params") params: Any? = null
+ ): Call
+
@POST("Applications/collection_get/execute-proc")
fun collectionGet(
@Query("schema") schema: String = "vn", @Query("params") params: Any? = null
@@ -504,6 +510,11 @@ interface SalixService {
@Query("params") params: Any? = null, @Query("schema") schema: String = "vn"
): Call
+ @POST("Applications/saleTracking_sectorCollectionAddPrevOK/execute-proc")
+ fun saleTrackingSectorCollectionAddPrevOK(
+ @Query("params") params: Any? = null, @Query("schema") schema: String = "vn"
+ ): Call
+
@POST("Applications/machine_getWorkerPlate/execute-proc")
fun machineGetWorkerPlate(
@Query("params") params: Any? = null, @Query("schema") schema: String = "vn"
@@ -854,8 +865,11 @@ interface SalixService {
@GET("Suppliers")
fun getSuppliers(
- @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
+ ): Call>
+ @GET("Suppliers/getWithPackaging")
+ fun getWithPackaging(
): Call>
@GET("Entries")
@@ -966,6 +980,11 @@ interface SalixService {
@Path("id") id: Number, @Body params: Any
): Call
+ @GET("ItemShelvings/{id}")
+ fun itemShelvingGet(
+ @Path("id") id: Number
+ ): Call
+
@POST("ItemShelvingSales/itemShelvingSale_addByCollection")
fun itemShelvingSaleAddByCollection(
@Body params: Any,
@@ -997,6 +1016,21 @@ interface SalixService {
@Body params: Any
): Call
+ @POST("Expeditions/deleteExpeditions")
+ fun deleteExpedition(
+ @Body params: Any
+ ): Call
+
+ @GET("ExpeditionStates/findOne")
+ fun findExpedition(
+ @Query("filter") filter: String
+ ): Call
+
+ @GET("ExpeditionStateTypes/findOne")
+ fun getExpeditionStateTypeId(
+ @Query("filter") filter: String
+ ): Call
+
@POST("WorkerMistakes")
fun workerMistakesAdd(
@Body workerMistake: WorkerMistakeSalix
diff --git a/app/src/main/java/es/verdnatura/presentation/base/BaseFragment.kt b/app/src/main/java/es/verdnatura/presentation/base/BaseFragment.kt
index 819ec77a..979ffe90 100644
--- a/app/src/main/java/es/verdnatura/presentation/base/BaseFragment.kt
+++ b/app/src/main/java/es/verdnatura/presentation/base/BaseFragment.kt
@@ -1,7 +1,10 @@
package es.verdnatura.presentation.base
import android.content.Context
+import android.content.pm.PackageInfo
+import android.content.pm.PackageManager
import android.os.Bundle
+import android.provider.Settings
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
@@ -143,6 +146,24 @@ abstract class BaseFragment(
tool.backButton.visibility = View.INVISIBLE
}
+ fun getInfoVersionNameApp(): String {
+ val manager: PackageManager = requireContext().packageManager
+ val info: PackageInfo = manager.getPackageInfo(requireContext().packageName, 0)
+ mobileApplication.versionName = info.versionName
+ return info.versionName
+ }
+
+ fun getDevicePDA(): Int? {
+ return try {
+ Settings.Global.getString(
+ mobileApplication.contentResolver, Settings.Global.DEVICE_NAME
+ ).toInt()
+ } catch (ex: Exception) {
+ null
+ }
+
+ }
+
}
fun database(myContext: Context): DeliveryDatabase {
diff --git a/app/src/main/java/es/verdnatura/presentation/common/SalixBackItems.kt b/app/src/main/java/es/verdnatura/presentation/common/SalixBackItems.kt
index 945ad08e..6c9d4049 100644
--- a/app/src/main/java/es/verdnatura/presentation/common/SalixBackItems.kt
+++ b/app/src/main/java/es/verdnatura/presentation/common/SalixBackItems.kt
@@ -38,11 +38,19 @@ data class ItemShelvingSaleSalix(
var isItemShelvingSaleEmpty: Boolean?
)
+data class ItemShelving(
+ var id: Int,
+ var itemFk: Int,
+ var shelvingFk: String,
+ var position: Int,
+ var quantity: Int
+)
+
data class ItemShelvingSalix(
var visible: Int,
var packing: Int?,
var grouping: Int?,
- var available : Int?
+ var available: Int?
)
@@ -65,12 +73,13 @@ data class CollectionItemSalix(
var warehouseFk: Int
)
+
//Tarea 6889
data class ItemAddSale(
var barcode: String,
var quantity: Int,
-)
+ )
data class TicketState(
val ticketFk: Int = 0,
@@ -82,8 +91,9 @@ data class TicketState(
val username: String = ""
)
}
+
data class ExpeditionPrintOut(
- val expeditionFk:Long,
- val itemFk:Int,
+ val expeditionFk: Long,
+ val itemFk: Int,
val isChecked: Boolean
)
\ No newline at end of file
diff --git a/app/src/main/java/es/verdnatura/presentation/common/UICallbacks.kt b/app/src/main/java/es/verdnatura/presentation/common/UICallbacks.kt
index 0daa0cb4..c5d5bec6 100644
--- a/app/src/main/java/es/verdnatura/presentation/common/UICallbacks.kt
+++ b/app/src/main/java/es/verdnatura/presentation/common/UICallbacks.kt
@@ -267,6 +267,10 @@ interface OnTicketClickSaleListener {
fun onTicketClickListener(sale: Sale)
}
+interface OnSaleReserveClickListener {
+ fun onSaleReserveListener(sale: Sale)
+}
+
interface OnBuyerSelectedListener {
fun onBuyerSelected(userFk: String)
}
diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/ajustes/fragment/AjustesFragment.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/ajustes/fragment/AjustesFragment.kt
index 2efae36a..c4e7d529 100644
--- a/app/src/main/java/es/verdnatura/presentation/view/feature/ajustes/fragment/AjustesFragment.kt
+++ b/app/src/main/java/es/verdnatura/presentation/view/feature/ajustes/fragment/AjustesFragment.kt
@@ -1,8 +1,11 @@
package es.verdnatura.presentation.view.feature.ajustes.fragment
import android.app.AlertDialog
+import android.content.pm.PackageInfo
+import android.content.pm.PackageManager
import android.graphics.Color
import android.graphics.drawable.Drawable
+import android.os.Build
import android.os.Bundle
import android.view.View
import android.view.ViewGroup
@@ -13,6 +16,7 @@ import androidx.recyclerview.widget.LinearLayoutManager
import es.verdnatura.R
import es.verdnatura.databinding.FragmentAjustesBinding
import es.verdnatura.domain.ConstAndValues.ANDROID_ID
+import es.verdnatura.domain.ConstAndValues.HOLDPOSITION
import es.verdnatura.domain.ConstAndValues.ITEMPACKING
import es.verdnatura.domain.ConstAndValues.MENUBYDEFAULTSELECTED
import es.verdnatura.domain.ConstAndValues.NUMBEROFWAGONS
@@ -99,14 +103,14 @@ class AjustesFragment :
getString(R.string.version) + ":\t" +
requireActivity().packageManager.getPackageInfo(
requireActivity().packageName, 0
- ).versionName!! + "\n" +
+ ).versionName!! + "(${getVersionCode()})" + "\n" +
getString(R.string.user) + ":\t" +
mobileApplication.userName + "\n" +
getString(R.string.androidid) + ":\t" +
mobileApplication.dataStoreApp.readDataStoreKey(
ANDROID_ID
) + "\n" +
- if (!mobileApplication.serialNumber.isNullOrBlank() ) {
+ if (!mobileApplication.serialNumber.isNullOrBlank()) {
getString(R.string.serialNumber) + "\t" +
mobileApplication.serialNumber
} else ""
@@ -122,6 +126,27 @@ class AjustesFragment :
LinearLayoutManager(requireContext(), LinearLayoutManager.HORIZONTAL, false)
}
+ private fun getVersionCode(): Long {
+ val context = requireContext()
+ val packageManager: PackageManager = context.packageManager
+ val packageInfo: PackageInfo = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
+ packageManager.getPackageInfo(
+ context.packageName,
+ PackageManager.PackageInfoFlags.of(0)
+ )
+ } else {
+ @Suppress("DEPRECATION")
+ packageManager.getPackageInfo(context.packageName, 0)
+ }
+
+ return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
+ packageInfo.longVersionCode
+ } else {
+ @Suppress("DEPRECATION")
+ packageInfo.versionCode.toLong()
+ }
+ }
+
override fun observeViewModel() {
with(viewModel) {
@@ -241,6 +266,7 @@ class AjustesFragment :
.setDescription(getString(R.string.Noprinters))
.setOkButton(getString(R.string.Close)) {
customDialog.dismiss()
+ handleUserCall()
}.show()
}
@@ -271,19 +297,40 @@ class AjustesFragment :
private fun getUserData() {
loginViewModel = LoginViewModel(requireActivity().applicationContext)
- try {
- loginViewModel.operatorGetData(mobileApplication.userId!!)
- } catch (_: Exception) {
- ma.messageWithSound(
- message = getString(R.string.errorGetData), isError = true, isPlayed = true
- )
- }
- loginViewModel.workerOperator.observe(this@AjustesFragment) { iti ->
- runBlocking { mobileApplication.dataStoreApp.saveDataOperator(iti) }
+ /* try {
+ loginViewModel.operatorGetData(mobileApplication.userId!!)
+ } catch (_: Exception) {
+ ma.messageWithSound(
+ message = getString(R.string.errorGetData), isError = true, isPlayed = true
+ )
+ }
+ loginViewModel.workerOperator.observe(this@AjustesFragment) { iti ->
+ runBlocking { mobileApplication.dataStoreApp.saveDataOperator(iti) }
+ }*/
+ handleUserCall()
+ loginViewModel.handleUserResponse.observe(this@AjustesFragment) { iti ->
+ runBlocking { mobileApplication.dataStoreApp.saveWorkerData(iti) }
}
setSettings()
}
+ private fun handleUserCall() {
+ val jsonData = mutableMapOf(
+ "androidId" to mobileApplication.androidId,
+ "nameApp" to getString(R.string.nameApp),
+ "versionApp" to getInfoVersionNameApp()
+ )
+ loginViewModel.handleUser(if (getDevicePDA() != null) {
+ jsonData.apply {
+ this["deviceId"] = getDevicePDA().toString() // Añadir nuevo campo
+ }
+ } else {
+ jsonData
+ }
+
+ )
+ }
+
private fun showMenuByDefault() {
pasilleroViewModel.inititializeDefaultDataInit()
@@ -311,9 +358,10 @@ class AjustesFragment :
mobileApplication.dataStoreApp.readDataStoreKey(ITEMPACKING),
menuDefault = mobileApplication.dataStoreApp.readDataStoreKey(
MENUBYDEFAULTSELECTED
- )
+ ),
+ holdPosition = mobileApplication.dataStoreApp.readDataStoreKey(HOLDPOSITION),
- )
+ )
}
binding.splashProgress.visibility = View.GONE
}
@@ -483,6 +531,7 @@ class AjustesFragment :
labelerFk = id
)
settingsAdapter!!.notifyItemChanged(2)
+ handleUserCall()
}
diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/ajustes/fragment/AjustesViewModel.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/ajustes/fragment/AjustesViewModel.kt
index 7d58be42..c20a4863 100644
--- a/app/src/main/java/es/verdnatura/presentation/view/feature/ajustes/fragment/AjustesViewModel.kt
+++ b/app/src/main/java/es/verdnatura/presentation/view/feature/ajustes/fragment/AjustesViewModel.kt
@@ -65,7 +65,8 @@ class AjustesViewModel(val context: Context) : BaseViewModel(context) {
printerSelected: String,
train: String?,
itemPackingType: String?,
- menuDefault: String
+ menuDefault: String,
+ holdPosition: Boolean = false
) {
_settingsItem.clear()
_settingsItem.add(
@@ -99,6 +100,15 @@ class AjustesViewModel(val context: Context) : BaseViewModel(context) {
action = false
)
)
+ /*Tarea 5443
+ _settingsItem.add(
+ AjustesItemVO(
+ "Bajar línea al revisar",
+ holdPosition = holdPosition,
+ action = true
+ )
+ )*/
+
_settingsItem.add(
AjustesItemVO(
context.getString(R.string.vehicleControl), action = true
diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/ajustes/model/AjustesItemVO.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/ajustes/model/AjustesItemVO.kt
index 31bfaac0..d0ced468 100644
--- a/app/src/main/java/es/verdnatura/presentation/view/feature/ajustes/model/AjustesItemVO.kt
+++ b/app/src/main/java/es/verdnatura/presentation/view/feature/ajustes/model/AjustesItemVO.kt
@@ -8,7 +8,8 @@ class AjustesItemVO(
var sectorFk: Int? = null,
var printerFk: Int? = null,
var printerSelected: String? = null,
- var action: Boolean
+ var action: Boolean,
+ var holdPosition: Boolean = false
)
class SectorItemVO(
@@ -28,7 +29,7 @@ class PrintersList(
class Printers(
var id: Int,
var name: String,
- var sector:Sector?
+ var sector: Sector?
)
diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/articulo/fragment/ItemCardViewModel.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/articulo/fragment/ItemCardViewModel.kt
index 6f9d6e3a..64d4a1b8 100644
--- a/app/src/main/java/es/verdnatura/presentation/view/feature/articulo/fragment/ItemCardViewModel.kt
+++ b/app/src/main/java/es/verdnatura/presentation/view/feature/articulo/fragment/ItemCardViewModel.kt
@@ -68,9 +68,16 @@ class ItemCardViewModel(var context: Context) : BaseViewModel(context) {
warehouseFk: Int,
shipped: String,
isShowedByType: Boolean,
+ daysInforward: Int = 0,
) {
salix.getItemSimilar(
- params = arrayListOf(itemFk, warehouseFk, shipped, isShowedByType).formatWithQuotes()
+ params = arrayListOf(
+ itemFk,
+ warehouseFk,
+ shipped,
+ isShowedByType,
+ daysInforward
+ ).formatWithQuotes()
).enqueue(object : SalixCallback>(context) {
override fun onSuccess(response: Response>) {
_itemProposalList.value = response.body()?.let {
@@ -196,7 +203,7 @@ class ItemCardViewModel(var context: Context) : BaseViewModel(context) {
}
fun getAddress() {
- salix.getAddress("""{"where":{"type":"internal"}, "include": [ { "relation": "address", "scope": { "fields": { "nickname": true } } } ] }""")
+ salix.getAddress("""{"where":{"type": { "neq": "external"}}, "include": [ { "relation": "address", "scope": { "fields": { "nickname": true } } } ] }""")
.enqueue(object : SalixCallback>(context) {
override fun onSuccess(response: Response>) {
_addressLosesList.value = response.body()?.let { AddressLosesList(it) }
diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/boxPicking/BoxPickingFragment.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/boxPicking/BoxPickingFragment.kt
index 8b9e2faf..3868eaef 100644
--- a/app/src/main/java/es/verdnatura/presentation/view/feature/boxPicking/BoxPickingFragment.kt
+++ b/app/src/main/java/es/verdnatura/presentation/view/feature/boxPicking/BoxPickingFragment.kt
@@ -5,15 +5,20 @@ import android.view.inputmethod.EditorInfo
import es.verdnatura.R
import es.verdnatura.databinding.FragmentGeneralBlackBinding
import es.verdnatura.presentation.base.BaseFragment
-import es.verdnatura.presentation.common.ExpeditionPrintOut
import es.verdnatura.presentation.common.OnCollectionSelectedListener
+import es.verdnatura.presentation.common.hideKeyboard
+import es.verdnatura.presentation.common.itemScanValue
import es.verdnatura.presentation.view.component.CustomDialogInput
+import es.verdnatura.presentation.view.feature.delivery.model.ExpeditionSalix
+import es.verdnatura.presentation.view.feature.delivery.model.Expeditions
+import es.verdnatura.presentation.view.feature.delivery.viewmodels.DeliveryViewModel
class BoxPickingFragment(var title: String) :
- BaseFragment(BoxPickingViewModel::class) {
+ BaseFragment(DeliveryViewModel::class) {
private var onCollectionSelectedListener: OnCollectionSelectedListener? = null
private var isBoxScanned: Boolean = false
private lateinit var customDialogInput: CustomDialogInput
+ private var codeStateId: Number = 0
override fun getLayoutId(): Int = R.layout.fragment_general_black
companion object {
@@ -25,6 +30,7 @@ class BoxPickingFragment(var title: String) :
binding.mainToolbar.toolbarTitle.text = title
setEvents()
customDialogInput = CustomDialogInput(requireContext())
+ viewModel.getExpeditionStateId("CHECKED")
super.init()
}
@@ -36,15 +42,28 @@ class BoxPickingFragment(var title: String) :
binding.scanInput.hint = getString(R.string.scanLabelExpedition)
binding.scanInput.requestFocus()
binding.scanInput.setOnEditorActionListener { _, actionId, _ ->
- if (actionId == EditorInfo.IME_ACTION_SEARCH || actionId == EditorInfo.IME_ACTION_DONE) {
+ if (actionId == EditorInfo.IME_ACTION_SEARCH || actionId == EditorInfo.IME_ACTION_DONE || actionId == 0 || actionId == 5) {
if (!binding.scanInput.text.isNullOrEmpty()) {
try {
- showScanBarcode(binding.scanInput.text.toString().toLong())
- }catch (ex:Exception){
- ma.messageWithSound(message =getString(R.string.itemNotValid), isError = true, isPlayed = true, isToasted = false)
- }
+ viewModel.findExpedition(
+ expedition = itemScanValue(
+ binding.scanInput.text.toString(),
+ arrayOf("expedition"),
+ "id"
+ ).toString().toLong(),
+ expeditionStateId = codeStateId
+ )
+
+ } catch (ex: Exception) {
+ ma.messageWithSound(
+ message = getString(R.string.itemNotValid),
+ isError = true,
+ isPlayed = true,
+ isToasted = false
+ )
+ }
}
binding.scanInput.setText("")
@@ -65,6 +84,7 @@ class BoxPickingFragment(var title: String) :
expeditionFk = expeditionFk,
customDialogInput.getValue()
)
+
}
customDialogInput.dismiss()
}
@@ -76,15 +96,15 @@ class BoxPickingFragment(var title: String) :
}.setValue("").show()
-
-
customDialogInput.getEditText().setOnEditorActionListener { _, actionId, _ ->
- if (actionId == EditorInfo.IME_ACTION_SEARCH || actionId == EditorInfo.IME_ACTION_DONE || actionId == 0) {
+ if (actionId == EditorInfo.IME_ACTION_SEARCH || actionId == EditorInfo.IME_ACTION_DONE || actionId == 0 || actionId == 5) {
if (customDialogInput.getValue().isNotEmpty()) {
viewModel.isBoxPickingInPrintOut(
expeditionFk = expeditionFk,
- customDialogInput.getValue()
+ itemScanValue(
+ customDialogInput.getValue(), arrayOf("buy"), "more"
+ ).toString()
)
}
customDialogInput.dismiss()
@@ -97,40 +117,61 @@ class BoxPickingFragment(var title: String) :
} catch (ex: Exception) {
getString(R.string.errorInput)
}
+ customDialogInput.getEditText().requestFocus()
}
override fun observeViewModel() {
with(viewModel) {
- /*isBoxPickingInPrintOut.observe(viewLifecycleOwner) {
-
+ responseExpeditionStateId.observe(viewLifecycleOwner) {
+ codeStateId = it
+ }
+ responseFindExpeditionId.observe(viewLifecycleOwner) { it ->
+ if (it != 0) {
+ showScanBarcode(it.toLong())
+ } else {
ma.messageWithSound(
- message = getString(R.string.errorInput),
- isError = !it,
- isPlayed = true,
- isToasted = null
-
+ getString(
+ R.string.errorBoxPicking
+ ), isError = true, isPlayed = true, isToasted = true
)
- binding.scanInput.requestFocus()
+ }
+ }
+ responseStateAdd.observe(viewLifecycleOwner) {
+ if (it) {
+ ma.messageWithSound(message = "", isPlayed = true, isError = false)
+ customDialogInput.dismiss()
+ binding.scanInput.requestFocus()
+ }
+ }
- }*/
- //Tarea 7751
isBoxPickingInPrintOut.observe(viewLifecycleOwner) {
- if (it.isChecked){
+ if (it.expeditionFk.toInt() == 0) {
ma.messageWithSound(
- message = getString(R.string.errorBoxPicking),
+ message = getString(R.string.errorBoxpicking),
isError = true,
isPlayed = true,
isToasted = false
-
)
- }else{
- viewModel.updateExpeditionPrint(it.expeditionFk, expeditionPrintOut = ExpeditionPrintOut(it.expeditionFk,it.itemFk, true))
+ } else {
+ viewModel.expeditionStateAddSalix(
+ expeditions = Expeditions(
+ arrayListOf(
+ ExpeditionSalix(
+ expeditionFk = it.expeditionFk.toInt(),
+ stateCode = "CHECKED",
+ isScanned = 1
+ )
+ )
+ )
+ )
+ }
- }
binding.scanInput.requestFocus()
+ hideKeyboard()
}
+
responseCode.observe(viewLifecycleOwner) {
ma.messageWithSound(
diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/boxPicking/BoxPickingViewModel.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/boxPicking/BoxPickingViewModel.kt
index 49afcaea..fc0a39ee 100644
--- a/app/src/main/java/es/verdnatura/presentation/view/feature/boxPicking/BoxPickingViewModel.kt
+++ b/app/src/main/java/es/verdnatura/presentation/view/feature/boxPicking/BoxPickingViewModel.kt
@@ -12,8 +12,11 @@ import retrofit2.Response
class BoxPickingViewModel(val context: Context) : BaseViewModel(context) {
private val getItemFromBarcodeUseCase = GetItemFromBarcodeUseCase(salix)
+
/*private val _isBoxPickingInPrintOut by lazy { MutableLiveData() }
val isBoxPickingInPrintOut: LiveData = _isBoxPickingInPrintOut*/
+ private val _responseFindExpeditionId by lazy { MutableLiveData() }
+ val responseFindExpeditionId: LiveData = _responseFindExpeditionId
//Tarea 7751
private val _isBoxPickingInPrintOut by lazy { MutableLiveData() }
@@ -28,16 +31,16 @@ class BoxPickingViewModel(val context: Context) : BaseViewModel(context) {
salix.isBoxPickingInPrintOut(
filter = """{"where":{"expeditionFk":$expeditionFk,"itemFk":$itemFk}}"""
- /* ).enqueue(object : SalixCallback(context) {
+ /* ).enqueue(object : SalixCallback(context) {
- override fun onSuccess(response: Response) {
- _isBoxPickingInPrintOut.value = true
- }
- override fun onError(t: Throwable) {
- _isBoxPickingInPrintOut.value = false
- }
+ override fun onSuccess(response: Response) {
+ _isBoxPickingInPrintOut.value = true
+ }
+ override fun onError(t: Throwable) {
+ _isBoxPickingInPrintOut.value = false
+ }
- })*/
+ })*/
//Tarea 7751
//isChecked
).enqueue(object : SalixCallback(context) {
@@ -45,8 +48,9 @@ class BoxPickingViewModel(val context: Context) : BaseViewModel(context) {
override fun onSuccess(response: Response) {
_isBoxPickingInPrintOut.value = response.body()
}
+
override fun onError(t: Throwable) {
- _isBoxPickingInPrintOut.value = ExpeditionPrintOut(0,0,false)
+ _isBoxPickingInPrintOut.value = ExpeditionPrintOut(0, 0, false)
}
})
@@ -70,8 +74,30 @@ class BoxPickingViewModel(val context: Context) : BaseViewModel(context) {
}
})
}
+
+ fun findExpedition(expedition: Number, expeditionStateId: Number) {
+ salix.findExpedition(
+ filter = """{"where":
+ {
+ "expeditionFk":$expedition,
+ "typeFk":$expeditionStateId
+ }
+ }""".trimMargin()
+ ).enqueue(object : SalixCallback(context) {
+ override fun onSuccess(response: Response) {
+ _responseFindExpeditionId.value = 0
+
+ }
+
+ override fun onError(t: Throwable) {
+ _responseFindExpeditionId.value = expedition
+ }
+
+ })
+ }
+
fun updateExpeditionPrint(expeditionFk: Long, expeditionPrintOut: ExpeditionPrintOut) {
- salix.update(expeditionFk, expeditionPrintOut)
+ salix.update(expeditionFk, expeditionPrintOut)
.enqueue(object : SalixCallback(context) {
})
diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/collection/adapter/SaleAdapterNew.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/collection/adapter/SaleAdapterNew.kt
index ac60ba19..185c1b28 100644
--- a/app/src/main/java/es/verdnatura/presentation/view/feature/collection/adapter/SaleAdapterNew.kt
+++ b/app/src/main/java/es/verdnatura/presentation/view/feature/collection/adapter/SaleAdapterNew.kt
@@ -6,6 +6,9 @@ import android.graphics.Color
import android.graphics.drawable.Drawable
import android.view.LayoutInflater
import android.view.View
+import android.view.View.GONE
+import android.view.View.INVISIBLE
+import android.view.View.VISIBLE
import android.view.ViewGroup
import androidx.core.content.ContextCompat.getColor
import androidx.core.graphics.drawable.DrawableCompat
@@ -14,13 +17,14 @@ import androidx.recyclerview.widget.RecyclerView
import es.verdnatura.R
import es.verdnatura.databinding.SaleRowFragmentBinding
import es.verdnatura.domain.ConstAndValues.PREITEMPICKERTEST
+import es.verdnatura.domain.ConstAndValues.PREPARED
import es.verdnatura.domain.ConstAndValues.SACADOR
import es.verdnatura.domain.toast
import es.verdnatura.presentation.common.OnMistakeClickListener
import es.verdnatura.presentation.common.OnPackingClickSaleListener
import es.verdnatura.presentation.common.OnPasillerosItemClickListener
-import es.verdnatura.presentation.common.OnQuantityClickSaleListener
import es.verdnatura.presentation.common.OnSaleClickSaleListener
+import es.verdnatura.presentation.common.OnSaleReserveClickListener
import es.verdnatura.presentation.common.OnTicketClickSaleListener
import es.verdnatura.presentation.view.feature.pasillero.model.PasillerosItemVO
import es.verdnatura.presentation.view.feature.sacador.model.Sale
@@ -28,12 +32,12 @@ import es.verdnatura.presentation.view.feature.sacador.model.Sale
class SaleAdapterNew(
private val items: List,
private val onPasillerosItemClickListener: OnPasillerosItemClickListener,
- private val onQuantityClick: OnQuantityClickSaleListener,
private val onSaleClickListener: OnSaleClickSaleListener,
private val onMistakeClickListener: OnMistakeClickListener,
private val onPackingClick: OnPackingClickSaleListener,
private var onTicketClick: OnTicketClickSaleListener? = null,
private var saleAdapter: SaleAdapterNew? = null,
+ private var onReserveSaleClick: OnSaleReserveClickListener? = null,
private var type: String? = null,
) : RecyclerView.Adapter() {
@@ -66,7 +70,7 @@ class SaleAdapterNew(
) : RecyclerView.ViewHolder(binding.root) {
fun bind(sale: Sale) {
binding.apply {
- // if (sale.reservedQuantity == null) sale.reservedQuantity = 0
+ // if (sale.reservedQuantity == null) sale.reservedQuantity = 0
val childLayoutManager =
LinearLayoutManager(context!!, RecyclerView.HORIZONTAL, false)
@@ -118,49 +122,52 @@ class SaleAdapterNew(
itemArticleFirstAccumulate.setOnClickListener {
//onQuantityClick.onQuantityClick(sale)
}
- itemFirstToPicker.setOnClickListener {
- onPackingClick.onPackingClick(sale)
+ /* itemFirstToPicker.setOnClickListener {
+ onPackingClick.onPackingClick(sale)
- }
- quantityReserved.setOnClickListener {
- onQuantityClick.onQuantityClick(sale)
- }
+ }/* quantityReserved.setOnClickListener {
+ onQuantityClick.onQuantityClick(sale)
+ }*/*/
linearLayoutItem.setOnClickListener {
- println("El ticket es ${sale.ticketFk}")
if (onTicketClick != null) {
onTicketClick!!.onTicketClickListener(sale)
}
}
+ println("type es $type")
imageErrorMessage.setOnClickListener {
// onMistakeClickListener.onMistakeClickListener(sale)
}
//ERROR
- println("Sacador sale item ${sale.itemFk} sale ${sale.saleFk} cantidad ${sale.saleQuantity} original ${sale.originalQuantity}")
if (sale.originalQuantity != sale.saleQuantity && sale.originalQuantity != null && !sale.isParent) {
- layoutError.visibility = View.VISIBLE
+ layoutError.visibility = VISIBLE
txtError.text =
binding.root.context.getString(R.string.originalQuantity) + sale.originalQuantity
} else {
- layoutError.visibility = View.GONE
+ layoutError.visibility = GONE
}
+ binding.deleteReserve.visibility = if (sale.isAdded == 1) VISIBLE else INVISIBLE
+
if (sale.isAdded == 1) {
- layoutError.visibility = View.VISIBLE
+ layoutError.visibility = VISIBLE
txtError.text = binding.root.context.getString(R.string.newItem)
+ binding.deleteReserve.setOnClickListener {
+ onReserveSaleClick!!.onSaleReserveListener(sale)
+ }
}
paintTicketcolor(sale.rgb, binding.itemTicketColor.background)
- if (sale.isAdded == 1 && sale.reservedQuantity != sale.saleQuantity) {
- layoutError.visibility = View.GONE
- }
+ /*if (sale.isAdded == 1 && sale.reservedQuantity != sale.saleQuantity) {
+ layoutError.visibility = GONE
+ }*/
if (isExpanded) {
@@ -203,7 +210,9 @@ class SaleAdapterNew(
txtdeNew.visibility = View.VISIBLE
itemArticleQuantityPicked.visibility = View.VISIBLE
itemArticleQuantityLine3.visibility = View.VISIBLE*/
- if (type != SACADOR) {
+
+ imageErrorMessage.visibility = View.GONE
+ if (type != SACADOR && type != PREITEMPICKERTEST) {
val colorRes =
if (sale.hasMistake == true) R.color.verdnatura_red_salix else R.color.verdnatura_black
imageErrorMessage.imageTintList =
@@ -221,7 +230,6 @@ class SaleAdapterNew(
adapter = SaleAdapterNew(
sale.sonSales,
onPasillerosItemClickListener,
- onQuantityClick,
onSaleClickListener,
onMistakeClickListener,
onPackingClick
@@ -271,7 +279,8 @@ class SaleAdapterNew(
val textToConcat2: String
- val result2: Int = sale.accumulatedQuantity % (sale.packing ?: sale.saleQuantity + 1)
+ val result2: Int =
+ sale.accumulatedQuantity % (sale.packing ?: sale.saleQuantity + 1)
if (result2 != 0) {
textToConcat2 =
"${(sale.saleQuantity - sale.accumulatedQuantity) / (sale.grouping ?: 1)} x ${sale.grouping ?: "1"}"
@@ -315,12 +324,19 @@ class SaleAdapterNew(
"${sale.reservedQuantity} de ${sale.saleQuantity}"
if (sale.isPicked == 1) {
- contentLayout.setBackgroundColor(
- //lolass
- getColor(
- context!!, R.color.verdnatura_dark_sky_blue
+ if (type == PREPARED) {
+ contentLayout.setBackgroundColor(
+ getColor(
+ context!!, R.color.verdnatura_orange_salix
+ )
)
- )
+ } else {
+ contentLayout.setBackgroundColor(
+ getColor(
+ context!!, R.color.verdnatura_dark_sky_blue
+ )
+ )
+ }
} else {
contentLayout.setBackgroundColor(
getColor(
@@ -330,10 +346,14 @@ class SaleAdapterNew(
}
- binding.itemParkingCode.text = if (type == PREITEMPICKERTEST)
- sale.parkingCodePrevia else sale.parkingCode
+ binding.itemParkingCode.text =
+ // if (type == PREITEMPICKERTEST) sale.parkingCodePrevia else sale.parkingCode
+ sale.parkingCodePrevia
+ println("parkingCodePrevia ${sale.parkingCodePrevia}")
+ println("parkingCode ${sale.parkingCode}")
+
this.sale = sale
}
@@ -344,13 +364,11 @@ class SaleAdapterNew(
if (color.isNullOrBlank()) {
DrawableCompat.setTint(
- backgroundDrawableTicket,
- Color.TRANSPARENT
+ backgroundDrawableTicket, Color.TRANSPARENT
)
} else {
DrawableCompat.setTint(
- backgroundDrawableTicket,
- Color.parseColor(color)
+ backgroundDrawableTicket, Color.parseColor(color)
)
}
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 aa8a9f0a..ab263c09 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
@@ -146,7 +146,7 @@ class CollectionFragment(
mperror = MediaPlayer.create((activity as MainActivity), R.raw.error)
mpok = MediaPlayer.create((activity as MainActivity), R.raw.ok)
- if (type.equals(CONTROLADOR)) {
+ if (type.equals(CONTROLADOR) && collection.collectionFk != 0) {
//sergio: comprueba si viene de la pantalla de controlador
//Tarea #4280
viewModel.ticketIsOutClosureZone(
@@ -162,7 +162,7 @@ class CollectionFragment(
}
- if (collection.tickets.isEmpty()) {
+ if (collection.tickets.isEmpty() && collection.collectionFk != 0) {
viewModel.collectionTicketGet(
collection.collectionFk,
mobileApplication.dataStoreApp.readDataStoreKey(SECTORFK),
@@ -179,7 +179,6 @@ class CollectionFragment(
}
override fun init() {
-
customDialogList = CustomDialogList(requireContext())
customDialogInput = CustomDialogInput(requireContext())
customDialog = CustomDialog(requireContext())
@@ -204,12 +203,15 @@ class CollectionFragment(
private fun setToolBar() {
binding.mainToolbar.toolbarSubtitle.visibility = VISIBLE
- binding.mainToolbar.toolbarIcons.visibility = VISIBLE
+ binding.mainToolbar.toolbarIcons.visibility =
+ if (type == CONTROLADOR && collection.collectionFk == 0) GONE else VISIBLE
binding.mainToolbar.backButton.visibility = VISIBLE
collection.collectionFk.let {
- binding.mainToolbar.toolbarTitle.text = collection.collectionFk.toString()
+ binding.mainToolbar.toolbarTitle.text =
+ if (collection.collectionFk != 0) collection.collectionFk.toString() else {
+ getString(R.string.controlticket)
+ }
}
-
val listIcons: ArrayList = ArrayList()
val iconPrint = ImageView(context)
iconPrint.setImageResource(R.drawable.ic_print_black_24dp)
@@ -406,7 +408,7 @@ class CollectionFragment(
binding.scanInput.setOnEditorActionListener { v, actionId, event ->
if (actionId == EditorInfo.IME_ACTION_SEARCH || actionId == EditorInfo.IME_ACTION_DONE || actionId == 0 || actionId == 5) {//ID=0 ACTION_NEXT ID=5 ACTION_UNESPECEFIED)
if (!binding.scanInput.text.toString().isNullOrEmpty()) {
-
+ binding.mainToolbar.toolbarIcons.visibility = VISIBLE
//sergio:para ver si ha marcado dos veces el mismo ticket
binding.scanInput.setText(textScanned_filterDouble(binding.scanInput.text!!.toString()))
@@ -438,7 +440,6 @@ class CollectionFragment(
}
buttonPushedGetCollection = false
-
}
binding.scanInput.setText("")
hideKeyboards()
@@ -525,18 +526,19 @@ class CollectionFragment(
}
})
- responseParking.observe(viewLifecycleOwner, Observer {
+ loadParking.observe(viewLifecycleOwner) { event ->
+ event.getContentIfNotHandled().notNull { it ->
- if (!goBack) {
+ if (!goBack) {
- ma.messageWithSound(
- if (it.isError) it.errorMessage else getString(R.string.Aparcado),
- it.isError,
- true
- )
+ ma.messageWithSound(
+ if (it.isError) it.errorMessage else getString(R.string.Aparcado),
+ it.isError,
+ true
+ )
+ }
}
-
- })
+ }
responsePrint.observe(viewLifecycleOwner, Observer {
@@ -575,22 +577,24 @@ class CollectionFragment(
}
- responseSaleGroup.observe(viewLifecycleOwner, Observer {
+ loadResponseSaleGroup.observe(viewLifecycleOwner) { event ->
+ event.getContentIfNotHandled().notNull {
- if (it.isError) {
+ if (it.isError) {
- ma.messageWithSound(it.errorMessage, true, true)
- } else {
- ma.messageWithSound(getString(R.string.previousCollected), false, true)
+ ma.messageWithSound(it.errorMessage, true, true)
+ } else {
+ ma.messageWithSound(getString(R.string.previousCollected), false, true)
- viewModel.collectionTicketGet(
- collection.collectionFk,
- mobileApplication.dataStoreApp.readDataStoreKey(SECTORFK),
- print = "0",
- type
- )
+ viewModel.collectionTicketGet(
+ collection.collectionFk,
+ mobileApplication.dataStoreApp.readDataStoreKey(SECTORFK),
+ print = "0",
+ type
+ )
+ }
}
- })
+ }
placementSuppleyList.observe(viewLifecycleOwner, Observer {
if (!goBack) printShelvingResult(it)
@@ -603,33 +607,34 @@ class CollectionFragment(
goBack = false
})
- responseNew.observe(viewLifecycleOwner, Observer {
+ loadAddNew.observe(viewLifecycleOwner) { event ->
+ event.getContentIfNotHandled().notNull { it ->
- // if (!goBack) {
- if (it.isError) {
- customDialog.setTitle(getString(R.string.disponibility))
- .setDescription(getString(R.string.errorCollectionNew) + it.errorMessage)
- .setKoButton(getString(R.string.close)) {
- scanRequest()
- customDialog.dismiss()
- }.show()
- } else {
+ // if (!goBack) {
+ if (it.isError) {
+ customDialog.setTitle(getString(R.string.disponibility))
+ .setDescription(getString(R.string.errorCollectionNew) + it.errorMessage)
+ .setKoButton(getString(R.string.close)) {
+ scanRequest()
+ customDialog.dismiss()
+ }.show()
+ } else {
- if (!goBack) {
+ if (!goBack) {
- viewModel.collectionTicketGet(
- collection.collectionFk,
- mobileApplication.dataStoreApp.readDataStoreKey(SECTORFK),
- print = "0",
- type
- )
+ viewModel.collectionTicketGet(
+ collection.collectionFk,
+ mobileApplication.dataStoreApp.readDataStoreKey(SECTORFK),
+ print = "0",
+ type
+ )
+ }
}
+
+ goBack = false
}
-
- goBack = false
-
- })
+ }
responseCode.observe(viewLifecycleOwner, Observer {
@@ -655,71 +660,76 @@ class CollectionFragment(
goBack2 = false
})
- responseTicketState.observe(viewLifecycleOwner) {
+ loadTicketState.observe(viewLifecycleOwner) { event ->
+ event.getContentIfNotHandled().notNull { it ->
- if (!goBack) {
- if ((it.code == "ON_CHECKING" || it.code == "CHECKED") && it.user.id != mobileApplication.userId) {
- var customDialogWarningChecking = CustomDialog(requireContext())
- customDialogWarningChecking.setTitle(getString(R.string.info))
- customDialogWarningChecking.setDescription(
- if (it.code == "ON_CHECKING") {
- getString(R.string.checkingByUser, it.user.username)
- } else {
- getString(R.string.checkedByUser, it.user.username)
- }
- ).setOkButton(getString(R.string.aware)) {
- customDialogWarningChecking.dismiss()
- }.show()
+ if (!goBack) {
+ if ((it.code == "ON_CHECKING" || it.code == "CHECKED") && it.user.id != mobileApplication.userId) {
+ var customDialogWarningChecking = CustomDialog(requireContext())
+ customDialogWarningChecking.setTitle(getString(R.string.info))
+ customDialogWarningChecking.setDescription(
+ if (it.code == "ON_CHECKING") {
+ getString(R.string.checkingByUser, it.user.username)
+ } else {
+ getString(R.string.checkedByUser, it.user.username)
+ }
+ ).setOkButton(getString(R.string.aware)) {
+ customDialogWarningChecking.dismiss()
+ }.show()
+ }
}
}
-
}
- responseTicketClosure.observe(viewLifecycleOwner, Observer {
+ loadTicketClousure.observe(viewLifecycleOwner) { event ->
+ event.getContentIfNotHandled().notNull { it ->
- if (!goBack) {
- if (it.response.toBoolean()) {
- var customDialogWarning = CustomDialog(requireContext())
- customDialogWarning.setTitle(getString(R.string.urgentWarning))
- customDialogWarning.setDescription(getString(R.string.ticketWarning))
- .setOkButton(getString(R.string.aware)) {
- customDialogWarning.dismiss()
- }.show()
- }
- }
-
- })
-
- responseIncQuantity.observe(viewLifecycleOwner, Observer {
-
- if (it.isError) {
- ma.messageWithSound(it.errorMessage, isError = true, true)
-
- } else {
if (!goBack) {
- incresaseSuccesful()
- } else {
- goBack = false
+ if (it.response.toBoolean()) {
+ var customDialogWarning = CustomDialog(requireContext())
+ customDialogWarning.setTitle(getString(R.string.urgentWarning))
+ customDialogWarning.setDescription(getString(R.string.ticketWarning))
+ .setOkButton(getString(R.string.aware)) {
+ customDialogWarning.dismiss()
+ }.show()
+ }
}
}
+ }
- })
+ loadIncQuantity.observe(viewLifecycleOwner) { event ->
+ event.getContentIfNotHandled().notNull { it ->
- responseSaleMistakeAdd.observe(viewLifecycleOwner, Observer {
-
- if (!goBack) {
if (it.isError) {
ma.messageWithSound(it.errorMessage, isError = true, true)
} else {
- ma.messageWithSound(
- getString(R.string.errorRegistered), isError = false, false
- )
- goBack = true
+ if (!goBack) {
+ incresaseSuccesful()
+ } else {
+ goBack = false
+ }
}
-
}
- })
+ }
+
+ loadSaleMistakeAdd.observe(viewLifecycleOwner) { event ->
+ event.getContentIfNotHandled().notNull { it ->
+
+ if (!goBack) {
+ if (it.isError) {
+ ma.messageWithSound(it.errorMessage, isError = true, true)
+
+ } else {
+ ma.messageWithSound(
+ getString(R.string.errorRegistered), isError = false, false
+ )
+ goBack = true
+ }
+
+ }
+ }
+ }
mistakeList.observe(viewLifecycleOwner, Observer {
diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/collection/fragment/CollectionFragmentPicker.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/collection/fragment/CollectionFragmentPicker.kt
index ba9d00ea..60281503 100644
--- a/app/src/main/java/es/verdnatura/presentation/view/feature/collection/fragment/CollectionFragmentPicker.kt
+++ b/app/src/main/java/es/verdnatura/presentation/view/feature/collection/fragment/CollectionFragmentPicker.kt
@@ -6,6 +6,8 @@ import android.graphics.drawable.Drawable
import android.media.MediaPlayer
import android.os.Build
import android.os.Bundle
+import android.os.Handler
+import android.os.Looper
import android.os.Parcelable
import android.text.InputType
import android.util.Log
@@ -123,6 +125,7 @@ class CollectionFragmentPicker(
private var itemShelvingTracking_mark: Int = 0
private var recylerViewState: Parcelable? = null
private var isScanned: Boolean? = null
+ private var myPosition: Int = 0
private lateinit var myGroupList: List
private var canChangeState = true
@@ -288,6 +291,9 @@ class CollectionFragmentPicker(
when (type) {
CONTROLADOR -> markLine(indice, type)
SACADOR -> {
+ //jose antonio
+ myPosition = myGroupList.indexOfFirst { it.saleGroupFk == saleGroupScanned }
+ println("previa $saleGroupScanned posicion $myPosition")
viewModel.saleTrackingAddPreparedSaleGroup(
saleGroupScanned.toInt()
)
@@ -546,7 +552,7 @@ class CollectionFragmentPicker(
ma.messageWithSound(it.errorMessage, true, true)
} else {
ma.messageWithSound(getString(R.string.previousCollected), false, true)
-
+
viewModel.collectionTicketGet(
collection.collectionFk,
mobileApplication.dataStoreApp.readDataStoreKey(SECTORFK),
@@ -835,6 +841,7 @@ class CollectionFragmentPicker(
} else {
// pintar línea
saleAdapter!!.notifyDataSetChanged()
+ myPosition = storedPosition
ReviewQuantityForRefreshingAndSorting(
sales[storedPosition].quantity!!.toInt(),
@@ -1378,6 +1385,13 @@ class CollectionFragmentPicker(
}
isMarking = true
setTotalLines()
+
+ val handler = Handler(Looper.getMainLooper())
+ handler.postDelayed({
+ val inputMethodManager =
+ requireContext().getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager
+ inputMethodManager.hideSoftInputFromWindow(binding.scanInput.windowToken, 0)
+ }, 300L)
}
private fun checkStateParent() {
@@ -1415,7 +1429,7 @@ class CollectionFragmentPicker(
}
private fun setListPosition(position: Int, isFromBack: Boolean) {
- lm!!.scrollToPositionWithOffset(storedBackPosition, 0)
+ lm!!.scrollToPositionWithOffset(myPosition, 0)
// lm!!.scrollToPositionWithOffset(position, 0)
/* storedPosition = position
@@ -1523,6 +1537,7 @@ class CollectionFragmentPicker(
}
}
storedBackPosition = position
+ myPosition = position
setListPosition(position, false)
if (type != PRECHECKER) {
diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/collection/fragment/CollectionFragmentPickerNew.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/collection/fragment/CollectionFragmentPickerNew.kt
index d44f2094..f4d80f81 100644
--- a/app/src/main/java/es/verdnatura/presentation/view/feature/collection/fragment/CollectionFragmentPickerNew.kt
+++ b/app/src/main/java/es/verdnatura/presentation/view/feature/collection/fragment/CollectionFragmentPickerNew.kt
@@ -32,7 +32,6 @@ import es.verdnatura.presentation.common.OnMistakeClickListener
import es.verdnatura.presentation.common.OnOptionsSelectedListener
import es.verdnatura.presentation.common.OnPackingClickSaleListener
import es.verdnatura.presentation.common.OnPasillerosItemClickListener
-import es.verdnatura.presentation.common.OnQuantityClickSaleListener
import es.verdnatura.presentation.common.OnSaleClickSaleListener
import es.verdnatura.presentation.common.OnTicketClickSaleListener
import es.verdnatura.presentation.common.ToolBarAdapterTooltip
@@ -345,18 +344,28 @@ class CollectionFragmentPickerNew(
}
}
- responseExistsItemShelvingSale.observe(viewLifecycleOwner) {
- if (!goBack) {
- if (it.exists) {
- markLine(it.position, it.quantity, true)
- } else {
+ loadExistsResponse.observe(viewLifecycleOwner) { event ->
+ event.getContentIfNotHandled().notNull {
+
+ getString(R.string.updateSalesReserve).toast(
+ requireContext()
+ )
+ updateScreen()
+ }
+ }
+
+ loadFindItemShelvingResponse.observe(viewLifecycleOwner) { event ->
+ event.getContentIfNotHandled().notNull {
+
+ if (it.shelvingFk != myGroupList[it.position].code) {
getString(R.string.updateSalesReserve).toast(
requireContext()
)
- viewModel.collectionTicketGetSalix(collection.collectionFk, false)
+ updateScreen()
+ } else {
+ markLine(it.position, it.quantity, true)
}
}
-
}
responseParking.observe(viewLifecycleOwner) {
@@ -398,46 +407,37 @@ class CollectionFragmentPickerNew(
responseConfirmReservedItemShelvingSale.observe(viewLifecycleOwner) {
- if (it.isError) {
- ma.messageWithSound(
- it.errorMessage,
- isError = true,
- isPlayed = true
- )
- }
- if (!it.isError) {
- myGroupList[positionConfirm].isPicked = 1
- saleAdapter!!.notifyDataSetChanged()
- lm!!.scrollToPositionWithOffset(storedPosition, 0)
- viewModel.collectionTicketGetSalix(
- collection.collectionFk, print = false
- )
- }
-
- }
-
-
- responseItemShelvingSale.observe(viewLifecycleOwner) {
myGroupList[positionConfirm].isPicked = 1
- myGroupList[positionConfirm].reservedQuantity = quantityConfirm
- viewModel.collectionTicketGetSalix(
- collection.collectionFk, print = false
- )
- lm!!.scrollToPositionWithOffset(positionConfirm, 0)
- ma.messageWithSound(
- getString(R.string.operationSuccess), it.isError, !it.isError, isToasted = false
- )
+ saleAdapter!!.notifyDataSetChanged()
+ lm!!.scrollToPositionWithOffset(storedPosition, 0)
+ /* viewModel.collectionTicketGetSalix(
+ collection.collectionFk, print = false
+ )*/
+
}
- responseItemShelvingSaleUnPicked.observe(viewLifecycleOwner) {
- myGroupList[positionUnmarked].isPicked = 1
- myGroupList[positionUnmarked].reservedQuantity = quantityConfirm
- viewModel.collectionTicketGetSalix(
- collection.collectionFk, print = false
- )
- lm!!.scrollToPositionWithOffset(positionUnmarked, 0)
- ma.messageWithSound(
- getString(R.string.operationSuccess), it.isError, !it.isError, isToasted = false
- )
+
+ /*
+ responseItemShelvingSale.observe(viewLifecycleOwner) {
+ myGroupList[positionConfirm].isPicked = 1
+ myGroupList[positionConfirm].reservedQuantity = quantityConfirm
+ viewModel.collectionTicketGetSalix(
+ collection.collectionFk, print = false
+ )
+ lm!!.scrollToPositionWithOffset(positionConfirm, 0)
+ ma.messageWithSound(
+ getString(R.string.operationSuccess), it.isError, !it.isError, isToasted = false
+ )
+ }*/
+ loadUnpicked.observe(viewLifecycleOwner) { event ->
+ event.getContentIfNotHandled().notNull {
+
+ myGroupList[positionUnmarked].isPicked = 0
+ myGroupList[positionUnmarked].reservedQuantity = quantityConfirm
+ saleAdapter!!.notifyItemChanged(positionUnmarked)
+
+ lm!!.scrollToPositionWithOffset(positionUnmarked, 0)
+
+ }
}
responseItemShelvingSaleGroup.observe(viewLifecycleOwner) {
@@ -512,24 +512,7 @@ class CollectionFragmentPickerNew(
saleAdapter = SaleAdapterNew(
myGroupList,
pasillerosItemClickListener!!,
- object : OnQuantityClickSaleListener {
- override fun onQuantityClick(sale: Sale) {
- sales.forEachIndexed { index, saleVO ->
-
- if (saleVO.saleFk == sale.saleFk) {
- if (sale.isPicked == 1) {
- showErrorMessage(
- title = getString(R.string.info),
- text = getString(R.string.unmarkForModify)
- )
- }
-
- }
- }
-
- }
- },
object : OnSaleClickSaleListener {
override fun onSaleClick(mySale: Sale) {
myGroupList.forEachIndexed { index, sale ->
@@ -886,13 +869,22 @@ class CollectionFragmentPickerNew(
}.setOkButtonTwo(getString(R.string.no)) {
scanRequest()
customDialogThreeButtonsQuantity.dismiss()
- if (quantity == 0) {
- viewModel.itemShelvingSaleExists(
- myGroupList[position].itemShelvingSaleFk, position, quantity
- )
- } else {
- markLine(position, quantity, true)
- }
+ viewModel.itemShelvingSaleExists(
+ myGroupList[position].itemShelvingSaleFk,
+ myGroupList[position].itemShelvingFk,
+ position,
+ quantity
+ )
+ /* if (quantity == 0) {
+ viewModel.itemShelvingSaleExists(
+ myGroupList[position].itemShelvingSaleFk,
+ myGroupList[position].itemShelvingFk,
+ position,
+ quantity
+ )
+ } else {
+ markLine(position, quantity, true)
+ }*/
}.setKoButton(getString(R.string.cancel)) {
scanRequest()
customDialogThreeButtonsQuantity.dismiss()
@@ -1170,7 +1162,8 @@ class CollectionFragmentPickerNew(
origin = value[0].origin,
size = value[0].size,
itemShelvingSaleFk = value[0].itemShelvingSaleFk,
- longName = value[0].parkingCode ?: ""
+ longName = value[0].parkingCode ?: "",
+ itemShelvingFk = 0
)
//prime elemento//hay que hacer una copia si no queda la referencia
diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/collection/fragment/CollectionFragmentPickerPreviousNew.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/collection/fragment/CollectionFragmentPickerPreviousNew.kt
index 7aa51b2d..d86f1111 100644
--- a/app/src/main/java/es/verdnatura/presentation/view/feature/collection/fragment/CollectionFragmentPickerPreviousNew.kt
+++ b/app/src/main/java/es/verdnatura/presentation/view/feature/collection/fragment/CollectionFragmentPickerPreviousNew.kt
@@ -7,12 +7,16 @@ import android.graphics.drawable.Drawable
import android.graphics.drawable.GradientDrawable
import android.media.MediaPlayer
import android.os.Bundle
+import android.os.Handler
+import android.os.Looper
import android.text.InputType
import android.view.Gravity
import android.view.KeyEvent
+import android.view.LayoutInflater
import android.view.View
import android.view.WindowManager
import android.view.inputmethod.EditorInfo
+import android.view.inputmethod.InputMethodManager
import android.widget.EditText
import android.widget.ImageView
import android.widget.TextView
@@ -22,9 +26,12 @@ import androidx.recyclerview.widget.RecyclerView
import com.google.gson.Gson
import es.verdnatura.R
import es.verdnatura.databinding.FragmentCollectionNewBinding
+import es.verdnatura.domain.ConstAndValues
import es.verdnatura.domain.ConstAndValues.BASEURLSALIX
+import es.verdnatura.domain.ConstAndValues.PREITEMPICKERTEST
+import es.verdnatura.domain.ConstAndValues.PREPARED
import es.verdnatura.domain.ConstAndValues.PRESACADOR
-import es.verdnatura.domain.ConstAndValues.PRINTERNAME
+import es.verdnatura.domain.ConstAndValues.SACADOR
import es.verdnatura.domain.ConstAndValues.SECTORFK
import es.verdnatura.domain.notNull
import es.verdnatura.domain.toast
@@ -35,8 +42,8 @@ import es.verdnatura.presentation.common.OnMistakeClickListener
import es.verdnatura.presentation.common.OnOptionsSelectedListener
import es.verdnatura.presentation.common.OnPackingClickSaleListener
import es.verdnatura.presentation.common.OnPasillerosItemClickListener
-import es.verdnatura.presentation.common.OnQuantityClickSaleListener
import es.verdnatura.presentation.common.OnSaleClickSaleListener
+import es.verdnatura.presentation.common.OnSaleReserveClickListener
import es.verdnatura.presentation.common.OnTicketClickSaleListener
import es.verdnatura.presentation.common.ToolBarAdapterTooltip
import es.verdnatura.presentation.common.hideKeyboard
@@ -60,6 +67,16 @@ import kotlinx.coroutines.runBlocking
import org.json.JSONObject
@Suppress("UNUSED_ANONYMOUS_PARAMETER")
+
+/*CAMBIO DEL SACADOR AL PRESACADOR, FUNCIONES EXTRA AL FINAL DEL FICHERO
+1- EL SACADOR AGRUPA LINEAS EL PRESACADOR NO
+2- AL AÑADIR ITEM A A LA COLECCIÓN , EL SACADOR SALEGROUPFK Y SECTORFK SON NULOS.
+3-VERIFICAR COLECCIÓN
+4-IMPRIMIR
+
+variables:
+isVerifiedCollection
+ */
class CollectionFragmentPickerPreviousNew(
var collection: CollectionTicket,
var type: String = PRESACADOR,
@@ -68,7 +85,6 @@ class CollectionFragmentPickerPreviousNew(
CollectionViewModel::class
) {
private var sales: List = listOf()
- private var salesParent: List = listOf()
private var saleAdapter: SaleAdapterNew? = null
private var lm: LinearLayoutManager? = null
private var storedPosition: Int = 0
@@ -81,29 +97,18 @@ class CollectionFragmentPickerPreviousNew(
private lateinit var customDialogThreeButtonsQuantity: CustomDialogThreeButtons
private var ticketSelected: Int = 0
private lateinit var customDialog: CustomDialog
- private var goBack: Boolean = false
- private var goBack2: Boolean = false
- private var goMistakeBack: Boolean = false
var mperror: MediaPlayer? = null
var mpok: MediaPlayer? = null
- private var itemShelvingFkStored: Int = 0
private var storedBackPosition: Int = 0
private var tickets: ArrayList = ArrayList()
- private var mistakeSale: SaleVO? = null
- private var isMarking = false
- private lateinit var ticketScanTxt: String
private var lastScanned: Int = 0
- private var buttonPushedGetCollection = false
private var positionUnmarked = -1
- private var state = 0
- private var originalItemScan: Long = 0
- private var workerFkFromTicket: String? = null
private var isScanned: Boolean? = null
private var positionConfirm = 0
private var quantityConfirm = 0
- private var positionMarkPrevia = 0
private lateinit var myGroupList: List
private var quantityReserveToCheckItemScan = 0
+ private var isVerifiedCollection = false
companion object {
fun newInstance(
@@ -119,11 +124,8 @@ class CollectionFragmentPickerPreviousNew(
override fun getLayoutId(): Int = R.layout.fragment_collection_new
override fun onCreate(savedInstanceState: Bundle?) {
-
mperror = MediaPlayer.create((activity as MainActivity), R.raw.error)
mpok = MediaPlayer.create((activity as MainActivity), R.raw.ok)
- println("create onRunning")
-
super.onCreate(savedInstanceState)
}
@@ -139,7 +141,7 @@ class CollectionFragmentPickerPreviousNew(
customDialogThreeButtons = CustomDialogThreeButtons(requireContext())
customDialogThreeButtonsQuantity = CustomDialogThreeButtons(requireContext())
ma.hideBottomNavigation(View.GONE)
-
+ println("type $type")
setEvents()
setToolBar()
viewModel.collectionTicketGetSalix(
@@ -149,13 +151,6 @@ class CollectionFragmentPickerPreviousNew(
super.init()
}
- override fun onPause() {
- super.onPause()
- goBack = true
- goBack2 = true
- goMistakeBack = true
- }
-
private fun setToolBar() {
binding.mainToolbar.toolbarSubtitle.visibility = View.VISIBLE
binding.mainToolbar.toolbarIcons.visibility = View.VISIBLE
@@ -165,47 +160,37 @@ class CollectionFragmentPickerPreviousNew(
}
val listIcons: ArrayList = ArrayList()
- val iconPrint = ImageView(context)
- iconPrint.setImageResource(R.drawable.ic_print_black_24dp)
+
val iconAdd = ImageView(context)
iconAdd.setImageResource(R.drawable.ic_playlist_add_black_24dp)
- val iconViewCollection = ImageView(context)
- iconViewCollection.setImageResource(R.drawable.ic_collection)
- val iconWorker = ImageView(context)
- iconWorker.setImageResource(R.drawable.ic_worker)
- val iconPhone = ImageView(context)
- iconPhone.setImageResource(R.drawable.phone_call)
val iconParking = ImageView(context)
iconParking.setImageResource(R.drawable.ic_local_parking_black_24dp)
val iconUpdate = ImageView(context)
iconUpdate.setImageResource(R.drawable.ic_autorenew_black_24dp)
+ val iconPrint = ImageView(context)
+ iconPrint.setImageResource(R.drawable.ic_print_black_24dp)
- iconPrint.tooltipText = getTooltip(R.drawable.ic_print_black_24dp)
iconAdd.tooltipText = getTooltip(R.drawable.ic_playlist_add_black_24dp)
- iconViewCollection.tooltipText = getTooltip(R.drawable.ic_collection)
- iconPhone.tooltipText = getTooltip(R.drawable.phone_call)
iconParking.tooltipText = getTooltip(R.drawable.ic_local_parking_black_24dp)
iconUpdate.tooltipText = getTooltip(R.drawable.ic_autorenew_black_24dp)
+ iconPrint.tooltipText = getTooltip(R.drawable.ic_print_black_24dp)
+
- // listIcons.add(iconPrint)
listIcons.add(iconAdd)
- listIcons.add(iconParking)
listIcons.add(iconUpdate)
- // listIcons.remove(iconWorker)
+ if (type == PREPARED) listIcons.add(iconPrint) else listIcons.add(iconParking)
binding.mainToolbar.toolbarIcons.adapter =
ToolBarAdapterTooltip(listIcons, object : OnOptionsSelectedListener {
override fun onOptionsItemSelected(item: Drawable) {
when (item) {
- //iconViewCollection.drawable -> getCollection()
iconPrint.drawable -> print()
iconAdd.drawable -> addItem()
- iconWorker.drawable -> showUser()
iconUpdate.drawable -> updateScreen()
iconParking.drawable -> pasillerosItemClickListener?.onPasillerosItemClickListener(
PasillerosItemVO(
- title =R.string.Parking
+ title = R.string.Parking
), ""
)
}
@@ -222,44 +207,14 @@ class CollectionFragmentPickerPreviousNew(
)
}
- /* private fun markPrevia(saleGroupScanned: String): Boolean {
- println("Sacador saleGroup $saleGroupScanned ")
- try {
- for (indice in sales.indices) {
- println("Sacador saleGroup ${sales[indice].saleGroupFk}")
- if (sales[indice].saleGroupFk != null && sales[indice].saleGroupFk == saleGroupScanned.toInt()) {
- println("Sacador saleGroup ${sales[indice].itemShelvingSaleFk}")
- viewModel.itemShelvingSaleSetSaleGroup(saleGroupScanned.toInt())
- positionMarkPrevia = indice
- mpok!!.start()
- return true
-
- }
- }
- } catch (ex: Exception) {
- return false
- }
- return false
- }*/
-
private fun scanRequest() {
binding.scanInput.requestFocus()
hideKeyboards()
}
- private fun showUser() {
-
- ma.onPasillerosItemClickListener(
- PasillerosItemVO(title = R.string.titleUserControlVehicle),
- workerFkFromTicket.toString()
- )
-
- }
-
private fun setEvents() {
binding.mainToolbar.backButton.setOnClickListener {
- println("reserva fuera")
ma.onMyBackPressed()
}
//ESCANER =========
@@ -274,12 +229,8 @@ class CollectionFragmentPickerPreviousNew(
if (itemScanIsQr(binding.scanInput.text.toString())) {
val myQr = ItemScanned(JSONObject(binding.scanInput.text.toString()))
when (myQr.table) {
- "saleGroup" -> {/* if (type == CONTROLADOR) {
- markPrevia(myQr.id.toString())
- } else {*/
+ "saleGroup" -> {
binding.scanInput.setText(myQr.id.toString())
- //findSale(binding.scanInput.text.toString())
- // }
}
"buy" -> binding.scanInput.setText(myQr.more)
@@ -289,7 +240,6 @@ class CollectionFragmentPickerPreviousNew(
ma.hideKeyboard(binding.scanInput)
findSale(binding.scanInput.text.toString())
}
- buttonPushedGetCollection = false
}
binding.scanInput.setText("")
hideKeyboards()
@@ -302,16 +252,8 @@ class CollectionFragmentPickerPreviousNew(
//LISTA =========
binding.collectionSwipe.setOnRefreshListener {
- isMarking = false
binding.collectionSwipe.isRefreshing = false
-
- updateScreen()/* viewModel.collectionTicketGet(
- collection.collectionFk,
- mobileApplication.dataStoreApp.readDataStoreKey(SECTORFK),
- print = "0",
- type
- )*/
- buttonPushedGetCollection = false
+ updateScreen()
binding.collectionSwipe.isRefreshing = false
}
@@ -336,11 +278,6 @@ class CollectionFragmentPickerPreviousNew(
if (it.tickets.isNotEmpty()) {
collection = it
createCollectionList()
- workerFkFromTicket = if (it.tickets[0].sales.isNotEmpty()) {
- it.tickets[0].sales[0].workerFk.toString()
- } else {
- ""
- }
} else {
binding.mainToolbar.toolbarSubtitle.text = "0/0"
@@ -357,29 +294,31 @@ class CollectionFragmentPickerPreviousNew(
}
}
- responseExistsItemShelvingSale.observe(viewLifecycleOwner) {
- if (!goBack) {
- if (it.exists) {
- markLine(it.position, it.quantity, true)
- } else {
+ loadExistsResponse.observe(viewLifecycleOwner) { event ->
+ event.getContentIfNotHandled().notNull {
+
+ getString(R.string.updateSalesReserve).toast(
+ requireContext()
+ )
+ updateScreen()
+ }
+ }
+
+ loadFindItemShelvingResponse.observe(viewLifecycleOwner) { event ->
+ event.getContentIfNotHandled().notNull {
+
+ if (it.shelvingFk != myGroupList[it.position].code) {
getString(R.string.updateSalesReserve).toast(
requireContext()
)
- viewModel.collectionTicketGetSalix(collection.collectionFk, false)
+ updateScreen()
+ } else {
+ markLine(it.position, it.quantity, true)
}
}
-
}
- responseParking.observe(viewLifecycleOwner) {
- if (!goBack) {
- ma.messageWithSound(
- if (it.isError) it.errorMessage else getString(R.string.Aparcado),
- it.isError,
- true
- )
- }
- }
+
loadResponseAddItem.observe(viewLifecycleOwner) { event ->
event.getContentIfNotHandled().notNull {
updateScreen()
@@ -387,117 +326,52 @@ class CollectionFragmentPickerPreviousNew(
}
- responsePrint.observe(viewLifecycleOwner) {
-
- if (!goBack) {
-
- if (it.isError) {
- ma.messageWithSound(
- it.errorMessage, isError = true, true
- )
- } else {
- (getString(R.string.Imprimiendo) + mobileApplication.dataStoreApp.readDataStoreKey(
- PRINTERNAME
- )).toast(
- requireContext()
- )
- }
- }
-
- }
-
- responseConfirmReservedItemShelvingSale.observe(viewLifecycleOwner) {
-
- if (it.isError) {
- ma.messageWithSound(
- it.errorMessage, isError = true, true
- )
- setTotalLines()
- } else {
+ loadPicked.observe(viewLifecycleOwner) { event ->
+ event.getContentIfNotHandled().notNull {
myGroupList[positionConfirm].isPicked = 1
saleAdapter!!.notifyItemChanged(positionConfirm)
- //lolass
- lm!!.scrollToPositionWithOffset(storedBackPosition, 0)
- // lm!!.scrollToPositionWithOffset(storedBackPosition + 1, 0)
-
+ lm!!.scrollToPositionWithOffset(positionConfirm, 0)
+ //lm!!.scrollToPositionWithOffset(storedBackPosition + 1, 0)
setTotalLines()
- viewModel.collectionTicketGetSalix(
- collection.collectionFk, print = false
- )
+
}
-
}
-
- responseItemShelvingSale.observe(viewLifecycleOwner) {
-
- myGroupList[positionConfirm].isPicked = 1
- myGroupList[positionConfirm].reservedQuantity = quantityConfirm
- viewModel.collectionTicketGetSalix(
- collection.collectionFk, print = false
- )
- lm!!.scrollToPositionWithOffset(positionConfirm, 0)
- //saleAdapter!!.notifyDataSetChanged()
- ma.messageWithSound(
- "Confirmada acción", it.isError, !it.isError
- )
- }
loadUnpicked.observe(viewLifecycleOwner) { event ->
event.getContentIfNotHandled().notNull {
- myGroupList[positionUnmarked].isPicked = 1
+ myGroupList[positionUnmarked].isPicked = 0
myGroupList[positionUnmarked].reservedQuantity = quantityConfirm
- viewModel.collectionTicketGetSalix(
- collection.collectionFk, print = false
- )
+ saleAdapter!!.notifyItemChanged(positionUnmarked)
lm!!.scrollToPositionWithOffset(positionUnmarked, 0)
- //saleAdapter!!.notifyDataSetChanged()
- ma.messageWithSound(
- "Confirmada acción", it.isError, !it.isError
- )
+
}
}
- responseItemShelvingSaleGroup.observe(viewLifecycleOwner) {
-
- viewModel.collectionTicketGetSalix(
- collection.collectionFk, print = false
- )
- lm!!.scrollToPositionWithOffset(positionMarkPrevia, 0)
-
- ma.messageWithSound(
- getString(R.string.previousCollected), it.isError, !it.isError
- )
- }
responseCode.observe(viewLifecycleOwner) {
- if (!goBack2) {
- if (it == null) {
- showErrorMessage(text = getString(R.string.codeNotExist))
- if (mperror != null) mperror?.start()
+ if (it == null) {
+ showErrorMessage(text = getString(R.string.codeNotExist))
+ if (mperror != null) mperror?.start()
+ } else {
+ if (checkItemScan(it.toString(), positionConfirm)) {
+ scanRequest()
+ customDialogList.dismiss()
+ mpok?.start()
+ markLine(positionConfirm, quantityReserveToCheckItemScan, false)
} else {
- if (checkItemScan(it.toString())) {
- scanRequest()
- customDialogList.dismiss()
- mpok?.start()
- markLine(storedPosition, quantityReserveToCheckItemScan, false)
- } else {
- customDialogList.setValueTwo("")
- showErrorMessage(text = getString(R.string.lineNotExist))
- if (mperror != null) mperror?.start()
- }
+ customDialogList.setValueTwo("")
+ showErrorMessage(text = getString(R.string.lineNotExist))
+ if (mperror != null) mperror?.start()
}
}
- goBack2 = false
-
}
}
}
private fun createCollectionList() {
- state = 0
binding.mainToolbar.toolbarTitle.text = collection.collectionFk.toString()
collection.map(requireContext())
@@ -509,8 +383,7 @@ class CollectionFragmentPickerPreviousNew(
val myPickingTo = mobileApplication.dataStoreApp.readDataStoreKey("PICKING_TO")
collection.tickets.forEach { ticket ->
- if (observations.isNotEmpty()) observations =
- observations + " " + ticket.observations
+ if (observations.isNotEmpty()) observations = observations + " " + ticket.observations
ticket.sales.forEach { sale ->
if (hasPickingOrder) {
@@ -523,35 +396,25 @@ class CollectionFragmentPickerPreviousNew(
}
}
-
- sales = salesList.sortedWith(compareBy { it.pickingOrderPrevia }.thenBy { it.itemFk })
-
+ // sales = salesList.sortedWith(compareBy { it.pickingOrderPrevia }.thenBy { it.itemFk })
//quitar comentarios FALTA AGRUPAR LAS PREVIAS
- myGroupList =
- salesList.sortedWith(compareBy { it.pickingOrderPrevia }.thenBy { it.itemFk })
- // sales //sales porque no se ggrupan las previas hay que cambiar los estados.
- saleAdapter = SaleAdapterNew(
- myGroupList,
- pasillerosItemClickListener!!,
- object : OnQuantityClickSaleListener {
+ when (type) {
+ PREITEMPICKERTEST -> {
+ myGroupList =
+ salesList.sortedWith(compareBy { it.pickingOrderPrevia }.thenBy { it.itemFk })
+ }
- override fun onQuantityClick(sale: Sale) {
- sales.forEachIndexed { index, saleVO ->
+ SACADOR -> {
+ myGroupList =
+ groupSaleGroup(salesList).sortedWith(compareBy { it.pickingOrder }.thenBy { it.itemFk })
+ }
- if (saleVO.saleFk == sale.saleFk) {
- if (sale.isPicked == 1) {
- showErrorMessage(
- title = getString(R.string.info),
- text = getString(R.string.unmarkForModify)
- )
- }
+ }
- }
- }
- }
- },
+ saleAdapter = SaleAdapterNew(myGroupList, pasillerosItemClickListener!!,
+
object : OnSaleClickSaleListener {
override fun onSaleClick(sale: Sale) {
@@ -565,48 +428,13 @@ class CollectionFragmentPickerPreviousNew(
}
}
- /* myGroupList.forEachIndexed { index, sale ->
- //sales.forEachIndexed { index, sale ->
- // println("Sacador la sale es ${sale.saleFk}")
- // println("Sacador la sale picked es ${sale.isPicked}")
- // println("Sacador la sale group es ${sale.saleGroupFk}")
- // println("Sacador la sale reserved es ${sale.reservedQuantity}")
- if (sale.itemShelvingSaleFk == 0) {
- println("Sacador Que hacemos en este caso ?? ")
- } else {
-
-
- if (sale.itemShelvingSaleFk == mysale.itemShelvingSaleFk) {
- println("Sacador **** itemShelvingSale es ${sale.itemShelvingSaleFk}")
- println("Sacador **** isPicked es ${sale.isPicked}")
- println("Sacador **** saleGroup es ${sale.saleGroupFk}")
- //println("Sacador la sale es ${sale.saleFk}")
- //println("Sacador la sale picked es ${sale.isPicked}")
- //println("Sacador la sale group es ${sale.saleGroupFk}")
- //println("Sacador la sale reserved es ${sale.reservedQuantity}")
- //println("Sacador la sale dentro es ${sale.saleFk}")
- if (sale.isPicked != 1 && sale.saleGroupFk == null) {
- println("Sacador **** showScanner")
- showScanner(index, sale)
- } else {
- println("Sacador **** desmarcar")
- unMarkLine(index, myGroupList[index])
- }
-
- }
- }
-
- }*/
}
- },
- object : OnMistakeClickListener {
+ }, object : OnMistakeClickListener {
override fun onMistakeClickListener(sale: SaleVO) {
}
- },
- object : OnPackingClickSaleListener {
+ }, object : OnPackingClickSaleListener {
override fun onPackingClick(sale: Sale) {
- goBack = true
if (!sale.code.isNullOrEmpty()) ma.onPasillerosItemClickListener(
PasillerosItemVO(
@@ -614,8 +442,7 @@ class CollectionFragmentPickerPreviousNew(
), entryPoint = sale.code
)
}
- },
- object : OnTicketClickSaleListener {
+ }, object : OnTicketClickSaleListener {
override fun onTicketClickListener(sale: Sale) {
val entryPoint = Gson().toJson(
mutableMapOf(
@@ -632,8 +459,12 @@ class CollectionFragmentPickerPreviousNew(
), entryPoint = entryPoint
)
}
- },
- type = type
+ }, onReserveSaleClick = object : OnSaleReserveClickListener {
+ override fun onSaleReserveListener(sale: Sale) {
+ showDeleteItemShelving(sale)
+ }
+
+ }, type = type
)
@@ -642,9 +473,32 @@ class CollectionFragmentPickerPreviousNew(
binding.fragmentSacadorCollections.layoutManager = lm
setTotalLines()
- setStoredPosition()
+ setListPosition()
setScrollListener(lm!!)
printObservations(observations)
+ if (!isVerifiedCollection && type == PREPARED) {
+ binding.fragmentSacadorCollections.visibility = View.INVISIBLE
+ verifyCollection()
+ }
+ }
+
+ private fun showDeleteItemShelving(sale: Sale) {
+ customDialog.setTitle(getString(R.string.deleteSale))
+ .setDescription(
+ getString(R.string.deleteSaleDescrip) + getString(
+ R.string.sure
+ )
+ ).setOkButton(getString(R.string.delete)) {
+
+ viewModel.itemShelvingSaleDeleteIsAdded(sale.itemShelvingSaleFk)
+ scanRequest()
+ customDialog.dismiss()
+
+ }.setKoButton(getString(R.string.cancel)) {
+ scanRequest()
+ customDialog.dismiss()
+ }.show()
+
}
private fun setScrollListener(lm: LinearLayoutManager) {
@@ -652,7 +506,8 @@ class CollectionFragmentPickerPreviousNew(
binding.fragmentSacadorCollections.addOnScrollListener(object :
RecyclerView.OnScrollListener() {
override fun onScrolled(recyclerView: RecyclerView, dx: Int, dy: Int) {
- storedBackPosition = lm.findFirstVisibleItemPosition()
+ // storedBackPosition = lm.findFirstVisibleItemPosition()
+ storedPosition = lm.findFirstVisibleItemPosition()
super.onScrolled(recyclerView, dx, dy)
}
})
@@ -670,14 +525,12 @@ class CollectionFragmentPickerPreviousNew(
private fun findSale(txtscan: String) {
- var isFoundSale = false // markPrevia(txtscan)
-
+ var isFoundSale = false
//Se busca la matricula en las lineas
for (indice in myGroupList.indices) {
if (myGroupList[indice].isPicked != 1 && myGroupList[indice].code != null && myGroupList[indice].code!!.uppercase() == txtscan.uppercase()) {
mpok!!.start()
isFoundSale = true
- positionMarkPrevia = indice
printShelvingResult(indice)
break
}
@@ -694,8 +547,6 @@ class CollectionFragmentPickerPreviousNew(
if (sale.code!!.uppercase() == txtscan.uppercase()) {
mpok!!.start()
printShelvingResult(position)
- //sale.isPicked = 1
- //saleAdapter!!.notifyItemChanged(position)
} else {
mperror!!.start()
}
@@ -704,30 +555,27 @@ class CollectionFragmentPickerPreviousNew(
private fun markLine(position: Int, quantity: Int, isItemShelvingSaleEmpty: Boolean?) {
- state = 0
isScanned = null
positionConfirm = position
quantityConfirm = quantity
- isMarking = true
runBlocking {
- var sectorFk = mobileApplication.dataStoreApp.readDataStoreKey(SECTORFK)
+ val sectorFk = mobileApplication.dataStoreApp.readDataStoreKey(SECTORFK)
viewModel.itemShelvingSaleSetQuantity(
- myGroupList[position].itemShelvingSaleFk, quantity, isItemShelvingSaleEmpty = isItemShelvingSaleEmpty, sectorFk = if (sectorFk == -1) null else sectorFk
+ myGroupList[position].itemShelvingSaleFk,
+ quantity,
+ isItemShelvingSaleEmpty = isItemShelvingSaleEmpty,
+ sectorFk = if (sectorFk == -1) null else sectorFk
)
}
- storedBackPosition = position/* var mySale = myGroupList[position].itemShelvingSaleFk
- for (indice in myGroupList.indices) {
- if (!myGroupList[indice].isParent && myGroupList[indice].itemShelvingSaleFk == mySale) {
- storedBackPosition = indice
- }
- }*/
+ // storedBackPosition = position
}
private fun setListPosition() {
- if (storedPosition == 0 && storedBackPosition == 0) { // se inicia lista, se busca porqué item vamos.
+ //if (storedPosition == 0 && storedBackPosition == 0) { // se inicia lista, se busca porqué item vamos.
+ if (storedPosition == 0) {
for (indice in myGroupList.indices) {
if (myGroupList[indice].isPicked == 0) {
//storedPosition = indice
@@ -737,12 +585,13 @@ class CollectionFragmentPickerPreviousNew(
}
} else {
- lm!!.scrollToPositionWithOffset(storedBackPosition, 0)
+ // lm!!.scrollToPositionWithOffset(storedBackPosition, 0)
+ lm!!.scrollToPositionWithOffset(storedPosition, 0)
}
}
private fun unMarkLine(position: Int, sale: Sale) {
- state = 0
+
customDialog.setTitle(getString(R.string.unmarkLine)).setDescription(
getString(R.string.goUnmark) + sale.itemFk + getString(
R.string.sure
@@ -750,17 +599,10 @@ class CollectionFragmentPickerPreviousNew(
).setOkButton(getString(R.string.unmark)) {
if (!sale.isParent && sale.reservedQuantity == 0 && sale.originalQuantity != sale.saleQuantity) {
getString(R.string.unmarkError).toast(requireContext())
- } else {/* saleAdapter!!.notifyDataSetChanged()
- var mySale = sale.saleFk
- for (indice in myGroupList.indices) {
- if (!myGroupList[indice].isParent && myGroupList[indice].saleFk == mySale) {
- d("VERDNATURA::", "la pos del index de la sale es" + indice)
- storedBackPosition = indice
- }
- }*/
- storedBackPosition = position
- setListPosition()
-
+ } else {
+ //storedBackPosition = position
+ //storedPosition = position
+ // setListPosition()
viewModel.itemShelvingSaleUnpicked(myGroupList[position].itemShelvingSaleFk)
sale.isPicked = 0
positionUnmarked = position
@@ -777,10 +619,10 @@ class CollectionFragmentPickerPreviousNew(
}
- //SHELVINGS
-
private fun printShelvingResult(pos: Int) {
+
storedPosition = pos
+ customDialogList = CustomDialogList(requireContext())
customDialogList.getEditTextTwo().inputType = InputType.TYPE_CLASS_TEXT
customDialogList.getEditTextTwo().setRawInputType(InputType.TYPE_CLASS_NUMBER)
customDialogList.getEditText().setRawInputType(InputType.TYPE_CLASS_NUMBER)
@@ -789,7 +631,6 @@ class CollectionFragmentPickerPreviousNew(
val item = myGroupList[pos].itemFk
val longName = myGroupList[pos].longName
val totalReserved = myGroupList[pos].reservedQuantity
- val itemShelvingFk = myGroupList[pos].itemShelvingSaleFk
try {
customDialogList.setTitle("$shelving($item) $totalReserved de $longName").setOkButton(
@@ -797,7 +638,7 @@ class CollectionFragmentPickerPreviousNew(
R.string.take
)
) {
- customDialogTakeAction(pos, itemShelvingFk, totalReserved, false)
+ customDialogTakeAction(pos, totalReserved, false)
}.setKoButton(getString(R.string.close)) {
requireActivity().hideKeyboard(customDialogList.getEditTextTwo())
@@ -812,7 +653,6 @@ class CollectionFragmentPickerPreviousNew(
customDialogTakeAction(
pos,
- itemShelvingFk,
totalReserved,
event != null && event.action == KeyEvent.ACTION_DOWN && event.keyCode == KeyEvent.KEYCODE_ENTER
)
@@ -828,9 +668,8 @@ class CollectionFragmentPickerPreviousNew(
}
private fun customDialogTakeAction(
- position: Int, itemShelvingFk: Int, totalReserved: Int, isItemScanned: Boolean?
+ position: Int, totalReserved: Int, isItemScanned: Boolean?
) {
- goBack = false
isScanned = isItemScanned
if (customDialogList.getValueTwo().isNotEmpty()) {
@@ -843,7 +682,7 @@ class CollectionFragmentPickerPreviousNew(
if (quantityToReserve < totalReserved) {
- if (customDialogList.getValueTwo() in sales[position].Barcodes || customDialogList.getValueTwo() == sales[position].itemFk.toString()) {
+ if (customDialogList.getValueTwo() in myGroupList[position].Barcodes || customDialogList.getValueTwo() == myGroupList[position].itemFk.toString()) {
customDialogList.dismiss()
showQuestionUbicationEmpty(position, quantityToReserve)
} else {
@@ -862,22 +701,19 @@ class CollectionFragmentPickerPreviousNew(
}
if (quantityToReserve == totalReserved) {
try {
- originalItemScan = customDialogList.getValueTwo().toLong()
- if (checkItemScan(customDialogList.getValueTwo())) {
+ if (checkItemScan(customDialogList.getValueTwo(), position)) {
- markLine(storedPosition, quantityToReserve, false)
+ markLine(position, quantityToReserve, false)
mpok?.start()
ma.hideKeyboard(customDialogList.getEditTextTwo())
customDialogList.dismiss()
- showTicket(sales[position].ticketFk)
+ showTicket(myGroupList[position].ticketFk)
scanRequest()
} else {
- itemShelvingFkStored = itemShelvingFk
-
quantityReserveToCheckItemScan = quantityToReserve
viewModel.getIdFromCodeSalix(
code = customDialogList.getValueTwo(),
@@ -895,29 +731,30 @@ class CollectionFragmentPickerPreviousNew(
}
}
- private fun showTicket(ticketFk:Int) {
-
- val toast = Toast.makeText(requireContext(), "$ticketFk", Toast.LENGTH_LONG)
- val view = toast.view
- val text = view?.findViewById(android.R.id.message)
- text?.setTextColor(requireContext().getColor(R.color.verdnatura_orange_salix))
- text?.textSize = 18f
+ private fun showTicket(ticketFk: Int) {
+ val inflater = LayoutInflater.from(requireContext())
+ val layout = inflater.inflate(R.layout.ticket_toast_layout, null)
+ val text = layout.findViewById(R.id.toast_text)
+ text.text = "$ticketFk"
+ text.setTextColor(requireContext().getColor(R.color.verdnatura_orange_salix))
+ text.textSize = 18f
val background = GradientDrawable()
background.setColor(Color.parseColor("#000000"))
background.cornerRadius = 16f
- view?.background = background
+ layout.background = background
+ val toast = Toast(requireContext())
+ toast.duration = Toast.LENGTH_LONG
+ toast.view = layout
toast.setGravity(Gravity.CENTER, 0, 0)
toast.show()
}
- private fun setStoredPosition() {
- setListPosition()/*if (goBack) setListPosition(storedBackPosition, isFromBack) else {
- setListPosition(storedPosition, isFromBack)*/
- }
-
- private fun checkItemScan(valueToCheck: String): Boolean {
-
- val saleToCheck = myGroupList[storedPosition]
+ private fun checkItemScan(valueToCheck: String, position: Int): Boolean {
+ println("CheckItemScan $valueToCheck")
+ val saleToCheck = myGroupList[position]
+ println("CheckItemScan saleTocheck$saleToCheck")
+ println("CheckItemScan saleTocheck Item ${saleToCheck.itemFk}")
+ println("CheckItemScan saleTocheck ItemBarcodes ${saleToCheck.Barcodes}")
if (saleToCheck.itemFk.toString() == valueToCheck) return true
else {
saleToCheck.Barcodes.forEach { barcode ->
@@ -929,12 +766,11 @@ class CollectionFragmentPickerPreviousNew(
}
private fun showQuestionUbicationEmpty(position: Int, quantity: Int = 0) {
-
customDialogThreeButtonsQuantity.setTitle(
getString(
- R.string.changeQuantity, quantity, sales[position].itemFk
+ R.string.changeQuantity, quantity, myGroupList[position].itemFk
)
- ).setDescription(getString(R.string.questionItemShelving, sales[position].itemFk))
+ ).setDescription(getString(R.string.questionItemShelving, myGroupList[position].itemFk))
.setValue("").setCustomDialogValue(View.GONE)
customDialogThreeButtonsQuantity.setOkButtonAdd(text = getString(R.string.yes)) {
scanRequest()
@@ -942,16 +778,30 @@ class CollectionFragmentPickerPreviousNew(
getString(R.string.errorQuantityShelving).toast(requireContext())
customDialogThreeButtonsQuantity.dismiss()
showQuestionUbicationEmpty(position, quantity)
- }.setOkButtonTwo("NO") {
+ }.setOkButtonTwo(getString(R.string.no)) {
scanRequest()
customDialogThreeButtonsQuantity.dismiss()
- if (quantity == 0) {
- viewModel.itemShelvingSaleExists(
- myGroupList[position].itemShelvingSaleFk, position, quantity
- )
- } else {
- markLine(position, quantity, true)
- }
+ viewModel.itemShelvingSaleExists(
+ myGroupList[position].itemShelvingSaleFk,
+ myGroupList[position].itemShelvingFk,
+ position,
+ quantity
+ )
+ /* if (quantity == 0) {
+
+ /* viewModel.itemShelvingGet(
+ myGroupList[position].itemShelvingFk,
+ position = position,
+ quantity = quantity
+ )*/
+ } else {
+ //markLine(position, quantity, true)
+ viewModel.itemShelvingGet(
+ myGroupList[position].itemShelvingFk,
+ position = position,
+ quantity = quantity
+ )
+ }*/
}.setKoButton(getString(R.string.cancel)) {
scanRequest()
customDialogThreeButtonsQuantity.dismiss()
@@ -959,25 +809,6 @@ class CollectionFragmentPickerPreviousNew(
customDialogThreeButtons.setFocusDialogValue()
}
- //OPTIONS
- private fun print() {
-
- if (ma.havePrinter() && ma.haveSector()) {
- showDialogLabelCount()
-
- } else {
- ma.messageWithSound(
- getString(R.string.printerFault),
- isError = true,
- true,
- getString(R.string.printError),
- false
- )
-
- }
-
- }
-
private fun addItem() {
listPlacementSupply = ArrayList()
collection.tickets.forEach {
@@ -993,13 +824,13 @@ class CollectionFragmentPickerPreviousNew(
.setOkButton(getString(R.string.Agregar)) {
customDialogAddItem()
}.setKoButton(getString(R.string.close)) {
- scanRequest()
customDialogList.dismiss()
+ scanRequest()
+ hideKeyboardFragment()
}.setHintValue(getString(R.string.Artículo)).setValue("")
.setHintValueTwo(getString(R.string.Cantidad)).setValueTwo("").show()
customDialogList.getEditText().requestFocus()
- requireActivity().hideKeyboard()
-
+ hideKeyboardFragment()
customDialogList.getEditText().setOnEditorActionListener { v, actionId, event ->
if (actionId == EditorInfo.IME_ACTION_SEARCH || actionId == EditorInfo.IME_ACTION_DONE || actionId == 0 || actionId == 5) {
if (customDialogList.getValue().isNotEmpty()) {
@@ -1023,7 +854,6 @@ class CollectionFragmentPickerPreviousNew(
}
-
customDialogList.getEditTextTwo().setOnEditorActionListener { v, actionId, event ->
if (actionId == EditorInfo.IME_ACTION_SEARCH || actionId == EditorInfo.IME_ACTION_DONE || actionId == 0 || actionId == 5) {
customDialogAddItem()
@@ -1059,22 +889,24 @@ class CollectionFragmentPickerPreviousNew(
) {
getString(R.string.Todosloscampossonobligatorios).toast(requireContext())
} else {
- val saleGroupSelected =
- collection.tickets.find { it.ticketFk == ticketSelected }?.sales?.get(0)?.saleGroupFk
- ?: 0
- runBlocking {
- viewModel.collectionAddWithReservation(
- customDialogList.getValue().toInt(),
- customDialogList.getValueTwo().toInt(),
- ticketSelected,
- saleGroupFk = saleGroupSelected,
- sectorFk = mobileApplication.dataStoreApp.readDataStoreKey(SECTORFK)
+ viewModel.collectionAddWithReservation(
+ customDialogList.getValue().toInt(),
+ customDialogList.getValueTwo().toInt(),
+ ticketSelected,
+ saleGroupFk = if (type == PREPARED) null else collection.tickets.find { it.ticketFk == ticketSelected }?.sales?.get(
+ 0
+ )?.saleGroupFk
+ ?: 0,
+ sectorFk = if (type == PREPARED) null else mobileApplication.dataStoreApp.readDataStoreKey(
+ SECTORFK
)
- }
+ )
+
customDialogList.dismiss()
- hideKeyboards()
- scanRequest()
+ customDialogList.cancel()
+ binding.scanInput.requestFocus()
+ hideKeyboardFragment()
}
} else {
getString(R.string.scanItem).toast(requireContext())
@@ -1082,6 +914,14 @@ class CollectionFragmentPickerPreviousNew(
}
+ private fun hideKeyboardFragment() {
+ Handler(Looper.getMainLooper()).postDelayed({
+ val inputMethodManager =
+ requireContext().getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager
+ inputMethodManager.hideSoftInputFromWindow(binding.scanInput.windowToken, 0)
+ }, 300L)
+ }
+
private fun toastDisponibility(item: ItemVO) {
if (item.available.isEmpty()) {
item.available = "0"
@@ -1096,27 +936,33 @@ class CollectionFragmentPickerPreviousNew(
}
private fun setTotalLines() {
-
- val totalMark = sales.count { it.isPicked == 1 }
-
+ println("total Mark ${myGroupList.count { it.isPicked == 1 }}")
+ println("total size ${myGroupList.size}")
+ val totalMark = myGroupList.count { it.isPicked == 1 }
binding.mainToolbar.toolbarTitle.text =
if (collection.collectionFk != 0) collection.collectionFk.toString() else ""
-
-
binding.mainToolbar.toolbarSubtitle.text =
- getString(R.string.totalsPicker, totalMark, sales.size)
-
- if (totalMark == sales.size) {
+ getString(R.string.totalsPicker, totalMark, myGroupList.size)
+ if (totalMark == myGroupList.size) {
getString(R.string.Coleccióncompleta).toast(this.context, Toast.LENGTH_SHORT)
- changeTicketState()
+ when (type) {
+ PREPARED -> {
+ tickets.forEach {
+ viewModel.ticketStateTodaySetState(
+ ticketFk = it.toInt(), state = "PREPARED"
+ )
+ }
+ }
+
+ PREITEMPICKERTEST -> {
+ //viewModel.saleTrackingAddPrevOK(collection.collectionFk)
+ viewModel.saleTrackingSectorCollectionAddPrevOK(collection.collectionFk)
+ }
+
+ }
}
}
- private fun changeTicketState() {
-
- viewModel.saleTrackingAddPrevOK(collection.collectionFk)
- }
-
private fun showScanner(index: Int, sale: Sale) {
customDialogInput.getEditText().inputType = InputType.TYPE_CLASS_TEXT
customDialogInput.setTitle("" + sale.itemFk)
@@ -1150,7 +996,6 @@ class CollectionFragmentPickerPreviousNew(
scanInput.requestFocus()
customDialogInput.dismiss()
scanInput.requestFocus()
-
}
private fun showErrorMessage(title: String = getString(R.string.errorMarkLine), text: String) {
@@ -1159,6 +1004,143 @@ class CollectionFragmentPickerPreviousNew(
}.show()
}
+ private fun groupSaleGroup(salesList: ArrayList): MutableList {
+ val myMap = salesList.groupBy { it.saleGroupFk }
+ val myList: MutableList = mutableListOf()
+
+ for ((key, value) in myMap.entries) {
+ if (key == null) { // si no tiene saleGroup se añaden las líneas
+ for (s in value) {
+ myList.add(s)
+ }
+ } else { // si tiene saleGroup se crea el padre con el tamaño e indicando que es padre, como ejemplo se toma el primer elemento
+ /*crea padre*/
+ if (value.size > 1) {
+ val mySale = //= value[0]
+ Sale(
+ level = value[0].level,
+ isPicked = value[0].isPicked,
+ parkingCode = getString(R.string.linesSaelGroup, value.size),
+ pickingOrder = value[0].pickingOrder,
+ workerFk = value[0].workerFk,
+ originalQuantity = value[0].originalQuantity,
+ saleQuantity = 0,
+ saleFk = value[0].saleFk,
+ saleGroupFk = value[0].saleGroupFk,
+ semaphore = value[0].semaphore,
+ ticketFk = value[0].ticketFk,
+ itemFk = value[0].saleGroupFk!!,
+ isAdded = value[0].isAdded,
+ hasMistake = value[0].hasMistake,
+ origin = value[0].origin,
+ size = value[0].size,
+ itemShelvingSaleFk = value[0].itemShelvingSaleFk,
+ longName = value[0].parkingCode ?: "",
+ itemShelvingFk = 0
+ )
+
+ //prime elemento//hay que hacer una copia si no queda la referencia
+ mySale.totalSales = value.size //total líneas
+ mySale.isParent = true
+ value as MutableList
+ mySale.sonSales =
+ value.sortedWith(compareBy { it.isPicked }) as MutableList
+
+ myList.add(mySale)
+ } else {
+ for (s in value) {
+ myList.add(s)
+ }
+ }
+
+ }
+
+ }
+
+ return myList
+ }
+
+ /* FUNCIONES PROPIAS DE LOS SACADORES */
+ private fun verifyCollection() {
+
+ customDialogList.setTitle(
+ getString(R.string.verifyCollection)
+ )
+ customDialogList.setDescription(
+
+ getString(R.string.scanTicketsVerifyCollection, collection.collectionFk)
+ ).setKoButton(getString(R.string.cancel)) {
+ ma.hideKeyboard(customDialogList.getEditText())
+ customDialogList.dismiss()
+ ma.onMyBackPressed()
+ }.setValue("").setOkButton(getString(R.string.print)) {
+ print()
+ }.show()
+
+ customDialogList.getEditText().requestFocus()
+ ma.hideKeyboard(customDialogList.getEditText())
+
+ customDialogList.getEditText().setOnEditorActionListener { v, actionId, event ->
+ if (actionId == EditorInfo.IME_ACTION_SEARCH || actionId == EditorInfo.IME_ACTION_DONE || actionId == 0 || actionId == 5) {
+ if (customDialogList.getValue().isNotEmpty()) {
+ try {
+ customDialogList.setValue(
+ itemScanValue(
+ customDialogList.getValue(), arrayOf("ticket", "saleGroup"), "id"
+ ).toString()
+ )
+
+ val foundTicketInCollection =
+ collection.tickets.find {
+ it.ticketFk == customDialogList.getValue().toInt()
+ }
+ if (foundTicketInCollection != null) {
+ isVerifiedCollection = true
+ ma.hideKeyboard(customDialogList.getEditText())
+ binding.fragmentSacadorCollections.visibility = View.VISIBLE
+ customDialogList.dismiss()
+ binding.scanInput.requestFocus()
+ } else {
+
+ throw Exception(getString(R.string.ticketErrorCollection))
+ }
+
+ } catch (ex: Exception) {
+ ma.messageWithSound(
+ ex.message.toString(), isError = true, isPlayed = true, isToasted = true
+ )
+ }
+
+ }
+ customDialogList.setValue("")
+ ma.hideKeyboard(customDialogList.getEditText())
+ return@setOnEditorActionListener true
+ }
+ false
+ }
+
+
+ customDialogList.getRecyclerView().layoutManager =
+ LinearLayoutManager(requireContext(), LinearLayoutManager.VERTICAL, false)
+
+ }
+
+ private fun print() {
+ if (ma.havePrinter() && ma.haveSector()) {
+ showDialogLabelCount()
+ } else {
+ ma.messageWithSound(
+ getString(R.string.printerFault),
+ isError = true,
+ true,
+ getString(R.string.printError),
+ false
+ )
+
+ }
+
+ }
+
private fun showDialogLabelCount() {
var isTicket = false
for (t in collection.tickets) {
@@ -1175,7 +1157,7 @@ class CollectionFragmentPickerPreviousNew(
collectionFk = collection.collectionFk, labelCount = (which + 1)
)
(getString(R.string.Imprimiendo) + mobileApplication.dataStoreApp.readDataStoreKey(
- PRINTERNAME
+ ConstAndValues.PRINTERNAME
)).toast(requireContext())
}
@@ -1187,9 +1169,5 @@ class CollectionFragmentPickerPreviousNew(
)
}
-
}
-
-}
-
-
+}
\ No newline at end of file
diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/collection/fragment/CollectionFragmentPreCheckerNew.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/collection/fragment/CollectionFragmentPreCheckerNew.kt
deleted file mode 100644
index 11f2b522..00000000
--- a/app/src/main/java/es/verdnatura/presentation/view/feature/collection/fragment/CollectionFragmentPreCheckerNew.kt
+++ /dev/null
@@ -1,1180 +0,0 @@
-package es.verdnatura.presentation.view.feature.collection.fragment
-
-import android.app.AlertDialog
-import android.content.Context
-import android.graphics.drawable.Drawable
-import android.media.MediaPlayer
-import android.os.Bundle
-import android.text.InputType
-import android.view.KeyEvent
-import android.view.View
-import android.view.WindowManager
-import android.view.inputmethod.EditorInfo
-import android.widget.EditText
-import android.widget.ImageView
-import android.widget.Toast
-import androidx.recyclerview.widget.LinearLayoutManager
-import androidx.recyclerview.widget.RecyclerView
-import com.google.gson.Gson
-import es.verdnatura.R
-import es.verdnatura.databinding.FragmentCollectionNewBinding
-import es.verdnatura.domain.ConstAndValues.BASEURLSALIX
-import es.verdnatura.domain.ConstAndValues.PRECHECKERNEW
-import es.verdnatura.domain.ConstAndValues.PRINTERNAME
-import es.verdnatura.domain.ConstAndValues.SECTORFK
-import es.verdnatura.domain.notNull
-import es.verdnatura.domain.toast
-import es.verdnatura.presentation.base.BaseFragment
-import es.verdnatura.presentation.common.ItemScanned
-import es.verdnatura.presentation.common.OnBarcodeRowClickListener
-import es.verdnatura.presentation.common.OnMistakeClickListener
-import es.verdnatura.presentation.common.OnOptionsSelectedListener
-import es.verdnatura.presentation.common.OnPackingClickSaleListener
-import es.verdnatura.presentation.common.OnPasillerosItemClickListener
-import es.verdnatura.presentation.common.OnQuantityClickSaleListener
-import es.verdnatura.presentation.common.OnSaleClickSaleListener
-import es.verdnatura.presentation.common.OnTicketClickSaleListener
-import es.verdnatura.presentation.common.ToolBarAdapterTooltip
-import es.verdnatura.presentation.common.hideKeyboard
-import es.verdnatura.presentation.common.itemScanIsQr
-import es.verdnatura.presentation.common.itemScanValue
-import es.verdnatura.presentation.view.component.CustomDialog
-import es.verdnatura.presentation.view.component.CustomDialogInput
-import es.verdnatura.presentation.view.component.CustomDialogList
-import es.verdnatura.presentation.view.component.CustomDialogThreeButtons
-import es.verdnatura.presentation.view.feature.articulo.adapter.BarcodeAdapter
-import es.verdnatura.presentation.view.feature.articulo.model.BarcodeVO
-import es.verdnatura.presentation.view.feature.collection.ItemVO
-import es.verdnatura.presentation.view.feature.collection.adapter.SaleAdapterNew
-import es.verdnatura.presentation.view.feature.collection.mapper.map
-import es.verdnatura.presentation.view.feature.main.activity.MainActivity
-import es.verdnatura.presentation.view.feature.pasillero.model.PasillerosItemVO
-import es.verdnatura.presentation.view.feature.sacador.model.CollectionTicket
-import es.verdnatura.presentation.view.feature.sacador.model.Sale
-import es.verdnatura.presentation.view.feature.sacador.model.SaleVO
-import kotlinx.coroutines.runBlocking
-import org.json.JSONObject
-
-class CollectionFragmentPreCheckerNew(
- var collection: CollectionTicket?,
- var type: String = PRECHECKERNEW,
- private var hasPickingOrder: Boolean = false
-) : BaseFragment(
- CollectionViewModel::class
-) {
- private var sales: List = listOf()
- private var salesParent: List = listOf()
- private var saleAdapter: SaleAdapterNew? = null
- private var lm: LinearLayoutManager? = null
- private var storedPosition: Int = 0
- private var pasillerosItemClickListener: OnPasillerosItemClickListener? = null
- private lateinit var customDialogList: CustomDialogList
- private var placementSupplyAdapter: BarcodeAdapter? = null
- private var listPlacementSupply: ArrayList = ArrayList()
- private lateinit var customDialogInput: CustomDialogInput
- private lateinit var customDialogThreeButtons: CustomDialogThreeButtons
- private lateinit var customDialogThreeButtonsQuantity: CustomDialogThreeButtons
- private var ticketSelected: Int = 0
- private lateinit var customDialog: CustomDialog
- private var goBack: Boolean = false
- private var goBack2: Boolean = false
- private var goMistakeBack: Boolean = false
- var mperror: MediaPlayer? = null
- var mpok: MediaPlayer? = null
- private var itemShelvingFkStored: Int = 0
- private var storedBackPosition: Int = 0
- private var tickets: ArrayList = ArrayList()
- private var mistakeSale: SaleVO? = null
- private var isMarking = false
- private lateinit var ticketScanTxt: String
- private var lastScanned: Int = 0
- private var buttonPushedGetCollection = false
- private var positionUnmarked = -1
- private var state = 0
- private var originalItemScan: Long = 0
- private var workerFkFromTicket: String? = null
- private var isScanned: Boolean? = null
- private var positionConfirm = 0
- private var quantityConfirm = 0
- private var positionMarkPrevia = 0
- private lateinit var myGroupList: List
- private var quantityReserveToCheckItemScan = 0
-
- companion object {
- fun newInstance(
- collection: CollectionTicket? = null, type: String, hasPickingOrder: Boolean = false
- ) = CollectionFragmentPreCheckerNew(collection, type, hasPickingOrder)
- }
-
- override fun onAttach(context: Context) {
- if (context is OnPasillerosItemClickListener) pasillerosItemClickListener = context
- super.onAttach(context)
- }
-
- override fun getLayoutId(): Int = R.layout.fragment_collection_new
-
- override fun onCreate(savedInstanceState: Bundle?) {
-
- mperror = MediaPlayer.create((activity as MainActivity), R.raw.error)
- mpok = MediaPlayer.create((activity as MainActivity), R.raw.ok)
- println("create onRunning")
-
- super.onCreate(savedInstanceState)
- }
-
- override fun onResume() {
- super.onResume()
- scanRequest()
- }
-
- override fun init() {
- customDialogList = CustomDialogList(requireContext())
- customDialogInput = CustomDialogInput(requireContext())
- customDialog = CustomDialog(requireContext())
- customDialogThreeButtons = CustomDialogThreeButtons(requireContext())
- customDialogThreeButtonsQuantity = CustomDialogThreeButtons(requireContext())
- ma.hideBottomNavigation(View.GONE)
-
- setEvents()
- setToolBar()
- /* viewModel.collectionTicketGetSalix(
- collection.collectionFk, print = false
- )*/
-
- super.init()
- }
-
- override fun onPause() {
- super.onPause()
- goBack = true
- goBack2 = true
- goMistakeBack = true
- }
-
- private fun setToolBar() {
- binding.mainToolbar.toolbarSubtitle.visibility = View.VISIBLE
- binding.mainToolbar.toolbarIcons.visibility = View.VISIBLE
- binding.mainToolbar.backButton.visibility = View.VISIBLE
- collection?.collectionFk.let {
- binding.mainToolbar.toolbarTitle.text = collection?.collectionFk.toString()
- }
-
- val listIcons: ArrayList = ArrayList()
- val iconPrint = ImageView(context)
- iconPrint.setImageResource(R.drawable.ic_print_black_24dp)
- val iconAdd = ImageView(context)
- iconAdd.setImageResource(R.drawable.ic_playlist_add_black_24dp)
- val iconViewCollection = ImageView(context)
- iconViewCollection.setImageResource(R.drawable.ic_collection)
- val iconWorker = ImageView(context)
- iconWorker.setImageResource(R.drawable.ic_worker)
- val iconPhone = ImageView(context)
- iconPhone.setImageResource(R.drawable.phone_call)
- val iconParking = ImageView(context)
- iconParking.setImageResource(R.drawable.ic_local_parking_black_24dp)
- val iconUpdate = ImageView(context)
- iconUpdate.setImageResource(R.drawable.ic_autorenew_black_24dp)
-
- iconPrint.tooltipText = getTooltip(R.drawable.ic_print_black_24dp)
- iconAdd.tooltipText = getTooltip(R.drawable.ic_playlist_add_black_24dp)
- iconViewCollection.tooltipText = getTooltip(R.drawable.ic_collection)
- iconPhone.tooltipText = getTooltip(R.drawable.phone_call)
- iconParking.tooltipText = getTooltip(R.drawable.ic_local_parking_black_24dp)
- iconUpdate.tooltipText = getTooltip(R.drawable.ic_autorenew_black_24dp)
-
- // listIcons.add(iconPrint)
- listIcons.add(iconAdd)
- listIcons.add(iconParking)
- listIcons.add(iconUpdate)
- // listIcons.remove(iconWorker)
-
- binding.mainToolbar.toolbarIcons.adapter =
- ToolBarAdapterTooltip(listIcons, object : OnOptionsSelectedListener {
- override fun onOptionsItemSelected(item: Drawable) {
-
- when (item) {
- //iconViewCollection.drawable -> getCollection()
- iconPrint.drawable -> print()
- iconAdd.drawable -> addItem()
- iconWorker.drawable -> showUser()
- iconUpdate.drawable -> updateScreen()
- iconParking.drawable -> pasillerosItemClickListener?.onPasillerosItemClickListener(
- PasillerosItemVO(
- title = R.string.Parking
- ), ""
- )
- }
-
- }
- })
- binding.mainToolbar.toolbarIcons.layoutManager =
- LinearLayoutManager(requireContext(), LinearLayoutManager.HORIZONTAL, false)
- }
-
- private fun updateScreen() {
- collection?.let {
- viewModel.collectionTicketGetSalix(
- it.collectionFk, print = false
- )
- }
-
- }
-
- private fun markPrevia(saleGroupScanned: String): Boolean {
- println("Sacador saleGroup $saleGroupScanned ")
- try {
- for (indice in sales.indices) {
- println("Sacador saleGroup ${sales[indice].saleGroupFk}")
- if (sales[indice].saleGroupFk != null && sales[indice].saleGroupFk == saleGroupScanned.toInt()) {
- println("Sacador saleGroup ${sales[indice].itemShelvingSaleFk}")
- viewModel.itemShelvingSaleSetSaleGroup(saleGroupScanned.toInt())
- positionMarkPrevia = indice
- mpok!!.start()
- return true
-
- }
- }
- } catch (ex: Exception) {
- return false
- }
- return false
- }
-
- private fun scanRequest() {
- binding.scanInput.requestFocus()
- hideKeyboards()
- }
-
- private fun showUser() {
-
- ma.onPasillerosItemClickListener(
- PasillerosItemVO(title = R.string.titleUserControlVehicle),
- workerFkFromTicket.toString()
- )
-
- }
-
- private fun setEvents() {
-
- binding.mainToolbar.backButton.setOnClickListener {
- println("reserva fuera")
- ma.onMyBackPressed()
- }
- //ESCANER =========
-
- binding.scanInput.requestFocus()
- binding.scanInput.setOnEditorActionListener { v, actionId, event ->
- if (actionId == EditorInfo.IME_ACTION_SEARCH || actionId == EditorInfo.IME_ACTION_DONE || actionId == 0 || actionId == 5) {//ID=0 ACTION_NEXT ID=5 ACTION_UNESPECEFIED)
- if (binding.scanInput.text.toString().isNotEmpty()) {
- binding.scanInput.setText(textScanned_filterDouble(binding.scanInput.text!!.toString()))
- isScanned =
- event != null && event.action == KeyEvent.ACTION_DOWN && event.keyCode == KeyEvent.KEYCODE_ENTER
- if (itemScanIsQr(binding.scanInput.text.toString())) {
- val myQr = ItemScanned(JSONObject(binding.scanInput.text.toString()))
- when (myQr.table) {
- "saleGroup" -> {/* if (type == CONTROLADOR) {
- markPrevia(myQr.id.toString())
- } else {*/
- binding.scanInput.setText(myQr.id.toString())
- //findSale(binding.scanInput.text.toString())
- // }
- }
-
- "buy" -> binding.scanInput.setText(myQr.more)
- }
-
- } else {
- ma.hideKeyboard(binding.scanInput)
- viewModel.collectionTicketGetSalix(
- binding.scanInput.text.toString().toInt(), print = false
- )
- //findSale(binding.scanInput.text.toString())
- }
- buttonPushedGetCollection = false
- }
- binding.scanInput.setText("")
- hideKeyboards()
- return@setOnEditorActionListener true
- }
- true
- }
-
- hideKeyboards()
-
- //LISTA =========
- binding.collectionSwipe.setOnRefreshListener {
- isMarking = false
- binding.collectionSwipe.isRefreshing = false
-
- updateScreen()/* viewModel.collectionTicketGet(
- collection.collectionFk,
- mobileApplication.dataStoreApp.readDataStoreKey(SECTORFK),
- print = "0",
- type
- )*/
- buttonPushedGetCollection = false
- binding.collectionSwipe.isRefreshing = false
-
- }
- }
-
- private fun hideKeyboards() {
- try {
- requireActivity().hideKeyboard()
- } catch (e: Exception) {
- println(e.message)
- }
- }
-
- override fun observeViewModel() {
-
- with(viewModel) {
-
- loadCollectionTicketSalix.observe(viewLifecycleOwner) { event ->
- event.getContentIfNotHandled().notNull {
- if (!it.isError) {
-
- if (it.tickets.isNotEmpty()) {
- collection = it
- createCollectionList()
- workerFkFromTicket = if (it.tickets[0].sales.isNotEmpty()) {
- it.tickets[0].sales[0].workerFk.toString()
- } else {
- ""
- }
-
- } else {
- binding.mainToolbar.toolbarSubtitle.text = "0/0"
- }
- } else {
- customDialog.setTitle(getString(R.string.error))
- .setDescription(it.errorMessage)
- .setOkButton(getString(R.string.accept)) {
- customDialog.dismiss()
- if (activity != null) ma.onMyBackPressed()
- }.show()
- }
-
- }
- }
-
- responseExistsItemShelvingSale.observe(viewLifecycleOwner) {
- if (!goBack) {
- if (it.exists) {
- markLine(it.position, it.quantity, true)
- } else {
- getString(R.string.updateSalesReserve).toast(
- requireContext()
- )
- viewModel.collectionTicketGetSalix(collection!!.collectionFk, false)
- }
- }
-
- }
- responseParking.observe(viewLifecycleOwner) {
- if (!goBack) {
- ma.messageWithSound(
- if (it.isError) it.errorMessage else getString(R.string.Aparcado),
- it.isError,
- true
- )
- }
-
- }
- loadResponseAddItem.observe(viewLifecycleOwner) { event ->
- event.getContentIfNotHandled().notNull {
- updateScreen()
- }
-
- }
-
- responsePrint.observe(viewLifecycleOwner) {
-
- if (!goBack) {
-
- if (it.isError) {
- ma.messageWithSound(
- it.errorMessage, isError = true, true
- )
- } else {
- (getString(R.string.Imprimiendo) + mobileApplication.dataStoreApp.readDataStoreKey(
- PRINTERNAME
- )).toast(
- requireContext()
- )
- }
- }
-
- }
-
- responseConfirmReservedItemShelvingSale.observe(viewLifecycleOwner) {
-
- if (it.isError) {
- ma.messageWithSound(
- it.errorMessage, isError = true, true
- )
- setTotalLines()
- } else {
- myGroupList[positionConfirm].isPicked = 1
- saleAdapter!!.notifyItemChanged(positionConfirm)
- //lolass
- lm!!.scrollToPositionWithOffset(storedBackPosition, 0)
- // lm!!.scrollToPositionWithOffset(storedBackPosition + 1, 0)
-
- setTotalLines()
- viewModel.collectionTicketGetSalix(
- collection!!.collectionFk, print = false
- )
- }
-
- }
-
-
- responseItemShelvingSale.observe(viewLifecycleOwner) {
-
- myGroupList[positionConfirm].isPicked = 1
- myGroupList[positionConfirm].reservedQuantity = quantityConfirm
- viewModel.collectionTicketGetSalix(
- collection!!.collectionFk, print = false
- )
- lm!!.scrollToPositionWithOffset(positionConfirm, 0)
- //saleAdapter!!.notifyDataSetChanged()
- ma.messageWithSound(
- "Confirmada acción", it.isError, !it.isError
- )
- }
- loadUnpicked.observe(viewLifecycleOwner) { event ->
- event.getContentIfNotHandled().notNull {
-
- myGroupList[positionUnmarked].isPicked = 1
- myGroupList[positionUnmarked].reservedQuantity = quantityConfirm
- viewModel.collectionTicketGetSalix(
- collection!!.collectionFk, print = false
- )
- lm!!.scrollToPositionWithOffset(positionUnmarked, 0)
- //saleAdapter!!.notifyDataSetChanged()
- ma.messageWithSound(
- "Confirmada acción", it.isError, !it.isError
- )
- }
- }
- responseItemShelvingSaleGroup.observe(viewLifecycleOwner) {
-
- viewModel.collectionTicketGetSalix(
- collection!!.collectionFk, print = false
- )
- lm!!.scrollToPositionWithOffset(positionMarkPrevia, 0)
-
- ma.messageWithSound(
- getString(R.string.previousCollected), it.isError, !it.isError
- )
- }
-
- responseCode.observe(viewLifecycleOwner) {
-
- if (!goBack2) {
- if (it == null) {
- showErrorMessage(text = getString(R.string.codeNotExist))
- if (mperror != null) mperror?.start()
- } else {
- if (checkItemScan(it.toString())) {
- scanRequest()
- customDialogList.dismiss()
- mpok?.start()
- markLine(storedPosition, quantityReserveToCheckItemScan, null)
- } else {
- customDialogList.setValueTwo("")
- showErrorMessage(text = getString(R.string.lineNotExist))
- if (mperror != null) mperror?.start()
- }
- }
- }
-
- goBack2 = false
-
- }
-
- }
- }
-
- private fun createCollectionList() {
- state = 0
- binding.mainToolbar.toolbarTitle.text = collection?.collectionFk.toString()
-
- collection!!.map(requireContext())
- val salesList: ArrayList = ArrayList()
-
- tickets = ArrayList()
- var observations = ""
- val myPickingFrom = mobileApplication.dataStoreApp.readDataStoreKey("PICKING_FROM")
- val myPickingTo = mobileApplication.dataStoreApp.readDataStoreKey("PICKING_TO")
- collection!!.tickets.forEach { ticket ->
-
- if (observations.isNotEmpty()) observations =
- observations + " " + ticket.observations
- ticket.sales.forEach { sale ->
-
- if (hasPickingOrder) {
- if (sale.pickingOrder != null && sale.pickingOrder in myPickingFrom..myPickingTo) {
- salesList.add(sale)
- }
- } else {
- salesList.add(sale)
- }
-
- }
- }
-
- sales = salesList.sortedWith(compareBy { it.pickingOrder }.thenBy { it.itemFk })
-
- //quitar comentarios FALTA AGRUPAR LAS PREVIAS
- myGroupList =
- salesList.sortedWith(compareBy { it.pickingOrder }.thenBy { it.itemFk })
- // sales //sales porque no se ggrupan las previas hay que cambiar los estados.
-
- saleAdapter = SaleAdapterNew(
- myGroupList,
- pasillerosItemClickListener!!,
- object : OnQuantityClickSaleListener {
-
- override fun onQuantityClick(sale: Sale) {
- sales.forEachIndexed { index, saleVO ->
-
- if (saleVO.saleFk == sale.saleFk) {
- if (sale.isPicked == 1) {
- showErrorMessage(
- title = getString(R.string.info),
- text = getString(R.string.unmarkForModify)
- )
- }
-
- }
- }
-
- }
- },
- object : OnSaleClickSaleListener {
- override fun onSaleClick(sale: Sale) {
-
- val position =
- myGroupList.indexOfFirst { it.itemShelvingSaleFk == sale.itemShelvingSaleFk }
- if (position > -1) {
- if (sale.isPicked == 1) {
- unMarkLine(position, myGroupList[position])
- } else {
- showScanner(position, sale)
- }
- }
-
- /* myGroupList.forEachIndexed { index, sale ->
- //sales.forEachIndexed { index, sale ->
- // println("Sacador la sale es ${sale.saleFk}")
- // println("Sacador la sale picked es ${sale.isPicked}")
- // println("Sacador la sale group es ${sale.saleGroupFk}")
- // println("Sacador la sale reserved es ${sale.reservedQuantity}")
- if (sale.itemShelvingSaleFk == 0) {
- println("Sacador Que hacemos en este caso ?? ")
- } else {
-
-
- if (sale.itemShelvingSaleFk == mysale.itemShelvingSaleFk) {
- println("Sacador **** itemShelvingSale es ${sale.itemShelvingSaleFk}")
- println("Sacador **** isPicked es ${sale.isPicked}")
- println("Sacador **** saleGroup es ${sale.saleGroupFk}")
- //println("Sacador la sale es ${sale.saleFk}")
- //println("Sacador la sale picked es ${sale.isPicked}")
- //println("Sacador la sale group es ${sale.saleGroupFk}")
- //println("Sacador la sale reserved es ${sale.reservedQuantity}")
- //println("Sacador la sale dentro es ${sale.saleFk}")
- if (sale.isPicked != 1 && sale.saleGroupFk == null) {
- println("Sacador **** showScanner")
- showScanner(index, sale)
- } else {
- println("Sacador **** desmarcar")
- unMarkLine(index, myGroupList[index])
- }
-
- }
- }
-
- }*/
- }
-
- },
- object : OnMistakeClickListener {
- override fun onMistakeClickListener(sale: SaleVO) {
- }
- },
- object : OnPackingClickSaleListener {
- override fun onPackingClick(sale: Sale) {
- goBack = true
-
- if (!sale.code.isNullOrEmpty()) ma.onPasillerosItemClickListener(
- PasillerosItemVO(
- title = R.string.titleUbicator,
- ), entryPoint = sale.code
- )
- }
- },
- object : OnTicketClickSaleListener {
- override fun onTicketClickListener(sale: Sale) {
- val entryPoint = Gson().toJson(
- mutableMapOf(
- "entryPoint" to sale.ticketFk, "web" to "${
- mobileApplication.dataStoreApp.readDataStoreKey(
- BASEURLSALIX
- )
- }/#!/ticket/${sale.ticketFk}/sale"
- )
- )
- ma.onPasillerosItemClickListener(
- PasillerosItemVO(
- title = R.string.titleWebViewer,
- ), entryPoint = entryPoint
- )
- }
- },
- type = type
- )
-
-
- lm = LinearLayoutManager(requireContext(), LinearLayoutManager.VERTICAL, false)
- binding.fragmentSacadorCollections.adapter = saleAdapter
- binding.fragmentSacadorCollections.layoutManager = lm
-
- setTotalLines()
- setStoredPosition()
- setScrollListener(lm!!)
- printObservations(observations)
- }
-
- private fun setScrollListener(lm: LinearLayoutManager) {
- binding.fragmentSacadorCollections.clearOnScrollListeners()
- binding.fragmentSacadorCollections.addOnScrollListener(object :
- RecyclerView.OnScrollListener() {
- override fun onScrolled(recyclerView: RecyclerView, dx: Int, dy: Int) {
- storedBackPosition = lm.findFirstVisibleItemPosition()
- super.onScrolled(recyclerView, dx, dy)
- }
- })
- }
-
- private fun printObservations(observations: String) {
- if (observations.trim().isNotEmpty()) {
- customDialog.setTitle(getString(R.string.observations)).setDescription(observations)
- .setOkButton(getString(R.string.accept)) {
- customDialog.hide()
- customDialog.dismiss()
- }.show()
- }
- }
-
- private fun findSale(txtscan: String) {
-
- var isFoundSale = false // markPrevia(txtscan)
-
- //Se busca la matricula en las lineas
- for (indice in myGroupList.indices) {
- if (myGroupList[indice].isPicked != 1 && myGroupList[indice].code != null && myGroupList[indice].code!!.uppercase() == txtscan.uppercase()) {
- mpok!!.start()
- isFoundSale = true
- positionMarkPrevia = indice
- printShelvingResult(indice)
- break
- }
- }
-
- if (!isFoundSale) mperror!!.start()
-
- }
-
- private fun findSale(txtscan: String, position: Int, sale: Sale) {
-
- storedPosition = position
-
- if (sale.code!!.uppercase() == txtscan.uppercase()) {
- mpok!!.start()
- printShelvingResult(position)
- //sale.isPicked = 1
- //saleAdapter!!.notifyItemChanged(position)
- } else {
- mperror!!.start()
- }
-
- }
-
- private fun markLine(position: Int, quantity: Int, isItemShelvingSaleEmpty: Boolean?) {
-
- state = 0
- isScanned = null
- positionConfirm = position
- quantityConfirm = quantity
- isMarking = true
-
- runBlocking {
- var sectorFk = mobileApplication.dataStoreApp.readDataStoreKey(SECTORFK)
- viewModel.itemShelvingSaleSetQuantity(
- myGroupList[position].itemShelvingSaleFk,
- quantity,
- isItemShelvingSaleEmpty,
- sectorFk = if (sectorFk == -1) null else sectorFk
- )
- }
- storedBackPosition = position/* var mySale = myGroupList[position].itemShelvingSaleFk
- for (indice in myGroupList.indices) {
- if (!myGroupList[indice].isParent && myGroupList[indice].itemShelvingSaleFk == mySale) {
- storedBackPosition = indice
- }
- }*/
-
- }
-
- private fun setListPosition() {
-
- if (storedPosition == 0 && storedBackPosition == 0) { // se inicia lista, se busca porqué item vamos.
- for (indice in myGroupList.indices) {
- if (myGroupList[indice].isPicked == 0) {
- //storedPosition = indice
- lm!!.scrollToPositionWithOffset(indice - 1, 0)
- break
- }
- }
-
- } else {
- lm!!.scrollToPositionWithOffset(storedBackPosition, 0)
- }
- }
-
- private fun unMarkLine(position: Int, sale: Sale) {
- state = 0
- customDialog.setTitle(getString(R.string.unmarkLine)).setDescription(
- getString(R.string.goUnmark) + sale.itemFk + getString(
- R.string.sure
- )
- ).setOkButton(getString(R.string.unmark)) {
- if (!sale.isParent && sale.reservedQuantity == 0 && sale.originalQuantity != sale.saleQuantity) {
- getString(R.string.unmarkError).toast(requireContext())
- } else {/* saleAdapter!!.notifyDataSetChanged()
- var mySale = sale.saleFk
- for (indice in myGroupList.indices) {
- if (!myGroupList[indice].isParent && myGroupList[indice].saleFk == mySale) {
- d("VERDNATURA::", "la pos del index de la sale es" + indice)
- storedBackPosition = indice
- }
- }*/
- storedBackPosition = position
- setListPosition()
-
- viewModel.itemShelvingSaleUnpicked(myGroupList[position].itemShelvingSaleFk)
- sale.isPicked = 0
- positionUnmarked = position
- setTotalLines()
- scanRequest()
- }
-
-
- customDialog.dismiss()
- }.setKoButton(getString(R.string.cancel)) {
- scanRequest()
- customDialog.dismiss()
- }.show()
-
- }
-
- //SHELVINGS
-
- private fun printShelvingResult(pos: Int) {
- storedPosition = pos
- customDialogList.getEditTextTwo().inputType = InputType.TYPE_CLASS_TEXT
- customDialogList.getEditTextTwo().setRawInputType(InputType.TYPE_CLASS_NUMBER)
- customDialogList.getEditText().setRawInputType(InputType.TYPE_CLASS_NUMBER)
- customDialogList.getEditTextTwo().requestFocus()
- val shelving = myGroupList[pos].code
- val item = myGroupList[pos].itemFk
- val longName = myGroupList[pos].longName
- val totalReserved = myGroupList[pos].reservedQuantity
- val itemShelvingFk = myGroupList[pos].itemShelvingSaleFk
-
- try {
- customDialogList.setTitle("$shelving($item) $totalReserved de $longName").setOkButton(
- getString(
- R.string.take
- )
- ) {
- customDialogTakeAction(pos, itemShelvingFk, totalReserved, false)
-
- }.setKoButton(getString(R.string.close)) {
- requireActivity().hideKeyboard(customDialogList.getEditTextTwo())
- customDialogList.dismiss()
- scanRequest()
-
- }.setHintValue(getString(R.string.quantitySelect)).setValue(totalReserved.toString())
- .setHintValueTwo(getString(R.string.scanItem)).setValueTwo("").show()
-
- customDialogList.getEditTextTwo().setOnEditorActionListener { v, actionId, event ->
- if (actionId == EditorInfo.IME_ACTION_SEARCH || actionId == EditorInfo.IME_ACTION_DONE || actionId == 0 || actionId == 5) {
-
- customDialogTakeAction(
- pos,
- itemShelvingFk,
- totalReserved,
- event != null && event.action == KeyEvent.ACTION_DOWN && event.keyCode == KeyEvent.KEYCODE_ENTER
- )
-
- return@setOnEditorActionListener true
-
- }
- false
- }
- } catch (e: Exception) {
- ma.messageWithSound(e.message.toString(), isError = true, true)
- }
- }
-
- private fun customDialogTakeAction(
- position: Int, itemShelvingFk: Int, totalReserved: Int, isItemScanned: Boolean?
- ) {
- goBack = false
- isScanned = isItemScanned
- if (customDialogList.getValueTwo().isNotEmpty()) {
-
- customDialogList.setValueTwo(
- itemScanValue(
- customDialogList.getValueTwo(), arrayOf("buy"), "more"
- ).toString()
- )
- val quantityToReserve = customDialogList.getValue().toInt()
-
- if (quantityToReserve < totalReserved) {
-
- if (customDialogList.getValueTwo() in sales[position].Barcodes || customDialogList.getValueTwo() == sales[position].itemFk.toString()) {
- customDialogList.dismiss()
- showQuestionUbicationEmpty(position, quantityToReserve)
- } else {
- ma.messageWithSound(
- message = getString(R.string.errorItem),
- isError = true,
- isPlayed = true,
- isToasted = false
- )
- }
- }
-
- if (quantityToReserve > totalReserved) {
- ma.hideKeyboard(customDialogList.getEditTextTwo())
- getString(R.string.quantityHigh).toast(requireContext())
- }
- if (quantityToReserve == totalReserved) {
- originalItemScan = customDialogList.getValueTwo().toLong()
- if (checkItemScan(customDialogList.getValueTwo())) {
-
- markLine(storedPosition, quantityToReserve, null)
-
- mpok?.start()
- ma.hideKeyboard(customDialogList.getEditTextTwo())
- customDialogList.dismiss()
- scanRequest()
-
- } else {
-
- itemShelvingFkStored = itemShelvingFk
-
- quantityReserveToCheckItemScan = quantityToReserve
- viewModel.getIdFromCodeSalix(
- code = customDialogList.getValueTwo(),
- )
- customDialogList.dismiss()
- }
- }
-
- } else {
- getString(R.string.scanItemValidate).toast(requireContext())
- }
- }
-
- private fun setStoredPosition() {
- setListPosition()/*if (goBack) setListPosition(storedBackPosition, isFromBack) else {
- setListPosition(storedPosition, isFromBack)*/
- }
-
- private fun checkItemScan(valueToCheck: String): Boolean {
-
- val saleToCheck = myGroupList[storedPosition]
- if (saleToCheck.itemFk.toString() == valueToCheck) return true
- else {
- saleToCheck.Barcodes.forEach { barcode ->
- if (barcode == valueToCheck) return true
- }
- }
-
- return false
- }
-
- private fun showQuestionUbicationEmpty(position: Int, quantity: Int = 0) {
-
- customDialogThreeButtonsQuantity.setTitle(
- getString(
- R.string.changeQuantity, quantity, sales[position].itemFk
- )
- ).setDescription(getString(R.string.questionItemShelving, sales[position].itemFk))
- .setValue("").setCustomDialogValue(View.GONE)
- customDialogThreeButtonsQuantity.setOkButtonAdd(text = getString(R.string.yes)) {
- scanRequest()
- customDialogThreeButtonsQuantity.dismiss()
- getString(R.string.errorQuantityShelving).toast(requireContext())
- customDialogThreeButtonsQuantity.dismiss()
- showQuestionUbicationEmpty(position, quantity)
- }.setOkButtonTwo("NO") {
- scanRequest()
- customDialogThreeButtonsQuantity.dismiss()
- if (quantity == 0) {
- viewModel.itemShelvingSaleExists(
- myGroupList[position].itemShelvingSaleFk, position, quantity
- )
- } else {
- markLine(position, quantity, true)
- }
- }.setKoButton(getString(R.string.cancel)) {
- scanRequest()
- customDialogThreeButtonsQuantity.dismiss()
- }.show()
- customDialogThreeButtons.setFocusDialogValue()
- }
-
- //OPTIONS
- private fun print() {
-
- if (ma.havePrinter() && ma.haveSector()) {
- showDialogLabelCount()
-
- } else {
- ma.messageWithSound(
- getString(R.string.printerFault),
- isError = true,
- true,
- getString(R.string.printError),
- false
- )
-
- }
-
- }
-
- private fun addItem() {
- listPlacementSupply = ArrayList()
- collection!!.tickets.forEach {
- listPlacementSupply.add(BarcodeVO(code = it.ticketFk.toString()))
- }
- if (listPlacementSupply.size == 1) {
- ticketSelected = listPlacementSupply[0].code!!.toInt()
- }
- customDialogList.window?.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE)
- customDialogList.getEditTextTwo().inputType = InputType.TYPE_CLASS_NUMBER
- customDialogList.getEditText().setRawInputType(InputType.TYPE_CLASS_NUMBER)
- customDialogList.setTitle(getString(R.string.Agregarartículoparaticket) + " " + ticketSelected)
- .setOkButton(getString(R.string.Agregar)) {
- customDialogAddItem()
- }.setKoButton(getString(R.string.close)) {
- scanRequest()
- customDialogList.dismiss()
- }.setHintValue(getString(R.string.Artículo)).setValue("")
- .setHintValueTwo(getString(R.string.Cantidad)).setValueTwo("").show()
- customDialogList.getEditText().requestFocus()
- requireActivity().hideKeyboard()
-
- customDialogList.getEditText().setOnEditorActionListener { v, actionId, event ->
- if (actionId == EditorInfo.IME_ACTION_SEARCH || actionId == EditorInfo.IME_ACTION_DONE || actionId == 0 || actionId == 5) {
- if (customDialogList.getValue().isNotEmpty()) {
- try {
- customDialogList.setValue(
- itemScanValue(
- customDialogList.getValue(), arrayOf("buy"), "more"
- ).toString()
- )
-
- } catch (e: Exception) {
- ma.messageWithSound(e.message.toString(), isError = true, true)
- }
- customDialogList.getEditTextTwo().requestFocus()
- }
-
- return@setOnEditorActionListener true
-
- }
- false
-
- }
-
-
- customDialogList.getEditTextTwo().setOnEditorActionListener { v, actionId, event ->
- if (actionId == EditorInfo.IME_ACTION_SEARCH || actionId == EditorInfo.IME_ACTION_DONE || actionId == 0 || actionId == 5) {
- customDialogAddItem()
- return@setOnEditorActionListener true
-
- }
- false
- }
-
- placementSupplyAdapter =
- BarcodeAdapter(listPlacementSupply, object : OnBarcodeRowClickListener {
- override fun onBarcodeRowClickListener(item: BarcodeVO) {
- customDialogInput.setTitle(getString(R.string.ArtículoparaTicket) + " " + item.code!!)
- ticketSelected = item.code!!.toInt()
- customDialogList.setTitle(getString(R.string.Agregarartículoparaticket) + " " + ticketSelected)
- }
- }, showDelete = false)
-
- customDialogList.getRecyclerView().adapter = placementSupplyAdapter
-
- customDialogList.getRecyclerView().layoutManager =
- LinearLayoutManager(requireContext(), LinearLayoutManager.VERTICAL, false)
-
- }
-
- private fun customDialogAddItem() {
-
- if (customDialogList.getValueTwo().isNotEmpty()) {
- if (ticketSelected == 0) {
- getString(R.string.Seleccionaunticketdelaista).toast(requireContext())
- } else if (customDialogList.getValue().isEmpty() || customDialogList.getValueTwo()
- .isEmpty()
- ) {
- getString(R.string.Todosloscampossonobligatorios).toast(requireContext())
- } else {
- val saleGroupSelected =
- collection!!.tickets.find { it.ticketFk == ticketSelected }?.sales?.get(0)?.saleGroupFk
- ?: 0
-
- runBlocking {
- viewModel.collectionAddWithReservation(
- customDialogList.getValue().toInt(),
- customDialogList.getValueTwo().toInt(),
- ticketSelected,
- saleGroupFk = saleGroupSelected,
- sectorFk = mobileApplication.dataStoreApp.readDataStoreKey(
- SECTORFK
- )
- )
- }
-
- customDialogList.dismiss()
- hideKeyboards()
- scanRequest()
- }
- } else {
- getString(R.string.scanItem).toast(requireContext())
- }
-
- }
-
- private fun toastDisponibility(item: ItemVO) {
- if (item.available.isEmpty()) {
- item.available = "0"
- }
- customDialog.setTitle(getString(R.string.itemPoints) + item.id)
- .setDescription(getString(R.string.available) + ":" + item.available)
- .setOkButton(getString(R.string.accept)) {
- scanRequest()
- customDialog.dismiss()
- }.show()
-
- }
-
- private fun setTotalLines() {
-
- val totalMark = sales.count { it.isPicked == 1 }
-
- binding.mainToolbar.toolbarTitle.text =
- if (collection!!.collectionFk != 0) collection!!.collectionFk.toString() else ""
-
-
- binding.mainToolbar.toolbarSubtitle.text =
- getString(R.string.totalsPicker, totalMark, sales.size)
-
- if (totalMark == sales.size) {
- getString(R.string.Coleccióncompleta).toast(this.context, Toast.LENGTH_SHORT)
- changeTicketState()
- }
- }
-
- private fun changeTicketState() {
-
- viewModel.saleTrackingAddPrevOK(collection!!.collectionFk)
- }
-
- private fun showScanner(index: Int, sale: Sale) {
- customDialogInput.getEditText().inputType = InputType.TYPE_CLASS_TEXT
- customDialogInput.setTitle("" + sale.itemFk)
- .setDescription(getString(R.string.scanWagonForItem))
- .setOkButton(getString(R.string.accept)) {
- findSaleAction(index, sale)
- }.setKoButton(getString(R.string.cancel)) {
- closeCustomDialog(binding.scanInput, customDialogInput)
- }.setValue("").show()
-
-
- customDialogInput.getEditText().setOnEditorActionListener { v, actionId, event ->
- if (actionId == EditorInfo.IME_ACTION_SEARCH || actionId == EditorInfo.IME_ACTION_DONE || actionId == 0) {
- findSaleAction(index, sale)
- return@setOnEditorActionListener false
- }
- false
- }
- customDialogInput.getEditText().requestFocus()
- }
-
- private fun findSaleAction(index: Int, sale: Sale) {
- if (customDialogInput.getValue().isNotEmpty()) {
- findSale(customDialogInput.getValue(), index, sale)
- }
- closeCustomDialog(binding.scanInput, customDialogInput)
- }
-
- private fun closeCustomDialog(scanInput: EditText, customDialogInput: CustomDialogInput) {
- requireContext().hideKeyboard(customDialogInput.getEditText())
- scanInput.requestFocus()
- customDialogInput.dismiss()
- scanInput.requestFocus()
-
- }
-
- private fun showErrorMessage(title: String = getString(R.string.errorMarkLine), text: String) {
- customDialog.setTitle(title).setDescription(text).setKoButton(getString(R.string.close)) {
- customDialog.dismiss()
- }.show()
- }
-
- private fun showDialogLabelCount() {
- var isTicket = false
- for (t in collection!!.tickets) {
- if (t.ticketFk == (collection!!.collectionFk)) {
- isTicket = true
- }
- }
- if (isTicket) {
- val builder = AlertDialog.Builder(context)
- builder.setTitle(getString(R.string.selectLabeltoPrint))
- val labelCount = arrayOf("1", "2", "3", "4", "5", "6", "7", "8", "9", "10")
- builder.setItems(labelCount) { dialog, which ->
- viewModel.collectionStickerPrint(
- collectionFk = collection!!.collectionFk, labelCount = (which + 1)
- )
- (getString(R.string.Imprimiendo) + mobileApplication.dataStoreApp.readDataStoreKey(
- PRINTERNAME
- )).toast(requireContext())
-
- }
- val dialog = builder.create()
- dialog.show()
- } else {
- viewModel.collectionStickerPrint(
- collectionFk = collection!!.collectionFk, null
- )
-
- }
-
- }
-
-}
-
-
diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/collection/fragment/CollectionViewModel.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/collection/fragment/CollectionViewModel.kt
index a45e1270..10bf08db 100644
--- a/app/src/main/java/es/verdnatura/presentation/view/feature/collection/fragment/CollectionViewModel.kt
+++ b/app/src/main/java/es/verdnatura/presentation/view/feature/collection/fragment/CollectionViewModel.kt
@@ -14,7 +14,7 @@ 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.ResponseItemExistsItemShelvingSale
+import es.verdnatura.presentation.common.ItemShelving
import es.verdnatura.presentation.common.ResponseItemVO
import es.verdnatura.presentation.common.SaleTrackingReplaceSalix
import es.verdnatura.presentation.common.SaleTrackingSalix
@@ -44,14 +44,20 @@ class CollectionViewModel(val context: Context) : BaseViewModel(context) {
val collectionTicketList: LiveData
get() = _collectionTicketList
- private val _responseCollectionId by lazy { MutableLiveData() }
- val responseCollectionId: LiveData
- get() = _responseCollectionId
-
- private val _responseExistsItemShelvingSale by lazy { MutableLiveData() }
- val responseExistsItemShelvingSale: LiveData
+ private val _responseExistsItemShelvingSale by lazy { MutableLiveData() }
+ val responseExistsItemShelvingSale: LiveData
get() = _responseExistsItemShelvingSale
+ val loadExistsResponse: LiveData> =
+ _responseExistsItemShelvingSale.map { Event(it) }
+
+ private val _responseItemShelvingFind by lazy { MutableLiveData() }
+ val responseItemShelvingFind: LiveData
+ get() = _responseItemShelvingFind
+
+ val loadFindItemShelvingResponse: LiveData> =
+ _responseItemShelvingFind.map { Event(it) }
+
private val _collectionTicketSalix by lazy { MutableLiveData() }
val collectionTicketSalix: LiveData
get() = _collectionTicketSalix
@@ -63,10 +69,6 @@ class CollectionViewModel(val context: Context) : BaseViewModel(context) {
val loadCollectionTicketSalix: LiveData> =
_collectionTicketSalix.map { Event(it) }
- private val _collectionTicketListLocal by lazy { MutableLiveData() }
- val collectionTicketListLocal: LiveData
- get() = _collectionTicketListLocal
-
private val _placementSuppleyList by lazy { MutableLiveData() }
val placementSuppleyList: LiveData
get() = _placementSuppleyList
@@ -78,6 +80,8 @@ class CollectionViewModel(val context: Context) : BaseViewModel(context) {
private val _responseSaleMistakeAdd by lazy { MutableLiveData() }
val responseSaleMistakeAdd: LiveData
get() = _responseSaleMistakeAdd
+ val loadSaleMistakeAdd: LiveData> =
+ _responseSaleMistakeAdd.map { Event(it) }
private val _responseItemShelvingSaleSupplyAdd by lazy { MutableLiveData() }
val responseItemShelvingSaleSupplyAdd: LiveData
@@ -91,33 +95,38 @@ class CollectionViewModel(val context: Context) : BaseViewModel(context) {
val responseSaleTracking_mark: LiveData
get() = _responseSaleTracking_mark
- private val _responseConfirmReservedItemShelvingSale by lazy { MutableLiveData() }
- val responseConfirmReservedItemShelvingSale: LiveData
+ private val _responseConfirmReservedItemShelvingSale by lazy { MutableLiveData() }
+ val responseConfirmReservedItemShelvingSale: LiveData
get() = _responseConfirmReservedItemShelvingSale
+ val loadPicked: LiveData> =
+ _responseConfirmReservedItemShelvingSale.map { Event(it) }
+
private val _responseItemShelvingSale by lazy { MutableLiveData() }
val responseItemShelvingSale: LiveData
get() = _responseItemShelvingSale
- private val _responseItemShelvingSaleUnPicked by lazy { MutableLiveData() }
- val responseItemShelvingSaleUnPicked: LiveData
+ private val _responseItemShelvingSaleUnPicked by lazy { MutableLiveData() }
+ val responseItemShelvingSaleUnPicked: LiveData
get() = _responseItemShelvingSaleUnPicked
- val loadUnpicked: LiveData> =
- _responseItemShelvingSaleUnPicked.map { Event(it) }
+ val loadUnpicked: LiveData> = _responseItemShelvingSaleUnPicked.map { Event(it) }
- private val _responseCollectionAddItem by lazy { MutableLiveData() }
- val responseCollectionAddItem: LiveData
+ private val _responseCollectionAddItem by lazy { MutableLiveData() }
+ val responseCollectionAddItem: LiveData
get() = _responseCollectionAddItem
- private val _responseConfirmReservedUpdate by lazy { MutableLiveData() }
- val responseConfirmReservedUpdate: LiveData
- get() = _responseConfirmReservedUpdate
+ private val _responseItemShelvingSaleDelete by lazy { MutableLiveData() }
+ val responseItemShelvingSaleDelete: LiveData = _responseItemShelvingSaleDelete
+ val loadResponseDelete: LiveData> =
+ _responseItemShelvingSaleDelete.map { Event(it) }
private val _responseParking by lazy { MutableLiveData() }
val responseParking: LiveData
get() = _responseParking
+ val loadParking: LiveData> = _responseParking.map { Event(it) }
+
private val _responsePrint by lazy { MutableLiveData() }
val responsePrint: LiveData
get() = _responsePrint
@@ -133,6 +142,8 @@ class CollectionViewModel(val context: Context) : BaseViewModel(context) {
private val _responseTicketState by lazy { MutableLiveData() }
val responseTicketState: LiveData = _responseTicketState
+ val loadTicketState: LiveData> = _responseTicketState.map { Event(it) }
+
private val _responseUsedShelves by lazy { MutableLiveData() }
val responseUsedShelves: LiveData
get() = _responseUsedShelves
@@ -141,26 +152,23 @@ class CollectionViewModel(val context: Context) : BaseViewModel(context) {
val responseSaleGroup: LiveData
get() = _responseSaleGroup
+ val loadResponseSaleGroup: LiveData> =
+ _responseSaleGroup.map { Event(it) }
+
private val _responseItemShelvingSaleGroup by lazy { MutableLiveData() }
val responseItemShelvingSaleGroup: LiveData
get() = _responseItemShelvingSaleGroup
- private val _responsecheckfully by lazy { MutableLiveData() }
- val responsecheckfully: LiveData
- get() = _responsecheckfully
-
private val _responseTicketClosure by lazy { MutableLiveData() }
val responseTicketClosure: LiveData
get() = _responseTicketClosure
+ val loadTicketClousure: LiveData> =
+ _responseTicketClosure.map { Event(it) }
private val _responseCollectionUnchecked by lazy { MutableLiveData() }
val responseCollectionUnchecked: LiveData
get() = _responseCollectionUnchecked
- /* private val _responseMissingTrash by lazy { MutableLiveData() }
- val responseMissingTrash: LiveData
- get() = _responseMissingTrash*/
-
private val _responseSplit by lazy { MutableLiveData() }
val responseSplit: LiveData
get() = _responseSplit
@@ -169,6 +177,8 @@ class CollectionViewModel(val context: Context) : BaseViewModel(context) {
val responseNew: LiveData
get() = _responseNew
+ val loadAddNew: LiveData> = _responseNew.map { Event(it) }
+
private val _responseCode by lazy { MutableLiveData() }
val responseCode: LiveData
get() = _responseCode
@@ -176,6 +186,7 @@ class CollectionViewModel(val context: Context) : BaseViewModel(context) {
private val _responseIncQuantity by lazy { MutableLiveData() }
val responseIncQuantity: LiveData
get() = _responseIncQuantity
+ val loadIncQuantity: LiveData> = _responseIncQuantity.map { Event(it) }
private val _mistakeList by lazy { MutableLiveData() }
val mistakeList: LiveData
@@ -187,7 +198,7 @@ class CollectionViewModel(val context: Context) : BaseViewModel(context) {
val loadResponseDel: LiveData> = _responseDel.map { Event(it) }
- val loadResponseAddItem: LiveData> =
+ val loadResponseAddItem: LiveData> =
_responseCollectionAddItem.map { Event(it) }
val loadResponseSaleTrackingMark: LiveData> =
@@ -301,7 +312,7 @@ class CollectionViewModel(val context: Context) : BaseViewModel(context) {
}
fun itemShelvingSaleExists(
- itemShelvingSaleFk: Number, position: Int, quantity: Int
+ itemShelvingSaleFk: Number, itemShelvingFk: Number, position: Int, quantity: Int
) {
salix.itemShelvingSaleExists(
@@ -309,9 +320,39 @@ class CollectionViewModel(val context: Context) : BaseViewModel(context) {
).enqueue(object : SalixCallback(context) {
override fun onSuccess(response: Response) {
- _responseExistsItemShelvingSale.value = ResponseItemExistsItemShelvingSale(
+
+ if (response.body()!!.entrySet().first().value.asBoolean) {
+ itemShelvingGet(itemShelvingFk, position, quantity)
+ } else {
+ _responseExistsItemShelvingSale.value = false
+ }
+ /*_responseExistsItemShelvingSale.value = ResponseItemExistsItemShelvingSale(
response.body()!!.entrySet().first().value.asBoolean, position, quantity
+ )*/
+ }
+ })
+ }
+
+ fun itemShelvingGet(
+ itemShelvingFk: Number, position: Int, quantity: Int
+
+ ) {
+ salix.itemShelvingGet(
+ id = itemShelvingFk
+ ).enqueue(object : SalixCallback(context) {
+
+ override fun onSuccess(response: Response) {
+ val itemShelving: ItemShelving = response.body()!!
+ itemShelving.position = position
+ itemShelving.quantity = quantity
+ _responseItemShelvingFind.value = ItemShelving(
+ itemShelving.id,
+ itemFk = itemShelving.itemFk,
+ shelvingFk = itemShelving.shelvingFk,
+ position = position,
+ quantity = quantity
)
+
}
})
}
@@ -394,32 +435,33 @@ class CollectionViewModel(val context: Context) : BaseViewModel(context) {
) {
salix.itemShelvingSaleSetquantitySalix(
params = arrayListOf(itemShelvingSaleFk, quantity, isItemShelvingSaleEmpty, sectorFk)
- //salix.itemShelvingSaleSetQuantity(
- // params = ItemShelvingSaleSalix(itemShelvingSaleFk, quantity, isItemShelvingSaleEmpty)
).enqueue(object : SalixCallback(context) {
- override fun onError(t: Throwable) {
- _responseConfirmReservedItemShelvingSale.value = ResponseItemVO(
- isError = true,
- errorMessage = getMessageFromAllResponse(nameofFunction(this), t.message!!)
- )
- }
override fun onSuccess(response: Response) {
- if (!response.isSuccessful) {
- _responseConfirmReservedItemShelvingSale.value = ResponseItemVO(
- isError = true, errorMessage = getMessageFromAllResponse(
- nameofFunction(this), response.message()
- )
- )
- } else {
- _responseConfirmReservedItemShelvingSale.value =
- ResponseItemVO(isError = false, response = "")
+ _responseConfirmReservedItemShelvingSale.value = true
+
+ if (isItemShelvingSaleEmpty == true)
+ _responseCollectionAddItem.value = true
- }
}
})
}
+ fun itemShelvingSaleDeleteIsAdded(
+ itemShelvingSale: Number
+ ) {
+ salix.itemShelvingSaleDeleteAdded(
+ params = arrayListOf(
+ itemShelvingSale
+ )
+ ).enqueue(object : SalixCallback(context) {
+ override fun onSuccess(response: Response) {
+ _responseCollectionAddItem.value = true
+ }
+
+ })
+ }
+
fun collectionAddWithReservation(
item: Int, quantity: Int, ticketSelected: Int, saleGroupFk: Int?, sectorFk: Int?
) {
@@ -429,44 +471,9 @@ class CollectionViewModel(val context: Context) : BaseViewModel(context) {
)
).enqueue(object : SalixCallback(context) {
override fun onSuccess(response: Response) {
- _responseCollectionAddItem.value = ResponseItemVO(isError = false, response = "")
+ _responseCollectionAddItem.value = true
}
- /* override fun onError(t: Throwable) {
- _responseCollectionAddItem.value = ResponseItemVO(
- isError = true,
- errorMessage = getMessageFromAllResponse(nameofFunction(this), t.message!!)
- )
- }*/
-
- })
- }
-
- fun confirmItemShelvingReservedUpdate(
- itemShelvingSaleFk: Int, isPicked: Boolean
- ) {
- salix.itemShelvingsReservedUpdate(
- id = itemShelvingSaleFk, params = hashMapOf("isPicked" to isPicked)
- ).enqueue(object : SalixCallback(context) {
- override fun onError(t: Throwable) {
- _responseConfirmReservedUpdate.value = ResponseItemVO(
- isError = true,
- errorMessage = getMessageFromAllResponse(nameofFunction(this), t.message!!)
- )
- }
-
- override fun onSuccess(response: Response) {
- if (!response.isSuccessful) {
- _responseConfirmReservedUpdate.value = ResponseItemVO(
- isError = true, errorMessage = getMessageFromAllResponse(
- nameofFunction(this), response.message()
- )
- )
- } else {
- _responseConfirmReservedUpdate.value =
- ResponseItemVO(isError = false, response = "")
- }
- }
})
}
@@ -562,15 +569,10 @@ class CollectionViewModel(val context: Context) : BaseViewModel(context) {
itemShelvingSaleFk
)
).enqueue(object : SalixCallback(context) {
- override fun onError(t: Throwable) {
- _responseItemShelvingSaleUnPicked.value = ResponseItemVO(
- isError = true,
- errorMessage = getMessageFromAllResponse(nameofFunction(this), t.message!!)
- )
- }
override fun onSuccess(response: Response) {
- _responseItemShelvingSaleUnPicked.value = ResponseItemVO(isError = false)
+ _responseItemShelvingSaleUnPicked.value = true
+ super.onSuccess(response)
}
})
}
@@ -592,7 +594,7 @@ class CollectionViewModel(val context: Context) : BaseViewModel(context) {
override fun onSuccess(response: Response) {
//Tarea 7926
- updateParkingFromSaleGroup(saleGroupFk)
+ // updateParkingFromSaleGroup(saleGroupFk)
_responseSaleGroup.value = ResponseItemVO(isError = false)
}
})
@@ -602,13 +604,11 @@ class CollectionViewModel(val context: Context) : BaseViewModel(context) {
saleGroupFk: Number
) {
salix.saleGroupUpdate(
- id = saleGroupFk,
- params = hashMapOf("parkingFk" to null)
- )
- .enqueue(object : SalixCallback(context) {
- override fun onSuccess(response: Response) {
- }
- })
+ id = saleGroupFk, params = hashMapOf("parkingFk" to null)
+ ).enqueue(object : SalixCallback(context) {
+ override fun onSuccess(response: Response) {
+ }
+ })
}
fun itemShelvingSaleSetSaleGroup(
@@ -671,20 +671,19 @@ class CollectionViewModel(val context: Context) : BaseViewModel(context) {
SaleTrackingDelSalix(
saleFk = saleFk, stateCodes = listOf("CHECKED", "OK", "PREPARED")
)
- )
- .enqueue(object : SalixCallback(context) {
- override fun onError(t: Throwable) {
- _responseDel.value = ResponseItemVO(
- isError = true,
- errorMessage = getMessageFromAllResponse(nameofFunction(this), t.message!!)
- )
- }
+ ).enqueue(object : SalixCallback(context) {
+ override fun onError(t: Throwable) {
+ _responseDel.value = ResponseItemVO(
+ isError = true,
+ errorMessage = getMessageFromAllResponse(nameofFunction(this), t.message!!)
+ )
+ }
- override fun onSuccess(response: Response) {
- _responseDel.value =
- ResponseItemVO(isError = false, response = response.message())
- }
- })
+ override fun onSuccess(response: Response) {
+ _responseDel.value =
+ ResponseItemVO(isError = false, response = response.message())
+ }
+ })
}
fun itemShelvingUpdateFromSale(
@@ -746,13 +745,12 @@ class CollectionViewModel(val context: Context) : BaseViewModel(context) {
}
fun getIdFromCodeSalix(code: String) {
- getItemFromBarcodeUseCase.execute(code)
- .enqueue(object : SalixCallback(context) {
- override fun onSuccess(response: Response) {
- _responseCode.value = response.body()
+ getItemFromBarcodeUseCase.execute(code).enqueue(object : SalixCallback(context) {
+ override fun onSuccess(response: Response) {
+ _responseCode.value = response.body()
- }
- })
+ }
+ })
}
fun collectionIncreaseQuantitySalix(
@@ -785,9 +783,7 @@ class CollectionViewModel(val context: Context) : BaseViewModel(context) {
salix.saleMistakeAdd(
SaleMistakeSalix(
- userFk = (context as MobileApplication).userId!!,
- saleFk = saleFk,
- typeFk = typeFk
+ userFk = (context as MobileApplication).userId!!, saleFk = saleFk, typeFk = typeFk
)
).enqueue(object : SalixCallback(context) {
override fun onError(t: Throwable) {
@@ -807,25 +803,23 @@ class CollectionViewModel(val context: Context) : BaseViewModel(context) {
}
fun mistakeType() {
- salix.getMistakeTypes()
- .enqueue(object : SalixCallback>(context) {
- override fun onSuccess(response: Response>) {
- if (response.body() != null) {
- _mistakeList.value =
- response.body()?.let { MistakeTypeListVO(it) }
- } else {
- val listError: ArrayList = ArrayList()
- listError.add(MistakeTypeVO(0, ""))
- _mistakeList.value = MistakeTypeListVO(listError)
- }
- }
-
- override fun onError(t: Throwable) {
+ salix.getMistakeTypes().enqueue(object : SalixCallback>(context) {
+ override fun onSuccess(response: Response>) {
+ if (response.body() != null) {
+ _mistakeList.value = response.body()?.let { MistakeTypeListVO(it) }
+ } else {
val listError: ArrayList = ArrayList()
listError.add(MistakeTypeVO(0, ""))
_mistakeList.value = MistakeTypeListVO(listError)
}
- })
+ }
+
+ override fun onError(t: Throwable) {
+ val listError: ArrayList = ArrayList()
+ listError.add(MistakeTypeVO(0, ""))
+ _mistakeList.value = MistakeTypeListVO(listError)
+ }
+ })
}
fun ticketIsOutClosureZone(
@@ -885,9 +879,7 @@ class CollectionViewModel(val context: Context) : BaseViewModel(context) {
override fun onSuccess(response: Response) {
_responseTicketClosure.value = ResponseItemVO(
- isError = false,
- response = response.body()!!.toString(),
- errorMessage = ""
+ isError = false, response = response.body()!!.toString(), errorMessage = ""
)
}
@@ -913,9 +905,7 @@ class CollectionViewModel(val context: Context) : BaseViewModel(context) {
if (response.body() != null) {
_responseCollectionUnchecked.value = ResponseItemVO(
- isError = false,
- response = response.body()!!,
- errorMessage = ""
+ isError = false, response = response.body()!!, errorMessage = ""
)
} else {
_responseCollectionUnchecked.value = ResponseItemVO(
@@ -979,4 +969,28 @@ class CollectionViewModel(val context: Context) : BaseViewModel(context) {
})
}
+ fun saleTrackingSectorCollectionAddPrevOK(
+ sectorCollectionFk: Int
+ ) {
+ salix.saleTrackingSectorCollectionAddPrevOK(arrayListOf(sectorCollectionFk))
+ .enqueue(object : SalixCallback(context) {
+ override fun onError(t: Throwable) {
+ _responseSaleAddPrevOK.value = ResponseItemVO(
+ isError = true, errorMessage = getMessageFromAllResponse(
+ nameofFunction(this), t.message!!
+ )
+ )
+
+ }
+
+ override fun onSuccess(response: Response) {
+ _responseSaleAddPrevOK.value = ResponseItemVO(
+ isError = false, errorMessage = "" + getMessageFromAllResponse(
+ nameofFunction(this), response.message()
+ )
+ )
+ }
+ })
+ }
+
}
diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/controlador/fragment/ControladorFragment.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/controlador/fragment/ControladorFragment.kt
index 3827f7da..b15ed2f5 100644
--- a/app/src/main/java/es/verdnatura/presentation/view/feature/controlador/fragment/ControladorFragment.kt
+++ b/app/src/main/java/es/verdnatura/presentation/view/feature/controlador/fragment/ControladorFragment.kt
@@ -31,7 +31,6 @@ class ControladorFragment :
}
override fun init() {
-
binding.scanInput.visibility = VISIBLE
binding.mainToolbar.toolbarTitle.text = getString(R.string.controlticket)
setEvents()
@@ -107,7 +106,7 @@ class ControladorFragment :
}
responseTicketState.observe(
- viewLifecycleOwner
+ viewLifecycleOwner
) {
if ((it.code == "ON_CHECKING" || it.code == "CHECKED") && it.user.id != mobileApplication.userId) {
val customDialogWarning = CustomDialog(requireContext())
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 d6aa5268..bbed5251 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
@@ -182,11 +182,13 @@ class LoadUnloadFragment(
for (l in list) {
mlist.add(
ExpeditionSalix(
- expeditionFk = l.id, stateCode = if (l.code != state && l.code != "FOUND") {
+ expeditionFk = l.id,
+ stateCode = if (l.code != state && l.code != "FOUND" && l.code != "DELIVERED") {
"LOST"
} else {
l.code
- }, isScanned = l.isScanned
+ },
+ isScanned = l.isScanned
)
)
}
@@ -459,7 +461,9 @@ class LoadUnloadFragment(
binding.expeditionloadunloadRecyclerview.layoutManager =
LinearLayoutManager(requireContext(), LinearLayoutManager.VERTICAL, false)
binding.mainToolbar.toolbarSubtitle.text = getString(
- R.string.summaryCount, myList.filter { it.code == state }.size, myList.size
+ R.string.summaryCount,
+ myList.filter { it.code == state || it.code == "DELIVERED" }.size,
+ myList.size
)
setListPosition(myList)
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 dbb54ca8..6a6b690b 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
@@ -152,7 +152,7 @@ class SummaryFragment(
) {
val listExpedition = list.filter { it.addressFk == address }.map { l ->
ExpeditionSalix(
- expeditionFk = l.id, stateCode = if (l.code == state) {
+ expeditionFk = l.id, stateCode = if (l.code == state && l.code != "DELIVERED") {
state
} else {
"FOUND"
diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/delivery/model/InfoCompany.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/delivery/model/InfoCompany.kt
index 4a560240..aa6b5b14 100644
--- a/app/src/main/java/es/verdnatura/presentation/view/feature/delivery/model/InfoCompany.kt
+++ b/app/src/main/java/es/verdnatura/presentation/view/feature/delivery/model/InfoCompany.kt
@@ -27,7 +27,7 @@ class Expeditions(
class ExpeditionSalix(
val expeditionFk: Number,
- val stateCode: String?,
+ val stateCode: String? = null,
val isScanned: Int? = 0
)
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 60b0463c..db8ace6b 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
@@ -6,8 +6,10 @@ import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.map
import es.verdnatura.R
import es.verdnatura.domain.SalixCallback
+import es.verdnatura.domain.userCases.GetItemFromBarcodeUseCase
import es.verdnatura.presentation.base.BaseViewModel
import es.verdnatura.presentation.common.Event
+import es.verdnatura.presentation.common.ExpeditionPrintOut
import es.verdnatura.presentation.common.ResponseSign
import es.verdnatura.presentation.view.feature.delivery.model.ClientTicketList
import es.verdnatura.presentation.view.feature.delivery.model.ClientTicketSalix
@@ -36,6 +38,13 @@ import java.io.File
class DeliveryViewModel(val context: Context) : BaseViewModel(context) {
+ private val getItemFromBarcodeUseCase = GetItemFromBarcodeUseCase(salix)
+ private val _isBoxPickingInPrintOut by lazy { MutableLiveData() }
+ val isBoxPickingInPrintOut: LiveData = _isBoxPickingInPrintOut
+
+ private val _responseCode by lazy { MutableLiveData() }
+ val responseCode: LiveData = _responseCode
+
private val _expeditionInfoList by lazy { MutableLiveData() }
val expeditionInfoList: LiveData = _expeditionInfoList
@@ -64,6 +73,15 @@ class DeliveryViewModel(val context: Context) : BaseViewModel(context) {
val responseStateAdd: LiveData
get() = _responseStateAdd
+ private val _responseExpeditionStateId by lazy { MutableLiveData() }
+ val responseExpeditionStateId: LiveData = _responseExpeditionStateId
+
+ private val _responseFindExpeditionId by lazy { MutableLiveData() }
+ val responseFindExpeditionId: LiveData = _responseFindExpeditionId
+
+ private val _responseDeleteExpedition by lazy { MutableLiveData() }
+ val responseDeleteExpedition: LiveData = _responseDeleteExpedition
+
private val _responseUpdateRoute by lazy { MutableLiveData() }
val responseUpdateRoute: LiveData
get() = _responseUpdateRoute
@@ -206,8 +224,6 @@ class DeliveryViewModel(val context: Context) : BaseViewModel(context) {
}
fun expeditionStateAddSalix(expeditions: Any) {
-
- // No se quita ResponseItem ya que en caso de fallo hay que guardar datos
salix.addExpeditionState(expeditions).enqueue(object : SalixCallback(context) {
override fun onSuccess(response: Response) {
super.onSuccess(response)
@@ -228,6 +244,53 @@ class DeliveryViewModel(val context: Context) : BaseViewModel(context) {
})
}
+ fun findExpedition(expedition: Number, expeditionStateId: Number) {
+ salix.findExpedition(
+ filter = """{"where":
+ {
+ "expeditionFk":$expedition,
+ "typeFk":$expeditionStateId
+ }
+ }""".trimMargin()
+ ).enqueue(object : SalixCallback(context) {
+ override fun onSuccess(response: Response) {
+ _responseFindExpeditionId.value = 0
+
+ }
+
+ override fun onError(t: Throwable) {
+ _responseFindExpeditionId.value = expedition
+ }
+
+ })
+ }
+
+ fun deleteExpedition(expeditionIds: ArrayList) {
+ salix.deleteExpedition(
+ hashMapOf("expeditionIds" to expeditionIds)
+ ).enqueue(object : SalixCallback(context) {
+ override fun onSuccess(response: Response) {
+ super.onSuccess(response)
+ _responseDeleteExpedition.value = true
+
+ }
+
+ })
+ }
+
+ fun getExpeditionStateId(stateCode: String) {
+
+ salix.getExpeditionStateTypeId(
+ filter = """{"where":{"code":"$stateCode"}}""".trimMargin()
+ ).enqueue(object : SalixCallback(context) {
+ override fun onSuccess(response: Response) {
+ _responseExpeditionStateId.value =
+ response.body()?.toString()?.let { JSONObject(it).getInt("id") }
+ }
+
+ })
+ }
+
fun getInfoFreelance(
userId: Int
) {
@@ -393,6 +456,45 @@ class DeliveryViewModel(val context: Context) : BaseViewModel(context) {
})
}
+
+ fun isBoxPickingInPrintOut(expeditionFk: Long, barcode: String) {
+ getItemFromBarcodeUseCase.execute(barcode).enqueue(object : SalixCallback(context) {
+
+ override fun onSuccess(response: Response) {
+
+ if (response.body() != null) {
+ isBoxPickingOk(
+ itemFk = response.body().toString().toLong(),
+ expeditionFk = expeditionFk
+ )
+ } else {
+ _responseCode.value = false
+ }
+
+ }
+ })
+ }
+
+ fun isBoxPickingOk(
+ expeditionFk: Long, itemFk: Long
+
+ ) {
+
+ salix.isBoxPickingInPrintOut(
+ filter = """{"where":{"expeditionFk":$expeditionFk,"itemFk":$itemFk}}"""
+ ).enqueue(object : SalixCallback(context) {
+
+ override fun onSuccess(response: Response) {
+ _isBoxPickingInPrintOut.value = response.body()
+ }
+
+ override fun onError(t: Throwable) {
+ _isBoxPickingInPrintOut.value = ExpeditionPrintOut(0, 0, false)
+ }
+
+ })
+ }
+
}
fun createJSONObject(listTickets: MutableList, note: String): String {
diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/login/fragment/LoginFragment.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/login/fragment/LoginFragment.kt
index 46615c5f..8aac834e 100644
--- a/app/src/main/java/es/verdnatura/presentation/view/feature/login/fragment/LoginFragment.kt
+++ b/app/src/main/java/es/verdnatura/presentation/view/feature/login/fragment/LoginFragment.kt
@@ -2,8 +2,6 @@ package es.verdnatura.presentation.view.feature.login.fragment
import android.annotation.SuppressLint
import android.content.Intent
-import android.content.pm.PackageInfo
-import android.content.pm.PackageManager
import android.net.Uri
import android.provider.Settings
import android.view.View.GONE
@@ -37,6 +35,7 @@ import es.verdnatura.presentation.view.component.CustomDialogInputThreeValues
import es.verdnatura.presentation.view.component.CustomDialogList
import es.verdnatura.presentation.view.feature.login.adapter.WorkFormAdapter
import es.verdnatura.presentation.view.feature.login.model.WorkForms
+import es.verdnatura.presentation.view.feature.login.model.WorkerData
import es.verdnatura.presentation.view.feature.main.activity.MainActivity
import kotlinx.coroutines.runBlocking
import java.util.Date
@@ -64,6 +63,7 @@ class LoginFragment(private var imageUri: Uri?) :
customDialog = CustomDialog(requireContext())
customDialogInput = CustomDialogInput(requireContext())
//createFolderSerial()
+ setSwitch()
saveIdentifiers()
checkUser()
binding.buttonLogin.setOnClickListener {
@@ -72,31 +72,12 @@ class LoginFragment(private var imageUri: Uri?) :
password = binding.edittextPassword.text.toString()
)
- //Tarea 6868
- /* viewModel.loginApp(
- LoginApp(
- user = binding.edittextUsername.text.toString(),
- password = binding.edittextPassword.text.toString(),
- deviceId = getDevicePDA(),
- androidId = mobileApplication.dataStoreApp.readDataStoreKey(ANDROID_ID),
- versionApp = getInfoVersionNameApp(),
- nameApp = getString(R.string.nameApp),
- )
- )*/
- }
+ }
if (mobileApplication.dataStoreApp.readDataStoreKey(TOKEN)
.isNotBlank() && binding.switchRemember.isChecked
) {
- if (getDevicePDA() != null) {
- viewModel.getSerialNumber(getDevicePDA()!!)
- } else {
- viewModel.getCurrentUserData(
- getString(R.string.logAppName),
- getInfoVersionNameApp(),
- mobileApplication.dataStoreApp.readDataStoreKey(ANDROID_ID),
- )
- }
+ handleUserCall()
}
@@ -143,25 +124,46 @@ class LoginFragment(private var imageUri: Uri?) :
}
binding.edittextUsername.requestFocus()
- binding.textviewRememberPassword.setOnLongClickListener {
- if (getDevicePDA() == 19591) {
- binding.edittextUsername.setText("sergiodt")
- binding.edittextPassword.setText("delatorre.1234")
+ }
+
+ private fun handleUserCall() {
+ val jsonData = mutableMapOf(
+ "androidId" to mobileApplication.androidId,
+ "nameApp" to getString(R.string.nameApp),
+ "versionApp" to getInfoVersionNameApp()
+ )
+ viewModel.handleUser(if (getDevicePDA() != null) {
+ jsonData.apply {
+ this["deviceId"] = getDevicePDA().toString() // Añadir nuevo campo
}
- true
+ } else {
+ jsonData
+ }
+
+ )
+ }
+
+ private fun setSwitch() {
+ binding.switchRemember.setOnCheckedChangeListener { _, isChecked ->
+ runBlocking {
+ mobileApplication.dataStoreApp.editDataStoreKey(
+ REMEMBER, isChecked
+ )
+ }
+
}
}
- private fun getDevicePDA(): Int? {
- return try {
- Settings.Global.getString(
- mobileApplication.contentResolver, Settings.Global.DEVICE_NAME
- ).toInt()
- } catch (ex: Exception) {
- null
- }
+ /* private fun getDevicePDA(): Int? {
+ return try {
+ Settings.Global.getString(
+ mobileApplication.contentResolver, Settings.Global.DEVICE_NAME
+ ).toInt()
+ } catch (ex: Exception) {
+ null
+ }
- }
+ }*/
/* private fun createFolderSerial() {
@@ -311,7 +313,7 @@ class LoginFragment(private var imageUri: Uri?) :
private fun checkUser() {
- if (mobileApplication.dataStoreApp.readDataStoreKey(REMEMBER)) {
+ if (mobileApplication.dataStoreApp.readDataStoreKey(REMEMBER)) {
binding.edittextUsername.setText(
mobileApplication.dataStoreApp.readDataStoreKey(
@@ -330,9 +332,53 @@ class LoginFragment(private var imageUri: Uri?) :
}
+ private fun reviewVersion(it: WorkerData) {
+ if (it.version == getInfoVersionNameApp()) {
+ goToMain()
+ } else {
+ if (binding.edittextServer.text.toString() == "Producción") {
+ mobileApplication.clearApplicationData()
+ }
+ customDialog.setTitle(getString(R.string.Actualizar))
+ .setDescription(getString(R.string.updatemng)).setOkButton(
+ getString(
+ R.string.Actualizar
+ )
+ ) {
+ try {
+ val openURL = Intent(Intent.ACTION_VIEW)
+ openURL.data = Uri.parse(it.url)
+ startActivity(openURL)
+ } catch (ex: Exception) {
+ getString(R.string.problemUpdate).toast(requireActivity())
+ }
+
+ }
+ if (it.isVersionCritical) {
+ customDialog.setDescription(getString(R.string.updatecritical))
+ } else {
+ customDialog.setKoButton(getString(R.string.cancel)) {
+ customDialog.dismiss()
+ goToMain()
+ }
+ }
+ customDialog.show()
+
+ }
+ }
+
override fun observeViewModel() {
with(viewModel) {
+ handleUserResponse.observe(viewLifecycleOwner) {
+ runBlocking {
+ mobileApplication.dataStoreApp.saveWorkerData(
+ it
+ )
+ }
+ reviewVersion(it)
+ }
+
versionAppItem.observe(viewLifecycleOwner) {
if (it.version == getInfoVersionNameApp()) {
@@ -382,8 +428,8 @@ class LoginFragment(private var imageUri: Uri?) :
if (it.vIsAuthorized == "0") {
- customDialog.setTitle(getString(R.string.error))
- .setDescription(it.vMessage!!).setOkButton(getString(R.string.close)) {
+ customDialog.setTitle(getString(R.string.error)).setDescription(it.vMessage!!)
+ .setOkButton(getString(R.string.close)) {
customDialog.dismiss()
}.show()
@@ -424,19 +470,6 @@ class LoginFragment(private var imageUri: Uri?) :
}
}
- /* devicelogresponse.observe(viewLifecycleOwner) {
-
- if (it.isError) {
- customDialog.setTitle(getString(R.string.error)).setDescription(it.errorMessage)
- .setOkButton(
- getString(R.string.accept)
- ) {
- customDialog.dismiss()
- getVersion()
- }.show()
- }
- }*/
-
loginSalixItem.observe(viewLifecycleOwner) {
@@ -483,15 +516,8 @@ class LoginFragment(private var imageUri: Uri?) :
)
}
- if (getDevicePDA() != null) {
- viewModel.getSerialNumber(getDevicePDA()!!)
- } else {
- viewModel.getCurrentUserData(
- getString(R.string.logAppName),
- getInfoVersionNameApp(),
- mobileApplication.dataStoreApp.readDataStoreKey(ANDROID_ID),
- )
- }
+ //Tarea 6868
+ handleUserCall()
}
}
@@ -524,12 +550,12 @@ class LoginFragment(private var imageUri: Uri?) :
Firebase.crashlytics.setUserId(userName)
}
- private fun getInfoVersionNameApp(): String {
- val manager: PackageManager = requireContext().packageManager
- val info: PackageInfo = manager.getPackageInfo(requireContext().packageName, 0)
- mobileApplication.versionName = info.versionName
- return info.versionName
- }
+ /* private fun getInfoVersionNameApp(): String {
+ val manager: PackageManager = requireContext().packageManager
+ val info: PackageInfo = manager.getPackageInfo(requireContext().packageName, 0)
+ mobileApplication.versionName = info.versionName
+ return info.versionName
+ }*/
private fun saveTokenPref(token: String, ttl: Long) {
diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/login/fragment/LoginViewModel.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/login/fragment/LoginViewModel.kt
index 36e62714..9892daf0 100644
--- a/app/src/main/java/es/verdnatura/presentation/view/feature/login/fragment/LoginViewModel.kt
+++ b/app/src/main/java/es/verdnatura/presentation/view/feature/login/fragment/LoginViewModel.kt
@@ -21,14 +21,13 @@ import es.verdnatura.presentation.view.feature.historicoshelvinglog.model.Device
import es.verdnatura.presentation.view.feature.login.model.AccessConfigSalix
import es.verdnatura.presentation.view.feature.login.model.AccessConfigSalixList
import es.verdnatura.presentation.view.feature.login.model.DataUserSalix
-import es.verdnatura.presentation.view.feature.login.model.LoginApp
-import es.verdnatura.presentation.view.feature.login.model.LoginAppData
import es.verdnatura.presentation.view.feature.login.model.LoginDevice
import es.verdnatura.presentation.view.feature.login.model.LoginSalixVO
import es.verdnatura.presentation.view.feature.login.model.OperatorAdd
import es.verdnatura.presentation.view.feature.login.model.OperatorSalix
import es.verdnatura.presentation.view.feature.login.model.RenewToken
import es.verdnatura.presentation.view.feature.login.model.VersionApp
+import es.verdnatura.presentation.view.feature.login.model.WorkerData
import es.verdnatura.presentation.view.feature.paletizador.model.ItemsExpeditionDynamics
import kotlinx.coroutines.runBlocking
import retrofit2.Response
@@ -40,8 +39,8 @@ class LoginViewModel(val context: Context) : BaseViewModel(context) {
val loginSalixItem: LiveData
get() = _loginSalixItem
- private val _loginApp by lazy { MutableLiveData() }
- val loginApp: LiveData = _loginApp
+ private val _handleUserResponse by lazy { MutableLiveData() }
+ val handleUserResponse: LiveData = _handleUserResponse
private val _serialNumber by lazy { MutableLiveData() }
val serialNumber: LiveData = _serialNumber
@@ -133,27 +132,17 @@ class LoginViewModel(val context: Context) : BaseViewModel(context) {
})
}
- fun loginApp(
- login: LoginApp,
-
- ) {
- salix.handleUser(login).enqueue(object : SalixCallback(context) {
- override fun onSuccess(response: Response) {
-
- _loginApp.value = response.body()
+ fun handleUser(
+ login: MutableMap
+ ) {
+ salix.handleUser(login).enqueue(object : SalixCallback(context) {
+ override fun onSuccess(response: Response) {
+ app.userName = response.body()?.nickname
+ app.userId = response.body()?.id
+ app.serialNumber = response.body()?.serialNumber
+ _handleUserResponse.value = response.body()
}
- override fun onError(t: Throwable) {/* val loginSalixVO = LoginAppData(
- user,
- password,
- "",
- isError = true,
- errorMessage = getMessageFromAllResponse(
- nameofFunction(this), t.message!!
- )
- )
- _loginSalixItem.value = loginSalixVO*/
- }
})
}
diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/login/model/LoginItemVO.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/login/model/LoginItemVO.kt
index bc52b077..89f4beca 100644
--- a/app/src/main/java/es/verdnatura/presentation/view/feature/login/model/LoginItemVO.kt
+++ b/app/src/main/java/es/verdnatura/presentation/view/feature/login/model/LoginItemVO.kt
@@ -10,35 +10,31 @@ class LoginSalixVO(
var errorMessage: String = ""
)
-data class LoginApp(
- val user: String,
- val password: String,
- val deviceId: Int?,
- val androidId: String,
- val versionApp: String,
- val nameApp: String
-
-)
-
-data class LoginAppData(
- val id: Int,
- val token: String,
- val ttl: Long,
+data class WorkerData(
val numberOfWagons: Int,
- var warehouseFk: Int,
+ val trainFk: Int,
val itemPackingTypeFk: String,
+ val warehouseFk: Int,
+ val labelerFk: Int,
+ val sectorFk: Int,
+ val sector: Sector?,
val printer: Printer,
val train: Train,
- val sector: Sector,
+ val id: Int,
val name: String,
val nickname: String,
- val serialNumber: String,
val isVersionCritical: Boolean,
val version: String,
- val vIsAuthorized: String,
- val vMessage: String,
+ val url: String?,
+ val message: String?,
+ val serialNumber: String,
+ val isOnReservationMode: Boolean = false
)
+data class Printer(val id: Int, val name: String)
+
+data class Train(val id: Int, val name: String)
+
class DataUserSalix(
val id: Int? = null,
val name: String = "",
@@ -76,12 +72,10 @@ data class Sector(
val id: Int = 0,
val description: String = "",
val warehouseFk: Int = 0,
- val backupPrinterFk: Int?
+ val backupPrinterFk: Int?,
+ val isOnReservationMode: Boolean? = false
)
-data class Printer(val id: Int, val name: String)
-data class Train(val id: Int, val name: String)
-
class AccessConfigSalix(
val id: Number = 0,
val renewPeriod: Long = 0,
diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/main/activity/MainActivity.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/main/activity/MainActivity.kt
index 77ad4f90..70a074de 100644
--- a/app/src/main/java/es/verdnatura/presentation/view/feature/main/activity/MainActivity.kt
+++ b/app/src/main/java/es/verdnatura/presentation/view/feature/main/activity/MainActivity.kt
@@ -20,14 +20,16 @@ import com.google.android.material.navigation.NavigationBarView
import es.verdnatura.MobileApplication
import es.verdnatura.R
import es.verdnatura.databinding.ActivityMainBinding
+import es.verdnatura.domain.ConstAndValues.CONTROLADOR
import es.verdnatura.domain.ConstAndValues.MAINACTIVITY
import es.verdnatura.domain.ConstAndValues.MENUBYDEFAULTSELECTED
-import es.verdnatura.domain.ConstAndValues.PRECHECKERNEW
import es.verdnatura.domain.ConstAndValues.PREITEMPICKER
+import es.verdnatura.domain.ConstAndValues.PREITEMPICKERTEST
import es.verdnatura.domain.ConstAndValues.PRINTERFK
import es.verdnatura.domain.ConstAndValues.PRINTERFKDEFAULT
import es.verdnatura.domain.ConstAndValues.RENEWINTERVAL
import es.verdnatura.domain.ConstAndValues.RENEWPERIOD
+import es.verdnatura.domain.ConstAndValues.SACADOR
import es.verdnatura.domain.ConstAndValues.SECTORFK
import es.verdnatura.domain.ConstAndValues.SECTORFKDEFAULT
import es.verdnatura.domain.ConstAndValues.TOKEN
@@ -63,13 +65,12 @@ import es.verdnatura.presentation.view.feature.claim.fragment.reubication.fragme
import es.verdnatura.presentation.view.feature.claim.fragment.reubication.model.Reubication
import es.verdnatura.presentation.view.feature.claim.fragment.ubication.ClaimUbicationFragment
import es.verdnatura.presentation.view.feature.collection.fragment.CollectionFragment
+import es.verdnatura.presentation.view.feature.collection.fragment.CollectionFragmentChecker
+import es.verdnatura.presentation.view.feature.collection.fragment.CollectionFragmentCheckerPreviousNew
import es.verdnatura.presentation.view.feature.collection.fragment.CollectionFragmentPicker
-import es.verdnatura.presentation.view.feature.collection.fragment.CollectionFragmentPickerNew
import es.verdnatura.presentation.view.feature.collection.fragment.CollectionFragmentPickerPreviousNew
import es.verdnatura.presentation.view.feature.collection.fragment.CollectionFragmentPreChecker
-import es.verdnatura.presentation.view.feature.collection.fragment.CollectionFragmentPreCheckerNew
import es.verdnatura.presentation.view.feature.collection.fragment.CollectionShowTicketFragment
-import es.verdnatura.presentation.view.feature.controlador.fragment.ControladorFragment
import es.verdnatura.presentation.view.feature.controlvehiculo.fragment.ControlVehiculoFragment
import es.verdnatura.presentation.view.feature.controlvehiculo.fragment.ControlVehiculoUsuarioFragment
import es.verdnatura.presentation.view.feature.delivery.fragments.InfoFragment
@@ -96,6 +97,7 @@ import es.verdnatura.presentation.view.feature.packaging.fragment.PackagingSumma
import es.verdnatura.presentation.view.feature.packaging.fragment.SupplierFragment
import es.verdnatura.presentation.view.feature.packingHolland.fragment.PackingHollandFragment
import es.verdnatura.presentation.view.feature.paletizador.fragment.CmrExpeditionPalletFragment
+import es.verdnatura.presentation.view.feature.paletizador.fragment.ExpeditionDeleteFragment
import es.verdnatura.presentation.view.feature.paletizador.fragment.ExpeditionPalletDetailFragment
import es.verdnatura.presentation.view.feature.paletizador.fragment.ExpeditionPalletFragment
import es.verdnatura.presentation.view.feature.paletizador.fragment.ExpeditionPreparedStateFragment
@@ -116,6 +118,7 @@ import es.verdnatura.presentation.view.feature.precontrol.PreControladorFragment
import es.verdnatura.presentation.view.feature.presacador.fragment.EndSacadorFragment
import es.verdnatura.presentation.view.feature.presacador.fragment.SectorCollectionReserveFragment
import es.verdnatura.presentation.view.feature.qr.QrFragment
+import es.verdnatura.presentation.view.feature.restaurant.RestaurantActivity
import es.verdnatura.presentation.view.feature.roadmap.fragment.RoadMapListFragment
import es.verdnatura.presentation.view.feature.roadmap.fragment.RoadMapSettingsFragment
import es.verdnatura.presentation.view.feature.roadmap.fragment.StopMapListFragment
@@ -513,8 +516,9 @@ class MainActivity : BaseActivity(), OnPasillerosItemClickL
}
getString(R.string.historicals) -> {
+
addFragmentOnTop(
- PasilleroFragment.newInstance(itemTitle, isInitMenu = false),
+ PasilleroFragment.newInstance(itemTitle, isInitMenu = false)
)
}
@@ -536,19 +540,36 @@ class MainActivity : BaseActivity