diff --git a/.idea/workspace.xml b/.idea/workspace.xml index 9b9884f5..4115ab39 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -127,36 +127,24 @@ - + + + - - - - - + + - - - - - - + + - - - - + - - - - @@ -176,7 +164,7 @@ - + - { - "keyToString": { - "ApkExportedModule": "Gestor_Almacén.app", - "ExportApk.ApkPathForGestor_Almacén.app": "C:\\Users\\sergiodt\\AndroidStudioProjects\\vn-warehouseManager\\app", - "PROJECT_TRUSTED_KEY": "true", - "RunOnceActivity.ShowReadmeOnStart": "true", - "RunOnceActivity.cidr.known.project.marker": "true", - "SHARE_PROJECT_CONFIGURATION_FILES": "true", - "android-custom-viewC:/Users/sergiodt/AppData/Local/Android/Sdk/sources/android-29/android/widget/TextView.java_SELECTED": "TextView", - "cidr.known.project.marker": "true", - "com.google.services.firebase.aqiPopupShown": "true", - "git-widget-placeholder": "dev", - "last_opened_file_path": "C:/Users/sergiodt/AndroidStudioProjects/vn-warehouseManager/app/src/main/res/drawable", - "project.structure.last.edited": "Dependencies", - "project.structure.proportion": "0.17", - "project.structure.side.proportion": "0.2", - "run.code.analysis.last.selected.profile": "pProject Default", - "settings.editor.selected.configurable": "preferences.rainbow.brackets.disable.when" + +}]]> + + + @@ -904,8 +900,8 @@ @@ -955,14 +951,6 @@ @@ -1005,6 +1001,10 @@ 29 diff --git a/app/beta/release/output-metadata.json b/app/beta/release/output-metadata.json index 939039d8..4eea9edf 100644 --- a/app/beta/release/output-metadata.json +++ b/app/beta/release/output-metadata.json @@ -11,8 +11,8 @@ "type": "SINGLE", "filters": [], "attributes": [], - "versionCode": 232, - "versionName": "23.40.1Beta", + "versionCode": 236, + "versionName": "23.42Beta", "outputFile": "app-beta-release.apk" } ], diff --git a/app/build.gradle b/app/build.gradle index bd3bd2ce..472153d0 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -13,8 +13,8 @@ android { applicationId "es.verdnatura" minSdkVersion 24 //21 targetSdkVersion 33 - versionCode 230 - versionName = "23.40Beta" + versionCode 236 + versionName = "23.42" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" } @@ -141,4 +141,7 @@ dependencies { //pickerImage implementation 'com.github.esafirm:android-image-picker:3.0.0-beta5' + //linphone + // implementation 'org.linphone:linphone-sdk-android:5.1.0+' + //implementation 'androidx.media:media:1.6.0' } diff --git a/app/src/main/java/es/verdnatura/domain/SalixService.kt b/app/src/main/java/es/verdnatura/domain/SalixService.kt index 43ef5550..c29b7966 100644 --- a/app/src/main/java/es/verdnatura/domain/SalixService.kt +++ b/app/src/main/java/es/verdnatura/domain/SalixService.kt @@ -320,7 +320,7 @@ interface SalixService { @POST("ItemShelvings/update") fun itemShelvingsUpdate( - @Query("where") id: Any, + @Query("where") where: Any, @Body params: Any ): Call diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/articulo/fragment/ItemCardFragment.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/articulo/fragment/ItemCardFragment.kt index f026798e..185f5a71 100644 --- a/app/src/main/java/es/verdnatura/presentation/view/feature/articulo/fragment/ItemCardFragment.kt +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/articulo/fragment/ItemCardFragment.kt @@ -567,221 +567,241 @@ class ItemCardFragment( private fun editItemCardRow(item: ItemCardRowVO, value: Int) { when (item.action) { - "itemStockUpdateAdd" -> prepareItemStockUpdate2(item, value) - "itemStockUpdateRemove" -> prepareItemStockUpdate2(item, value) - "updateGrouping" -> - viewModel.updateGrouping( + "itemStockUpdateAdd" -> { + showProgress() + viewModel.itemTrash( itemFk = itemInfoG!!.id, - value = value, - warehouseFk = warehouseFk!! + warehouseFk = warehouseFk!!, + newValue = (value * -1), + isTrash = false + ) - - "updatePacking" -> viewModel.updatePacking( - itemFk = itemInfoG!!.id, - value = value, - warehouseFk = warehouseFk!! - ) - - "itemSaveStem" -> viewModel.item_saveStems( - itemFk = itemInfoG!!.id, - value = value - ) - - "item_saveReference" -> viewModel.item_saveReference( - itemFk = itemInfoG!!.id, - value = value - ) - - } - if (item.action != "itemStockUpdate" && item.action != "itemStockUpdateRemove" && item.action != "itemStockUpdateAdd") - // changeOfflineValue(item,value, listBarcodes) - showProgress() - } - - //sergio: changeOffLineValue solo hace visible el progress - - private fun showProgress() { - binding.splashProgress.visibility = View.VISIBLE - } - - private fun prepareItemStockUpdate2(itemB: ItemCardRowVO, value: Int) { - - //Tarea 5652 , quitar código cuando está asignada tarea - var test = false - if (test) { - binding.splashProgress.visibility = View.VISIBLE - viewModel.getAddress() - quantityToDiscard = value - - } else { - try { - value.toInt() - - if (itemB.action == "itemStockUpdateRemove") { - - customDialogTwo.setTitle(itemB.title!!) - .setDescription(getString(R.string.deleteStock)) - .setOkButton(getString(R.string.fault)) { - viewModel.itemTrash( - itemFk = itemInfoG!!.id, - warehouseFk = warehouseFk!!, - newValue = value, - isTrash = false - - ) - //changeOfflineValue(itemB,value, listBarcodes) - showProgress() - customDialogTwo.dismiss() - - }.setOkButtonTwo(getString(R.string.trash)) { - viewModel.itemTrash( - itemFk = itemInfoG!!.id, - warehouseFk = warehouseFk!!, - newValue = value, - isTrash = true - - ) - - showProgress() - customDialogTwo.dismiss() - - }.setKoButton(getString(R.string.cancel)) { - - customDialogTwo.dismiss() - }.show() - - } else { - - showProgress() - viewModel.itemTrash( - itemFk = itemInfoG!!.id, - warehouseFk = warehouseFk!!, - newValue = (value * -1), - isTrash = false - - ) - } - } catch (e: Exception) { - // binding.itemcardLayout.visibility = View.GONE - ma.messageWithSound(getString(R.string.errorNotNumber), true, true) - - } - } - } - - private fun showDialogTrashFault(listAddress: List) { - - customDynamic.setTitle("") - customDynamic.setDescription(getString(R.string.deleteStock)) - customDynamic.createDynamicButtons(listAddress) - customDynamic.show() - } - - private fun prepareBarcodeDialog(itemB: ItemCardRowVO) { - - customDialogList.setTitle(getString(R.string.barcodes)) - .setOkButton(getString(R.string.save)) { - ma.hideKeyboard(customDialogList.getEditText()) - if (!customDialogList.getValue().isEmpty()) - updateBarcode(customDialogList.getValue(), false) - customDialogList.dismiss() - - }.setKoButton(getString(R.string.close)) { - ma.hideKeyboard(customDialogList.getEditText()) - customDialogList.dismiss() - }.setValue("").show() - - - ma.hideKeyboard(customDialogList.getEditText()) - customDialogList.getEditText().setOnEditorActionListener { _, actionId, _ -> - if (actionId == EditorInfo.IME_ACTION_SEARCH || actionId == EditorInfo.IME_ACTION_DONE || actionId == 0) { - if (!customDialogList.getValue().isNullOrEmpty()) - updateBarcode(customDialogList.getValue(), false) - customDialogList.setValue("") - customDialogList.dismiss() - ma.hideKeyboard(customDialogList.getEditText()) - return@setOnEditorActionListener true - } - false - } - - barcodeAdapter = BarcodeAdapter(listBarcodes, object : OnBarcodeRowClickListener { - override fun onBarcodeRowClickListener(item: BarcodeVO) { - updateBarcode(item.code!!, true) - customDialogList.setValue("") - customDialogList.dismiss() - } - }) - customDialogList.getRecyclerView().adapter = barcodeAdapter - - customDialogList.getRecyclerView().layoutManager = - LinearLayoutManager(requireContext(), LinearLayoutManager.VERTICAL, false) - } - - private fun updateBarcode(code: String, delete: Boolean) { - if (delete) { - var i = 0 - var posDelete = 0 - listBarcodes.forEach { - if (it.code == code) - posDelete = i - i += 1 - } - listBarcodes.removeAt(posDelete) - viewModel.barcodesEdit( - itemFk = itemInfoG!!.id, - value = code, - delete = delete, - ) - } else { - listBarcodes.add(BarcodeVO(code)) - viewModel.barcodesEditSalix( - itemFk = itemInfoG!!.id, - barCodeValue = code - ) - - } - - barcodeAdapter!!.notifyDataSetChanged() - showProgress() - } - - private fun showDialogSelectItemTypePacking() { - - var array = arrayOfNulls(itemsPackingType.size) - for (indice in array.indices) { - array[indice] = - itemsPackingType[indice].code + " : " + itemsPackingType[indice].description - } - val builder = AlertDialog.Builder(this.context) - builder.setTitle(getString(R.string.mensajeseleccionencajado)) - .setItems( - array - ) { _, position -> - - updateItemPackingType(itemsPackingType[position].code) - - } - - builder.create().show() - } - - private fun updateItemPackingType(itemPackingType: String) { - binding.splashProgress.visibility = View.VISIBLE - viewModel.updatePackingTypeSalix( - itemInfoG!!.id, - itemPackingType + "itemStockUpdateRemove" -> prepareItemStockUpdate2(item, value) + "updateGrouping" -> + viewModel.updateGrouping( + itemFk = itemInfoG!!.id, + value = value, + warehouseFk = warehouseFk!! ) + + "updatePacking" -> viewModel.updatePacking( + itemFk = itemInfoG!!.id, + value = value, + warehouseFk = warehouseFk!! + ) + + "itemSaveStem" -> viewModel.item_saveStems( + itemFk = itemInfoG!!.id, + value = value + ) + + "item_saveReference" -> viewModel.item_saveReference( + itemFk = itemInfoG!!.id, + value = value + ) + + + } + if (item.action != "itemStockUpdate" && item.action != "itemStockUpdateRemove" && item.action != "itemStockUpdateAdd") + // changeOfflineValue(item,value, listBarcodes) + showProgress() +} + +private fun prepareItemStockAdd(value: Int) { + + showProgress() + viewModel.itemTrash( + itemFk = itemInfoG!!.id, + warehouseFk = warehouseFk!!, + newValue = (value * -1), + isTrash = false + + ) +} + +//sergio: changeOffLineValue solo hace visible el progress + +private fun showProgress() { + binding.splashProgress.visibility = View.VISIBLE +} + +private fun prepareItemStockUpdate2(itemB: ItemCardRowVO, value: Int) { + + //Tarea 5652 , quitar código cuando está asignada tarea + var test = true + if (test) { + binding.splashProgress.visibility = View.VISIBLE + viewModel.getAddress() + quantityToDiscard = value + + } else { + try { + value.toInt() + + if (itemB.action == "itemStockUpdateRemove") { + + customDialogTwo.setTitle(itemB.title!!) + .setDescription(getString(R.string.deleteStock)) + .setOkButton(getString(R.string.fault)) { + viewModel.itemTrash( + itemFk = itemInfoG!!.id, + warehouseFk = warehouseFk!!, + newValue = value, + isTrash = false + + ) + //changeOfflineValue(itemB,value, listBarcodes) + showProgress() + customDialogTwo.dismiss() + + }.setOkButtonTwo(getString(R.string.trash)) { + viewModel.itemTrash( + itemFk = itemInfoG!!.id, + warehouseFk = warehouseFk!!, + newValue = value, + isTrash = true + + ) + + showProgress() + customDialogTwo.dismiss() + + }.setKoButton(getString(R.string.cancel)) { + + customDialogTwo.dismiss() + }.show() + + } else { + + showProgress() + viewModel.itemTrash( + itemFk = itemInfoG!!.id, + warehouseFk = warehouseFk!!, + newValue = (value * -1), + isTrash = false + + ) + } + } catch (e: Exception) { + // binding.itemcardLayout.visibility = View.GONE + ma.messageWithSound(getString(R.string.errorNotNumber), true, true) + + } + } +} + +private fun showDialogTrashFault(listAddress: List) { + + customDynamic.setTitle("") + customDynamic.setDescription(getString(R.string.deleteStock)) + customDynamic.createDynamicButtons(listAddress) + customDynamic.show() +} + +private fun prepareBarcodeDialog(itemB: ItemCardRowVO) { + + customDialogList.setTitle(getString(R.string.barcodes)) + .setOkButton(getString(R.string.save)) { + ma.hideKeyboard(customDialogList.getEditText()) + if (!customDialogList.getValue().isEmpty()) + updateBarcode(customDialogList.getValue(), false) + customDialogList.dismiss() + + }.setKoButton(getString(R.string.close)) { + ma.hideKeyboard(customDialogList.getEditText()) + customDialogList.dismiss() + }.setValue("").show() + + + ma.hideKeyboard(customDialogList.getEditText()) + customDialogList.getEditText().setOnEditorActionListener { _, actionId, _ -> + if (actionId == EditorInfo.IME_ACTION_SEARCH || actionId == EditorInfo.IME_ACTION_DONE || actionId == 0) { + if (!customDialogList.getValue().isNullOrEmpty()) + updateBarcode(customDialogList.getValue(), false) + customDialogList.setValue("") + customDialogList.dismiss() + ma.hideKeyboard(customDialogList.getEditText()) + return@setOnEditorActionListener true + } + false } - override fun onClickDynamic(addressFK: Int) { - println("Acabas de pulsar" + addressFK) - customDynamic.dismiss() - binding.splashProgress.visibility = View.VISIBLE - viewModel.setVisibleDiscard(itemInfoG!!.id, warehouseFk!!, quantityToDiscard, addressFK) + barcodeAdapter = BarcodeAdapter(listBarcodes, object : OnBarcodeRowClickListener { + override fun onBarcodeRowClickListener(item: BarcodeVO) { + updateBarcode(item.code!!, true) + customDialogList.setValue("") + customDialogList.dismiss() + } + }) + customDialogList.getRecyclerView().adapter = barcodeAdapter + + customDialogList.getRecyclerView().layoutManager = + LinearLayoutManager(requireContext(), LinearLayoutManager.VERTICAL, false) +} + +private fun updateBarcode(code: String, delete: Boolean) { + if (delete) { + var i = 0 + var posDelete = 0 + listBarcodes.forEach { + if (it.code == code) + posDelete = i + i += 1 + } + listBarcodes.removeAt(posDelete) + viewModel.barcodesEdit( + itemFk = itemInfoG!!.id, + value = code, + delete = delete, + ) + } else { + listBarcodes.add(BarcodeVO(code)) + viewModel.barcodesEditSalix( + itemFk = itemInfoG!!.id, + barCodeValue = code + ) + } + barcodeAdapter!!.notifyDataSetChanged() + showProgress() +} + +private fun showDialogSelectItemTypePacking() { + + var array = arrayOfNulls(itemsPackingType.size) + for (indice in array.indices) { + array[indice] = + itemsPackingType[indice].code + " : " + itemsPackingType[indice].description + } + val builder = AlertDialog.Builder(this.context) + builder.setTitle(getString(R.string.mensajeseleccionencajado)) + .setItems( + array + ) { _, position -> + + updateItemPackingType(itemsPackingType[position].code) + + } + + builder.create().show() +} + +private fun updateItemPackingType(itemPackingType: String) { + binding.splashProgress.visibility = View.VISIBLE + viewModel.updatePackingTypeSalix( + itemInfoG!!.id, + itemPackingType + ) +} + +override fun onClickDynamic(addressFK: Int) { + customDynamic.dismiss() + binding.splashProgress.visibility = View.VISIBLE + viewModel.setVisibleDiscard(itemInfoG!!.id, warehouseFk!!, quantityToDiscard, addressFK) +} + } 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 e563f763..d6253ae1 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 @@ -407,23 +407,4 @@ class ItemCardViewModel(var context: Context) : BaseViewModel(context) { }) } - - fun getAddressLoses( - - ) { - - - val mermaRecords = listOf( - AddressLoses(77, "MERMA: CONTENEDOR", "BASURA"), - AddressLoses(317, "MERMA: FALTAS", "FALTAS"), - AddressLoses(1535, "MERMA: FALTAS (INVENTARIO)", "FALTAS"), - AddressLoses(2230, "MERMA: RECLAMACION BASURA", "BASURA"), - AddressLoses(7475, "MERMA: RECLAMACION TALLER", "BASURA"), - AddressLoses(43432, "MERMA: TRANSPORTE", "BASURA") - ) - println("Vamos a a lista") - _addressLosesList.value = AddressLosesList(mermaRecords) - - } - } 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 41a24430..542d48c1 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 @@ -1430,7 +1430,7 @@ class CollectionFragmentPicker( } - private fun findSale(txtscan: String, position: Int, checkParking: Boolean = true) { + private fun findSale(txtscan: String, position: Int) { var isOk = false if (type == SACADOR) { @@ -1457,36 +1457,29 @@ class CollectionFragmentPicker( shelvingIndex += 1 } } - /* - if (!isOk){ - //3- Por barcode - saleVO.Barcodes.forEach { barcode -> - if (txtscan == barcode){ - if (mpok != null) mpok!!.start() - isOk = true - markLine(position,type) - } - } - }*/ + } if (!isOk) { - if (txtscan.contains("-") && checkParking) { - tickets.forEach { - viewModel.parking( - ticketFk = it.toInt(), - parking = txtscan - ) - } - - } else { - if (mperror != null) mperror!!.start() - } - + checkIsParking(txtscan) } } } + private fun checkIsParking(txtscan: String) { + if (txtscan.contains("-")) { + tickets.forEach { + viewModel.parking( + ticketFk = it.toInt(), + parking = txtscan + ) + } + + } else { + if (mperror != null) mperror!!.start() + } + } + //Tarea #4371 private fun markLine(position: Int, newType: String) { state = 0 @@ -2676,7 +2669,7 @@ class CollectionFragmentPicker( .isNullOrEmpty() ) { //Tarea 5675 - findSale(customDialogInput.getValue(), index,false) + findSale(customDialogInput.getValue(), index) } else { ma.messageWithSound( @@ -2699,7 +2692,7 @@ class CollectionFragmentPicker( if (actionId == EditorInfo.IME_ACTION_SEARCH || actionId == EditorInfo.IME_ACTION_DONE || actionId == 0) { if (!customDialogInput.getValue().isNullOrEmpty()) { //Tarea 5675 - findSale(customDialogInput.getValue(), index, false) + findSale(customDialogInput.getValue(), index) } customDialogInput.setValue("") scanRequest() diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/collection/fragment/CollectionFragmentPreChecker.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/collection/fragment/CollectionFragmentPreChecker.kt index 3350499f..24aa3496 100644 --- a/app/src/main/java/es/verdnatura/presentation/view/feature/collection/fragment/CollectionFragmentPreChecker.kt +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/collection/fragment/CollectionFragmentPreChecker.kt @@ -1793,13 +1793,6 @@ class CollectionFragmentPreChecker( viewModel.getIdFromCodeSalix( code = customDialogList.getValueTwo(), ) - /* } else { - viewModel.getIdFromCode( - usuario = getData(USER), - password = getData(PASSWORD), - code = customDialogList.getValueTwo(), "barcodeToItem" - ) - }*/ customDialogList.dismiss() } @@ -1886,14 +1879,6 @@ class CollectionFragmentPreChecker( viewModel.getIdFromCodeSalix( code = customDialogList.getValueTwo() ) -/* - } else { - viewModel.getIdFromCode( - getData(USER), - getData(PASSWORD), - code = customDialogList.getValueTwo(), "barcodeToItem" - ) - }*/ customDialogList.dismiss() scanRequest() } diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/collection/fragment/ShowTicketFragment.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/collection/fragment/ShowTicketFragment.kt new file mode 100644 index 00000000..f3d525d0 --- /dev/null +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/collection/fragment/ShowTicketFragment.kt @@ -0,0 +1,350 @@ +package es.verdnatura.presentation.view.feature.collection.fragment + +import android.app.AlertDialog +import android.content.Context +import android.graphics.drawable.Drawable +import android.os.Build +import android.os.Bundle +import android.view.View +import android.view.View.GONE +import android.view.View.VISIBLE +import android.view.inputmethod.EditorInfo +import android.widget.ImageView +import android.widget.Toast +import androidx.lifecycle.Observer +import androidx.recyclerview.widget.LinearLayoutManager +import es.verdnatura.R +import es.verdnatura.databinding.FragmentCollectionBinding +import es.verdnatura.domain.ConstAndValues.VERTICKET +import es.verdnatura.domain.toast +import es.verdnatura.presentation.base.BaseFragment +import es.verdnatura.presentation.common.OnMistakeClickListener +import es.verdnatura.presentation.common.OnOptionsSelectedListener +import es.verdnatura.presentation.common.OnPasillerosItemClickListener +import es.verdnatura.presentation.common.OnQuantityClickListener +import es.verdnatura.presentation.common.OnSaleClickListener +import es.verdnatura.presentation.common.ToolBarAdapterTooltip +import es.verdnatura.presentation.common.hideKeyboard +import es.verdnatura.presentation.common.onPackingClickListener +import es.verdnatura.presentation.view.component.CustomDialog +import es.verdnatura.presentation.view.feature.collection.adapter.SaleAdapter +import es.verdnatura.presentation.view.feature.sacador.model.CollectionVO +import es.verdnatura.presentation.view.feature.sacador.model.SaleVO + +class CollectionShowTicketFragment( + var collection: CollectionVO = CollectionVO(0), + var type: String = "" +) : BaseFragment(CollectionViewModel::class) { + + private var sales: List = listOf() + private var saleAdapter: SaleAdapter? = null + private var lm: LinearLayoutManager? = null + private var pasillerosItemClickListener: OnPasillerosItemClickListener? = null + private lateinit var customDialog: CustomDialog + private var tickets: ArrayList = ArrayList() + + private var lastScanned: Int = 0 + private var buttonPushedGetCollection = false + + companion object { + fun newInstance(collection: CollectionVO, type: String) = + CollectionShowTicketFragment(collection, type) + } + + override fun onAttach(context: Context) { + if (context is OnPasillerosItemClickListener) pasillerosItemClickListener = context + super.onAttach(context) + } + + override fun getLayoutId(): Int = R.layout.fragment_collection + + override fun onCreate(savedInstanceState: Bundle?) { + + if (collection.tickets.isEmpty()) { + viewModel.collectionTicketGet( + collection.collectionFk, + getDataInt(SECTORFK), + print = "0", + type + ) + } + + super.onCreate(savedInstanceState) + } + + override fun init() { + customDialog = CustomDialog(requireContext()) + //84ma.hideBottomNavigation(GONE) + binding.splashProgress.visibility = VISIBLE + setEvents() + setToolBarIcon() + binding.mainToolbar.toolbarSubtitle.visibility = VISIBLE + + if (collection.tickets.isNotEmpty()) { + createCollectionList() + } + + super.init() + } + + private fun setToolBarIcon() { + binding.mainToolbar.toolbarSubtitle.visibility = VISIBLE + val listIcons: ArrayList = ArrayList() + val iconPrint = ImageView(context) + val iconViewCollection = ImageView(context) + + iconViewCollection.setImageResource(R.drawable.ic_collection) + iconPrint.setImageResource(R.drawable.ic_print_black_24dp) + + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { + iconPrint.tooltipText = getTooltip(R.drawable.ic_print_black_24dp) + + } + listIcons.add(iconPrint) + listIcons.add(iconViewCollection) + + binding.mainToolbar.toolbarIcons.adapter = + ToolBarAdapterTooltip(listIcons, object : OnOptionsSelectedListener { + override fun onOptionsItemSelected(item: Drawable) { + when (item) { + iconPrint.drawable -> print() + iconViewCollection.drawable -> getCollection() + } + } + + }) + binding.mainToolbar.toolbarIcons.layoutManager = + LinearLayoutManager(requireContext(), LinearLayoutManager.HORIZONTAL, false) + } + + private fun getCollection() { + + binding.splashProgress.visibility = VISIBLE + + if (!buttonPushedGetCollection) { + viewModel.collection_get( + collection.collectionFk, + getDataInt(SECTORFK), + print = "0", + type + ) + buttonPushedGetCollection = true + } else { + viewModel.collectionTicketGet( + lastScanned, + getDataInt(SECTORFK), + print = "0", + type + + ) + buttonPushedGetCollection = false + } + lastScanned = collection.collectionFk + } + + private fun print() { + + //tarea#4672 + var isTicket = false + for (t in collection.tickets) { + if (t.ticketFk.toInt() == (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) + ) + } + val dialog = builder.create() + dialog.show() + } else { + viewModel.collectionStickerPrint( + + collectionFk = collection.collectionFk, + labelCount = null + ) + + + } + + } + + private fun setEvents() { + + binding.mainToolbar.backButton.setOnClickListener { + requireActivity().onBackPressed() + } + + binding.scanInput.setOnEditorActionListener { _, actionId, _ -> + 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.splashProgress.visibility = VISIBLE + viewModel.collectionTicketGet( + binding.scanInput.text.toString().toInt(), + getDataInt(SECTORFK), + print = "0", + type + ) + + + } + binding.scanInput.setText("") + hideKeyboards() + + return@setOnEditorActionListener true + } + true + } + + hideKeyboards() + + + binding.collectionSwipe.setOnRefreshListener { + + binding.collectionSwipe.isRefreshing = false + binding.splashProgress.visibility = VISIBLE + viewModel.collectionTicketGet( + collection.collectionFk, + getDataInt(SECTORFK), + print = "0", + type + ) + binding.collectionSwipe.isRefreshing = false + + } + } + + private fun hideKeyboards() { + try { + requireActivity().hideKeyboard() + } catch (e: Exception) { + } + } + + override fun observeViewModel() { + with(viewModel) { + + binding.splashProgress.visibility = GONE + collectionTicketList.observe(viewLifecycleOwner, Observer { + + if (!it.isError) { + if (it.tickets.isNotEmpty()) { + collection = it + createCollectionList() + + + } else { + binding.mainToolbar.toolbarSubtitle.text = "0/0" + } + } else { + ma.messageWithSound(it.errorMessage, it.isError, false) + if (activity != null) requireActivity().onBackPressed() + + } + + }) + + responsePrint.observe(viewLifecycleOwner, Observer { + binding.splashProgress.visibility = GONE + + if (it.isError) { + ma.messageWithSound( + it.errorMessage, + it.isError, true + ) + } else { + (getString(R.string.Imprimiendo) + getData(PRINTERNAME)).toast(requireContext()) + } + + + }) + } + } + + + private fun createCollectionList() { + + binding.mainToolbar.toolbarTitle.text = collection.collectionFk.toString() + binding.splashProgress.visibility = View.GONE + var salesList: ArrayList = ArrayList() + tickets = ArrayList() + var observations = "" + collection.tickets.forEach { ticket -> + ticket.sales.forEach { saleVO -> + if (type == VERTICKET) { + salesList.add(saleVO) + if (tickets.firstOrNull { it == saleVO.ticketFk }.isNullOrEmpty()) + tickets.add(saleVO.ticketFk) + + } + + observations = observations + " " + ticket.observations + } + } + sales = salesList.sortedWith(compareBy({ it.saleOrder })) + + + saleAdapter = + SaleAdapter(sales, pasillerosItemClickListener!!, object : OnQuantityClickListener { + + override fun onQuantityClick(sale: SaleVO) { + } + }, object : OnSaleClickListener { + override fun onSaleClick(sale: SaleVO) { + } + + }, object : OnMistakeClickListener { + override fun onMistakeClickListener(sale: SaleVO) { + } + }, object : onPackingClickListener { + override fun onPackingClick(sale: SaleVO) { + } + + } + ) + + lm = LinearLayoutManager(requireContext(), LinearLayoutManager.VERTICAL, false) + binding.fragmentSacadorCollections.adapter = saleAdapter + binding.fragmentSacadorCollections.layoutManager = lm + setTotalLines() + printObservations(observations) + binding.scanInput.requestFocus() + } + + + 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 setTotalLines() { + var totalMark = 0 + sales.forEach { + + if (it.isControlled == "1") + totalMark += 1 + } + binding.mainToolbar.toolbarTitle.text = + collection.collectionFk.toString() + binding.mainToolbar.toolbarSubtitle.text = + "" + totalMark + "/" + sales.size + if (totalMark == sales.size) { + getString(R.string.Coleccióncompleta).toast(this.context, Toast.LENGTH_SHORT) + + } + } + + +} 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 c91ceb17..fff936a0 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 @@ -37,6 +37,7 @@ import es.verdnatura.presentation.view.feature.collection.fragment.CollectionFra 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.CollectionFragmentPreChecker +import es.verdnatura.presentation.view.feature.collection.fragment.CollectionShowTicketFragment import es.verdnatura.presentation.view.feature.controlador.fragment.ControladorFragment import es.verdnatura.presentation.view.feature.controlador.fragment.WebFragment import es.verdnatura.presentation.view.feature.controlvehiculo.fragment.ControlVehiculoFragment @@ -1070,6 +1071,10 @@ class MainActivity : BaseActivity(), OnPasillerosItemClickL addFragmentOnTop(EndSacadorFragment.newInstance(collection, type)) } + "SHOWTICKET" -> { + addFragmentOnTop(CollectionShowTicketFragment.newInstance(collection, type)) + } + //Tarea 4711 "PRECHECKER" -> { addFragmentOnTop(CollectionFragmentPreChecker.newInstance(collection, type)) diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/sacador/fragment/showticket/ShowTicketFragment.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/sacador/fragment/showticket/ShowTicketFragment.kt index 9b79cca0..82c51198 100644 --- a/app/src/main/java/es/verdnatura/presentation/view/feature/sacador/fragment/showticket/ShowTicketFragment.kt +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/sacador/fragment/showticket/ShowTicketFragment.kt @@ -120,6 +120,7 @@ class ShowTicketFragment(var menuOrigin: String) : } private fun navigateToCollectionList(collection: CollectionVO) { + onCollectionSelectedListener?.onCollectionSelected(collection, ConstAndValues.VERTICKET) } diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/sacador/mapper/SacadoresMapper.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/sacador/mapper/SacadoresMapper.kt index 9881753f..8610dcac 100644 --- a/app/src/main/java/es/verdnatura/presentation/view/feature/sacador/mapper/SacadoresMapper.kt +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/sacador/mapper/SacadoresMapper.kt @@ -6,7 +6,7 @@ import es.verdnatura.presentation.common.convertToDateString import es.verdnatura.presentation.view.feature.sacador.model.CollectionTicket import es.verdnatura.presentation.view.feature.sacador.model.CollectionVO import java.text.SimpleDateFormat -import java.util.* +import java.util.Calendar fun List.toDateFormat(context: Context): ArrayList { val collections: ArrayList = ArrayList() @@ -29,7 +29,9 @@ fun List.toDateFormating(context: Context): ArrayListAccede al parking de tickets de previa Selecciona comprador para visualizar inventario Datos no cargados todavía. Recargue pantalla + No se puede llevar a cabo la acción. Selecciona carro antes. + Envíada hoja de ruta + Nota añadida correctamente diff --git a/app/src/main/res/values-fr/strings.xml b/app/src/main/res/values-fr/strings.xml index 5c44672a..fcbbbfbd 100644 --- a/app/src/main/res/values-fr/strings.xml +++ b/app/src/main/res/values-fr/strings.xml @@ -680,6 +680,9 @@ Accede al parking de tickets de previa Selecciona comprador para visualizar inventario Datos no cargados todavía. Recargue pantalla + No se puede llevar a cabo la acción. Selecciona carro antes. + Envíada hoja de ruta + Nota añadida correctamente diff --git a/app/src/main/res/values-pt/strings.xml b/app/src/main/res/values-pt/strings.xml index b05356cd..83bbe90b 100644 --- a/app/src/main/res/values-pt/strings.xml +++ b/app/src/main/res/values-pt/strings.xml @@ -680,6 +680,9 @@ Accede al parking de tickets de previa Selecciona comprador para visualizar inventario Datos no cargados todavía. Recargue pantalla + No se puede llevar a cabo la acción. Selecciona carro antes. + Envíada hoja de ruta + Nota añadida correctamente diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 431418d5..f4bea29b 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -679,5 +679,8 @@ Accede al parking de tickets de previa Selecciona comprador para visualizar inventario Datos no cargados todavía. Recargue pantalla + No se puede llevar a cabo la acción. Selecciona carro antes. + Envíada hoja de ruta + Nota añadida correctamente diff --git a/build.gradle b/build.gradle index 310b69c3..ab5a4a43 100644 --- a/build.gradle +++ b/build.gradle @@ -34,6 +34,13 @@ allprojects { google() mavenCentral()//jcenter()// maven{url 'https://jitpack.io'} + /* maven { + name "linphone.org maven repository" + url "https://linphone.org/maven_repository/" + content { + includeGroup "org.linphone" + } + }*/ } }