refs #4021 feat:packaging

This commit is contained in:
Sergio De la torre 2024-03-12 07:32:12 +01:00
parent 669b05826e
commit 317aae6286
18 changed files with 305 additions and 162 deletions

View File

@ -37,6 +37,7 @@ object ConstAndValues {
const val WORKFORMSELECTED = "workFormSelected"
const val SUPPLIERID = "SUPPLIERID"
const val SUPPLIERNAME = "SUPPLIERNAME"
const val ENTRYID = "ENTRYID"
const val ITEMPACKING = "itemPackingType"
const val ITEMPACKINGFK = "itemPackingTypeFk"
const val BUYER = "buyernickname"

View File

@ -42,6 +42,8 @@ import es.verdnatura.presentation.view.feature.main.model.WorkerActionSalix
import es.verdnatura.presentation.view.feature.packaging.model.EntrySalix
import es.verdnatura.presentation.view.feature.packaging.model.ItemSupplier
import es.verdnatura.presentation.view.feature.packaging.model.Supplier
import es.verdnatura.presentation.view.feature.packaging.model.notificationQueue
import es.verdnatura.presentation.view.feature.packaging.model.obervationEntry
import es.verdnatura.presentation.view.feature.paletizador.model.ItemExpeditionScanVO
import es.verdnatura.presentation.view.feature.paletizador.model.ItemExpeditionTruckVO
import es.verdnatura.presentation.view.feature.paletizador.model.ItemPalletVO
@ -50,13 +52,31 @@ import es.verdnatura.presentation.view.feature.paletizador.model.ItemScanVO
import es.verdnatura.presentation.view.feature.presacador.model.PreSacadorItemVO
import es.verdnatura.presentation.view.feature.reubication.model.Reubication
import es.verdnatura.presentation.view.feature.sacador.model.CollectionTicket
import es.verdnatura.presentation.view.feature.packaging.model.*
import es.verdnatura.presentation.view.feature.sacador.model.CollectionVO
import es.verdnatura.presentation.view.feature.sacador.model.MistakeTypeVO
import es.verdnatura.presentation.view.feature.sacador.model.PlacementSupplyVO
import es.verdnatura.presentation.view.feature.sacador.model.TicketStateSalix
import es.verdnatura.presentation.view.feature.ubicador.model.ItemUbicador
import es.verdnatura.presentation.view.feature.ubicador.model.ItemUbicadorVO
import es.verdnatura.presentation.view.feature.workermistake.model.DepartmentMistake
import es.verdnatura.presentation.view.feature.workermistake.model.ExpeditionMistakeSalix
import es.verdnatura.presentation.view.feature.workermistake.model.MistakeType
import es.verdnatura.presentation.view.feature.workermistake.model.SaleMistakeSalix
import es.verdnatura.presentation.view.feature.workermistake.model.WorkerFromMistake
import es.verdnatura.presentation.view.feature.workermistake.model.WorkerMistakeSalix
import okhttp3.MultipartBody
import org.json.JSONObject
import retrofit2.Call
import retrofit2.http.*
import retrofit2.http.Body
import retrofit2.http.DELETE
import retrofit2.http.GET
import retrofit2.http.Multipart
import retrofit2.http.PATCH
import retrofit2.http.POST
import retrofit2.http.PUT
import retrofit2.http.Part
import retrofit2.http.Path
import retrofit2.http.Query
import retrofit2.http.QueryMap
interface SalixService {
@ -749,8 +769,9 @@ interface SalixService {
): Call<Any>
//DE MOMENTO NO FUNCIONA, SE QUERÍA AÑADIR POR INSERTIGNORE
@POST("Operators/add")
@POST("Operators")
fun operatorAdd(
@Body params: Any
): Call<Any>
@POST("DeviceLogs")
@ -796,8 +817,10 @@ interface SalixService {
@GET("Suppliers")//REVISADA
fun getSuppliers(
//@Query("filter") filter:String="""{"fields":{"id":true,"name":true}}"""
//@Body params:JSONObject=JSONObject("""filter"={"fields":{"id":true,"name":true},"include":[{"relation":"contacts","scope":{"fields":["email"],"order":"id DESC","limit":1,"where":{"email":{"neq":null}}}}]}""")
/* @Query("filter") filter:String="{\"fields\":{\"id\":true,\"name\":true},\"include\":[{\"relation\":\"contacts\"," +
@Query("filter") filter:String = """{"fields":{"id":true,"name":true},"order":"name ASC","where":{"isActive":1,"name":{"neq":null}}, "include":[{"relation":"contacts","scope":{"fields":["email"],"where":{"email":{"neq":null}}}}]}"""
/* @Query("filter") filter:String="{\"fields\":{\"id\":true,\"name\":true},\"include\":[{\"relation\":\"contacts\"," +
"\"scope\":{" +
"\"fields\":[\"email\"],\"order\":\"id DESC\",\"limit\":1," +
"\"where\":{ \"email\":{\"neq\":null } }}}]})"*/
@ -833,6 +856,7 @@ interface SalixService {
):
Call<EntrySalix>
@PATCH("Entries/{entryId}")//REVISADA
fun entry_updateObserv(
@Path("entryId") entryId:Int,

View File

@ -217,3 +217,14 @@ fun PackageManager.getPackageInfoCompat(packageName: String, flags: Int = 0): Pa
} else {
@Suppress("DEPRECATION") getPackageInfo(packageName, flags)
}
fun convertToDateString(date: String?): String? {
if (date.isNullOrEmpty()) {
return date
}
val formatoEntrada = SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'") // Formato de entrada
val formatoSalida = SimpleDateFormat("yyyy-MM-dd") // Formato de salida
val fechaDate = formatoEntrada.parse(date) // Convertir fecha de String a objeto Date
return formatoSalida.format(fechaDate) // Convertir fecha a String con formato deseado
}

View File

@ -13,6 +13,11 @@ import com.esafirm.imagepicker.features.registerImagePicker
import com.esafirm.imagepicker.model.Image
import es.verdnatura.R
import es.verdnatura.databinding.FragmentPackagingObsBinding
import es.verdnatura.domain.ConstAndValues.ENTRYID
import es.verdnatura.domain.ConstAndValues.ENTRYNUMBERIMAGES
import es.verdnatura.domain.ConstAndValues.ENTRYOBSERVATIONS
import es.verdnatura.domain.ConstAndValues.ENTRYTYPE
import es.verdnatura.domain.ConstAndValues.SUPPLIERNAME
import es.verdnatura.presentation.base.BaseFragment
import es.verdnatura.presentation.common.*
import es.verdnatura.presentation.view.component.CustomDialog
@ -20,7 +25,7 @@ import es.verdnatura.presentation.view.component.CustomDialogList
import es.verdnatura.presentation.view.feature.packaging.adapter.ListImageAdapter
import es.verdnatura.presentation.view.feature.packaging.fragment.PackagingViewModel.PackagingViewModel
import es.verdnatura.presentation.view.feature.pasillero.model.PasillerosItemVO
import kotlinx.coroutines.runBlocking
@Suppress("UNUSED_ANONYMOUS_PARAMETER")
class ObservFragment(
@ -58,7 +63,11 @@ class ObservFragment(
private fun setToolBar() {
binding.mainToolbar.toolbarTitle.text = getData("ENTRYTYPE") + ": " + getData("SUPPLIERNAME")
binding.mainToolbar.toolbarTitle.text = buildString {
append(mobileApplication.dataStoreApp.readDataStoreKey<String>(ENTRYTYPE))
append(": ")
append(mobileApplication.dataStoreApp.readDataStoreKey<String>(SUPPLIERNAME))
}
val listIcons: ArrayList<ImageView> = ArrayList()
val iconNext = ImageView(context)
@ -72,16 +81,14 @@ class ObservFragment(
override fun onOptionsItemSelected(item: Drawable) {
when (item) {
iconNext.drawable -> {
saveData(
"ENTRYNUMBERIMAGES",
if (listImages.isNullOrEmpty()) "0" else {
listImages!!.size.toString()
}
)
saveData("ENTRYOBSERVATIONS",binding.observations.text.toString() )
viewModel.entry_updateObserv(getDataInt("ENTRYID"),binding.observations.text.toString())
runBlocking {
mobileApplication.dataStoreApp.editDataStoreKey(ENTRYNUMBERIMAGES,
if (listImages.isNullOrEmpty()) 0 else {
listImages!!.size
} )
mobileApplication.dataStoreApp.editDataStoreKey(ENTRYOBSERVATIONS,binding.observations.text.toString())
}
viewModel.entry_updateObserv(mobileApplication.dataStoreApp.readDataStoreKey(ENTRYID),binding.observations.text.toString())
ma.onPasillerosItemClickListener(
PasillerosItemVO(title = getString(R.string.titlePackagingSummary)),
getString(R.string.titlePackagingSummary)
@ -158,10 +165,21 @@ class ObservFragment(
adapterListImage =
ListImageAdapter(list, object : OnImageUpdateClickListener {
//http://localhost:3000/api/Entries/1/uploadFile?warehouseId=1&companyId=442&dmsTypeId=21&reference=1&description
// ="Example description"&hasFile=false (tiene que ser de tipo Multipart y llevar adjunto un fichero)
override fun OnImageUpdateClickListener(item: Any) {
d("VERDNATURA::", "Seleccionado update" + (item as Image).name)
}
println("a subir imagen")
/* viewModel.entry_uploadPhotoSalix(
warehouseId = mobileApplication.dataStoreApp.readDataStoreKey<Int>(
WAREHOUSEFK),
companyId = 442,
dmsTypeId = 21,
reference = mobileApplication.dataStoreApp.readDataStoreKey<String>(ENTRYID).toString(),
description = "Entry id",
hasFile = false,
file= MultipartBody.Part
)*/
}
}, object : OnImageTrashClickListener {
override fun OnImageTrashClickListener(item: Any) {
d("VERDNATURA::", "Seleccionado trash" + (item as Image).name)

View File

@ -40,9 +40,9 @@ class PackagingCountFragment(
override fun init() {
binding.splashProgress.visibility = View.VISIBLE
// binding.splashProgress.visibility = View.VISIBLE
viewModel.getItemsPackaging(
getDataInt("SUPPLIERID"), getDataInt("ENTRYID")
mobileApplication.dataStoreApp.readDataStoreKey("SUPPLIERID"), mobileApplication.dataStoreApp.readDataStoreKey("ENTRYID")
)
customDialogInput = CustomDialogInput(requireContext())
customDialog = CustomDialog(requireContext())
@ -55,7 +55,8 @@ class PackagingCountFragment(
private fun setToolBar() {
binding.mainToolbar.toolbarTitle.text =
"${getData("ENTRYTYPE")}: ${getData("SUPPLIERNAME")}"
"${mobileApplication.dataStoreApp.readDataStoreKey<String>("ENTRYTYPE")}:" +
" ${mobileApplication.dataStoreApp.readDataStoreKey<String>("SUPPLIERNAME")}"
val listIcons: ArrayList<ImageView> = ArrayList()
val iconNext = ImageView(context)
@ -100,20 +101,19 @@ class PackagingCountFragment(
entryAdd.observe(viewLifecycleOwner) {
if (it.isError) {
binding.splashProgress.visibility = View.INVISIBLE
//binding.splashProgress.visibility = View.INVISIBLE
ma.messageWithSound(it.errorMessage, true, true)
} else {
ma.messageWithSound(it.errorMessage, false, true)
binding.splashProgress.visibility = View.VISIBLE
//binding.splashProgress.visibility = View.VISIBLE
viewModel.getItemsPackaging(
getDataInt("SUPPLIERID"), getDataInt("ENTRYID")
)
mobileApplication.dataStoreApp.readDataStoreKey("SUPPLIERID"), mobileApplication.dataStoreApp.readDataStoreKey("ENTRYID"))
}
}
itemSupplierList.observe(viewLifecycleOwner) {
binding.splashProgress.visibility = View.GONE
//binding.splashProgress.visibility = View.GONE
adapteritemsupplier =
ItemSupplierAdapter(it.list, object : OnImageUpdateClickListener {
@ -152,17 +152,17 @@ class PackagingCountFragment(
customDialogInput.setTitle(getString(R.string.quantityReviewed))
.setDescription(getString(R.string.Indicanuevacantidad))
.setOkButton(getString(R.string.accept)) {
if (!customDialogInput.getValue().isEmpty()) {
if (customDialogInput.getValue().isNotEmpty()) {
requireActivity().hideKeyboard()
}
binding.splashProgress.visibility = View.VISIBLE
//binding.splashProgress.visibility = View.VISIBLE
viewModel.entry_addFromBuy(
getDataInt("ENTRYID"), item = item.id!!.toInt(),
(if (getData("ENTRYTYPE") == "Rec") {
mobileApplication.dataStoreApp.readDataStoreKey<Int>("ENTRYID"), item = item.id!!.toInt(),
(if (mobileApplication.dataStoreApp.readDataStoreKey<String>("ENTRYTYPE") == "Rec") {
(item.printedStickers.plus(customDialogInput.getValue().toInt()))
} else {
item.printedStickers.plus(customDialogInput.getValue().toInt() * -1)
item.printedStickers.plus(customDialogInput.getValue().toInt())
}) as Number
)
customDialog.cancel()
@ -190,9 +190,9 @@ class PackagingCountFragment(
) {
customDialog.cancel()
customDialog.dismiss()
binding.splashProgress.visibility = View.VISIBLE
//binding.splashProgress.visibility = View.VISIBLE
viewModel.entry_addFromBuy(
getDataInt("ENTRYID"), item = item.id!!.toInt(),
mobileApplication.dataStoreApp.readDataStoreKey("ENTRYID"), item = item.id!!.toInt(),
0
)
}

View File

@ -7,6 +7,12 @@ import android.widget.ImageView
import androidx.recyclerview.widget.LinearLayoutManager
import es.verdnatura.R
import es.verdnatura.databinding.FragmentPackagingSummaryBinding
import es.verdnatura.domain.ConstAndValues.ENTRYID
import es.verdnatura.domain.ConstAndValues.ENTRYNUMBERIMAGES
import es.verdnatura.domain.ConstAndValues.ENTRYOBSERVATIONS
import es.verdnatura.domain.ConstAndValues.ENTRYTYPE
import es.verdnatura.domain.ConstAndValues.SUPPLIERID
import es.verdnatura.domain.ConstAndValues.SUPPLIERNAME
import es.verdnatura.presentation.base.BaseFragment
import es.verdnatura.presentation.common.*
import es.verdnatura.presentation.view.component.CustomDialog
@ -34,12 +40,12 @@ class PackagingSummaryFragment(
override fun init() {
customDialog = CustomDialog(requireContext())
binding.totalImages.text = getData("ENTRYNUMBERIMAGES")
binding.observations.text = getData("ENTRYOBSERVATIONS")
binding.totalImages.text = mobileApplication.dataStoreApp.readDataStoreKey<Int>(ENTRYNUMBERIMAGES).toString()
binding.observations.text = mobileApplication.dataStoreApp.readDataStoreKey<String>(ENTRYOBSERVATIONS)
binding.splashProgress.visibility = View.VISIBLE
viewModel.getItemsPackaging(
getDataInt("SUPPLIERID"), getDataInt("ENTRYID")
mobileApplication.dataStoreApp.readDataStoreKey(SUPPLIERID), mobileApplication.dataStoreApp.readDataStoreKey(ENTRYID)
)
ma.hideBottomNavigation(View.GONE)
@ -51,7 +57,11 @@ class PackagingSummaryFragment(
private fun setToolBar() {
binding.mainToolbar.toolbarTitle.text = getData("ENTRYTYPE") + ": " + getData("SUPPLIERNAME")
binding.mainToolbar.toolbarTitle.text = buildString {
append(mobileApplication.dataStoreApp.readDataStoreKey<String>(ENTRYTYPE))
append(": ")
append(mobileApplication.dataStoreApp.readDataStoreKey<String>(SUPPLIERNAME))
}
val listIcons: ArrayList<ImageView> = ArrayList()
val iconConfirm = ImageView(context)
@ -113,7 +123,7 @@ class PackagingSummaryFragment(
R.string.accept
)
) {
viewModel.notificationQueues("modified-entry",getDataInt(USERFK),"""{"url":"${getData("base_urlSalix")}/#!/entry/${getDataInt("ENTRYID")}/summary"}""")
viewModel.notificationQueues("modified-entry",mobileApplication.userId!!,"""{"url":"${mobileApplication.dataStoreApp.readDataStoreKey<String>("base_urlSalix")}/#!/entry/${mobileApplication.dataStoreApp.readDataStoreKey<Int>("ENTRYID")}/summary"}""")
customDialog.dismiss()
}

View File

@ -3,20 +3,26 @@ package es.verdnatura.presentation.view.feature.packaging.fragment.PackagingView
import android.content.Context
import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.Transformations
import androidx.lifecycle.map
import es.verdnatura.domain.SilexCallback
import es.verdnatura.presentation.base.BaseViewModel
import es.verdnatura.presentation.base.getMessageFromAllResponse
import es.verdnatura.presentation.base.nameofFunction
import es.verdnatura.presentation.common.Event
import es.verdnatura.presentation.common.ResponseItemVO
import es.verdnatura.presentation.view.feature.packaging.model.*
import es.verdnatura.presentation.view.feature.packaging.model.EntryList
import es.verdnatura.presentation.view.feature.packaging.model.EntrySalix
import es.verdnatura.presentation.view.feature.packaging.model.ItemSupplier
import es.verdnatura.presentation.view.feature.packaging.model.Supplier
import es.verdnatura.presentation.view.feature.packaging.model.SupplierList
import es.verdnatura.presentation.view.feature.packaging.model.itemSupplierList
import es.verdnatura.presentation.view.feature.packaging.model.notificationQueue
import es.verdnatura.presentation.view.feature.packaging.model.obervationEntry
import okhttp3.MultipartBody
import retrofit2.Response
class PackagingViewModel(val context: Context) : BaseViewModel(context) {
private val _itemSupplierList by lazy { MutableLiveData<itemSupplierList>() }
val itemSupplierList: LiveData<itemSupplierList>
get() = _itemSupplierList
@ -45,7 +51,8 @@ class PackagingViewModel(val context: Context) : BaseViewModel(context) {
val response: LiveData<ResponseItemVO>
get() = _response
val loadEntryAdd = Transformations.map(_entryAdd) { Event(it) }
val loadEntryAdd: LiveData<Event<EntrySalix>> = _entryAdd.map { Event(it) }
//val loadEntryAdd = Transformations.map(_entryAdd) { Event(it) }
fun getSuppliers() {
salix.getSuppliers()
@ -87,6 +94,38 @@ class PackagingViewModel(val context: Context) : BaseViewModel(context) {
})
}
//http://localhost:3000/api/Entries/1/uploadFile?warehouseId=1&companyId=442&dmsTypeId=21&reference=1&description="Example description"&hasFile=false (tiene que ser de tipo Multipart y llevar adjunto un fichero)
fun uploadFile(entry: EntrySalix) {
salix.add_entry(entry)
.enqueue(object :
SilexCallback<EntrySalix>(context) {
override fun onError(t: Throwable) {
_entry.value = EntrySalix(
isError = true,
errorMessage = getMessageFromAllResponse(
nameofFunction(this),
t.message!!
)
)
}
override fun onSuccess(response: Response<EntrySalix>) {
if (response.body() != null) {
_entry.value = response.body()
} else {
_entry.value = EntrySalix(
isError = true,
errorMessage = getMessageFromAllResponse(
nameofFunction(this),
response.message()
)
)
}
}
})
}
fun getEntries_fromSupplier(supplier: Int) {
salix.getEntries_fromSupplier("""{"where": {"supplierFk": "$supplier"},"limit":5, "order":"created DESC"}""")
.enqueue(object :
@ -159,7 +198,7 @@ class PackagingViewModel(val context: Context) : BaseViewModel(context) {
})
}
fun entry_addSalix(entry: EntrySalix) {
fun entry_addSalix(entry: EntrySalix) {
salix.add_entry(entry)
.enqueue(object :
SilexCallback<EntrySalix>(context) {
@ -191,7 +230,7 @@ class PackagingViewModel(val context: Context) : BaseViewModel(context) {
}
fun entry_updateObserv(entryId: Int, observation: String) {
salix.entry_updateObserv(entryId,obervationEntry(observation))
salix.entry_updateObserv(entryId, obervationEntry(observation))
.enqueue(object :
SilexCallback<EntrySalix>(context) {
override fun onError(t: Throwable) {
@ -221,22 +260,41 @@ class PackagingViewModel(val context: Context) : BaseViewModel(context) {
})
}
fun entry_uploadPhotoSalix(id: Number, warehouseId: Number, companyId: Number, dmsTypeId: Number, reference: String, description: String, hasFile: Boolean, file: MultipartBody.Part) {
salix.uploadEntryPhoto(id, warehouseId, companyId, dmsTypeId, reference, description, hasFile, file)
.enqueue(object : SilexCallback<Any>(context){})
fun entry_uploadPhotoSalix(
idEntry:Number,
warehouseId: Number,
companyId: Number,
dmsTypeId: Number,
reference: String,
description: String,
hasFile: Boolean,
file: MultipartBody.Part
) {
salix.uploadEntryPhoto(
idEntry,
warehouseId,
companyId,
dmsTypeId,
reference,
description,
hasFile,
file
)
.enqueue(object : SilexCallback<Any>(context) {})
}
fun entry_addFromBuy(id: Number, item: Number, printedStickers: Number) {
salix.addFromBuy(id, item, printedStickers)
.enqueue(object : SilexCallback<EntrySalix>(context){override fun onError(t: Throwable) {
_entryAdd.value = EntrySalix(
isError = true,
errorMessage = getMessageFromAllResponse(
nameofFunction(this),
t.message!!
.enqueue(object : SilexCallback<EntrySalix>(context) {
override fun onError(t: Throwable) {
_entryAdd.value = EntrySalix(
isError = true,
errorMessage = getMessageFromAllResponse(
nameofFunction(this),
t.message!!
)
)
)
}
}
override fun onSuccess(response: Response<EntrySalix>) {
if (response.body() != null) {
@ -254,32 +312,35 @@ class PackagingViewModel(val context: Context) : BaseViewModel(context) {
}
})
}
fun notificationQueues(notification: String, workerfk: Int, bodyUrl: String) {
salix.notificationQueues(notificationQueue(notification,workerfk,bodyUrl))
.enqueue(object : SilexCallback<Void>(context){override fun onError(t: Throwable) {
_response.value = ResponseItemVO(
isError = true,
errorMessage = getMessageFromAllResponse(
nameofFunction(this),
t.message!!
salix.notificationQueues(notificationQueue(notification, workerfk, bodyUrl))
.enqueue(object : SilexCallback<Void>(context) {
override fun onError(t: Throwable) {
_response.value = ResponseItemVO(
isError = true,
errorMessage = getMessageFromAllResponse(
nameofFunction(this),
t.message!!
)
)
)
}
}
override fun onSuccess(response: Response<Void>) {
_response.value = ResponseItemVO(
isError = true,
errorMessage = getMessageFromAllResponse(
nameofFunction(this),
response.message()
)
isError = true,
errorMessage = getMessageFromAllResponse(
nameofFunction(this),
response.message()
)
)
}
})
}
fun entry_addFromPackaging(supplier: Number,isPackaging: Boolean) {
fun entry_addFromPackaging(supplier: Int, isPackaging: Boolean) {
salix.addFromPackaging(supplier, isPackaging)
.enqueue(object : SilexCallback<EntrySalix>(context) {
override fun onError(t: Throwable) {
@ -308,34 +369,35 @@ class PackagingViewModel(val context: Context) : BaseViewModel(context) {
}
})
}
fun getItemsPackaging(supplierId: Int,entryId: Int) {
salix.getItemsPackaging(supplierId, entryId)
.enqueue(object : SilexCallback<List<ItemSupplier>>(context){
override fun onError(t: Throwable) {
val listError: ArrayList<ItemSupplier> = ArrayList()
listError.add(
ItemSupplier(
isError = true,
errorMessage = getMessageFromAllResponse(
nameofFunction(this),
t.message!!
)
fun getItemsPackaging(supplierId: Int, entryId: Int) {
salix.getItemsPackaging(supplierId, entryId)
.enqueue(object : SilexCallback<List<ItemSupplier>>(context) {
override fun onError(t: Throwable) {
val listError: ArrayList<ItemSupplier> = ArrayList()
listError.add(
ItemSupplier(
isError = true,
errorMessage = getMessageFromAllResponse(
nameofFunction(this),
t.message!!
)
)
)
_itemSupplierList.value = itemSupplierList(listError)
}
override fun onSuccess(response: Response<List<ItemSupplier>>) {
if (response.body() != null) {
_itemSupplierList.value =
response.body()?.let { itemSupplierList(it) }
} else {
val listError: ArrayList<ItemSupplier> = ArrayList()
listError.add(ItemSupplier(null, null))
_itemSupplierList.value = itemSupplierList(listError)
}
}
override fun onSuccess(response: Response<List<ItemSupplier>>) {
if (response.body() != null) {
_itemSupplierList.value =
response.body()?.let { itemSupplierList(it) }
} else {
val listError: ArrayList<ItemSupplier> = ArrayList()
listError.add(ItemSupplier(null, null))
_itemSupplierList.value = itemSupplierList(listError)
}
}
})
})
}
}

View File

@ -17,7 +17,7 @@ import es.verdnatura.presentation.view.feature.packaging.model.EntrySalix
import es.verdnatura.presentation.view.feature.packaging.model.Supplier
import es.verdnatura.presentation.view.feature.pasillero.model.PasillerosItemVO
import ir.mirrajabi.searchdialog.SimpleSearchDialogCompat
import kotlinx.coroutines.runBlocking
@Suppress("UNUSED_ANONYMOUS_PARAMETER")
class SupplierFragment(
@ -34,8 +34,6 @@ class SupplierFragment(
private val entries = ArrayList<SearchSupplierModel>()
private lateinit var customDialog: CustomDialog
companion object {
fun newInstance(entryPoint: String) = SupplierFragment(entryPoint)
}
@ -54,7 +52,6 @@ class SupplierFragment(
val drawableId: Int =
R.drawable.background_test // Reemplaza "mi_drawable" con el nombre de tu recurso Drawable
/* val uri: Uri = Uri.parse(
ContentResolver.SCHEME_ANDROID_RESOURCE + "://" +
context!!.resources.getResourcePackageName(drawableId) + '/' +
@ -64,24 +61,23 @@ class SupplierFragment(
val rutaAbsoluta: String = uri.toString()*/
/*
val file = File("/storage/emulated/0/Android/data/es.verdnatura.sfusion/files/Pictures/test.png")
val filePart = MultipartBody.Part.createFormData(
"file",
file.name,
RequestBody.create(MediaType.parse("image/png"), file)
)
viewModel.entry_uploadPhotoSalix(
1,
1,
442,
21,
"1",
"Example description",
false,
file = filePart
)*/
/*
val file = File("/storage/emulated/0/Android/data/es.verdnatura.sfusion/files/Pictures/test.png")
val filePart = MultipartBody.Part.createFormData(
"file",
file.name,
RequestBody.create(MediaType.parse("image/png"), file)
)
viewModel.entry_uploadPhotoSalix(
1,
1,
442,
21,
"1",
"Example description",
false,
file = filePart
)*/
// viewModel.entry_addFromBuy(8,1,100)
super.onCreate(savedInstanceState)
}
@ -103,10 +99,19 @@ class SupplierFragment(
null,
suppliers
) { baseSearchDialogCompat, nombre, position ->
binding.filterSupplier.setText((nombre.getName()))
binding.filterSupplier.text = (nombre.getName())
println("nombreSupplier"+nombre.getName())
binding.radiobuttonTypePackaging.visibility = View.VISIBLE
saveData("SUPPLIERNAME", nombre.getName())
saveDataInt("SUPPLIERID", nombre.getId().toInt())
runBlocking {
mobileApplication.dataStoreApp.editDataStoreKey(
"SUPPLIERNAME",
nombre.getName()
)
mobileApplication.dataStoreApp.editDataStoreKey(
"SUPPLIERID",
nombre.getId().toInt()
)
}
viewModel.getEntries_fromSupplier(nombre.getId().toInt())
baseSearchDialogCompat.dismiss()
}.show()
@ -133,11 +138,15 @@ class SupplierFragment(
binding.radiobuttonTypePackaging.setOnCheckedChangeListener { buttonView, isChecked ->
when (isChecked) {
R.id.radioButtonRec -> {
saveData("ENTRYTYPE", "Rec")
runBlocking {
mobileApplication.dataStoreApp.editDataStoreKey("ENTRYTYPE", "Rec")
}
}
R.id.radioButtonDev -> {
saveData("ENTRYTYPE", "Dev")
R.id.radioButtonDev -> {
runBlocking {
mobileApplication.dataStoreApp.editDataStoreKey("ENTRYTYPE", "Dev")
}
}
}
@ -161,7 +170,12 @@ class SupplierFragment(
if (nombre.getName() == getString(R.string.newEntry)) {
addEntry()
} else {
saveDataInt("ENTRYID", nombre.getId().toInt())
runBlocking {
mobileApplication.dataStoreApp.editDataStoreKey(
"ENTRYID",
nombre.getId().toInt()
)
}
ma.onPasillerosItemClickListener(
PasillerosItemVO(title = getString(R.string.titlePackagingCount)),
getString(R.string.titlePackagingCount)
@ -173,7 +187,6 @@ class SupplierFragment(
}
override fun observeViewModel() {
with(viewModel) {
supplierList.observe(viewLifecycleOwner) {
@ -199,7 +212,13 @@ class SupplierFragment(
ma.messageWithSound(it.errorMessage, true, false)
} else {
saveDataInt("ENTRYID", it.id!!.toInt())
runBlocking {
mobileApplication.dataStoreApp.editDataStoreKey(
"ENTRYID",
it.id!!.toInt()
)
}
ma.onPasillerosItemClickListener(
PasillerosItemVO(title = getString(R.string.titlePackagingCount)),
it.id!!.toString()
@ -209,20 +228,18 @@ class SupplierFragment(
}
}
/* entryAdd.observe(viewLifecycleOwner) {
if (it.isError) {
ma.messageWithSound(it.errorMessage, true, false)
/* entryAdd.observe(viewLifecycleOwner) {
if (it.isError) {
ma.messageWithSound(it.errorMessage, true, false)
} else {
saveDataInt("ENTRYID", it.id!!.toInt())
ma.onPasillerosItemClickListener(
PasillerosItemVO(title = getString(R.string.titlePackagingCount)),
it.id!!.toString()
)
}
}*/
} else {
saveDataInt("ENTRYID", it.id!!.toInt())
ma.onPasillerosItemClickListener(
PasillerosItemVO(title = getString(R.string.titlePackagingCount)),
it.id!!.toString()
)
}
}*/
entry.observe(viewLifecycleOwner) {
binding.splashProgress.visibility = View.GONE
@ -230,7 +247,10 @@ class SupplierFragment(
ma.messageWithSound(it.errorMessage, true, false)
} else {
saveDataInt("ENTRYID", it.id!!.toInt())
runBlocking {
mobileApplication.dataStoreApp.editDataStoreKey("ENTRYID", it.id!!.toInt())
}
ma.onPasillerosItemClickListener(
PasillerosItemVO(title = getString(R.string.titlePackagingCount)),
getString(R.string.titlePackagingCount)
@ -240,7 +260,6 @@ class SupplierFragment(
}
}
private fun createSupplierList(list: List<Supplier>) {
suppliers.clear()
list.forEach { supplier ->
@ -287,8 +306,8 @@ class SupplierFragment(
customDialog.dismiss()
binding.splashProgress.visibility = View.VISIBLE
viewModel.entry_addFromPackaging(
getDataInt("SUPPLIERID"),
getData("ENTRYTYPE") == "Rec"
mobileApplication.dataStoreApp.readDataStoreKey("SUPPLIERID"),
mobileApplication.dataStoreApp.readDataStoreKey<String>("ENTRYTYPE") == "Rec"
)
}
@ -297,7 +316,6 @@ class SupplierFragment(
customDialog.cancel()
customDialog.dismiss()
}
.show()
}

View File

@ -438,10 +438,9 @@ class PasilleroViewModel(context: Context) : BaseViewModel(context) {
)
)
*/
//#tarea4021
_pasillerositem.add(
/* _pasillerositem.add(
PasillerosItemVO(
6,
R.drawable.ic_packaging_entries,
@ -449,7 +448,7 @@ class PasilleroViewModel(context: Context) : BaseViewModel(context) {
R.string.titlePackaging,
contextApp.getString(R.string.titlePackagingDescrip)
)
)
)*/
_pasillerositem.add(
PasillerosItemVO(
6,
@ -458,7 +457,7 @@ class PasilleroViewModel(context: Context) : BaseViewModel(context) {
R.string.titlePhotos,
contextApp.getString(R.string.titlePhotos)
)
)
_pasillerositem.add(
PasillerosItemVO(
50,

View File

@ -54,8 +54,8 @@
android:id="@+id/button_finalizar"
style="@style/DefaultButton"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginTop="16dp"
android:layout_marginEnd="16dp"
android:layout_weight="1"
android:background="@drawable/btn_orange"

View File

@ -39,7 +39,7 @@
android:textColor="#FFF"
android:textSize="18dp"
android:drawableEnd="@drawable/ic_add_black_24dp"
android:visibility="gone"
android:visibility="visible"
app:layout_constraintStart_toEndOf="@+id/observations"
app:layout_constraintTop_toBottomOf="@+id/observations" />
<LinearLayout
@ -51,7 +51,7 @@
android:layout_marginBottom="@dimen/layout_margin_1"
android:paddingLeft="@dimen/layout_margin_min"
android:paddingRight="@dimen/layout_margin_min"
android:visibility="gone"
android:visibility="visible"
app:layout_constraintTop_toBottomOf="@+id/openPickerImages" >
@ -72,7 +72,7 @@
android:id="@+id/listImagesRecycler"
android:layout_width="match_parent"
android:layout_height="550dp"
android:visibility="gone"
android:visibility="visible"
app:layout_constraintStart_toEndOf="@+id/textImages"
app:layout_constraintTop_toBottomOf="@+id/textImages"
tools:listitem="@layout/item_image_row"

View File

@ -4,6 +4,7 @@
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/main_frame_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/verdnatura_black">
@ -21,7 +22,8 @@
android:id="@+id/webView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="0dp" />
android:layout_marginTop="0dp"
/>
</androidx.constraintlayout.widget.ConstraintLayout>
</layout>

View File

@ -54,7 +54,7 @@
android:gravity="center_vertical"
android:scaleType="centerCrop"
android:src="@drawable/ic_history_black_24dp"
android:visibility="gone" />
android:visibility="visible" />
<ImageView
android:layout_marginLeft="@dimen/default_layout_margin"

View File

@ -69,7 +69,7 @@
android:layout_marginLeft="@dimen/pasilleros_margin_main_menu"
android:layout_weight="1.25"
android:layout_gravity="center"
android:text="@{Integer.toString(item.printedStickers)}"
android:text="@{String.valueOf(item.printedStickers)}"
android:textColor="@color/verdnatura_white"
android:textSize="@dimen/h8"
android:visibility="visible"

View File

@ -246,7 +246,7 @@
<string name="take">Coger</string>
<string name="errorRegistered">Causa del error registrado</string>
<string name="printerFault">Falta seleccionar impresora</string>
<string name="observations">Observaciones</string>
<string name="observations">Observaciones:</string>
<string name="scanShelvingHistorical">Escanea matrícula para ver histórico</string>
<string name="scanPlate">Escanea matrícula del vehículo</string>
<string name="scanPlateTakeoff">Escanea matrícula para dejar vehículo</string>
@ -738,8 +738,6 @@
<string name="imageToSend">Imágenes adjuntas:</string>
<string name="addWorkForm">Añadir…</string>
<string name="itemOlderInfo">¿Estás seguro que quieres parkinear la matricula %1$s? Tienes material mas antiguo en otra ubicación.</string>
<string name="checkItemShelvingDescrip">Revisión del carro</string>
<string name="quantityReviewed">Cantidad revisada a sumar/restar del total</string>
<string name="deleteEntryReviewed">Vas a borrar la cantidad de la compra de la entrada</string>
<string name="quantityToReview">Cantidad a revisar</string>

View File

@ -246,7 +246,7 @@
<string name="take">Coger</string>
<string name="errorRegistered">Causa del error registrado</string>
<string name="printerFault">Falta seleccionar impresora</string>
<string name="observations">Observaciones</string>
<string name="observations">Observaciones:</string>
<string name="scanShelvingHistorical">Escanea matrícula para ver histórico</string>
<string name="scanPlate">Escanea matrícula del vehículo</string>
<string name="scanPlateTakeoff">Escanea matrícula para dejar vehículo</string>

View File

@ -246,7 +246,7 @@
<string name="take">Coger</string>
<string name="errorRegistered">Causa del error registrado</string>
<string name="printerFault">Falta seleccionar impresora</string>
<string name="observations">Observaciones</string>
<string name="observations">Observaciones:</string>
<string name="scanShelvingHistorical">Escanea matrícula para ver histórico</string>
<string name="scanPlate">Escanea matrícula del vehículo</string>
<string name="scanPlateTakeoff">Escanea matrícula para dejar vehículo</string>

View File

@ -281,7 +281,7 @@
<string name="take">Take</string>
<string name="errorRegistered">Cause of error registered</string>
<string name="printerFault">Select printer</string>
<string name="observations">Observations</string>
<string name="observations">Observations:</string>
<string name="scanShelvingHistorical">Scan plate for looking historical </string>
<string name="scanPlate">Scan vehicle plate</string>
<string name="scanPlateTakeoff">"Scan plate to take off "</string>