Merge pull request #1 from androidappsergio/master

Master
This commit is contained in:
androidappsergio 2022-03-30 07:28:58 +02:00 committed by GitHub
commit 212879f340
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
116 changed files with 5051 additions and 1590 deletions

View File

@ -4,7 +4,8 @@
<option name="filePathToZoomLevelMap">
<map>
<entry key="..\:/Users/sergiodt/AndroidStudioProjects/vn-warehouseManager/app/src/main/res/drawable-v24/background_gradient.xml" value="0.1" />
<entry key="..\:/Users/sergiodt/AndroidStudioProjects/vn-warehouseManager/app/src/main/res/drawable-v24/ic_history_orange_24dp.xml" value="0.38229166666666664" />
<entry key="..\:/Users/sergiodt/AndroidStudioProjects/vn-warehouseManager/app/src/main/res/drawable-v24/ic_history_orang.xml" value="0.22037037037037038" />
<entry key="..\:/Users/sergiodt/AndroidStudioProjects/vn-warehouseManager/app/src/main/res/drawable-v24/ic_history_orange_24dp.xml" value="0.16666666666666666" />
<entry key="..\:/Users/sergiodt/AndroidStudioProjects/vn-warehouseManager/app/src/main/res/drawable-v24/ic_launcher_foreground.xml" value="0.13541666666666666" />
<entry key="..\:/Users/sergiodt/AndroidStudioProjects/vn-warehouseManager/app/src/main/res/drawable-v24/selector_bottombar_text.xml" value="0.13541666666666666" />
<entry key="..\:/Users/sergiodt/AndroidStudioProjects/vn-warehouseManager/app/src/main/res/drawable/alpha_b_circle_outline.xml" value="0.2359375" />
@ -13,7 +14,9 @@
<entry key="..\:/Users/sergiodt/AndroidStudioProjects/vn-warehouseManager/app/src/main/res/drawable/background_oval_unchecked.xml" value="0.30052083333333335" />
<entry key="..\:/Users/sergiodt/AndroidStudioProjects/vn-warehouseManager/app/src/main/res/drawable/barcode.xml" value="0.2359375" />
<entry key="..\:/Users/sergiodt/AndroidStudioProjects/vn-warehouseManager/app/src/main/res/drawable/barcode_scan.xml" value="0.1" />
<entry key="..\:/Users/sergiodt/AndroidStudioProjects/vn-warehouseManager/app/src/main/res/drawable/border.xml" value="0.27447916666666666" />
<entry key="..\:/Users/sergiodt/AndroidStudioProjects/vn-warehouseManager/app/src/main/res/drawable/border_parental.xml" value="0.11979166666666667" />
<entry key="..\:/Users/sergiodt/AndroidStudioProjects/vn-warehouseManager/app/src/main/res/drawable/btn_blue.xml" value="0.27447916666666666" />
<entry key="..\:/Users/sergiodt/AndroidStudioProjects/vn-warehouseManager/app/src/main/res/drawable/buffer_accumulate.xml" value="0.18489583333333334" />
<entry key="..\:/Users/sergiodt/AndroidStudioProjects/vn-warehouseManager/app/src/main/res/drawable/buffer_accumulation.xml" value="0.19814814814814816" />
<entry key="..\:/Users/sergiodt/AndroidStudioProjects/vn-warehouseManager/app/src/main/res/drawable/buffer_desactivate.xml" value="0.1" />
@ -21,6 +24,7 @@
<entry key="..\:/Users/sergiodt/AndroidStudioProjects/vn-warehouseManager/app/src/main/res/drawable/buffer_fill.xml" value="0.19814814814814816" />
<entry key="..\:/Users/sergiodt/AndroidStudioProjects/vn-warehouseManager/app/src/main/res/drawable/buffer_flejado.xml" value="0.2916666666666667" />
<entry key="..\:/Users/sergiodt/AndroidStudioProjects/vn-warehouseManager/app/src/main/res/drawable/buffer_full.xml" value="0.18489583333333334" />
<entry key="..\:/Users/sergiodt/AndroidStudioProjects/vn-warehouseManager/app/src/main/res/drawable/buffer_load.xml" value="0.14666666666666667" />
<entry key="..\:/Users/sergiodt/AndroidStudioProjects/vn-warehouseManager/app/src/main/res/drawable/buffer_off.xml" value="0.1" />
<entry key="..\:/Users/sergiodt/AndroidStudioProjects/vn-warehouseManager/app/src/main/res/drawable/buffer_outline.xml" value="0.22407407407407406" />
<entry key="..\:/Users/sergiodt/AndroidStudioProjects/vn-warehouseManager/app/src/main/res/drawable/car.xml" value="0.30052083333333335" />
@ -31,6 +35,8 @@
<entry key="..\:/Users/sergiodt/AndroidStudioProjects/vn-warehouseManager/app/src/main/res/drawable/crane.xml" value="0.23802083333333332" />
<entry key="..\:/Users/sergiodt/AndroidStudioProjects/vn-warehouseManager/app/src/main/res/drawable/day_of_sale.xml" value="0.184375" />
<entry key="..\:/Users/sergiodt/AndroidStudioProjects/vn-warehouseManager/app/src/main/res/drawable/delete.xml" value="0.19166666666666668" />
<entry key="..\:/Users/sergiodt/AndroidStudioProjects/vn-warehouseManager/app/src/main/res/drawable/drawable_white_circle.xml" value="0.1775" />
<entry key="..\:/Users/sergiodt/AndroidStudioProjects/vn-warehouseManager/app/src/main/res/drawable/emoticon_error.xml" value="0.27447916666666666" />
<entry key="..\:/Users/sergiodt/AndroidStudioProjects/vn-warehouseManager/app/src/main/res/drawable/eraser.xml" value="0.26564102564102565" />
<entry key="..\:/Users/sergiodt/AndroidStudioProjects/vn-warehouseManager/app/src/main/res/drawable/face_man_outline.xml" value="0.22708333333333333" />
<entry key="..\:/Users/sergiodt/AndroidStudioProjects/vn-warehouseManager/app/src/main/res/drawable/filter_outline.xml" value="0.22239583333333332" />
@ -38,12 +44,18 @@
<entry key="..\:/Users/sergiodt/AndroidStudioProjects/vn-warehouseManager/app/src/main/res/drawable/ic_add_black_24dp.xml" value="0.22708333333333333" />
<entry key="..\:/Users/sergiodt/AndroidStudioProjects/vn-warehouseManager/app/src/main/res/drawable/ic_arrow_back_black_24dp.xml" value="0.22708333333333333" />
<entry key="..\:/Users/sergiodt/AndroidStudioProjects/vn-warehouseManager/app/src/main/res/drawable/ic_arrow_drop_down_black_24dp.xml" value="0.22708333333333333" />
<entry key="..\:/Users/sergiodt/AndroidStudioProjects/vn-warehouseManager/app/src/main/res/drawable/ic_autorenew_black_24dp.xml" value="0.1775" />
<entry key="..\:/Users/sergiodt/AndroidStudioProjects/vn-warehouseManager/app/src/main/res/drawable/ic_baseline_star_24.xml" value="0.1775" />
<entry key="..\:/Users/sergiodt/AndroidStudioProjects/vn-warehouseManager/app/src/main/res/drawable/ic_build_black_24dp.xml" value="0.22708333333333333" />
<entry key="..\:/Users/sergiodt/AndroidStudioProjects/vn-warehouseManager/app/src/main/res/drawable/ic_chevron_right_black_24dp.xml" value="0.1775" />
<entry key="..\:/Users/sergiodt/AndroidStudioProjects/vn-warehouseManager/app/src/main/res/drawable/ic_dashboard_black_24dp.xml" value="0.1775" />
<entry key="..\:/Users/sergiodt/AndroidStudioProjects/vn-warehouseManager/app/src/main/res/drawable/ic_delete_black_24dp.xml" value="0.15052083333333333" />
<entry key="..\:/Users/sergiodt/AndroidStudioProjects/vn-warehouseManager/app/src/main/res/drawable/ic_delete_forever_black_24dp.xml" value="0.15052083333333333" />
<entry key="..\:/Users/sergiodt/AndroidStudioProjects/vn-warehouseManager/app/src/main/res/drawable/ic_device_hub_black_24dp_selected.xml" value="0.15052083333333333" />
<entry key="..\:/Users/sergiodt/AndroidStudioProjects/vn-warehouseManager/app/src/main/res/drawable/ic_device_hub_black_24dp.xml" value="0.22" />
<entry key="..\:/Users/sergiodt/AndroidStudioProjects/vn-warehouseManager/app/src/main/res/drawable/ic_device_hub_black_24dp_selected.xml" value="0.22" />
<entry key="..\:/Users/sergiodt/AndroidStudioProjects/vn-warehouseManager/app/src/main/res/drawable/ic_flash_auto_black_24dp.xml" value="0.15052083333333333" />
<entry key="..\:/Users/sergiodt/AndroidStudioProjects/vn-warehouseManager/app/src/main/res/drawable/ic_history_black_24dp.xml" value="0.15052083333333333" />
<entry key="..\:/Users/sergiodt/AndroidStudioProjects/vn-warehouseManager/app/src/main/res/drawable/ic_history_orange.xml" value="0.22037037037037038" />
<entry key="..\:/Users/sergiodt/AndroidStudioProjects/vn-warehouseManager/app/src/main/res/drawable/ic_launcher_background.xml" value="0.24010416666666667" />
<entry key="..\:/Users/sergiodt/AndroidStudioProjects/vn-warehouseManager/app/src/main/res/drawable/ic_local_florist_black_24dp.xml" value="0.15052083333333333" />
<entry key="..\:/Users/sergiodt/AndroidStudioProjects/vn-warehouseManager/app/src/main/res/drawable/ic_local_florist_black_24dp_selected.xml" value="0.21041666666666667" />
@ -66,6 +78,7 @@
<entry key="..\:/Users/sergiodt/AndroidStudioProjects/vn-warehouseManager/app/src/main/res/drawable/ic_transaction.xml" value="0.22708333333333333" />
<entry key="..\:/Users/sergiodt/AndroidStudioProjects/vn-warehouseManager/app/src/main/res/drawable/ic_verified_user_black_24dp.xml" value="0.1" />
<entry key="..\:/Users/sergiodt/AndroidStudioProjects/vn-warehouseManager/app/src/main/res/drawable/ic_verified_user_black_24dp_selected.xml" value="0.1" />
<entry key="..\:/Users/sergiodt/AndroidStudioProjects/vn-warehouseManager/app/src/main/res/drawable/ic_visibility.xml" value="0.1775" />
<entry key="..\:/Users/sergiodt/AndroidStudioProjects/vn-warehouseManager/app/src/main/res/drawable/ic_visibility_black_24dp.xml" value="0.2546875" />
<entry key="..\:/Users/sergiodt/AndroidStudioProjects/vn-warehouseManager/app/src/main/res/drawable/ic_visibility_black_24dp_white.xml" value="0.2546875" />
<entry key="..\:/Users/sergiodt/AndroidStudioProjects/vn-warehouseManager/app/src/main/res/drawable/ic_visibility_white_24dp.xml" value="0.2546875" />
@ -74,20 +87,23 @@
<entry key="..\:/Users/sergiodt/AndroidStudioProjects/vn-warehouseManager/app/src/main/res/drawable/pallet_shipping_black.xml" value="0.1" />
<entry key="..\:/Users/sergiodt/AndroidStudioProjects/vn-warehouseManager/app/src/main/res/drawable/pallet_shipping_selected.xml" value="0.1" />
<entry key="..\:/Users/sergiodt/AndroidStudioProjects/vn-warehouseManager/app/src/main/res/drawable/phone_call.xml" value="0.26145833333333335" />
<entry key="..\:/Users/sergiodt/AndroidStudioProjects/vn-warehouseManager/app/src/main/res/drawable/previous_delete.xml" value="0.27447916666666666" />
<entry key="..\:/Users/sergiodt/AndroidStudioProjects/vn-warehouseManager/app/src/main/res/drawable/qrcode_scan.xml" value="0.17395833333333333" />
<entry key="..\:/Users/sergiodt/AndroidStudioProjects/vn-warehouseManager/app/src/main/res/drawable/rectangle.xml" value="0.31979166666666664" />
<entry key="..\:/Users/sergiodt/AndroidStudioProjects/vn-warehouseManager/app/src/main/res/drawable/revision_icon.xml" value="0.1" />
<entry key="..\:/Users/sergiodt/AndroidStudioProjects/vn-warehouseManager/app/src/main/res/drawable/round_av_timer_24.xml" value="0.15052083333333333" />
<entry key="..\:/Users/sergiodt/AndroidStudioProjects/vn-warehouseManager/app/src/main/res/drawable/round_outline.xml" value="0.11979166666666667" />
<entry key="..\:/Users/sergiodt/AndroidStudioProjects/vn-warehouseManager/app/src/main/res/drawable/walk.xml" value="0.10885416666666667" />
<entry key="..\:/Users/sergiodt/AndroidStudioProjects/vn-warehouseManager/app/src/main/res/drawable/worker.xml" value="0.12" />
<entry key="..\:/Users/sergiodt/AndroidStudioProjects/vn-warehouseManager/app/src/main/res/drawable/worker_mistake.xml" value="0.15364583333333334" />
<entry key="..\:/Users/sergiodt/AndroidStudioProjects/vn-warehouseManager/app/src/main/res/layout/activity_imageview.xml" value="0.134375" />
<entry key="..\:/Users/sergiodt/AndroidStudioProjects/vn-warehouseManager/app/src/main/res/layout/activity_login.xml" value="0.134375" />
<entry key="..\:/Users/sergiodt/AndroidStudioProjects/vn-warehouseManager/app/src/main/res/layout/activity_login.xml" value="0.1" />
<entry key="..\:/Users/sergiodt/AndroidStudioProjects/vn-warehouseManager/app/src/main/res/layout/activity_main.xml" value="0.17916666666666667" />
<entry key="..\:/Users/sergiodt/AndroidStudioProjects/vn-warehouseManager/app/src/main/res/layout/buyers_fragment.xml" value="0.18333333333333332" />
<entry key="..\:/Users/sergiodt/AndroidStudioProjects/vn-warehouseManager/app/src/main/res/layout/component_custom_dialog.xml" value="0.1490036231884058" />
<entry key="..\:/Users/sergiodt/AndroidStudioProjects/vn-warehouseManager/app/src/main/res/layout/component_custom_edit_dialog.xml" value="0.10208333333333333" />
<entry key="..\:/Users/sergiodt/AndroidStudioProjects/vn-warehouseManager/app/src/main/res/layout/component_custom_hour.xml" value="0.1793478260869565" />
<entry key="..\:/Users/sergiodt/AndroidStudioProjects/vn-warehouseManager/app/src/main/res/layout/component_custom_list_dialog.xml" value="0.1490036231884058" />
<entry key="..\:/Users/sergiodt/AndroidStudioProjects/vn-warehouseManager/app/src/main/res/layout/component_custom_list_dialog.xml" value="0.3333333333333333" />
<entry key="..\:/Users/sergiodt/AndroidStudioProjects/vn-warehouseManager/app/src/main/res/layout/component_custom_three_dialog.xml" value="0.12817028985507245" />
<entry key="..\:/Users/sergiodt/AndroidStudioProjects/vn-warehouseManager/app/src/main/res/layout/component_custom_two_dialog.xml" value="0.1793478260869565" />
<entry key="..\:/Users/sergiodt/AndroidStudioProjects/vn-warehouseManager/app/src/main/res/layout/fragment_ajustes.xml" value="0.3333333333333333" />
@ -125,13 +141,14 @@
<entry key="..\:/Users/sergiodt/AndroidStudioProjects/vn-warehouseManager/app/src/main/res/layout/fragment_sacador.xml" value="0.12952898550724637" />
<entry key="..\:/Users/sergiodt/AndroidStudioProjects/vn-warehouseManager/app/src/main/res/layout/fragment_sacador_associatesmarttag.xml" value="0.22" />
<entry key="..\:/Users/sergiodt/AndroidStudioProjects/vn-warehouseManager/app/src/main/res/layout/fragment_shelving_parking.xml" value="0.1793478260869565" />
<entry key="..\:/Users/sergiodt/AndroidStudioProjects/vn-warehouseManager/app/src/main/res/layout/fragment_shelvinglog.xml" value="0.13269927536231885" />
<entry key="..\:/Users/sergiodt/AndroidStudioProjects/vn-warehouseManager/app/src/main/res/layout/fragment_shelvinglog.xml" value="0.3333333333333333" />
<entry key="..\:/Users/sergiodt/AndroidStudioProjects/vn-warehouseManager/app/src/main/res/layout/fragment_smarttag_register.xml" value="0.3118811881188119" />
<entry key="..\:/Users/sergiodt/AndroidStudioProjects/vn-warehouseManager/app/src/main/res/layout/fragment_transferencia.xml" value="0.10666666666666667" />
<entry key="..\:/Users/sergiodt/AndroidStudioProjects/vn-warehouseManager/app/src/main/res/layout/fragment_ubicador.xml" value="0.22" />
<entry key="..\:/Users/sergiodt/AndroidStudioProjects/vn-warehouseManager/app/src/main/res/layout/fragment_vehiclecontrol.xml" value="0.1546875" />
<entry key="..\:/Users/sergiodt/AndroidStudioProjects/vn-warehouseManager/app/src/main/res/layout/fragment_vehiclecontrol_user.xml" value="0.23052536231884058" />
<entry key="..\:/Users/sergiodt/AndroidStudioProjects/vn-warehouseManager/app/src/main/res/layout/fragment_web.xml" value="0.2463768115942029" />
<entry key="..\:/Users/sergiodt/AndroidStudioProjects/vn-warehouseManager/app/src/main/res/layout/fragment_workermistake.xml" value="0.2265625" />
<entry key="..\:/Users/sergiodt/AndroidStudioProjects/vn-warehouseManager/app/src/main/res/layout/item_ajustes_row.xml" value="0.10009057971014493" />
<entry key="..\:/Users/sergiodt/AndroidStudioProjects/vn-warehouseManager/app/src/main/res/layout/item_article_row.xml" value="0.4466666666666667" />
<entry key="..\:/Users/sergiodt/AndroidStudioProjects/vn-warehouseManager/app/src/main/res/layout/item_article_row_presacador.xml" value="0.4466666666666667" />
@ -146,6 +163,7 @@
<entry key="..\:/Users/sergiodt/AndroidStudioProjects/vn-warehouseManager/app/src/main/res/layout/item_expeditionstate_row.xml" value="0.23489583333333333" />
<entry key="..\:/Users/sergiodt/AndroidStudioProjects/vn-warehouseManager/app/src/main/res/layout/item_expeditiontruck_row.xml" value="0.1793478260869565" />
<entry key="..\:/Users/sergiodt/AndroidStudioProjects/vn-warehouseManager/app/src/main/res/layout/item_faltas_row.xml" value="0.1793478260869565" />
<entry key="..\:/Users/sergiodt/AndroidStudioProjects/vn-warehouseManager/app/src/main/res/layout/item_general_row.xml" value="0.13360507246376813" />
<entry key="..\:/Users/sergiodt/AndroidStudioProjects/vn-warehouseManager/app/src/main/res/layout/item_historico_row.xml" value="0.15353260869565216" />
<entry key="..\:/Users/sergiodt/AndroidStudioProjects/vn-warehouseManager/app/src/main/res/layout/item_historicovehiculo_row.xml" value="0.18795289855072464" />
<entry key="..\:/Users/sergiodt/AndroidStudioProjects/vn-warehouseManager/app/src/main/res/layout/item_inventary_row.xml" value="0.22604166666666667" />
@ -157,12 +175,13 @@
<entry key="..\:/Users/sergiodt/AndroidStudioProjects/vn-warehouseManager/app/src/main/res/layout/item_proposal_row.xml" value="0.22604166666666667" />
<entry key="..\:/Users/sergiodt/AndroidStudioProjects/vn-warehouseManager/app/src/main/res/layout/item_reposicion.xml" value="0.1" />
<entry key="..\:/Users/sergiodt/AndroidStudioProjects/vn-warehouseManager/app/src/main/res/layout/item_shelvingdayofsale_row.xml" value="0.2375" />
<entry key="..\:/Users/sergiodt/AndroidStudioProjects/vn-warehouseManager/app/src/main/res/layout/item_shelvinglog_row.xml" value="0.21739130434782608" />
<entry key="..\:/Users/sergiodt/AndroidStudioProjects/vn-warehouseManager/app/src/main/res/layout/item_shelvinglog_row.xml" value="0.3333333333333333" />
<entry key="..\:/Users/sergiodt/AndroidStudioProjects/vn-warehouseManager/app/src/main/res/layout/item_shelvingparking_row.xml" value="0.1793478260869565" />
<entry key="..\:/Users/sergiodt/AndroidStudioProjects/vn-warehouseManager/app/src/main/res/layout/item_smarttag_row.xml" value="0.20153985507246377" />
<entry key="..\:/Users/sergiodt/AndroidStudioProjects/vn-warehouseManager/app/src/main/res/layout/item_toolbar_row.xml" value="0.15307971014492755" />
<entry key="..\:/Users/sergiodt/AndroidStudioProjects/vn-warehouseManager/app/src/main/res/layout/item_ubication_row.xml" value="0.11822916666666666" />
<entry key="..\:/Users/sergiodt/AndroidStudioProjects/vn-warehouseManager/app/src/main/res/layout/item_worker_image.xml" value="0.23177083333333334" />
<entry key="..\:/Users/sergiodt/AndroidStudioProjects/vn-warehouseManager/app/src/main/res/layout/item_workermistake_row.xml" value="0.4466666666666667" />
<entry key="..\:/Users/sergiodt/AndroidStudioProjects/vn-warehouseManager/app/src/main/res/layout/qauality_fragment.xml" value="0.15353260869565216" />
<entry key="..\:/Users/sergiodt/AndroidStudioProjects/vn-warehouseManager/app/src/main/res/layout/reposicion_fragment.xml" value="0.15353260869565216" />
<entry key="..\:/Users/sergiodt/AndroidStudioProjects/vn-warehouseManager/app/src/main/res/layout/shelvinglog_row.xml" value="0.18385416666666668" />

View File

@ -3,21 +3,22 @@ apply plugin: 'kotlin-android'
//apply plugin: 'kotlin-android-extensions'//deprecated:sergio
apply plugin: 'kotlin-kapt'
apply plugin: 'com.google.gms.google-services'
apply plugin: 'com.google.firebase.crashlytics'
//apply plugin: 'com.google.firebase.crashlytics'
android {
compileSdkVersion 29
compileSdkVersion 30
// buildToolsVersion "29.0.3"
defaultConfig {
applicationId "es.verdnatura"
minSdkVersion 21
targetSdkVersion 29
versionCode 100
versionName "7.6" //VERSION CODE 100. Envios rocket a previa, revisados databinding layouts,
//versionName "7.5.1" //VERSION CODE 97. Control de previa, Llamadas ok, menú ok y textos en iconos y imágenes.
//versionName "7.5.1" VERSION CODE 99 PARA TESTEAR APP-->INSTALADA EN VARIOS USUARIO 24-01-2022
targetSdkVersion 30
versionCode 107
versionName "7.9" //VERSION CODE 107 Seleccionar impresora para imprimir
//versionName "7.8" //VERSION CODE 106 Previa final,tiene en cuenta si hay varios carros donde coger,,
//versionName "7.7.2" //VERSION CODE 105 Previa final , si se pone a 0 un artículo se revisa el total de líneas
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
@ -110,7 +111,7 @@ dependencies {
// Add the Firebase Crashlytics SDK.
implementation 'com.google.firebase:firebase-analytics:17.5.0'
implementation 'com.google.firebase:firebase-crashlytics:17.2.1'
//implementation 'com.google.firebase:firebase-crashlytics:17.2.1'
//search
implementation 'com.github.mirrajabi:search-dialog:1.1'

View File

@ -11,8 +11,8 @@
"type": "SINGLE",
"filters": [],
"attributes": [],
"versionCode": 99,
"versionName": "7.5.1",
"versionCode": 107,
"versionName": "7.9",
"outputFile": "app-release.apk"
}
],

Binary file not shown.

View File

@ -29,11 +29,18 @@ import es.verdnatura.presentation.view.feature.shelvingparking.fragment.Shelving
import es.verdnatura.presentation.view.feature.smarttag.sacador.fragment.SmartTagsViewModel
import es.verdnatura.presentation.view.feature.ubicador.fragment.AutomaticAddItemViewModel
import es.verdnatura.presentation.view.feature.ubicador.fragment.UbicadorViewModel
import es.verdnatura.presentation.view.feature.workermistake.fragment.WorkermistakeViewModel
import org.koin.android.ext.koin.androidContext
import org.koin.androidx.viewmodel.dsl.viewModel
import org.koin.dsl.module
val viewModelModule = module {
viewModel{
WorkermistakeViewModel(androidContext())
}
// Login
viewModel {
LoginViewModel(androidContext())

View File

@ -7,7 +7,7 @@ class ApiNodeJsUtils {
companion object {
//const val BASE_URL:String = "http://192.168.1.108:8000/"
const val BASE_URL:String = "http://10.2.2.49:7777"
const val BASE_URL:String = "https://smart-tag.verdnatura.es"
fun getApiService():NodeJsService{
val nodeJsRetrofit = Retrofit.Builder().baseUrl(BASE_URL).addConverterFactory(
GsonConverterFactory.create()).build()

View File

@ -6,8 +6,8 @@ import retrofit2.converter.gson.GsonConverterFactory
class ApiSalixUtils {
companion object {
//const val BASE_URL:String = "http://192.168.1.155:9009/"
// const val BASE_URL: String = "https://test-salix.verdnatura.es/api/"
const val BASE_URL: String = "https://salix.verdnatura.es/api/"
//const val BASE_URL: String = "https://test-salix.verdnatura.es/api/"
fun getApiService(): SalixService {
val salixRetrofit = Retrofit.Builder().baseUrl(BASE_URL).addConverterFactory(
GsonConverterFactory.create()

View File

@ -8,6 +8,8 @@ object ConstAndValues {
const val ON_PREPARATION = "ON_PREPARATION"
//const val CHECKED = "CHECKED"
const val PRESACADOR = "PRESACADOR" //PREITEMPICKER
const val PREITEMPICKER = "PREITEMPICKER"
const val ON_CHECKING = "ON_CHECKING"
const val PRECHECKER = "PRECHECKER"
const val MAINACTIVITY = "MAIN"

View File

@ -1,6 +1,7 @@
package es.verdnatura.domain
import android.content.Context
import es.verdnatura.presentation.view.feature.ajustes.model.Printers
import es.verdnatura.presentation.view.feature.ajustes.model.SectorItemVO
import retrofit2.Call
@ -13,4 +14,22 @@ class GetAjustesUserCase(context: Context) : RestClient(context) {
fun getSectorsSalix(token:String): Call<List<SectorItemVO>> {
return salixClient!!.getSectorsSalix(content_type = "application/json", authorization = token)
}
fun worker_updateSector(usuario: String, password: String,sectorFk:String): Call<Unit> {
val params: ArrayList<String> = ArrayList()
params.add(sectorFk)
return restClient!!.worker_updateSector("json", "1", usuario, password, "application/json",params)
}
fun worker_updatePrinter(usuario: String, password: String,labelerFk:String): Call<Unit> {
val params: ArrayList<String> = ArrayList()
params.add(labelerFk)
return restClient!!.worker_updatePrinter("json", "1", usuario, password, "application/json",params)
}
fun printer_get(usuario: String, password: String): Call<List<Printers>> {
return restClient!!.printer_get("json", "1", usuario, password, "application/json")
}
}

View File

@ -1,19 +1,17 @@
package es.verdnatura.domain
import android.content.Context
import com.google.gson.JsonObject
import es.verdnatura.presentation.view.feature.diadeventa.model.ItemShelvingSaleDate
import es.verdnatura.presentation.view.feature.historicovehiculo.model.ItemHistoricoVehiculo
import retrofit2.Call
class GetDayOfSaleUSerCase(context: Context) : RestClient(context) {
fun itemShelving_updateSpam(usuario: String, password: String,vShelvingFK:String): Call<Boolean> {
/*fun itemShelving_updateSpam(usuario: String, password: String,vShelvingFK:String): Call<Boolean> {
val params: ArrayList<String> = ArrayList()
params.add(vShelvingFK)
return restClient!!.itemShelving_updateSpam("json", "1", usuario, password, "application/json",params=params)
}
}*/
/* fun itemShelving_getSaleDateOld(
usuario: String,
password: String,

View File

@ -1,21 +1,13 @@
package es.verdnatura.domain
import android.content.Context
import es.verdnatura.presentation.view.feature.ajustes.model.SectorItemVO
import es.verdnatura.presentation.view.feature.login.model.*
import retrofit2.Call
class GetLoginUserCase(context: Context) : RestClient(context)
{
fun login(usuario: String, password: String, androiid: String): Call<String>
{
val params: ArrayList<String> = ArrayList()
params.add(usuario)
params.add(password)
params.add(androiid)
return restClient!!.login("json", "1", usuario, password, "application/json", params)
}
fun device_checkLogin(
usuario: String,
password: String,
@ -69,31 +61,41 @@ class GetLoginUserCase(context: Context) : RestClient(context)
}
//NODEJS TEST
fun nodeJsTest(
/*fun nodeJsTest(
smarttag: String,
wagon: String,
shelving: String
): Call<NodeJsService.SmartTagNode>
{
return nodejsClient!!.bindShelving("application/json", "A0A3B8224DBF", "ABC", "2")
//https://smart-tag.verdnatura.es/bindShelving/A0A3B8224DBF&ABC&1
return nodejsClient!!.bindShelving("application/json", "A0A3B8224DBF", "AAA", "1")
// return nodejsClient!!.bindShelving("application/json", NodeJsService.SmartTagNode(smarttag, wagon, shelving),"A0A3B8224DBF","ABC","2")
}
}*/
// SALIX SERGIO MENSAJE : PARA NO ENVIAR MENSAJES A COMERCIALES PONGO QUE LAS MODIFICACIONES SE ENVIAN AL CANAL CREADO.
// SE CAMBIA VARIABLE A TRUE/FALSE
/* fun checkVersion_old(usuario: String, password: String, version: String): Call<Boolean>
{
val params: ArrayList<String> = ArrayList()
params.add(version)
return restClient!!.version("json", "1", usuario, password, "application/json", params)
*/
//SALIX SERGIO MENSAJE : PARA NO ENVIAR MENSAJES A COMERCIALES PONGO QUE LAS MODIFICACIONES SE ENVIAN AL CANAL CREADO.
fun sendChekingPresence(token:String,workerId:Int,message:String) : Call<Boolean>{
return salixClient!!.sendChekingPresence(content_type = "application/json", authorization = token, params = SalixMessageVO(workerId = workerId,message = message))
}
// SERGIO: PARA DESARROLLO SE DESCOMENTA ESTAS LÍNEAS Y SE COMENTAN LAS DE ARRIBA
var working_in_test=false
if (!working_in_test) {
return salixClient!!.sendChekingPresence(
content_type = "application/json",
authorization = token,
params = SalixMessageVO(workerId = workerId, message = message)
)
}else{
return salixClient!!.sendGroup(
content_type = "application/json",
authorization = token,
params = SalixGrupo(to = "#android-test", message = message))
}
}
/*fun sendChekingPresence(token: String, workerId: Int, message: String): Call<Boolean>
{
@ -110,5 +112,9 @@ val params: ArrayList<String> = ArrayList()
params.add(nameApp)
return restClient!!.getVersion("json", "1", usuario, password, "application/json", params)
}
fun worker_getSector(usuario: String, password: String): Call<SectorItemVO> {
//val params: ArrayList<String> = ArrayList()
return restClient!!.worker_getSector("json", "1", usuario, password, "application/json")
}
}

View File

@ -2,6 +2,7 @@ package es.verdnatura.domain
import android.content.Context
import es.verdnatura.presentation.view.feature.presacador.model.PreSacadorItemVO
import es.verdnatura.presentation.view.feature.sacador.model.CollectionVO
import retrofit2.Call
class GetPreSacadorUseCase(context: Context) : RestClient(context) {
@ -61,4 +62,111 @@ class GetPreSacadorUseCase(context: Context) : RestClient(context) {
)
}
}
fun sectorCollection_new(
usuario: String,
password: String,
sectorFk: String
): Call<Unit> {
val params: ArrayList<String> = ArrayList()
params.add(sectorFk)
return restClient!!.sectorCollection_new(
"json",
"1",
usuario,
password,
"application/json",
params
)
}
fun sectorCollectionSaleGroup_add(
usuario: String,
password: String,
vSaleGroupFk: String,
vSectorCollectionFk:String
): Call<Unit> {
val params: ArrayList<String> = ArrayList()
params.add(vSaleGroupFk)
params.add(vSectorCollectionFk)
return restClient!!.sectorCollectionSaleGroup_add(
"json",
"1",
usuario,
password,
"application/json",
params
)
}
fun saleTracking_addPrevOK(
usuario: String,
password: String,
vSectorCollectionFk:String
): Call<Unit> {
val params: ArrayList<String> = ArrayList()
params.add(vSectorCollectionFk)
return restClient!!.saleTracking_addPrevOK(
"json",
"1",
usuario,
password,
"application/json",
params
)
}
fun saleTracking_updateIsChecked(
usuario: String,
password: String,
vSaleFk:String,
vIsChecked:String
): Call<Unit> {
val params: ArrayList<String> = ArrayList()
params.add(vSaleFk)
params.add(vIsChecked)
return restClient!!.saleTracking_updateIsChecked(
"json",
"1",
usuario,
password,
"application/json",
params
)
}
fun sectorCollection_get(usuario: String, password: String): Call<List<CollectionVO>> {
return restClient!!.sectorCollection_get("json", "1", usuario, password, "application/json")
}
fun sectorCollection_getSale(
usuario: String,
password: String,
sectorCollectionFK: String,
vSectorFk:String
): Call<List<PreSacadorItemVO>> {
val params: ArrayList<String> = ArrayList()
params.add(sectorCollectionFK)
params.add(vSectorFk)
return restClient!!.sectorCollection_getSale(
"json",
"1",
usuario,
password,
"application/json",
params
)
}
}

View File

@ -120,6 +120,9 @@ class GetSacadorControladorUserCase(context: Context) : RestClient(context) {
// val params:ArrayList<String> = ArrayList()
return restClient!!.collectionGet("json", "1", usuario, password, "application/json")
}
fun collectionGetSalix(token:String): Call<List<CollectionVO>> {
// val params:ArrayList<String> = ArrayList()
return salixClient!!.getCollectionSalix(content_type = "application/json",token)
@ -150,6 +153,8 @@ class GetSacadorControladorUserCase(context: Context) : RestClient(context) {
)
}
fun itemPlacementSupplyAiming(
usuario: String,
password: String,

View File

@ -1,6 +1,7 @@
package es.verdnatura.domain
import android.content.Context
import es.verdnatura.presentation.view.feature.smarttag.sacador.model.SmartTagRegister
import retrofit2.Call
class GetSmarttagsUserCase(context: Context) : RestClient(context) {
@ -30,10 +31,24 @@ class GetSmarttagsUserCase(context: Context) : RestClient(context) {
params
)
}
fun smartTagRegister(
smarttag: String,
shelving: String,
level: String
): Call<SmartTagRegister>
{
//https://smart-tag.verdnatura.es/bindShelving/A0A3B8224DBF&ABC&1
return nodejsClient!!.bindShelving("application/json", smarttag, shelving, level)
// return nodejsClient!!.bindShelving("application/json", NodeJsService.SmartTagNode(smarttag, wagon, shelving),"A0A3B8224DBF","ABC","2")
/* fun smartTag_nextLevel(usuario:String,password:String,vShelvingFk :String) : Call<String> {
val params:ArrayList<String> = ArrayList();
params.add(vShelvingFk)
return restClient!!.smartTag_nextLevel("json","1",usuario,password,"application/json",params)
}*/
}
fun smartTagInsertTicket(
smarttag: String,
): Call<SmartTagRegister>
{
return nodejsClient!!.insertTicket("application/json", smarttag)
}
}

View File

@ -0,0 +1,59 @@
package es.verdnatura.domain
import android.content.Context
import es.verdnatura.presentation.view.feature.sacador.model.CollectionVO
import es.verdnatura.presentation.view.feature.sacador.model.MistakeTypeVO
import es.verdnatura.presentation.view.feature.workermistake.model.DepartmentMistake
import es.verdnatura.presentation.view.feature.workermistake.model.MistakeWorkerType
import es.verdnatura.presentation.view.feature.workermistake.model.WorkerFromMistake
import retrofit2.Call
class GetWokerMistakeUSerCase(context: Context) : RestClient(context) {
fun collectionGet(usuario: String, password: String): Call<List<CollectionVO>> {
// val params:ArrayList<String> = ArrayList()
return restClient!!.collectionGet("json", "1", usuario, password, "application/json")
}
fun collectionGetSalix(token:String): Call<List<CollectionVO>> {
// val params:ArrayList<String> = ArrayList()
return salixClient!!.getCollectionSalix(content_type = "application/json",token)
}
fun workerMistake_Add(
usuario: String,
password: String,
vUserFk: String,
vTypeFk: String
): Call<Unit> {
val params: ArrayList<String> = ArrayList()
params.add(vUserFk)
params.add(vTypeFk)
return restClient!!.workerMistake_Add(
"json",
"1",
usuario,
password,
"application/json",
params
)
}
fun workerMistakeType_get(usuario: String, password: String): Call<List<MistakeWorkerType>> {
return restClient!!.workerMistakeType_get("json", "1", usuario, password, "application/json")
}
fun department_getHasMistake(usuario: String, password: String): Call<List<DepartmentMistake>> {
return restClient!!.department_getHasMistake("json", "1", usuario, password, "application/json")
}
fun worker_getFromHasMistake(usuario: String, password: String, department:String): Call<List<WorkerFromMistake>> {
val params: ArrayList<String> = ArrayList()
params.add(department)
return restClient!!.worker_getFromHasMistake("json", "1", usuario, password, "application/json",params)
}
}

View File

@ -1,9 +1,8 @@
package es.verdnatura.domain
import es.verdnatura.presentation.view.feature.smarttag.sacador.model.SmartTagRegister
import retrofit2.Call
import retrofit2.http.Header
import retrofit2.http.POST
import retrofit2.http.Path
import retrofit2.http.*
interface NodeJsService {
@ -14,16 +13,25 @@ interface NodeJsService {
//NODEJS TEST
// @FormUrlEncoded
@POST("/bindShelving/{Id1}&{Id2}&{Id3}")
//@FormUrlEncoded
@GET("/bindShelving/{smarttag}&{shelvingFK}&{height}")
fun bindShelving(
@Header("Content-Type") content_type: String,
@Path("Id1") id: String,
@Path("Id2") id2: String,
@Path("Id3") id3: String
@Path("smarttag") id: String,
@Path("shelvingFK") id2: String,
@Path("height") id3: String
):
Call<SmartTagNode>
Call<SmartTagRegister>
@GET("/insertTicket/{collectionFk}")
fun insertTicket(
@Header("Content-Type") content_type: String,
@Path("collectionFk") id: String
):
Call<SmartTagRegister>
class SmartTagNode(
var message: String = "",

View File

@ -37,7 +37,7 @@ interface SalixService {
fun getSectorsSalix(
@Header("Content-Type") content_type: String,
@Header("Authorization") authorization: String,
//@Body params: SalixGrupo
):
Call<List<SectorItemVO>>
@ -48,4 +48,12 @@ interface SalixService {
):
Call<List<CollectionVO>>
@GET("collections/sectorCollection_get")
fun sectorCollection_get(
@Header("Content-Type") content_type: String,
@Header("Authorization") authorization: String,
):
Call<List<CollectionVO>>
}

View File

@ -1,6 +1,7 @@
package es.verdnatura.domain
import com.google.gson.JsonObject
import es.verdnatura.presentation.view.feature.ajustes.model.Printers
import es.verdnatura.presentation.view.feature.ajustes.model.SectorItemVO
import es.verdnatura.presentation.view.feature.articulo.model.ItemCardVO
import es.verdnatura.presentation.view.feature.articulo.model.ItemPackingType
@ -25,6 +26,9 @@ import es.verdnatura.presentation.view.feature.sacador.model.MistakeTypeVO
import es.verdnatura.presentation.view.feature.sacador.model.PlacementSupplyVO
import es.verdnatura.presentation.view.feature.shelvingparking.model.ItemShelvingParkingVO
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.MistakeWorkerType
import es.verdnatura.presentation.view.feature.workermistake.model.WorkerFromMistake
import retrofit2.Call
import retrofit2.http.Body
import retrofit2.http.Header
@ -111,6 +115,48 @@ interface VerdnaturaService {
):
Call<List<SectorItemVO>>
@POST("almacennew/printer_get")//REVISADA
fun printer_get(
@Header("aplicacion") aplicacion: String,
@Header("version") version: String,
@Header("user") user: String,
@Header("pass") pass: String,
@Header("Content-Type") content_type: String
):
Call<List<Printers>>
@POST("almacennew/worker_updatePrinter")//REVISADA
fun worker_updatePrinter(
@Header("aplicacion") aplicacion: String,
@Header("version") version: String,
@Header("user") user: String,
@Header("pass") pass: String,
@Header("Content-Type") content_type: String,
@Body params:List<String>
):
Call<Unit>
@POST("almacennew/worker_updateSector")//REVISADA
fun worker_updateSector(
@Header("aplicacion") aplicacion: String,
@Header("version") version: String,
@Header("user") user: String,
@Header("pass") pass: String,
@Header("Content-Type") content_type: String,
@Body params:List<String>
):
Call<Unit>
@POST("almacennew/worker_getSector")//REVISADA
fun worker_getSector(
@Header("aplicacion") aplicacion: String,
@Header("version") version: String,
@Header("user") user: String,
@Header("pass") pass: String,
@Header("Content-Type") content_type: String
):
Call<SectorItemVO>
//PRESACADORES ========================================================================>
@POST("almacennew/ticketToPrePrepare")//REVISADA
@ -124,6 +170,17 @@ interface VerdnaturaService {
):
Call<List<PreSacadorItemVO>>
@POST("almacennew/sectorCollection_getSale")//REVISADA
fun sectorCollection_getSale(
@Header("aplicacion") aplicacion: String,
@Header("version") version: String,
@Header("user") user: String,
@Header("pass") pass: String,
@Header("Content-Type") content_type: String,
@Body params: List<String>
):
Call<List<PreSacadorItemVO>>
@POST("almacennew/itemPlacementSupplyGetOrder")//REVISADA
fun itemPlacementSupplyGetOrder(
@Header("aplicacion") aplicacion: String,
@ -157,6 +214,17 @@ interface VerdnaturaService {
):
Call<List<CollectionVO>>
@POST("almacennew/sectorCollection_get") //REVISADA
fun sectorCollection_get(
@Header("aplicacion") aplicacion: String,
@Header("version") version: String,
@Header("user") user: String,
@Header("pass") pass: String,
@Header("Content-Type") content_type: String
):
Call<List<CollectionVO>>
@POST("almacennew/collectionNew")//REVISADA
fun collectionNew(
@Header("aplicacion") aplicacion: String,
@ -168,6 +236,50 @@ interface VerdnaturaService {
):
Call<String>
@POST("almacennew/sectorCollection_new")//REVISADA
fun sectorCollection_new(
@Header("aplicacion") aplicacion: String,
@Header("version") version: String,
@Header("user") user: String,
@Header("pass") pass: String,
@Header("Content-Type") content_type: String,
@Body params: List<String>
):
Call<Unit>
@POST("almacennew/sectorCollectionSaleGroup_add")//REVISADA
fun sectorCollectionSaleGroup_add(
@Header("aplicacion") aplicacion: String,
@Header("version") version: String,
@Header("user") user: String,
@Header("pass") pass: String,
@Header("Content-Type") content_type: String,
@Body params: List<String>
):
Call<Unit>
@POST("almacennew/saleTracking_addPrevOK")//REVISADA
fun saleTracking_addPrevOK(
@Header("aplicacion") aplicacion: String,
@Header("version") version: String,
@Header("user") user: String,
@Header("pass") pass: String,
@Header("Content-Type") content_type: String,
@Body params: List<String>
):
Call<Unit>
@POST("almacennew/saleTracking_updateIsChecked")//REVISADA
fun saleTracking_updateIsChecked(
@Header("aplicacion") aplicacion: String,
@Header("version") version: String,
@Header("user") user: String,
@Header("pass") pass: String,
@Header("Content-Type") content_type: String,
@Body params: List<String>
):
Call<Unit>
/* @POST("almacennew/collectionTicketGet")//REVISADA-ANULADA POT collection_getTickets
fun collectionTicketGet(
@Header("aplicacion") aplicacion: String,
@ -235,6 +347,17 @@ interface VerdnaturaService {
):
Call<String>
/* @POST("almacennew/saleTracking_update")//REVISADA
fun saleTracking_update(
@Header("aplicacion") aplicacion: String,
@Header("version") version: String,
@Header("user") user: String,
@Header("pass") pass: String,
@Header("Content-Type") content_type: String,
@Body params: List<String>
):
Call<Unit>*/
@POST("almacennew/itemPlacementSupplyAiming")//REVISADA
fun itemPlacementSupplyAiming(
@Header("aplicacion") aplicacion: String,
@ -413,6 +536,17 @@ interface VerdnaturaService {
):
Call<String>
@POST("almacennew/workerMistake_Add")//REVISADA
fun workerMistake_Add(
@Header("aplicacion") aplicacion: String,
@Header("version") version: String,
@Header("user") user: String,
@Header("pass") pass: String,
@Header("Content-Type") content_type: String,
@Body params: List<String>
):
Call<Unit>
@POST("almacennew/mistakeType")//REVISADA
fun mistakeType(
@Header("aplicacion") aplicacion: String,
@ -423,6 +557,39 @@ interface VerdnaturaService {
):
Call<List<MistakeTypeVO>>
@POST("almacennew/workerMistakeType_get")//REVISADA
fun workerMistakeType_get(
@Header("aplicacion") aplicacion: String,
@Header("version") version: String,
@Header("user") user: String,
@Header("pass") pass: String,
@Header("Content-Type") content_type: String
):
Call<List<MistakeWorkerType>>
@POST("almacennew/department_getHasMistake")//REVISADA
fun department_getHasMistake(
@Header("aplicacion") aplicacion: String,
@Header("version") version: String,
@Header("user") user: String,
@Header("pass") pass: String,
@Header("Content-Type") content_type: String,
):
Call<List<DepartmentMistake>>
@POST("almacennew/worker_getFromHasMistake")//REVISADA
fun worker_getFromHasMistake(
@Header("aplicacion") aplicacion: String,
@Header("version") version: String,
@Header("user") user: String,
@Header("pass") pass: String,
@Header("Content-Type") content_type: String,
@Body params: List<String>
):
Call<List<WorkerFromMistake>>
//PASILLEROS ========================================================================>
//CONSULTAR ARTICULO ========================================================================>
@ -595,7 +762,8 @@ interface VerdnaturaService {
//INVENTARIO ========================================================================>
@POST("almacennew/itemShelvingRadar")//REVISADA
/* @POST("almacennew/itemShelvingRadar")//REVISADA
fun itemShelvingRadar(
@Header("aplicacion") aplicacion: String,
@Header("version") version: String,
@ -605,7 +773,7 @@ interface VerdnaturaService {
@Body params: List<String>
):
Call<List<ItemInventaryVO>>
*/
@POST("almacennew/itemShelving_filterBuyer")//REVISADA
fun itemShelvingRadarFilterBuyer(
@Header("aplicacion") aplicacion: String,

View File

@ -14,7 +14,6 @@ import android.speech.RecognizerIntent
import android.speech.SpeechRecognizer
import android.speech.tts.TextToSpeech
import android.speech.tts.UtteranceProgressListener
import android.text.Editable
import android.util.Log
import android.view.LayoutInflater
import android.view.View
@ -24,6 +23,7 @@ import androidx.annotation.LayoutRes
import androidx.databinding.DataBindingUtil
import androidx.databinding.ViewDataBinding
import androidx.fragment.app.Fragment
import androidx.preference.PreferenceManager
import com.google.gson.Gson
import com.google.gson.reflect.TypeToken
import es.verdnatura.R
@ -31,6 +31,7 @@ import es.verdnatura.domain.ConstAndValues
import es.verdnatura.domain.ConstAndValues.SECTORFKDEFAULT
import es.verdnatura.domain.toast
import es.verdnatura.presentation.common.mediaCurrentVolume
import es.verdnatura.presentation.view.feature.main.activity.MainActivity
import org.koin.androidx.viewmodel.ext.android.viewModel
import timber.log.Timber
import java.util.*
@ -49,6 +50,10 @@ abstract class BaseFragment<T : ViewDataBinding, V : BaseViewModel>(viewModelCla
protected val TOKEN = "token"
protected val SECTORDESCRIP = "sectordescrip"
protected val SECTORFK = "sectorFk"
protected val PRINTERNAME= "printername"
protected val PRINTERFK = "printerFk"
protected val WAREHOUSEFK = "warehouseFk"
protected val RECORDAR = "recordar"
protected val ANDROID_ID = "ANDROID_ID"
@ -60,10 +65,14 @@ abstract class BaseFragment<T : ViewDataBinding, V : BaseViewModel>(viewModelCla
protected val WAGON = "wagon"
protected val TAGSTYPE = "tagstype"
protected val WAREHOUSEFK_DEFAULT = 60
protected val DATENOVEHICLE="DATENOVEHICLE"
protected val DEPARTMENTMISTAKE="DEPARTMENTMISTAKE"
protected val DEPARTMENTMISTAKEID="DEPARTMENTMISTAKEID"
protected val viewModel: V by viewModel(viewModelClass)
protected lateinit var binding: T
private var isOnReadyForSpeech = false
protected lateinit var ma: MainActivity
private var textToSpeech: TextToSpeech? = null
private var mAudioManager: AudioManager? = null
@ -89,6 +98,16 @@ abstract class BaseFragment<T : ViewDataBinding, V : BaseViewModel>(viewModelCla
)
override fun onAttach(context: Context) {
super.onAttach(context)
if ((requireActivity().componentName).toString().contains("MainActivity")){
ma=activity as MainActivity
}
}
override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
@ -115,11 +134,14 @@ override fun onViewCreated(view: View, savedInstanceState: Bundle?)
observeViewModel()
runSound()
//requestRecordAudioPermission()
requestRecordAudioPermissionNew()
requestCallPhonePermissionNew()
//requestRecordAudioPermissionNew()
//sergio: para llamadas con SIP
//requestCallPhonePermissionNew()
init()
}
@LayoutRes
@ -185,9 +207,8 @@ override fun onViewCreated(view: View, savedInstanceState: Bundle?)
if (textScanned.length>13) {
var size = textScanned.length
if (textScanned!!.substring((size / 2), size)
.equals(textScanned.substring(0, size / 2))
) {
if (textScanned.substring((size / 2), size) == textScanned.substring(0, size / 2)
) {
return textScanned.substring(0, size / 2)
}
@ -224,6 +245,7 @@ override fun onViewCreated(view: View, savedInstanceState: Bundle?)
R.drawable.alpha_b_circle_outline->"Ver movimientos de Basura"
R.drawable.filter_outline->"Filtra por tipo de flor"
R.drawable.previous_delete->"Quita de pantalla lo que ya está sacado ( misma función que escanear 2.000.000)"
else -> {""}
}
@ -478,7 +500,10 @@ override fun onViewCreated(view: View, savedInstanceState: Bundle?)
mSpeechRecognizer = null
}
}
private fun getDefaults(key: String?, context: Context?): String? {
val preferences = PreferenceManager.getDefaultSharedPreferences(context)
return preferences.getString(key, null)
}
fun getData(name:String):String{
val prefs: SharedPreferences = requireActivity().getSharedPreferences(PREFS_USER, 0)
return when (name){
@ -495,12 +520,71 @@ override fun onViewCreated(view: View, savedInstanceState: Bundle?)
SECTORDESCRIP->prefs.getString(name,getString(R.string.Sinsector)).toString()
BUYER->prefs.getString(name,"").toString()
BUYERID->prefs.getString(name,"").toString()
DATENOVEHICLE->prefs.getString(name,"0").toString()
DEPARTMENTMISTAKE->prefs.getString(name,"").toString()
DEPARTMENTMISTAKEID->prefs.getString(name,"").toString()
PRINTERFK->prefs.getInt(name,0).toString()
PRINTERNAME->prefs.getString(name,"Sin impresora").toString()
"base_url"->{
val preferences = PreferenceManager.getDefaultSharedPreferences(context)
preferences.getString("base_url","").toString()
}
else -> {""}
}
}
fun setDefaults(key: String?, value: String?, context: Context?) {
val preferences: SharedPreferences = PreferenceManager.getDefaultSharedPreferences(context)
val editor = preferences.edit()
editor.putString(key, value)
editor.commit()
}
fun saveData(name:String,value:String){
val prefs: SharedPreferences = requireActivity().getSharedPreferences(PREFS_USER, 0)
val editor = prefs.edit()
// Log.d("VERDNATURA::","El name es "+name+":"+ "y el valor "+value)
when (name) {
ANDROID_ID -> editor.putString(name, value)
"base_url" -> {
val preferences = PreferenceManager.getDefaultSharedPreferences(context)
val editorPref = preferences.edit()
editorPref.putString("base_url", value)
editorPref.commit()
}
else -> {
editor.putString(name, value)
}
}
editor.commit()
}
fun saveDataInt(name:String,value:Int){
val prefs: SharedPreferences = requireActivity().getSharedPreferences(PREFS_USER, 0)
val editor = prefs.edit()
when (name){
name-> editor.putInt(name, value)
ANDROID_ID->editor.putInt(name, value)
}
editor.apply()
}
fun saveBuyer(buyernickname: String) {
val prefs: SharedPreferences = requireActivity().getSharedPreferences(PREFS_USER, 0)
@ -522,23 +606,6 @@ override fun onViewCreated(view: View, savedInstanceState: Bundle?)
return imei.toString()
}
/* fun getANDROIDID(): String {
val prefs: SharedPreferences = requireActivity().getSharedPreferences(PREFS_USER, 0)
val androidid = prefs.getString(ANDROID_ID, "0")
return androidid.toString()
}*/
/*fun getWagons(): Int {
val prefs: SharedPreferences = requireActivity().getSharedPreferences(PREFS_USER, 0)
val wagons = prefs.getInt(WAGON, 2)
return wagons
}*/
/* fun getTagsType(): String {
val prefs: SharedPreferences = requireActivity().getSharedPreferences(PREFS_USER, 0)
val tagstype = prefs.getString(TAGSTYPE, "Stickers")
return tagstype.toString()
}*/
fun getMessageFromJSON(json: String): String {
val gson = Gson()

View File

@ -29,6 +29,7 @@ fun getMessageFromAllResponse(callFunction: String, ResponseMessage: String): St
messageFromError = ResponseMessage
}
//sergio:para personalizar los mensajes de respuesta según la llamada.
when (callFunction)
{

View File

@ -0,0 +1,47 @@
package es.verdnatura.presentation.common
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.recyclerview.widget.RecyclerView
import es.verdnatura.databinding.ItemGeneralRowBinding
class GeneralAdapter(
private val items: List<GeneralItem>,
private val OnGeneralItemRowClickListener: OnGeneralItemRowClickListener,
// private var showDelete: Boolean = true
): RecyclerView.Adapter<GeneralAdapter.ItemHolder> () {
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ItemHolder {
return ItemHolder(
ItemGeneralRowBinding.inflate(LayoutInflater.from(parent.context),parent,false)
)
}
override fun getItemCount() =items.size
override fun onBindViewHolder(holder: ItemHolder, position: Int) {
holder.bind(items[position])
holder.binding.root.setOnClickListener {
OnGeneralItemRowClickListener.OnGeneralItemRowClickListener(items[position])
}
}
inner class ItemHolder(
val binding: ItemGeneralRowBinding
) : RecyclerView.ViewHolder(binding.root){
//private val res = binding.root.context.resources
fun bind(item: GeneralItem) {
binding.apply {
this.item = item
/* if (showDelete) itemImage.visibility = View.VISIBLE
else itemImage.visibility = View.GONE*/
itemTitle.visibility=View.GONE
}
}
}
}

View File

@ -19,4 +19,9 @@ class DataMessageSalix(
var quantity: String = "",
var personSale: String = ""
)
)
class GeneralItem(
var code:String? = "",
var text:String? = ""
)

View File

@ -17,6 +17,7 @@ import es.verdnatura.presentation.view.feature.sacador.model.CollectionVO
import es.verdnatura.presentation.view.feature.sacador.model.SaleVO
import es.verdnatura.presentation.view.feature.smarttag.model.SmartTag
import es.verdnatura.presentation.view.feature.ubicador.model.ItemUbicadorVO
import es.verdnatura.presentation.view.feature.workermistake.model.WorkerFromMistake
interface OnOptionsSelectedListener {
fun onOptionsItemSelected(item: Drawable)
@ -27,6 +28,10 @@ interface OnPasillerosItemClickListener {
fun onPasillerosItemClickListener(item: PasillerosItemVO,entryPoint:String)
}
interface onMistakeWorkerClickListener {
fun onMistakeWorkerClickListener(item: WorkerFromMistake)
}
interface hideBottomNavigation{
fun hideBottomNavigation(entryPoint:String)
@ -40,9 +45,9 @@ interface OnAjustesItemClickListener {
interface OnItemCardRowClickListener {
fun onItemCardRowClickListener(item: ItemCardRowVO)
}
interface OnItemExpeditionStateRowClickListener {
/*interface OnItemExpeditionStateRowClickListener {
fun OnItemExpeditionStateRowClickListener(item: ItemExpeditionStateRow)
}
}*/
interface OnBarcodeRowClickListener {
fun onBarcodeRowClickListener(item: BarcodeVO)
@ -52,6 +57,10 @@ interface OnSmartTagRowClickListener {
fun OnSmartTagRowClickListener(item: SmartTag)
}
interface OnGeneralItemRowClickListener {
fun OnGeneralItemRowClickListener(item: GeneralItem)
}
interface OnLocationRowClickListener {
fun onLocationRowClickListener(item: ItemLocationVO)
}

View File

@ -8,6 +8,7 @@ import android.content.Context.CLIPBOARD_SERVICE
import android.content.SharedPreferences
import android.os.Bundle
import android.provider.Settings
import android.util.Log
import android.view.KeyEvent
import android.view.View
import androidx.appcompat.widget.TooltipCompat.setTooltipText
@ -22,15 +23,18 @@ import es.verdnatura.presentation.common.hideKeyboard
import es.verdnatura.presentation.view.component.CustomDialog
import es.verdnatura.presentation.view.feature.ajustes.adapter.AjustesAdapter
import es.verdnatura.presentation.view.feature.ajustes.model.AjustesItemVO
import es.verdnatura.presentation.view.feature.ajustes.model.Printers
import es.verdnatura.presentation.view.feature.ajustes.model.SectorItemVO
import es.verdnatura.presentation.view.feature.main.activity.MainActivity
import es.verdnatura.presentation.view.feature.pasillero.model.PasillerosItemVO
import timber.log.Timber.d
class AjustesFragment :
BaseFragment<FragmentAjustesBinding, AjustesViewModel>(AjustesViewModel::class) {
private lateinit var customDialog: CustomDialog
private var sectorListVO: List<SectorItemVO> = listOf()
private var printersList: List<Printers> = listOf()
private var vozList: List<String> = listOf()
private var prefs: SharedPreferences? = null
private var ajustesAdapter: AjustesAdapter? = null
@ -50,21 +54,13 @@ class AjustesFragment :
prefs = requireActivity().getSharedPreferences(PREFS_USER, 0)
customDialog = CustomDialog(requireContext())
viewModel.inititializeDefaultAjusts(
/*prefs!!.getString(
SECTORDESCRIP,
getString(R.string.Sinsector)
).toString(),
prefs!!.getInt(SECTORFK, 0),
prefs!!.getInt(WAREHOUSEFK, 0),
prefs!!.getString(VOZ, "NO").toString(),
prefs!!.getInt(WAGON, 2).toString(),
prefs!!.getString(TAGSTYPE, "Stickers").toString()*/
getData(SECTORDESCRIP),
getData(SECTORFK).toInt(),
getData(WAREHOUSEFK).toInt(),
getData(VOZ),
getData(WAGON),
getData(TAGSTYPE)
getData(TAGSTYPE),
getData(PRINTERFK).toInt(),
getData(PRINTERNAME),
)
@ -75,7 +71,7 @@ class AjustesFragment :
override fun init() {
(activity as MainActivity).hideBottomNavigation(View.VISIBLE)
ma.hideBottomNavigation(View.VISIBLE)
binding.userText.setText(getData(USER))
val versionName = requireActivity().packageManager.getPackageInfo(
requireActivity().packageName,
@ -85,16 +81,12 @@ class AjustesFragment :
binding.androididText.setText(
getData(ANDROID_ID)
/*Settings.Secure.getString(
context?.contentResolver,
Settings.Secure.ANDROID_ID
)*/
)
binding.txtserver.setText(this.getDefaults("base_url", this.requireContext()))
binding.txtserver.setText(getData("base_url"))
super.init()
setEvents()
}
fun setEvents() {
@ -131,12 +123,13 @@ class AjustesFragment :
} else if (item.id == 2) {
val listVoz: ArrayList<String> = ArrayList()
viewModel.printer_get(getData(USER),getData(PASSWORD))
/* val listVoz: ArrayList<String> = ArrayList()
listVoz.add("NO")
listVoz.add("YES")
vozList = listVoz
val array = arrayOfNulls<String>(listVoz.size)
showDialogVoz(array = listVoz.toArray(array))
showDialogVoz(array = listVoz.toArray(array))*/
} else if (item.id == 3) {
val listTagsType: ArrayList<String> = ArrayList()
@ -146,7 +139,7 @@ class AjustesFragment :
val array = arrayOfNulls<String>(listTagsType.size)
showItemPickerType(array = listTagsType.toArray(array))
} else if (item.id == 4) {
(activity as MainActivity).onPasillerosItemClickListener(
ma.onPasillerosItemClickListener(
PasillerosItemVO(
title = "Control de usuario de vehículo"
), getData(USERFK)
@ -155,11 +148,24 @@ class AjustesFragment :
}
}
})
workerupdateSector.observe(viewLifecycleOwner, {
binding.splashProgress.visibility = View.GONE
ma.messageWithSound(it.errorMessage,it.isError,false)
})
workerupdatePrinter.observe(viewLifecycleOwner, {
binding.splashProgress.visibility = View.GONE
ma.messageWithSound(it.errorMessage,it.isError,false)
})
binding.ajustessItems.adapter = ajustesAdapter
binding.ajustessItems.layoutManager =
LinearLayoutManager(requireContext(), LinearLayoutManager.VERTICAL, false)
loadSectorList.observe(viewLifecycleOwner, { event ->
loadSectorList.observe(viewLifecycleOwner) { event ->
event.getContentIfNotHandled().notNull {
binding.splashProgress.visibility = View.INVISIBLE
if (it.list.isNotEmpty() && it.list.get(0).isError) {
@ -188,11 +194,69 @@ class AjustesFragment :
}
}
})
}
loadprintersList.observe(viewLifecycleOwner) { event ->
event.getContentIfNotHandled().notNull {
binding.splashProgress.visibility = View.INVISIBLE
if (it.list.isNotEmpty() && it.list.get(0).isError) {
customDialog.setTitle("Error").setDescription(it.list.get(0).errorMessage)
.setOkButton(getString(R.string.Close)) {
customDialog.dismiss()
}.show()
} else {
if (it.list != null && it.list.size > 0) {
val listPrinters: ArrayList<String> = ArrayList()
it.list.forEach {
listPrinters.add(it.name)
}
val array = arrayOfNulls<String>(listPrinters.size)
printersList= it.list
showDialogPrinters(listPrinters.toArray(array))
} else {
customDialog.setTitle("Impresoras")
.setDescription(getString(R.string.Noprinters))
.setOkButton(getString(R.string.Close)) {
customDialog.dismiss()
}.show()
}
}
}
}
}
super.observeViewModel()
}
private fun showDialogPrinters(array: Array<String>) {
val builder = AlertDialog.Builder(this.context)
builder.setTitle(getString(R.string.Selecccionaimpresoara))
builder.setItems(array) { _, which ->
val selected = array[which]
printersList.forEach {
if (it.name.equals(selected)) {
val editor = prefs!!.edit()
editor.putString(PRINTERNAME, it.name)
editor.putInt(PRINTERFK, it.id)
editor.apply()
viewModel.ajustesitem.get(2).selected = it.name
viewModel.worker_updatePrinter(getData(USER),getData(PASSWORD),it.id.toString())
ajustesAdapter!!.notifyDataSetChanged()
return@forEach
}
}
}
val dialog = builder.create()
dialog.show()
}
private fun showDialogSector(array: Array<String>) {
val builder = AlertDialog.Builder(this.context)
@ -211,6 +275,8 @@ class AjustesFragment :
viewModel.ajustesitem.get(0).sectorFk = it.id
viewModel.ajustesitem.get(0).warehouse = it.warehouseFk
viewModel.ajustesitem.get(0).selected = it.description
d("El sector marcado es "+it.id.toString())
viewModel.worker_updateSector(getData(USER),getData(PASSWORD),it.id.toString())
ajustesAdapter!!.notifyDataSetChanged()
return@forEach
@ -234,7 +300,10 @@ class AjustesFragment :
val editor = prefs!!.edit()
editor.putString(VOZ, it)
editor.apply()
viewModel.ajustesitem.get(2).selected = it
ajustesAdapter!!.notifyDataSetChanged()
return@forEach
@ -301,17 +370,17 @@ class AjustesFragment :
}
fun setDefaults(key: String?, value: String?, context: Context?) {
/* fun setDefaults(key: String?, value: String?, context: Context?) {
val preferences: SharedPreferences = PreferenceManager.getDefaultSharedPreferences(context)
val editor = preferences.edit()
editor.putString(key, value)
editor.commit()
}
}*/
private fun getDefaults(key: String?, context: Context?): String? {
/* private fun getDefaults(key: String?, context: Context?): String? {
val preferences = PreferenceManager.getDefaultSharedPreferences(context)
return preferences.getString(key, null)
}
}*/
private fun copyanddrag(string: String): Boolean {

View File

@ -3,6 +3,7 @@ package es.verdnatura.presentation.view.feature.ajustes.fragment
import android.content.Context
import android.util.Log
import android.util.Printer
import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.Transformations
@ -11,12 +12,12 @@ 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.view.feature.ajustes.model.AjustesItemVO
import es.verdnatura.presentation.view.feature.ajustes.model.SectorItemVO
import es.verdnatura.presentation.view.feature.ajustes.model.SectorListVO
import es.verdnatura.presentation.common.ResponseItemVO
import es.verdnatura.presentation.view.feature.ajustes.model.*
import retrofit2.Call
import retrofit2.Callback
import retrofit2.Response
import timber.log.Timber.d
class AjustesViewModel(context: Context) : BaseViewModel() {
@ -32,19 +33,34 @@ class AjustesViewModel(context: Context) : BaseViewModel() {
val sectorList: LiveData<SectorListVO>
get() = _sectorList
private val _workerupdateSector by lazy { MutableLiveData<ResponseItemVO>() }
val workerupdateSector: LiveData<ResponseItemVO>
get() = _workerupdateSector
private val _workerupdatePrinter by lazy { MutableLiveData<ResponseItemVO>() }
val workerupdatePrinter: LiveData<ResponseItemVO>
get() = _workerupdatePrinter
private val _printerList by lazy { MutableLiveData<PrintersList>() }
val printerList: LiveData<PrintersList>
get() = _printerList
val loadSectorList = Transformations.map(_sectorList) {Event(it)}
val loadprintersList = Transformations.map(_printerList) {Event(it)}
fun inititializeDefaultAjusts(sectorDescrip: String,sectorFk : Int, warehouseFk : Int,vozDescrip:String,carroDescrip:String,TypeTags:String) {
fun inititializeDefaultAjusts(sectorDescrip: String,sectorFk : Int, warehouseFk : Int,carroDescrip:String,TypeTags:String,printerFk:Int,printerSelected:String) {
_ajustesitem.add(
AjustesItemVO(0,
"Sector",
sectorDescrip,
sectorFk,
warehouseFk)
warehouseFk,
0,
printerSelected)
)
@ -53,35 +69,40 @@ class AjustesViewModel(context: Context) : BaseViewModel() {
"Carros",
carroDescrip,
0,
0)
0,
0,"Sin impresora")
)
_ajustesitem.add(
AjustesItemVO(2,
"Voz",
vozDescrip,
"Impresora etiquetas",
printerSelected,
0,
0)
0,
printerFk,printerSelected)
)
_ajustesitem.add(
AjustesItemVO(3,
"Tipo etiqueta",
TypeTags,
0,
0)
0,
0,"Sin impresora")
)
_ajustesitem.add(
AjustesItemVO(4,
"Control de vehículos",
"",
0,
0)
0,
0,"Sin impresora")
)
_ajustesitem.add(
AjustesItemVO(5,
"Cerrar Sesión",
"",
0,
0)
0,
0,"Sin impresora")
)
}
@ -136,4 +157,93 @@ class AjustesViewModel(context: Context) : BaseViewModel() {
})
}
fun printer_get(user:String,password:String){
getAjustesUserCase.printer_get(user,password).enqueue(object : Callback<List<Printers>>{
override fun onFailure(call: Call<List<Printers>>, t: Throwable) {
val listError:ArrayList<Printers> = ArrayList()
listError.add(Printers(0,"",true,t.message!!))
_printerList.value = PrintersList(listError)
}
override fun onResponse(
call: Call<List<Printers>>,
response: Response<List<Printers>>
) {
if (response.body() != null){
_printerList.value = response.body()?.let { PrintersList (it) }
}else{
val listError:ArrayList<Printers> = ArrayList()
listError.add(Printers(0,"",true,
getMessageFromAllResponse(nameofFunction(this),response.message())
))
_printerList.value = PrintersList(listError)
}
}
})
}
fun worker_updateSector(user:String,password:String,sectorFk:String){
d("El sector marcado dentro es "+sectorFk)
getAjustesUserCase.worker_updateSector(user,password,sectorFk).enqueue(object : Callback<Unit>{
override fun onFailure(call: Call<Unit>, t: Throwable) {
_workerupdateSector.value = ResponseItemVO(isError = true, errorMessage = getMessageFromAllResponse(nameofFunction(this),t.message!!))
}
override fun onResponse(
call: Call<Unit>,
response: Response<Unit>
) {
if (!response.isSuccessful()){
_workerupdateSector.value=ResponseItemVO(
isError = true,
errorMessage = getMessageFromAllResponse(nameofFunction(this),response.message())
)
}else{
_workerupdateSector.value=ResponseItemVO(response="Actualizado sector",isError = false, errorMessage ="Actualizado sector")
}
/*if (response.body() != null){
_sectorList.value = response.body()?.let { SectorListVO(it) }
}else{
val listError:ArrayList<SectorItemVO> = ArrayList()
listError.add(SectorItemVO(0,"",0,true,"Error en la llamada sector_get"))
_sectorList.value = SectorListVO(listError)
}*/
}
})
}
fun worker_updatePrinter(user:String,password:String,printerFk:String){
d("La impresora marcada "+printerFk)
getAjustesUserCase.worker_updatePrinter(user,password,printerFk).enqueue(object : Callback<Unit>{
override fun onFailure(call: Call<Unit>, t: Throwable) {
_workerupdatePrinter.value = ResponseItemVO(isError = true, errorMessage = getMessageFromAllResponse(nameofFunction(this),t.message!!))
}
override fun onResponse(
call: Call<Unit>,
response: Response<Unit>
) {
if (!response.isSuccessful()){
_workerupdatePrinter.value=ResponseItemVO(
isError = true,
errorMessage = getMessageFromAllResponse(nameofFunction(this),response.message())
)
}else{
_workerupdatePrinter.value=ResponseItemVO(response="Actualizada impresora",isError = false, errorMessage ="Actualizada impresora")
}
}
})
}
}

View File

@ -5,12 +5,14 @@ class AjustesItemVO (
var title: String = "",
var selected: String = "",
var sectorFk : Int?,
var warehouse: Int?
var warehouse: Int?,
var printerFk:Int?,
var printerSelected:String=""
)
class SectorItemVO (
var id: Int,
var description:String = "",
var description:String = "des",
val warehouseFk:Int?,
val isError : Boolean = false,
var errorMessage : String = ""
@ -18,4 +20,15 @@ class SectorItemVO (
class SectorListVO (
var list: List<SectorItemVO> = listOf()
)
class PrintersList (
var list: List<Printers> = listOf()
)
class Printers(
var id: Int,
var name: String="",
val isError : Boolean = false,
var errorMessage : String = ""
)

View File

@ -44,9 +44,9 @@ class ItemProposalAdapter(
/* itemNicho.setOnClickListener {
onInvetoryNichoClickListener.onInvetoryNichoClickListener(item)
}*/
itemNicho.setOnClickListener {
/* itemNicho.setOnClickListener {
onItemProposalClickListener.onItemProposalClickListener(item)
}
}*/
itemFk.setOnClickListener {
onPasillerosItemClickListener.onPasillerosItemClickListener(
PasillerosItemVO(

View File

@ -54,7 +54,7 @@ class ItemCardFragment(
fun newInstance(entryPoint: String) = ItemCardFragment(entryPoint)
}
private lateinit var customDialog: CustomDialog
// private lateinit var customDialog: CustomDialog
private lateinit var customDialogInput: CustomDialogInput
private lateinit var customDialogList: CustomDialogList
private lateinit var customDialogTwo: CustomDialogTwoButtons
@ -66,13 +66,13 @@ class ItemCardFragment(
override fun init() {
binding.itemcardLayout.visibility = View.GONE
(activity as MainActivity).hideBottomNavigation(View.GONE)
ma.hideBottomNavigation(View.GONE)
setEvents()
//toolbar_title.text = getString(R.string.ConsultarArticulo)
binding.mainToolbar.toolbarTitle.text = getString(R.string.ConsultarArticulo)
customDialog = CustomDialog(requireContext())
//customDialog = CustomDialog(requireContext())
customDialogInput = CustomDialogInput(requireContext())
customDialogList = CustomDialogList(requireContext())
customDialogTwo = CustomDialogTwoButtons(requireContext())
@ -117,7 +117,7 @@ class ItemCardFragment(
if (itemFk.isNullOrEmpty()) {
"Escanea un item".toast(requireActivity())
} else {
(activity as MainActivity).onPasillerosItemClickListener(
ma.onPasillerosItemClickListener(
PasillerosItemVO(title = "Historico"),
itemInfoG!!.id
)
@ -147,7 +147,7 @@ class ItemCardFragment(
if (!binding.editItemFk.text.toString().isNullOrEmpty())
getItemCard(binding.editItemFk.text.toString())
binding.editItemFk.setText("")
(activity as MainActivity).hideKeyboard(binding.editItemFk)
ma.hideKeyboard(binding.editItemFk)
return@setOnEditorActionListener true
}
false
@ -190,10 +190,8 @@ class ItemCardFragment(
binding.itemcardLayout.visibility = GONE
binding.splashProgressTwo.visibility = GONE
binding.mainToolbar.toolbarTitle.text = "ItemCard"
customDialog.setTitle("Error").setDescription(it.errorMessage)
.setOkButton("Cerrar") {
customDialog.dismiss()
}.show()
ma.messageWithSound(it.errorMessage,true,false)
} else {
if (it.id != "0") {
binding.itemcardLayout.visibility = View.VISIBLE
@ -202,11 +200,8 @@ class ItemCardFragment(
binding.splashProgressTwo.visibility = GONE
binding.itemcardLayout.visibility = View.GONE
binding.mainToolbar.toolbarTitle.text = "ItemCard"
customDialog.setTitle("Sin resultados")
.setDescription("No hemos podido encontrar el articulo. Revisa el sector.")
.setOkButton("Cerrar") {
customDialog.dismiss()
}.show()
ma.messageWithSound("No hemos podido encontrar el articulo. Revisa el sector.",true,false,"Sin resultados")
}
}
@ -221,10 +216,7 @@ class ItemCardFragment(
response.observe(viewLifecycleOwner, Observer {
binding.splashProgress.visibility = View.GONE
if (it.isError) {
customDialog.setTitle("Error").setDescription(it.errorMessage)
.setOkButton("Cerrar") {
customDialog.dismiss()
}.show()
ma.messageWithSound(it.errorMessage,true,false)
} else {
getItemCard(itemFk)
}
@ -361,7 +353,7 @@ class ItemCardFragment(
listItemsRow.add(
ItemCardRowVO(
title = getString(R.string.Referencia),
value = itemInfo.referencia,
value = itemInfo.reference,
isEditable = true,
action = "item_saveReference"
)
@ -394,7 +386,7 @@ class ItemCardFragment(
if (item.action == "itemProposal") {
(activity as MainActivity).onPasillerosItemClickListener(
ma.onPasillerosItemClickListener(
PasillerosItemVO(
title = "Buscar artículos similares"
), itemFk
@ -408,12 +400,12 @@ class ItemCardFragment(
customDialogInput.setTitle(item.title!!)
.setDescription("Valor actual: " + item.value!!)
.setOkButton("Guardar") {
(activity as MainActivity).hideKeyboard(customDialogInput.getEditText())
ma.hideKeyboard(customDialogInput.getEditText())
editItemCardRow(item, customDialogInput.getValue())
customDialogInput.dismiss()
}.setKoButton("Cancelar") {
(activity as MainActivity).hideKeyboard(customDialogInput.getEditText())
ma.hideKeyboard(customDialogInput.getEditText())
customDialogInput.dismiss()
}.setValue("").show()
customDialogInput.getEditText().requestFocus()
@ -424,7 +416,7 @@ class ItemCardFragment(
editItemCardRow(item, customDialogInput.getValue())
customDialogInput.setValue("")
customDialogInput.dismiss()
(activity as MainActivity).hideKeyboard(customDialogInput.getEditText())
ma.hideKeyboard(customDialogInput.getEditText())
return@setOnEditorActionListener true
}
false
@ -433,7 +425,7 @@ class ItemCardFragment(
//BARCODE ROW
prepareBarcodeDialog(item)
} else if (item.action == "buscarItem") {
(activity as MainActivity).onPasillerosItemClickListener(
ma.onPasillerosItemClickListener(
PasillerosItemVO(
title = "Buscar item"
), itemFk
@ -442,12 +434,12 @@ class ItemCardFragment(
customDialogInput.setTitle(item.title!!)
.setDescription("Indica la cantidad a dar de alta")
.setOkButton("Guardar") {
(activity as MainActivity).hideKeyboard(customDialogInput.getEditText())
ma.hideKeyboard(customDialogInput.getEditText())
editItemCardRow(item, customDialogInput.getValue())
customDialogInput.dismiss()
}.setKoButton("Cancelar") {
(activity as MainActivity).hideKeyboard(customDialogInput.getEditText())
ma.hideKeyboard(customDialogInput.getEditText())
customDialogInput.dismiss()
}.setValue("").show()
customDialogInput.getEditText().requestFocus()
@ -458,7 +450,7 @@ class ItemCardFragment(
editItemCardRow(item, customDialogInput.getValue())
customDialogInput.setValue("")
customDialogInput.dismiss()
(activity as MainActivity).hideKeyboard(customDialogInput.getEditText())
ma.hideKeyboard(customDialogInput.getEditText())
return@setOnEditorActionListener true
}
false
@ -467,12 +459,12 @@ class ItemCardFragment(
customDialogInput.setTitle(item.title!!)
.setDescription("Indica la cantidad a dar de baja ")
.setOkButton("Guardar") {
(activity as MainActivity).hideKeyboard(customDialogInput.getEditText())
ma.hideKeyboard(customDialogInput.getEditText())
editItemCardRow(item, customDialogInput.getValue())
customDialogInput.dismiss()
}.setKoButton("Cancelar") {
(activity as MainActivity).hideKeyboard(customDialogInput.getEditText())
ma.hideKeyboard(customDialogInput.getEditText())
customDialogInput.dismiss()
}.setValue("").show()
customDialogInput.getEditText().requestFocus()
@ -483,7 +475,7 @@ class ItemCardFragment(
editItemCardRow(item, customDialogInput.getValue())
customDialogInput.setValue("")
customDialogInput.dismiss()
(activity as MainActivity).hideKeyboard(customDialogInput.getEditText())
ma.hideKeyboard(customDialogInput.getEditText())
return@setOnEditorActionListener true
}
false
@ -556,7 +548,7 @@ class ItemCardFragment(
}
if (item.action != "itemStockUpdate")
if (item.action != "itemStockUpdate" && item.action != "itemStockUpdateRemove" && item.action !="itemStockUpdateAdd")
// changeOfflineValue(item,value, listBarcodes)
showProgress()
}
@ -620,6 +612,7 @@ class ItemCardFragment(
private fun prepareItemStockUpdate2(itemB: ItemCardRowVO, value: String) {
try {
value.toInt()
if (itemB.action == "itemStockUpdateRemove") {
customDialogTwo.setTitle(itemB.title!!)
@ -669,36 +662,34 @@ class ItemCardFragment(
)
}
} catch (e: Exception) {
binding.itemcardLayout.visibility = View.GONE
customDialog.setTitle("Error").setDescription("El elemento introducido no es un número")
.setKoButton("Cancelar") {
customDialog.dismiss()
}.show()
// binding.itemcardLayout.visibility = View.GONE
ma.messageWithSound("El elemento introducido no es un número",true,true)
}
}
private fun prepareBarcodeDialog(itemB: ItemCardRowVO) {
customDialogList.setTitle("Barcodes").setOkButton("Guardar") {
(activity as MainActivity).hideKeyboard(customDialogList.getEditText())
ma.hideKeyboard(customDialogList.getEditText())
if (!customDialogList.getValue().isNullOrEmpty())
updateBarcode(customDialogList.getValue(), "0", itemB)
customDialogList.dismiss()
}.setKoButton("Cerrar") {
(activity as MainActivity).hideKeyboard(customDialogList.getEditText())
ma.hideKeyboard(customDialogList.getEditText())
customDialogList.dismiss()
}.setValue("").show()
(activity as MainActivity).hideKeyboard(customDialogList.getEditText())
ma.hideKeyboard(customDialogList.getEditText())
customDialogList.getEditText().setOnEditorActionListener { v, actionId, event ->
if (actionId == EditorInfo.IME_ACTION_SEARCH || actionId == EditorInfo.IME_ACTION_DONE || actionId == 0) {
if (!customDialogList.getValue().isNullOrEmpty())
updateBarcode(customDialogList.getValue(), "0", itemB)
customDialogList.setValue("")
customDialogList.dismiss()
(activity as MainActivity).hideKeyboard(customDialogList.getEditText())
ma.hideKeyboard(customDialogList.getEditText())
return@setOnEditorActionListener true
}
false

View File

@ -7,7 +7,6 @@ import android.os.Bundle
import android.view.View
import android.widget.ImageView
import androidx.core.content.ContextCompat
import androidx.lifecycle.Observer
import androidx.recyclerview.widget.LinearLayoutManager
import es.verdnatura.R
import es.verdnatura.databinding.FragmentItemproposalBinding
@ -16,8 +15,6 @@ import es.verdnatura.presentation.common.OnItemProposalClickListener
import es.verdnatura.presentation.common.OnOptionsSelectedListener
import es.verdnatura.presentation.common.OnPasillerosItemClickListener
import es.verdnatura.presentation.common.ToolBarAdapterTooltip
import es.verdnatura.presentation.view.component.CustomDialog
import es.verdnatura.presentation.view.component.CustomDialogInput
import es.verdnatura.presentation.view.feature.articulo.adapter.ItemProposalAdapter
import es.verdnatura.presentation.view.feature.articulo.model.ItemProposal
import es.verdnatura.presentation.view.feature.main.activity.MainActivity
@ -31,17 +28,12 @@ class ItemProposalFragment(
ItemCardViewModel::class
) {
private var adapter: ItemProposalAdapter? = null
private lateinit var customDialogInput: CustomDialogInput
private var listInvetory: ArrayList<ItemProposal> = ArrayList()
private var listInvetoryAux: ArrayList<ItemProposal> = ArrayList()
private lateinit var customDialog: CustomDialog
private var listProposal: ArrayList<ItemProposal> = ArrayList()
private var pasillerosItemClickListener: OnPasillerosItemClickListener? = null
private var hideLoad = true
private var layoutManager: LinearLayoutManager? = null
private var firstVisiblePosition = 0
private var filter = "TRUE"
private var filter = "1"
companion object {
fun newInstance(entryPoint: String) = ItemProposalFragment(entryPoint)
@ -59,7 +51,7 @@ class ItemProposalFragment(
itemFk,
getData(WAREHOUSEFK),
vShipped = currentDay(),
vIsShowedByType = "TRUE",
vIsShowedByType = filter,
user = getData(USER),
password = getData(PASSWORD),"item_getSimilar"
)
@ -69,18 +61,16 @@ class ItemProposalFragment(
private fun currentDay(): String {
val calendar = Calendar.getInstance()
val format = SimpleDateFormat("yyyy-MM-dd")
val format = SimpleDateFormat("yyyy-MM-dd",Locale.getDefault())
return format.format(calendar.time)
}
override fun init() {
customDialogInput = CustomDialogInput(requireContext())
customDialog = CustomDialog(requireContext())
(activity as MainActivity).hideBottomNavigation(View.GONE)
ma.hideBottomNavigation(View.GONE)
binding.splashProgress.visibility = View.VISIBLE
binding.mainToolbar.toolbarTitle.text = getString(R.string.ArticleSimilar) + ":" + itemFk
"${getString(R.string.ArticleSimilar)}:$itemFk".also { it -> it.also { binding.mainToolbar.toolbarTitle.text = it } }
setToolBar()
setEvents()
@ -104,21 +94,11 @@ class ItemProposalFragment(
when (item){
iconFilter.drawable-> {
binding.splashProgress.visibility = View.VISIBLE
firstVisiblePosition = layoutManager?.findFirstVisibleItemPosition() ?: 0
iconFilter.drawable.setTint(ContextCompat.getColor(
context!!,if (filter=="1") R.color.verdnatura_white else R.color.verdnatura_pumpkin_orange
))
filter = if (filter=="1") "0" else "1"
if (filter.equals("TRUE")) {
filter = "FALSE"
iconFilter.drawable.setTint(ContextCompat.getColor(
context!!,
R.color.verdnatura_white))
} else {
filter = "TRUE"
iconFilter.drawable.setTint(
ContextCompat.getColor(
context!!,
R.color.verdnatura_pumpkin_orange))
}
viewModel.item_getSimilar(
itemFk,
getData(WAREHOUSEFK),
@ -129,7 +109,6 @@ class ItemProposalFragment(
callFunction = "item_getSimilar")
}
@ -151,52 +130,29 @@ class ItemProposalFragment(
}
override fun onPause() {
super.onPause()
firstVisiblePosition = layoutManager?.findFirstVisibleItemPosition() ?: 0
}
override fun onResume() {
super.onResume()
if (binding.locationRecyclerview.layoutManager != null) {
if (firstVisiblePosition <= listInvetory.size) {
binding.locationRecyclerview.layoutManager!!.scrollToPosition(firstVisiblePosition)
}
}
}
override fun observeViewModel() {
with(viewModel) {
itemProposallist.observe(viewLifecycleOwner, Observer {
itemProposallist.observe(viewLifecycleOwner, { it ->
if (hideLoad) {
binding.splashProgress.visibility = View.GONE
} else {
hideLoad = true
}
listInvetory = ArrayList()
listInvetoryAux = ArrayList()
it.list.forEach {
if (it.longName != "0") {
listInvetory.add(it)
listInvetoryAux.add(it)
}
}
listProposal= ArrayList()
if (!it.list.isNullOrEmpty()){
it.list.forEach {
adapter = ItemProposalAdapter(listInvetory, object : OnItemProposalClickListener {
listProposal.add(it)
}}
adapter = ItemProposalAdapter(listProposal, object : OnItemProposalClickListener {
override fun onItemProposalClickListener(item: ItemProposal) {
customDialog.setTitle(item.itemFk + "\n" + item.longName + " " + item.subName)
.setDescription("Cantidad real(" + item.available + ")")
.setOkButton("Prueba") {
customDialog.dismiss()
}.setKoButton("Cancelar") {
// customDialogInput.dismiss()
customDialog.dismiss()
}.show()
}
}, onPasillerosItemClickListener = pasillerosItemClickListener!!)
@ -205,9 +161,6 @@ class ItemProposalFragment(
LinearLayoutManager(requireContext(), LinearLayoutManager.VERTICAL, false)
binding.locationRecyclerview.layoutManager = layoutManager
if (firstVisiblePosition <= listInvetory.size) {
binding.locationRecyclerview.layoutManager!!.scrollToPosition(firstVisiblePosition)
}
})

View File

@ -31,7 +31,7 @@ class ItemCardVO (
var urlImage200:String = "",
var urlImage:String = "",
var itemPackingTypeFk:String =" ",
var referencia:String="",
var reference:String="",
//sergio para modificar la llamada de itemCard a item_getInfo

View File

@ -17,7 +17,7 @@ class BufferFragment(
private var password = ""
private var goBack: Boolean = false
override fun getLayoutId(): Int = R.layout.fragment_buffer
private lateinit var customDialog: CustomDialog
//private lateinit var customDialog: CustomDialog
companion object {
fun newInstance(entryPoint: String) = BufferFragment(entryPoint)
@ -27,7 +27,7 @@ class BufferFragment(
override fun init() {
binding.splashProgress.visibility = View.GONE
customDialog = CustomDialog(requireContext())
//customDialog = CustomDialog(requireContext())
setToolbar()
setEvents()
super.init()
@ -77,7 +77,7 @@ class BufferFragment(
}
binding.scanInput.setText("")
(activity as MainActivity).hideKeyboard( binding.scanInput)
ma.hideKeyboard( binding.scanInput)
return@setOnEditorActionListener true
}
false
@ -91,12 +91,12 @@ class BufferFragment(
binding.splashProgress.visibility = View.GONE
if (it.isError) {
(activity as MainActivity).messageWithSound(
ma.messageWithSound(
it.errorMessage,true,isPlayed = true)
} else {
(activity as MainActivity).messageWithSound("Operación "+entryPoint.lowercase() + " buffer realizada correctamente",false,isPlayed = true)
ma.messageWithSound("Operación "+entryPoint.lowercase() + " buffer realizada correctamente",false,isPlayed = true)
binding.mainToolbar.backButton.performClick()
}

View File

@ -41,7 +41,7 @@ class BufferLoadFragment(
customDialogList = CustomDialogList(requireContext())
goBack = false
(activity as MainActivity).hideBottomNavigation(GONE)
ma.hideBottomNavigation(GONE)
binding.splashProgress.visibility = GONE
mperror = MediaPlayer.create((activity as MainActivity),R.raw.error)
@ -107,12 +107,12 @@ class BufferLoadFragment(
if (it.isError) {
(activity as MainActivity).messageWithSound(it.errorMessage,it.isError,true)
ma.messageWithSound(it.errorMessage,it.isError,true)
} else {
if (it.response.equals("Registro añadido")){
(activity as MainActivity).messageWithSound(it.response,false,true)
ma.messageWithSound(it.response,false,true)
}else{
mperror?.start()
it.response.toast(requireContext())
@ -156,7 +156,7 @@ class BufferLoadFragment(
customDialogList.setTitle("Escanea etiqueta de la expedición.")
.setOkButton("Cerrar") {
(activity as MainActivity).hideKeyboard(customDialogList.getEditText())
ma.hideKeyboard(customDialogList.getEditText())
listTags.clear()
@ -168,7 +168,7 @@ class BufferLoadFragment(
customDialogList.getEditText().requestFocus()
(activity as MainActivity).hideKeyboard(customDialogList.getEditText())
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 || actionId == 6) {
@ -179,7 +179,7 @@ class BufferLoadFragment(
}
customDialogList.setValue("")
(activity as MainActivity).hideKeyboard(customDialogList.getEditText())
ma.hideKeyboard(customDialogList.getEditText())
return@setOnEditorActionListener true
}
false

View File

@ -21,7 +21,6 @@ class BuscarItemFragment(
) : BaseFragment<FragmentBuscarItemBinding,BuscarItemViewModel>(BuscarItemViewModel::class) {
private var adapter : LocationAdapter? = null
private lateinit var customDialog: CustomDialog
private var pasillerosItemClickListener: OnPasillerosItemClickListener? = null
companion object {
@ -36,9 +35,8 @@ class BuscarItemFragment(
override fun init() {
(activity as MainActivity).hideBottomNavigation(GONE)
ma.hideBottomNavigation(GONE)
binding.mainToolbar.toolbarTitle.text = getString(R.string.getubicaition)
customDialog = CustomDialog(requireContext())
setEvents()
if (!itemFk.isNullOrEmpty()){
getLocations(itemFk)
@ -54,7 +52,7 @@ class BuscarItemFragment(
if (!binding.editItemFk.text.toString().isNullOrEmpty())
getLocations(binding.editItemFk.text.toString())
binding.editItemFk.setText("")
(activity as MainActivity).hideKeyboard(binding.editItemFk)
ma.hideKeyboard(binding.editItemFk)
return@setOnEditorActionListener true
}
false

View File

@ -10,7 +10,8 @@ class ItemLocationVO (
var created:String = "",
var itemFk:String = "",
val isError : Boolean = false,
var errorMessage : String = ""
var errorMessage : String = "",
var priority:String = ""
)
class LocationListVO (

View File

@ -25,7 +25,7 @@ import es.verdnatura.presentation.view.feature.main.activity.MainActivity
class BuyersFragment : BaseFragment<BuyersFragmentBinding,BuyersViewModel>(BuyersViewModel::class) {
private lateinit var customDialog: CustomDialog
// private lateinit var customDialog: CustomDialog
private var onBuyerSelectedListener : OnBuyerSelectedListener? = null
private var buyersAdapter: AjustesAdapter? = null
@ -46,8 +46,8 @@ class BuyersFragment : BaseFragment<BuyersFragmentBinding,BuyersViewModel>(Buyer
}
override fun init() {
customDialog = CustomDialog(requireContext())
(activity as MainActivity).hideBottomNavigation(View.GONE)
// customDialog = CustomDialog(requireContext())
ma.hideBottomNavigation(View.GONE)
binding.splashProgress.visibility = View.VISIBLE
binding.mainToolbar.toolbarTitle.text = getString(R.string.quality)
@ -108,8 +108,9 @@ class BuyersFragment : BaseFragment<BuyersFragmentBinding,BuyersViewModel>(Buyer
id = buyer.userFk.toInt(),
title = buyer.nickname,
sectorFk = 0,
warehouse = 0
)
warehouse = 0,
printerFk=0,
printerSelected ="")
)
}catch (e:Exception){}
}

View File

@ -53,7 +53,7 @@ class QaualityFragment(
override fun init() {
customDialog = CustomDialog(requireContext())
(activity as MainActivity).hideBottomNavigation(View.GONE)
ma.hideBottomNavigation(View.GONE)
binding.splashProgress.visibility = View.VISIBLE
binding.mainToolbar.toolbarTitle.text = "itemShelving_BuyerTask"
setToolBar()

View File

@ -52,13 +52,6 @@ class CollectionFragment(
) : BaseFragment<FragmentCollectionBinding, CollectionViewModel>(CollectionViewModel::class) {
private lateinit var dataMessageSalix: DataMessageSalix
/* private var user = ""
private var password = ""
private var sectorFk = ""
private var warehouseFk = ""
private var SectorDescription = ""
private var token = ""
private var voz = ""*/
private var sales: List<SaleVO> = listOf()
private var saleAdapter: SaleAdapter? = null
private var lm: LinearLayoutManager? = null
@ -88,6 +81,8 @@ class CollectionFragment(
private var positionCollectionMissing = 0
private var quantityCollectionMissing = ""
private var isMarking = false
private var positionCollectionSplit = 0
private var quantityCollectionSplit = ""
//private var myKM: KeyguardManager? = null
private var state = 0
@ -154,8 +149,7 @@ class CollectionFragment(
customDialogInput = CustomDialogInput(requireContext())
customDialog = CustomDialog(requireContext())
customDialogThreeButtons = CustomDialogThreeButtons(requireContext())
//requireActivity().main_bottom_navigation.visibility = View.GONE
(activity as MainActivity).hideBottomNavigation(View.GONE)
ma.hideBottomNavigation(View.GONE)
if (binding.splashProgress != null) binding.splashProgress.visibility = VISIBLE
setEvents()
@ -250,7 +244,7 @@ class CollectionFragment(
private fun showUser() {
(activity as MainActivity).onPasillerosItemClickListener(
ma.onPasillerosItemClickListener(
PasillerosItemVO(title = "Control de usuario de vehículo"),
workerFkFromTicket
)
@ -355,15 +349,16 @@ class CollectionFragment(
responseUsedShelves.observe(viewLifecycleOwner, Observer {
binding.splashProgress.visibility = GONE
(activity as MainActivity).messageWithSound(
if (!goBack){
ma.messageWithSound(
if (it.isError) it.errorMessage else "Baldas guardadas",
it.isError,true
)
)}
})
responseItem_updatePackingShelve.observe(viewLifecycleOwner, Observer {
binding.splashProgress.visibility = GONE
(activity as MainActivity).messageWithSound(
ma.messageWithSound(
if (it.isError) it.errorMessage else "Packing guardado",
it.isError,!it.isError
)
@ -384,9 +379,9 @@ class CollectionFragment(
if (it.isError) {
(activity as MainActivity).messageWithSound(it.errorMessage, true,true)
ma.messageWithSound(it.errorMessage, true,true)
} else {
(activity as MainActivity).messageWithSound("Previa recogida", false,true)
ma.messageWithSound("Previa recogida", false,true)
binding.splashProgress.visibility = VISIBLE
viewModel.collectionTicketGet(
getData(USER),
@ -424,6 +419,8 @@ class CollectionFragment(
if (binding.splashProgress != null) binding.splashProgress.visibility =
View.VISIBLE
if (!goBack){
sendSalixMessage(
item = dataMessageSalix.item,
ticketFk = dataMessageSalix.ticket,
@ -440,6 +437,7 @@ class CollectionFragment(
// //Log.i("VERDNATURA:","La collection es ${collection.collectionFk}")
}
}
// }
goBack = false
@ -476,14 +474,16 @@ class CollectionFragment(
responseMissingTrash.observe(viewLifecycleOwner, Observer {
if (it.isError) {
(activity as MainActivity).messageWithSound(it.errorMessage, isError = true,true)
if (!goBack){
if (it.isError) {
ma.messageWithSound(it.errorMessage, isError = true,true)
} else {
} else {
missingTrashSuccesful()
missingTrashSuccesful()
} //sergio:esto ya estaba
}
} //sergio:esto ya estaba
/* binding.splashProgress.visibility = View.VISIBLE
viewModel.collectionTicketGet(user,password,collection.collectionFk,getData(SECTORFK))*/
})
@ -492,13 +492,23 @@ class CollectionFragment(
responseIncQuantity.observe(viewLifecycleOwner, Observer {
if (it.isError) {
(activity as MainActivity).messageWithSound(it.errorMessage, isError = true,true)
/*customDialog.setTitle("Error").setDescription(it.errorMessage)
.setOkButton("Aceptar") {
customDialog.dismiss()
}.show()*/
ma.messageWithSound(it.errorMessage, isError = true,true)
} else {
incresaseSuccesful()
if (!goBack){ incresaseSuccesful()}else{goBack=false}
}
})
responseSaleMove.observe(viewLifecycleOwner, Observer {
if (it.isError) {
ma.messageWithSound(it.errorMessage, isError = true,true)
} else {
if (!goBack)
responseSaleMoveSuccesful()
goBack=false
}
})
@ -507,11 +517,13 @@ class CollectionFragment(
binding.splashProgress.visibility=GONE
if (it.isError) {
(activity as MainActivity).messageWithSound(it.errorMessage+"Usuario:"+workerFkFromTicket, isError = true,true)
if (!goBack)
ma.messageWithSound(it.errorMessage+"Usuario:"+workerFkFromTicket, isError = true,true)
goBack = false
} else {
if (!goBack)
callPicker(it.response)
goBack = false
}
})
@ -519,7 +531,8 @@ class CollectionFragment(
mistakeList.observe(viewLifecycleOwner, Observer {
if (binding.splashProgress != null) binding.splashProgress.visibility = GONE
/*sergio:se quita esta comprobacion if (!goBack) */
/*sergio:se quita y se pone esta comprobacion porque si no aparece de nuevo otra vez al volver atrás */
if (!goBack)
showMistakeList(it.list)
goBack = false
})
@ -527,13 +540,15 @@ class CollectionFragment(
responsecheckfully.observe(viewLifecycleOwner, Observer {
binding.splashProgress.visibility = View.GONE
if (it.isError) {
customDialog.setTitle("Error").setDescription(it.errorMessage)
ma.messageWithSound(it.errorMessage,it.isError,false)
/*customDialog.setTitle("Error").setDescription(it.errorMessage)
.setOkButton("Aceptar") {
customDialog.dismiss()
}.show()
}.show()*/
} else {
//sergio: devuelve false si no hay para revisar y <> false.
if (it.response != "false") {
customDialog.setTitle("Aviso")
.setDescription("Pendiente de revisar : " + it.response)
.setOkButton("Aceptar") {
@ -560,11 +575,17 @@ class CollectionFragment(
})
responseSalixMessage.observe(viewLifecycleOwner, Observer {
if (it.isError) {
customDialog.setTitle("Error").setDescription(it.errorMessage)
if (!goBack){
ma.messageWithSound(it.errorMessage,it.isError,false)}else{goBack=false}
/*customDialog.setTitle("Error").setDescription(it.errorMessage)
.setOkButton("Aceptar") {
customDialog.dismiss()
}.show()
}.show()*/
}
})
@ -572,6 +593,22 @@ class CollectionFragment(
}
}
private fun responseSaleMoveSuccesful() {
sales[positionCollectionSplit].quantity = quantityCollectionSplit
if (quantityCollectionSplit == "0")
markLine(positionCollectionSplit, type)
saleAdapter!!.notifyDataSetChanged()
val ticket =
"[" + sales[positionCollectionSplit].ticketFk + "](https://salix.verdnatura.es/#!/ticket/" + sales[positionCollectionSplit].ticketFk + "/summary)"
val message =
"Se ha enviado a Split el articulo " + sales[positionCollectionSplit].itemFk + " del ticket " + ticket
sendSalixMessageNew(message,sales[positionCollectionSplit].salePersonFk)
}
private fun callPicker(extensionNumber:String) {
@ -656,31 +693,12 @@ class CollectionFragment(
observations = observations + " " + ticket.observations
}
//sales = salesList.sortedWith(compareBy({it.placements.get(0).placement}))
sales = salesList.sortedWith(compareBy({ it.saleOrder }))
//sales=salesList
/* for (s in sales)
{
Log.i("VERDNATURA:","La sale del ticket ${s.ticketFk} es ${s.saleOrder}")
for (p in s.placements){
Log.i("VERDNATURA:","La sale del ticket ${s.saleOrder} es ${p.placement}")
//s.placements=s.placements.sortedBy { it.saleOrder}.sortedBy { !it.visible.equals("0") }
s.placements=s.placements.sortedBy { !it.visible.equals("0") }
// Log.i("VERDNATURA:","La sale del ticket ${s.saleOrder} es saleorder ${p.saleOrder}")
}
}*/
/*for (s in salesList)
{
Log.i("VERDNATURA:","La sale del ticket ${s.ticketFk} es ${s.saleOrder}")
for (p in s.placements){
Log.i("VERDNATURA:","La sale del ticket ${s.saleOrder} es ${p.placement}")
// Log.i("VERDNATURA:","La sale del ticket ${s.saleOrder} es saleorder ${p.saleOrder}")
}
}*/
//pruebas sergio
// sales = salesList.sortedWith(compareBy({it.placements.get(0).created}))
//sales = salesList.sortedWith(compareBy({it.placements.get(0).placement}))
// SalesSorter()
@ -709,8 +727,7 @@ class CollectionFragment(
markLine(index, type)
//////Log.i("VERDNATURA:","marcamos linea")
} else if (type == SACADOR) {
Log.d("VERDNATURA", "El tipo es sacador")
Log.d("VERDNATURA", "La sale es" + sale.isPrepared)
if (sale.isPrepared == "0" || sale.isPrepared.isNullOrEmpty()) {
showScanner(index, sale)
} else {
@ -1033,6 +1050,7 @@ class CollectionFragment(
}*/
saleTrackingReplace(position, newType)
isMarking = true
setTotalLines()
}
@ -1056,8 +1074,7 @@ class CollectionFragment(
}
private fun saleTrackingReplace(position: Int, type: String) {
//////Log.i("VERDNATURA:","POSICION $position y el tipo $type")
//////Log.i("VERDNATURA:","El buyfk que no es real es $originalItemScan")
viewModel.saleTrackingReplace(
getData(USER),
getData(PASSWORD),
@ -1405,7 +1422,7 @@ class CollectionFragment(
)
(getString(R.string.Imprimiendo) + " por " + getData(SECTORDESCRIP)).toast(requireContext())
(getString(R.string.Imprimiendo) + " por " + getData(PRINTERNAME)).toast(requireContext())
}
private fun addItem() {
@ -1598,7 +1615,7 @@ class CollectionFragment(
}
private fun setTotalLines() {
// Log.d("VERDNTURA::","el itempacking ggg es "+collection.tickets.get(0).itemPackingTypeFk)
var totalMark = 0
sales.forEach {
if (type == SACADOR) {
@ -1618,11 +1635,12 @@ class CollectionFragment(
if (collection.collectionFk != null) collection.collectionFk else ""
if (binding.mainToolbar.toolbarSubtitle != null && totalMark != null && sales != null) binding.mainToolbar.toolbarSubtitle.text =
"" + totalMark + "/" + sales.size
if (totalMark == sales.size) {
getString(R.string.Coleccióncompleta).toast(this.context, Toast.LENGTH_SHORT)
if (!goBack)
ticketCollection_setUsedShelves()
goBack=false
//showBottomNavigation(View.VISIBLE)
//sergio: se quita porque se realiza desde triggers
@ -1775,13 +1793,7 @@ class CollectionFragment(
customDialogThreeButtons.getValue(),
getString(R.string.Faltas)
)
/*if (customDialogThreeButtons.getValue().trim().isNullOrEmpty()) {
getString(R.string.Indicanuevacantidad).toast(requireContext())
} else {
trash(position, customDialogThreeButtons.getValue())
scanRequest()
customDialogThreeButtons.dismiss()
}*/
}.setOkButtonTwo(getString(R.string.BasuraRechazar)) {
checkAndCall(
@ -1838,6 +1850,10 @@ class CollectionFragment(
}
private fun split(position: Int, quantity: String) {
quantityCollectionSplit=quantity
positionCollectionSplit=position
var totalQuantity: Int = 0
try {
totalQuantity = sales[position].quantity.toInt() - quantity.toInt()
@ -1851,9 +1867,8 @@ class CollectionFragment(
originalQuantity = sales[position].quantity,
"saleMove"
)
//sales[position].originalQuantity = quantity
sales[position].quantity = quantity
//sales[position].startQuantity = quantity
/* sales[position].quantity = quantity
if (quantity == "0")
markLine(position, type)
@ -1868,7 +1883,7 @@ class CollectionFragment(
token = getData(TOKEN),
workerId = sales[position].salePersonFk,
message = message, "sendChekingPresence"
)
)*/
}
@ -2042,9 +2057,11 @@ class CollectionFragment(
"TRUE"->{
message = "Se ha enviado a Basura " + totalQuantity + " del articulo " + sales[positionCollectionMissing].itemFk + " ticket " + ticket
}
"FALSE"->{
message= "Se ha enviado a Faltas la cantidad de " + totalQuantity + " del articulo " + sales[positionCollectionMissing].itemFk + " ticket " + ticket
}
"reject"->{
message = "Se ha modificado la cantidad de " + sales[positionCollectionMissing].originalQuantity + " del artículo " + sales[positionCollectionMissing].itemFk + " a nueva cantidad: " + sales[positionCollectionMissing].quantity + " del ticket " + ticket
@ -2068,9 +2085,12 @@ class CollectionFragment(
private fun incresaseSuccesful() {
try {
//val quantityPicked = (quantity.toInt() - sales[position].quantity.toInt()).toString()
//sales[position].originalQuantity = quantity
sales[positionIncreaseQuantity].quantity = quantityIncrease
//val quantityPicked = (quantity.toInt() - sales[position].quantitytoInt()).toString()
// sergio: se añade linea para que se actualice la originalQuantity
//sales[positionIncreaseQuantity].originalQuantity = quantityIncrease
sales[positionIncreaseQuantity].quantity = quantityIncrease
/*if (type == CONTROLADOR){
showShelving(position,0,quantityPicked)
}*/
@ -2084,6 +2104,7 @@ class CollectionFragment(
val message =
"Se ha modificado la cantidad original " + sales[positionIncreaseQuantity].originalQuantity + " del artículo " + sales[positionIncreaseQuantity].itemFk + " a nueva cantidad: " + sales[positionIncreaseQuantity].quantity + " del ticket " + ticket
sendSalixMessageNew(message, sales[positionIncreaseQuantity].salePersonFk)
/* val ticket =
"[" + sales[positionIncreaseQuantity].ticketFk + "](https://salix.verdnatura.es/#!/ticket/" + sales[positionIncreaseQuantity].ticketFk + "/summary)"
@ -2094,6 +2115,7 @@ class CollectionFragment(
workerId = sales[positionIncreaseQuantity].salePersonFk,
message = message, "sendChekingPresence"
)*/
sales[positionIncreaseQuantity].originalQuantity = quantityIncrease
}
@ -2220,7 +2242,7 @@ class CollectionFragment(
}
customDialogList.setTitle("Causa de error").setKoButton("Cerrar") {
customDialogList.setTitle("Causa de error").setKoButton("Cancelar") {
scanRequest()
hideKeyboards()
customDialogList.dismiss()

View File

@ -37,6 +37,10 @@ class CollectionViewModel(context: Context) : BaseViewModel()
val response: LiveData<ResponseItemVO>
get() = _response
private val _responseSaleMove by lazy { MutableLiveData<ResponseItemVO>() }
val responseSaleMove: LiveData<ResponseItemVO>
get() = _responseSaleMove
private val _responseUsedShelves by lazy { MutableLiveData<ResponseItemVO>() }
val responseUsedShelves: LiveData<ResponseItemVO>
get() = _responseUsedShelves
@ -508,7 +512,7 @@ class CollectionViewModel(context: Context) : BaseViewModel()
{
override fun onFailure(call: Call<String>, t: Throwable)
{
_response.value = ResponseItemVO(
_responseSaleMove.value = ResponseItemVO(
isError = true,
errorMessage = getMessageFromAllResponse(nameofFunction(this),t.message!!)
)
@ -518,13 +522,13 @@ class CollectionViewModel(context: Context) : BaseViewModel()
{
if (response.body() == null)
{
_response.value = ResponseItemVO(
_responseSaleMove.value = ResponseItemVO(
isError = true,
errorMessage = getMessageFromAllResponse(nameofFunction(this),response.message()))
} else
{
_response.value = ResponseItemVO(isError = false, response = response.body()!!)
_responseSaleMove.value = ResponseItemVO(isError = false, response = response.body()!!)
}
}
})

View File

@ -67,7 +67,7 @@ class CollectionShowTicketFragment(
override fun init() {
customDialog = CustomDialog(requireContext())
(activity as MainActivity).hideBottomNavigation(GONE)
ma.hideBottomNavigation(GONE)
binding.splashProgress.visibility = VISIBLE
setEvents()
setToolBarIcon()
@ -113,7 +113,7 @@ class CollectionShowTicketFragment(
"collectionStickerPrint"
)
(getString(R.string.Imprimiendo) + " por " + getData(SECTORDESCRIP)).toast(requireContext())
(getString(R.string.Imprimiendo) + " por " + getData(PRINTERNAME)).toast(requireContext())
}
private fun setEvents() {
@ -186,7 +186,7 @@ class CollectionShowTicketFragment(
binding.mainToolbar.toolbarSubtitle.text = "0/0"
}
} else {
(activity as MainActivity).messageWithSound(it.errorMessage,it.isError,false)
ma.messageWithSound(it.errorMessage,it.isError,false)
if (activity != null) requireActivity().onBackPressed()
}

View File

@ -19,7 +19,7 @@ class ControladorFragment :
private var goBack: Boolean = false
private var onCollectionSelectedListener: OnCollectionSelectedListener? = null
override fun getLayoutId(): Int = R.layout.fragment_controlador
private lateinit var customDialog: CustomDialog
//private lateinit var customDialog: CustomDialog
companion object {
fun newInstance() = ControladorFragment()
@ -33,10 +33,10 @@ class ControladorFragment :
override fun init() {
binding.splashProgress.visibility = View.GONE
customDialog = CustomDialog(requireContext())
// customDialog = CustomDialog(requireContext())
binding.mainToolbar.toolbarTitle.text = getString(R.string.controlticket)
setEvents()
(activity as MainActivity).hideBottomNavigation(View.VISIBLE)
ma.hideBottomNavigation(View.VISIBLE)
super.init()
}
@ -73,7 +73,7 @@ class ControladorFragment :
}
binding.scanInput.setText("")
(activity as MainActivity).hideKeyboard(binding.scanInput)
ma.hideKeyboard(binding.scanInput)
return@setOnEditorActionListener true
}
false
@ -85,10 +85,11 @@ class ControladorFragment :
collectionTicketList.observe(viewLifecycleOwner, Observer {
binding.splashProgress.visibility = View.GONE
if (it.isError) {
customDialog.setTitle("Error").setDescription(it.errorMessage)
ma.messageWithSound(it.errorMessage,isError = true, isPlayed = false)
/*customDialog.setTitle("Error").setDescription(it.errorMessage)
.setOkButton("Aceptar") {
customDialog.dismiss()
}.show()
}.show()*/
} else {
if (!goBack) navigateToCollectionList(it)

View File

@ -7,7 +7,6 @@ import android.util.TypedValue
import android.view.View.*
import android.view.inputmethod.EditorInfo
import android.widget.ImageView
import androidx.lifecycle.Observer
import androidx.recyclerview.widget.LinearLayoutManager
import es.verdnatura.R
import es.verdnatura.databinding.FragmentVehiclecontrolBinding
@ -18,9 +17,9 @@ import es.verdnatura.presentation.view.component.CustomDialog
import es.verdnatura.presentation.view.component.CustomDialogInput
import es.verdnatura.presentation.view.component.CustomDialogThreeButtons
import es.verdnatura.presentation.view.feature.historicovehiculo.fragment.HistoricoVehiculoFragment
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.fragment.SacadorFragment
import java.text.SimpleDateFormat
import java.util.*
import kotlin.collections.ArrayList
@ -36,7 +35,7 @@ class ControlVehiculoFragment(
private lateinit var customDialog: CustomDialog
private var isWorkedTimed = "UNREGISTERED"
private lateinit var customDialogInput: CustomDialogInput
private lateinit var customDialogThreeButtons: CustomDialogThreeButtons
private lateinit var customDialogThreeButtons: CustomDialogThreeButtons
companion object {
fun newInstance(tagName: String) = ControlVehiculoFragment(tagName)
@ -58,7 +57,7 @@ class ControlVehiculoFragment(
/* if (getWagons() < 2 && !tagName.equals(SacadorFragment.TAG))
{
(activity as MainActivity).openFragmentPickers()
ma.openFragmentPickers()
}*/
@ -66,20 +65,24 @@ class ControlVehiculoFragment(
setToolBar("HISTORY")
showScanner("Escanea matrícula para ver histórico", "HISTORY")
} else {
checkControlTimeVehicle()
setToolBar("ALL")
}
setEvents()
setEvents()
super.init()
}
override fun onPause() {
goBack = true
super.onPause()
}
private fun setToolBar(direction: String) {
private fun setToolBar(direction: String?) {
binding.mainToolbar.toolbarTitle.text = getString(R.string.vehiclecontrol)
binding.mainToolbar.toolbarTitle.setTextSize(TypedValue.COMPLEX_UNIT_SP, 13F)
@ -112,29 +115,8 @@ class ControlVehiculoFragment(
listIcons.add(iconVehicleIn)
listIcons.add(iconHistory)
}
"OUT"->{
listIcons.remove(iconVehicleOut)
listIcons.remove(iconVehicleIn)
listIcons.add(iconHistory)
}
}
/* if (direction.equals("OUT")) {
listIcons.remove(iconVehicleIn)
listIcons.add(iconVehicleOut)
listIcons.add(iconHistory)
}
if (direction.equals("IN")) {
listIcons.remove(iconVehicleOut)
listIcons.add(iconVehicleIn)
listIcons.add(iconHistory)
}
if (direction.equals("HISTORY")) {
listIcons.remove(iconVehicleOut)
listIcons.remove(iconVehicleIn)
listIcons.add(iconHistory)
}*/
binding.mainToolbar.toolbarIcons.adapter = ToolBarAdapterTooltip(listIcons, object : OnOptionsSelectedListener {
override fun onOptionsItemSelected(item: Drawable) {
@ -154,7 +136,7 @@ class ControlVehiculoFragment(
customDialogInput.setTitle(getString(R.string.vehiclecontrol)).setDescription(description)
.setOkButton("Aceptar") {
if (!customDialogInput.getValue().isNullOrEmpty()) {
if (customDialogInput.getValue().isNotEmpty()) {
// "$description ${customDialogInput.getValue()} OK".toast(requireContext())
insertControlTimeVehicle(customDialogInput.getValue(), action)
}
@ -166,14 +148,18 @@ class ControlVehiculoFragment(
.setKoButton("Cancelar") {
customDialogInput.dismiss()
if (tagName.equals(HistoricoVehiculoFragment.TAG)) {
ma.onBackPressed()
}
}.setValue("").show()
customDialogInput.getEditText().requestFocus()
customDialogInput.setFocusText()
customDialogInput.getEditText().setOnEditorActionListener { v, actionId, event ->
if (actionId == EditorInfo.IME_ACTION_SEARCH || actionId == EditorInfo.IME_ACTION_DONE || actionId == 0) {
if (!customDialogInput.getValue().isNullOrEmpty()) {
if (customDialogInput.getValue().isNotEmpty()) {
insertControlTimeVehicle(customDialogInput.getValue(), action)
}
@ -191,15 +177,20 @@ class ControlVehiculoFragment(
private fun checkControlTimeVehicle() {
if (!goBack) {
// d("la fecha es "+getData("DATENOVEHICLE"))
//if (!IsNoVehicleDataToday()){
binding.splashProgress.visibility = VISIBLE
viewModel.workerMachinery_isRegistered(getData(USER),getData(PASSWORD),"workerMachinery_isRegistered")
/*}else{
ma.openFragmentPickers()
}*/
}
}
private fun insertControlTimeVehicle(plateNumber: String, direction: String) {
if (direction.equals("HISTORY")) {
(activity as MainActivity).onPasillerosItemClickListener(
ma.onPasillerosItemClickListener(
PasillerosItemVO(title = "Historico Vehículo"),
plateNumber
)
@ -211,15 +202,15 @@ class ControlVehiculoFragment(
viewModel.machineWorker_update(getData(USER),getData(PASSWORD), plateNumber,"machineWorker_update")
} else if (direction.equals("")) {
(activity as MainActivity).openFragmentPickers()
ma.openFragmentPickers(true)
}
}
private fun scanRequest() {
if (binding.scanInput != null) {
// if (binding.scanInput != null) {
binding.scanInput.requestFocus()
}
//}
hideKeyboards()
}
@ -234,7 +225,9 @@ class ControlVehiculoFragment(
private fun setEvents() {
binding.mainToolbar.backButton.setOnClickListener {
requireActivity().onBackPressed()
ma.openFragmentPickers(true)
//requireActivity().onBackPressed()
}
binding.scanInput.requestFocus()
@ -249,7 +242,7 @@ class ControlVehiculoFragment(
}
}
binding.scanInput.setText("")
(activity as MainActivity).hideKeyboard(binding.scanInput)
ma.hideKeyboard(binding.scanInput)
return@setOnEditorActionListener true
}
false
@ -264,7 +257,7 @@ class ControlVehiculoFragment(
.setValue(plate)
if (isWorkedTimed.equals("UNREGISTERED")) {
customDialogThreeButtons.setOkButtonTwo("COGER") {
if (customDialogThreeButtons.getValue().trim().isNullOrEmpty()) {
if (customDialogThreeButtons.getValue().trim().isEmpty()) {
"Vuelva a escanear".toast(requireContext())
} else {
binding.splashProgress.visibility = VISIBLE
@ -275,7 +268,7 @@ class ControlVehiculoFragment(
} else {
customDialogThreeButtons.setOkButtonThree("DEJAR") {
if (customDialogThreeButtons.getValue().trim().isNullOrEmpty()) {
if (customDialogThreeButtons.getValue().trim().isEmpty()) {
"Vuelva a escanear".toast(requireContext())
} else {
binding.splashProgress.visibility = VISIBLE
@ -284,7 +277,7 @@ class ControlVehiculoFragment(
}
}
}.setOkButtonFour("HISTÓRICO") {
if (customDialogThreeButtons.getValue().trim().isNullOrEmpty()) {
if (customDialogThreeButtons.getValue().trim().isEmpty()) {
"Vuelva a escanear".toast(requireContext())
} else {
customDialogThreeButtons.dismiss()
@ -306,7 +299,7 @@ class ControlVehiculoFragment(
.setValue(plate)
.setOkButtonFour("HISTÓRICO") {
if (customDialogThreeButtons.getValue().trim().isNullOrEmpty()) {
if (customDialogThreeButtons.getValue().trim().isEmpty()) {
"Vuelva a escanear".toast(requireContext())
} else {
customDialogThreeButtons.dismiss()
@ -324,16 +317,16 @@ class ControlVehiculoFragment(
with(viewModel) {
binding.splashProgress.visibility = GONE
responseinsert.observe(viewLifecycleOwner, Observer {
responseinsert.observe(viewLifecycleOwner, {
if (it.isError) {
customDialog.setTitle("Error").setDescription(it.errorMessage)
ma.messageWithSound(it.errorMessage,true,false)
/*customDialog.setTitle("Error").setDescription(it.errorMessage)
.setOkButton("Cerrar") {
customDialog.dismiss()
}.show()
}.show()*/
} else {
if (it.response == null || it.response == "false") {
if (it.response == "false") {
customDialog.setTitle("Error")
.setDescription("Revisar llamada del registro de vehículos")
@ -350,8 +343,8 @@ class ControlVehiculoFragment(
.setOkButton("Cerrar") {
customDialog.dismiss()
}.show()*/
(activity as MainActivity).openFragmentPickers()
//(activity as MainActivity).onPasillerosItemClickListener( PasillerosItemVO(title = "Sacadores"),"CONTROL")
ma.openFragmentPickers(true)
//ma.onPasillerosItemClickListener( PasillerosItemVO(title = "Sacadores"),"CONTROL")
//checkControlTimeVehicle()
}
@ -360,54 +353,68 @@ class ControlVehiculoFragment(
binding.splashProgress.visibility = GONE
})
responsecontrol.observe(viewLifecycleOwner, Observer {
responsecontrol.observe(viewLifecycleOwner, {
binding.splashProgress.visibility = GONE
// Log.i("VERDNATURA:","${it.response}")
if (it.isError) {
customDialog.setTitle("Error").setDescription(it.errorMessage)
ma.messageWithSound(it.errorMessage,true,false)
/*customDialog.setTitle("Error").setDescription(it.errorMessage)
.setOkButton("Cerrar") {
customDialog.dismiss()
}.show()
}.show()*/
} else {
if (it.response == null) {
customDialog.setTitle("Error")
.setDescription("Revisar llamada de control de vehículos")
.setOkButton("Cerrar") {
customDialog.dismiss()
}.show()
} else {
if (it.response.equals("1")) {
isWorkedTimed = "REGISTERED"
setToolBar("OUT")
/* customDialog.setTitle("Control de vehículos")
.setDescription("SI Tienes coche asignado")
.setOkButton("Cerrar") {
customDialog.dismiss()
}.show()*/
if (!tagName.equals(SacadorFragment.TAG)) {
(activity as MainActivity).openFragmentPickers()
}
} else {
if (it.response.equals("0")) {
setToolBar("IN")
customDialog.setTitle("Control de vehículos")
.setDescription("Escanea la matrícula del vehículo o elige sin vehículo")
.setOkButton("Escanear vehículo") {
customDialog.dismiss()
showScanner("Escanea matrícula del vehículo", "IN")
}
.setKoButton("SIN VEHÍCULO") {
customDialog.dismiss()
(activity as MainActivity).openFragmentPickers()
// getActivity()?.getFragmentManager()?.popBackStack();
}.show()
}
if (it.response.equals("1")) {
isWorkedTimed = "REGISTERED"
setToolBar("OUT")
/* customDialog.setTitle("Control de vehículos")
.setDescription("SI Tienes coche asignado")
.setOkButton("Cerrar") {
customDialog.dismiss()
}.show()*/
if (!tagName.equals(SacadorFragment.TAG)) {
ma.openFragmentPickers(true)
}
} else {
if (it.response.equals("0")) {
setToolBar("IN")
/* customDialog.setTitle("Control de vehículos")
.setDescription("Escanea la matrícula del vehículo o elige sin vehículo")
.setOkButton("Escanear vehículo") {
customDialog.dismiss()
showScanner("Escanea matrícula del vehículo", "IN")
}
.setKoButton("SIN VEHÍCULO") {
customDialog.dismiss()
saveData(DATENOVEHICLE, SimpleDateFormat("yyyy-MM-dd",Locale.getDefault()).format(Date()).toString())
ma.openFragmentPickers(true)
}.show()*/
customDialogInput.setTitle(getString(R.string.vehiclecontrol)).setDescription("Escanea la matrícula del vehículo o elige sin vehículo")
.setOkButton("Coger vehículo") {
if (customDialogInput.getValue().isNotEmpty()) {
// "$description ${customDialogInput.getValue()} OK".toast(requireContext())
insertControlTimeVehicle(customDialogInput.getValue(), "IN")
}
customDialogInput.setValue("")
scanRequest()
customDialogInput.dismiss()
hideKeyboards()
}
.setKoButton("Sin vehículo") {
customDialogInput.dismiss()
ma.openFragmentPickers(true)
/* if (tagName.equals(HistoricoVehiculoFragment.TAG)) {
ma.onBackPressed()
}*/
}.setValue("").show()
customDialogInput.setFocusText()
}
}
}
})
@ -415,6 +422,13 @@ class ControlVehiculoFragment(
}
}
private fun IsNoVehicleDataToday(): Boolean {
return (getData(DATENOVEHICLE)==SimpleDateFormat("yyyy-MM-dd",Locale.getDefault()).format(Date()))
}
}

View File

@ -7,6 +7,7 @@ import es.verdnatura.databinding.FragmentVehiclecontrolUserBinding
import es.verdnatura.presentation.base.BaseFragment
import es.verdnatura.presentation.common.loadUrl
import es.verdnatura.presentation.view.component.CustomDialog
import es.verdnatura.presentation.view.feature.main.activity.MainActivity
class ControlVehiculoUsuarioFragment(
@ -18,7 +19,7 @@ class ControlVehiculoUsuarioFragment(
private var userFk = ""
private var goBack: Boolean = false
override fun getLayoutId(): Int = R.layout.fragment_vehiclecontrol_user
private lateinit var customDialog: CustomDialog
//private lateinit var customDialog: CustomDialog
companion object {
fun newInstance(vUserFK: String) = ControlVehiculoUsuarioFragment(vUserFK)
@ -26,7 +27,7 @@ class ControlVehiculoUsuarioFragment(
override fun init() {
binding.mainToolbar.toolbarTitle.text = getString(R.string.vehiclecontroluser)
customDialog = CustomDialog(requireContext())
// customDialog = CustomDialog(requireContext())
goBack = false
binding.splashProgress.visibility = GONE
setEvents()
@ -86,10 +87,11 @@ class ControlVehiculoUsuarioFragment(
responsemachine.observe(viewLifecycleOwner, Observer {
binding.splashProgress.visibility = GONE
if (it.isError) {
customDialog.setTitle("Error").setDescription(it.errorMessage)
ma.messageWithSound(it.errorMessage,true,false)
/*customDialog.setTitle("Error").setDescription(it.errorMessage)
.setOkButton("Cerrar") {
customDialog.dismiss()
}.show()
}.show()*/
} else {
//sergio: se modifica el response = null. En casi todas las llamadas se utilizaba para ver si había error.
// Ahora ya no.

View File

@ -24,6 +24,7 @@ class DayOfSaleFragment(
) : BaseFragment<FragmentItemdayofsaleCardBinding, DayOfSaleViewModel>(DayOfSaleViewModel::class) {
private lateinit var customDialogList: CustomDialogList
private lateinit var customDialog: CustomDialog
private var adapter: DayOfSaleAdapter? = null
private var itemScan = ""
@ -31,7 +32,6 @@ class DayOfSaleFragment(
fun newInstance(entryPoint: String) = DayOfSaleFragment(entryPoint)
}
private lateinit var customDialog: CustomDialog
override fun getLayoutId(): Int = R.layout.fragment_itemdayofsale_card
@ -83,7 +83,7 @@ class DayOfSaleFragment(
itemScan = binding.scanInput.text.toString()
}
binding.scanInput.setText("")
(activity as MainActivity).hideKeyboard(binding.scanInput)
ma.hideKeyboard(binding.scanInput)
return@setOnEditorActionListener true
}
false
@ -126,7 +126,7 @@ class DayOfSaleFragment(
}else{
if (it.list.get(0).isError){
(activity as MainActivity).messageWithSound(it.list.get(0).errorMessage,it.list.get(0).isError,isPlayed = false)
ma.messageWithSound(it.list.get(0).errorMessage,it.list.get(0).isError,isPlayed = false)
/*customDialog.setTitle("Error")
.setDescription(it.list.get(0).errorMessage)
.setOkButton("Cerrar") {
@ -141,9 +141,10 @@ class DayOfSaleFragment(
if (it.isError){
binding.splashProgress.visibility = View.GONE
customDialog.setTitle("Error").setDescription(it.errorMessage).setOkButton("Cerrar"){
ma.messageWithSound(it.errorMessage,true,false)
/*customDialog.setTitle("Error").setDescription(it.errorMessage).setOkButton("Cerrar"){
customDialog.dismiss()
}.show()
}.show()*/
}else{
@ -165,7 +166,7 @@ class DayOfSaleFragment(
customDialogList.setTitle("Escanea el parking")
.setOkButton("Cerrar") {
(activity as MainActivity).hideKeyboard(customDialogList.getEditText())
ma.hideKeyboard(customDialogList.getEditText())
customDialogList.dismiss()
@ -173,7 +174,7 @@ class DayOfSaleFragment(
customDialogList.getEditText().requestFocus()
(activity as MainActivity).hideKeyboard(customDialogList.getEditText())
ma.hideKeyboard(customDialogList.getEditText())
customDialogList.getEditText().setOnEditorActionListener { _, actionId, _ ->
if (actionId == EditorInfo.IME_ACTION_SEARCH || actionId == EditorInfo.IME_ACTION_DONE || actionId == 0 || actionId == 5 || actionId == 6) {
@ -181,7 +182,7 @@ class DayOfSaleFragment(
parking(customDialogList.getValue())
}
customDialogList.setValue("")
(activity as MainActivity).hideKeyboard(customDialogList.getEditText())
ma.hideKeyboard(customDialogList.getEditText())
return@setOnEditorActionListener true
}
false

View File

@ -26,7 +26,7 @@ class FaltasFragment : BaseFragment<FragmentFaltasBinding, FaltasViewModel>(Falt
private lateinit var customDialogInput: CustomDialogInput
private var listInvetory:ArrayList<ItemFaltasVO> = ArrayList()
private var listInvetoryAux:ArrayList<ItemFaltasVO> = ArrayList()
private lateinit var customDialog: CustomDialog
// private lateinit var customDialog: CustomDialog
private var pasillerosItemClickListener: OnPasillerosItemClickListener? = null
private var reload = false
private var hideLoad = true
@ -50,12 +50,12 @@ class FaltasFragment : BaseFragment<FragmentFaltasBinding, FaltasViewModel>(Falt
override fun init() {
binding.splashProgress.visibility = View.VISIBLE
(activity as MainActivity).hideBottomNavigation(View.GONE)
ma.hideBottomNavigation(View.GONE)
binding.mainToolbar.toolbarTitle.text = getString(R.string.faultsReview)
setToolBar()
customDialogInput = CustomDialogInput(requireContext())
customDialog = CustomDialog(requireContext())
// customDialog = CustomDialog(requireContext())
setEvents()
if (reload){
reload = false
@ -154,7 +154,7 @@ class FaltasFragment : BaseFragment<FragmentFaltasBinding, FaltasViewModel>(Falt
}
customDialogInput.setValue("")
customDialogInput.dismiss()
(activity as MainActivity).hideKeyboard(customDialogInput.getEditText())
ma.hideKeyboard(customDialogInput.getEditText())
return@setOnEditorActionListener true
}
false
@ -176,7 +176,7 @@ class FaltasFragment : BaseFragment<FragmentFaltasBinding, FaltasViewModel>(Falt
response.observe(viewLifecycleOwner, Observer {
if (it.isError){
(activity as MainActivity).messageWithSound(it.errorMessage,it.isError,false)
ma.messageWithSound(it.errorMessage,it.isError,false)
/* customDialog.setTitle("Error").setDescription(it.errorMessage).setOkButton("Cerrar"){
customDialog.dismiss()
}.show()*/

View File

@ -32,8 +32,8 @@ class HistoricoArticuloFragment(
HistoricoArticuloViewModel::class
) {
private var adapter: HistoricoAdapter? = null
private lateinit var customDialogInput: CustomDialogInput
private lateinit var customDialog: CustomDialog
// private lateinit var customDialogInput: CustomDialogInput
// private lateinit var customDialog: CustomDialog
private var listHistoric: ArrayList<ItemHistoricoVO> = ArrayList()
private var listHistoryAux: ArrayList<ItemHistoricoVO> = ArrayList()
private var filter: String = ""
@ -46,9 +46,9 @@ class HistoricoArticuloFragment(
override fun init() {
customDialogInput = CustomDialogInput(requireContext())
customDialog = CustomDialog(requireContext())
(activity as MainActivity).hideBottomNavigation(View.GONE)
// customDialogInput = CustomDialogInput(requireContext())
// customDialog = CustomDialog(requireContext())
ma.hideBottomNavigation(View.GONE)
filter = "all"
viewModel.itemDiary(getData(USER), getData(PASSWORD), itemFk, getData(WAREHOUSEFK),"itemDiary")
binding.mainToolbar.toolbarTitle.text = getString(R.string.itemdiary) + ":" + itemFk

View File

@ -18,7 +18,7 @@ class itemShelvingLogFragment(
var entryPoint: String = ""
// ) : BaseFragment<FragmentItemdayofsaleCardBinding, itemShelvingLogViewModel>(itemShelvingLogViewModel::class) {
) : BaseFragment<FragmentItemshelvinglogBinding, itemShelvingLogViewModel>(itemShelvingLogViewModel::class) {
private lateinit var customDialogList: CustomDialogList
//private lateinit var customDialogList: CustomDialogList
private var adapter: ItemShelvingLogAdapter? = null
private var itemScan = ""
@ -33,7 +33,7 @@ class itemShelvingLogFragment(
override fun init() {
customDialog = CustomDialog(requireContext())
customDialogList = CustomDialogList(requireContext())
// customDialogList = CustomDialogList(requireContext())
setEvents()
setToolBar(getString(R.string.itemShelvingLog))
super.init()
@ -56,7 +56,7 @@ class itemShelvingLogFragment(
itemScan = binding.scanInput.text.toString()
}
binding.scanInput.setText("")
(activity as MainActivity).hideKeyboard(binding.scanInput)
ma.hideKeyboard(binding.scanInput)
return@setOnEditorActionListener true
}
false

View File

@ -18,7 +18,7 @@ class shelvingLogFragment(
) : BaseFragment<FragmentShelvinglogBinding, shelvingLogViewModel>(
shelvingLogViewModel::class) {
private lateinit var customDialogList: CustomDialogList
// private lateinit var customDialogList: CustomDialogList
private var adapter: ShelvingLogAdapter? = null
private var itemScan = ""
@ -33,7 +33,7 @@ class shelvingLogFragment(
override fun init() {
customDialog = CustomDialog(requireContext())
customDialogList = CustomDialogList(requireContext())
// customDialogList = CustomDialogList(requireContext())
setEvents()
setToolBar(getString(R.string.shelvingLog))
super.init()
@ -57,7 +57,7 @@ class shelvingLogFragment(
itemScan = binding.scanInput.text.toString()
}
binding.scanInput.setText("")
(activity as MainActivity).hideKeyboard(binding.scanInput)
ma.hideKeyboard(binding.scanInput)
return@setOnEditorActionListener true
}
false

View File

@ -12,6 +12,7 @@ import es.verdnatura.presentation.view.component.CustomDialogInput
import es.verdnatura.presentation.view.feature.historicovehiculo.adapter.HistoricoVehiculoAdapter
import es.verdnatura.presentation.view.feature.historicovehiculo.model.ItemHistoricoVehiculoList
import es.verdnatura.presentation.view.feature.main.activity.MainActivity
import timber.log.Timber.d
import java.text.SimpleDateFormat
import java.util.*
@ -22,9 +23,6 @@ class HistoricoVehiculoFragment (
HistoricoVehiculoViewModel::class) {
private var adapter : HistoricoVehiculoAdapter? = null
private lateinit var customDialogInput: CustomDialogInput
private lateinit var customDialog: CustomDialog
companion object {
fun newInstance(entryPoint:String) = HistoricoVehiculoFragment(entryPoint)
@ -36,9 +34,7 @@ class HistoricoVehiculoFragment (
override fun init()
{
customDialogInput = CustomDialogInput(requireContext())
customDialog = CustomDialog(requireContext())
(activity as MainActivity).hideBottomNavigation(View.GONE)
ma.hideBottomNavigation(View.GONE)
viewModel.machineWorker_getHistorical(getData(USER),getData(PASSWORD),numberPlate,"machineWorker_getHistorical")
binding.mainToolbar.toolbarTitle.text = getString(R.string.vehiclediary)
@ -63,6 +59,10 @@ class HistoricoVehiculoFragment (
binding.historicovehiculoRecyclerview.layoutManager = LinearLayoutManager(requireContext(), LinearLayoutManager.VERTICAL, false)
navigateToToday(it)
if (it.list.isEmpty()){
ma.messageWithSound("Solo puedes visualizar cuando has cogido tu mismo el vehículo a no ser que tengas permisos para ello.",true,true,"Información")
}
}
})
}

View File

@ -12,7 +12,7 @@ class ImageViewActivity : BaseActivity<ActivityImageviewBinding>(){
override fun init() {
binding.mainToolbar.toolbarTitle.text = (intent.getStringExtra("title"))
binding.imgView.loadUrl(intent.getStringExtra("url"))
binding.imgView.loadUrl(intent.getStringExtra("url")!!)
binding.mainToolbar.backButton.setOnClickListener {
onBackPressed()

View File

@ -90,7 +90,7 @@ class InventaryFragment : BaseFragment<FragmentInventaryBinding,InventaryViewMod
customDialogInput = CustomDialogInput(requireContext())
customDialog = CustomDialog(requireContext())
(activity as MainActivity).hideBottomNavigation(View.GONE)
ma.hideBottomNavigation(View.GONE)
binding.splashProgress.visibility = View.VISIBLE
binding.mainToolbar.toolbarTitle.text = getString(R.string.itemShelvingRadar)
setToolBar()
@ -241,9 +241,10 @@ class InventaryFragment : BaseFragment<FragmentInventaryBinding,InventaryViewMod
response.observe(viewLifecycleOwner, Observer {
if (it.isError){
customDialog.setTitle("Error").setDescription(it.errorMessage).setOkButton("Cerrar"){
ma.messageWithSound(it.errorMessage,true,false)
/* customDialog.setTitle("Error").setDescription(it.errorMessage).setOkButton("Cerrar"){
customDialog.dismiss()
}.show()
}.show()*/
}
})
}

View File

@ -6,6 +6,7 @@ import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.Transformations
import es.verdnatura.domain.GetInventaryUserCase
import es.verdnatura.domain.GetItemCardUserCase
import es.verdnatura.domain.GetWokerMistakeUSerCase
import es.verdnatura.presentation.base.BaseViewModel
import es.verdnatura.presentation.base.getMessageFromAllResponse
import es.verdnatura.presentation.base.nameofFunction
@ -13,17 +14,24 @@ import es.verdnatura.presentation.common.Event
import es.verdnatura.presentation.common.ResponseItemVO
import es.verdnatura.presentation.view.feature.calidad.model.BuyerListVO
import es.verdnatura.presentation.view.feature.calidad.model.BuyerVO
import es.verdnatura.presentation.view.feature.historicovehiculo.model.ItemHistoricoVehiculo
import es.verdnatura.presentation.view.feature.historicovehiculo.model.ItemHistoricoVehiculoList
import es.verdnatura.presentation.view.feature.inventario.model.InventaryListVO
import es.verdnatura.presentation.view.feature.inventario.model.ItemInventaryVO
import es.verdnatura.presentation.view.feature.sacador.model.MistakeTypeListVO
import es.verdnatura.presentation.view.feature.sacador.model.MistakeTypeVO
import es.verdnatura.presentation.view.feature.workermistake.model.*
import retrofit2.Call
import retrofit2.Callback
import retrofit2.Response
import timber.log.Timber.d
class InventaryViewModel(context: Context) : BaseViewModel() {
private val getInventaryUserCase: GetInventaryUserCase = GetInventaryUserCase(context)
private val getItemCardUserCase: GetItemCardUserCase = GetItemCardUserCase(context)
private val getWorkerMistakeUserCase:GetWokerMistakeUSerCase= GetWokerMistakeUSerCase(context)
private val _inventaryList by lazy { MutableLiveData<InventaryListVO>() }
val inventaryList: LiveData<InventaryListVO>
@ -38,6 +46,22 @@ class InventaryViewModel(context: Context) : BaseViewModel() {
val buyersList: LiveData<BuyerListVO>
get() = _buyersList
//********************** a borrar, solo para montar fragment ****************/
private val _mistakeDepartmentList by lazy { MutableLiveData<departmentMistakeList>() }
val mistakeDepartmentList: LiveData<departmentMistakeList>
get() = _mistakeDepartmentList
private val _workerFromMistakeList by lazy { MutableLiveData<workerFromMistakeList>() }
val workerFromMistakeList: LiveData<workerFromMistakeList>
get() = _workerFromMistakeList
private val _mistakeWorkerList by lazy { MutableLiveData<workerMistakeTypeList>()}
val mistakeWorkerList: LiveData<workerMistakeTypeList>
get() = _mistakeWorkerList
private val _responseAddMistake by lazy { MutableLiveData<ResponseItemVO>() }
val responseAddMistake: LiveData<ResponseItemVO>
get() = _responseAddMistake
//sergio para obtener comprador
fun itemShelvingBuyerGet(user:String,password:String,callFunction:String){
@ -172,4 +196,136 @@ class InventaryViewModel(context: Context) : BaseViewModel() {
}
fun department_getHasMistake(usuario: String, password: String)
{
getWorkerMistakeUserCase.department_getHasMistake(usuario, password)
.enqueue(object : Callback<List<DepartmentMistake>>
{
override fun onFailure(call: Call<List<DepartmentMistake>>, t: Throwable)
{
val listError: ArrayList<DepartmentMistake> = ArrayList()
listError.add(DepartmentMistake(isError = true,errorMessage =getMessageFromAllResponse(nameofFunction(this),t.message!!)))
_mistakeDepartmentList.value = departmentMistakeList(listError)
}
override fun onResponse(
call: Call<List<DepartmentMistake>>,
response: Response<List<DepartmentMistake>>
)
{
if (response.body() != null)
{
_mistakeDepartmentList.value = response.body()?.let { departmentMistakeList(it) }
} else
{
val listError: ArrayList<DepartmentMistake> = ArrayList()
listError.add(DepartmentMistake("0", ""))
_mistakeDepartmentList.value = departmentMistakeList(listError)
}
}
})
}
fun worker_getFromHasMistake(usuario:String,password:String,departmentFk:String,callFunction:String){
getWorkerMistakeUserCase.worker_getFromHasMistake(usuario,password,departmentFk).enqueue(object :
Callback<List<WorkerFromMistake>> {
override fun onFailure(call: Call<List<WorkerFromMistake>>, t: Throwable) {
val listError:ArrayList<WorkerFromMistake> = ArrayList()
listError.add(WorkerFromMistake(isError = true,errorMessage =getMessageFromAllResponse(nameofFunction(this),t.message!!)))
_workerFromMistakeList.value = workerFromMistakeList(listError)
}
override fun onResponse(
call: Call<List<WorkerFromMistake>>,
response: Response<List<WorkerFromMistake>>
) {
if (response.body() != null){
_workerFromMistakeList.value = response.body()?.let { workerFromMistakeList(it) }
}else{
val listError:ArrayList<WorkerFromMistake> = ArrayList()
listError.add(WorkerFromMistake(isError = true,errorMessage = getMessageFromAllResponse(nameofFunction(this),response.message())))
_workerFromMistakeList.value = workerFromMistakeList(listError)
}
}
})
}
fun workerMistakeType_get(usuario: String, password: String)
{
getWorkerMistakeUserCase.workerMistakeType_get(usuario, password)
.enqueue(object : Callback<List<MistakeWorkerType>>
{
override fun onFailure(call: Call<List<MistakeWorkerType>>, t: Throwable)
{
val listError: ArrayList<MistakeWorkerType> = ArrayList()
listError.add(MistakeWorkerType(isError=true,errorMessage =getMessageFromAllResponse(nameofFunction(this),t.message!!),id="0", description = ""))
_mistakeWorkerList.value = workerMistakeTypeList(listError)
}
override fun onResponse(
call: Call<List<MistakeWorkerType>>,
response: Response<List<MistakeWorkerType>>
)
{
if (response.body() != null)
{
_mistakeWorkerList.value = response.body()?.let { workerMistakeTypeList(it) }
} else
{
val listError: ArrayList<MistakeWorkerType> = ArrayList()
listError.add(MistakeWorkerType(isError=true,errorMessage =getMessageFromAllResponse(nameofFunction(this),response.message()),id="0", description = ""))
_mistakeWorkerList.value = workerMistakeTypeList(listError)
}
}
})
}
fun workerMistake_Add(
usuario: String,
password: String,
vUserFk: String,
vTypeFk: String,callFunction:String
)
{
getWorkerMistakeUserCase.workerMistake_Add(usuario, password, vUserFk, vTypeFk)
.enqueue(object :
Callback<Unit>
{
override fun onFailure(call: Call<Unit>, t: Throwable)
{
d("Error message "+t.message)
_responseAddMistake.value = ResponseItemVO(
isError = true,
errorMessage =getMessageFromAllResponse(nameofFunction(this),t.message!!)
)
}
override fun onResponse(
call: Call<Unit>,
response: Response<Unit>
)
{
if (!response.isSuccessful)
{
d("Error message:"+{response.errorBody()}+"-"+response.message()+"-"+response.raw())
_responseAddMistake.value = ResponseItemVO(
isError = true,
errorMessage = getMessageFromAllResponse(nameofFunction(this),response.message())
)
} else
{
// sergio:refactor:solo debería haber un mensaje no un response o errorMessage
_responseAddMistake.value =
ResponseItemVO(isError = false, response ="Causa del error registrada", errorMessage = "Causa del error registrada")
}
}
})
}
}

View File

@ -19,4 +19,23 @@ class SearchBuyerModel(private var nickname: String?, private var buyerId: Strin
return nickname!!
}
}
class SearchDepartmentModel(private var name: String?, private var departmentId: String?) : Searchable {
override fun getTitle(): String {
return name!!
}
fun getDepartmentId(): String {
return departmentId!!
}
fun getDepartmentName(): String {
return name!!
}
}

View File

@ -1,8 +1,7 @@
package es.verdnatura.presentation.view.feature.login.fragment
import android.app.AlarmManager
import android.app.PendingIntent
import android.content.Context
//import es.verdnatura.presentation.view.feature.login.model.LoginItemVO
import android.annotation.SuppressLint
import android.content.Intent
import android.content.SharedPreferences
import android.content.pm.PackageInfo
@ -11,16 +10,13 @@ import android.net.Uri
import android.provider.Settings
import android.view.KeyEvent
import android.view.View
import androidx.lifecycle.Observer
import androidx.preference.PreferenceManager
import es.verdnatura.R
import es.verdnatura.databinding.FragmentLoginBinding
import es.verdnatura.presentation.base.BaseFragment
import es.verdnatura.presentation.common.hideKeyboard
import es.verdnatura.presentation.view.component.CustomDialog
import es.verdnatura.presentation.view.feature.login.activity.LoginActivity
import es.verdnatura.presentation.view.feature.login.model.LoginItemVO
import es.verdnatura.presentation.view.feature.main.activity.MainActivity
import timber.log.Timber.d
import java.lang.Boolean.TRUE
import kotlin.system.exitProcess
@ -39,13 +35,20 @@ class LoginFragment : BaseFragment<FragmentLoginBinding, LoginViewModel>(LoginVi
customDialog = CustomDialog(requireContext())
saveIdentifiers()
checkUser()
binding.buttonLogin.setOnClickListener(View.OnClickListener {
binding.buttonLogin.setOnClickListener({
binding.splashProgress.visibility = View.VISIBLE
viewModel.device_checkLogin(
/* viewModel.device_checkLogin(
binding.edittextUsername.text.toString(),
binding.edittextPassword.text.toString(),
getData(ANDROID_ID), callFunction = "device_checkLogin"
)
*/
viewModel.loginSalix(
user = binding.edittextUsername.text.toString(),
password = binding.edittextPassword.text.toString(),
callFunction = "login de Salix"
)
})
@ -58,23 +61,22 @@ class LoginFragment : BaseFragment<FragmentLoginBinding, LoginViewModel>(LoginVi
binding.edittextServer.setText(this.getDefaults("base_url", this.requireContext()))
binding.edittextServer.setOnKeyListener(View.OnKeyListener { v, keyCode, event ->
binding.edittextServer.setText(getData("base_url"))
binding.edittextServer.setOnKeyListener { _, keyCode, event ->
if (keyCode == KeyEvent.KEYCODE_ENTER && event.action == KeyEvent.ACTION_UP) {
this.setDefaults(
saveData(
"base_url",
binding.edittextServer.text.toString(),
this.requireContext()
binding.edittextServer.text.toString()
)
this.hideKeyboard()
//sergio: deberia lanzar la funcion nueva creada por mi restartapp de BaseFragment. Pero no vuelve a arrancar
exitProcess(0)
restartapp()
return@OnKeyListener false
}
false
})
}
binding.textviewWelcome.setOnLongClickListener {
@ -82,24 +84,14 @@ class LoginFragment : BaseFragment<FragmentLoginBinding, LoginViewModel>(LoginVi
true
}
//NODEJS TEST
// Log.i("VERDNATURA:","NODEJS in")
// viewModel.nodeJsTest("A0A3B8224DBF","ABC","1")
}
@SuppressLint("HardwareIds")
private fun saveIdentifiers() {
val resolver = requireActivity().contentResolver
val AndroidId: String = Settings.Secure.getString(resolver, Settings.Secure.ANDROID_ID)
var deviceName = Settings.Secure.getString(resolver, "bluetooth_name")
val prefs: SharedPreferences = requireActivity().getSharedPreferences(PREFS_USER, 0)
val editor = prefs.edit()
editor.putString(ANDROID_ID, AndroidId)
editor.putString(DEVICENAME, deviceName)
editor.apply()
val AndroidId: String = Settings.Secure.getString(requireActivity().contentResolver, Settings.Secure.ANDROID_ID)
saveData(ANDROID_ID,AndroidId)
}
@ -118,17 +110,17 @@ class LoginFragment : BaseFragment<FragmentLoginBinding, LoginViewModel>(LoginVi
override fun observeViewModel() {
with(viewModel) {
versionappitem.observe(viewLifecycleOwner, Observer {
versionappitem.observe(viewLifecycleOwner, {
if (it.isError) {
binding.splashProgress.visibility = View.INVISIBLE
binding.splashProgress.visibility = View.GONE
customDialog.setTitle("Error").setDescription(it.errorMessage)
.setOkButton("Cerrar") {
customDialog.dismiss()
}.show()
} else {
if (it.version.equals(getInfoVersionNameApp())) {
if (it.version == getInfoVersionNameApp()) {
goToMain()
} else {
@ -159,21 +151,21 @@ class LoginFragment : BaseFragment<FragmentLoginBinding, LoginViewModel>(LoginVi
}
})
logindevice.observe(viewLifecycleOwner, Observer {
logindevice.observe(viewLifecycleOwner, {
if (it.isError) {
binding.splashProgress.visibility = View.INVISIBLE
binding.splashProgress.visibility = View.GONE
customDialog.setTitle("Error").setDescription(it.errorMessage)
.setOkButton("Cerrar") {
customDialog.dismiss()
}.show()
} else {
if (it.vIsAuthorized.equals("0")) {
if (it.vIsAuthorized == "0") {
customDialog.setTitle("Error").setDescription(it.vMessage!!)
.setOkButton("Cerrar") {
customDialog.dismiss()
binding.splashProgress.visibility = View.INVISIBLE
binding.splashProgress.visibility = View.GONE
// goToMain()
}.show()
@ -184,6 +176,11 @@ class LoginFragment : BaseFragment<FragmentLoginBinding, LoginViewModel>(LoginVi
binding.edittextPassword.text.toString(),
callFunction = "worker_getId"
)
viewModel.worker_getSector(
binding.edittextUsername.text.toString(),
binding.edittextPassword.text.toString())
deviceLog_add(
binding.edittextUsername.text.toString(),
binding.edittextPassword.text.toString(),
@ -192,12 +189,11 @@ class LoginFragment : BaseFragment<FragmentLoginBinding, LoginViewModel>(LoginVi
getData(ANDROID_ID), "deviceLog_add"
)
//saveUserFkPref(it)
if (binding.switchRemember.isChecked) {
saveRemember(true)
} else {
saveRemember(false)
}
if (binding.switchRemember.isChecked) {
saveRemember(true)
} else {
saveRemember(false)
}
saveUserAccesPref(
binding.edittextUsername.text.toString(),
@ -205,26 +201,23 @@ class LoginFragment : BaseFragment<FragmentLoginBinding, LoginViewModel>(LoginVi
)
if (it.vIsAuthorized.equals("1") && it.vMessage.isNullOrEmpty()) {
if (it.vIsAuthorized == "1" && it.vMessage.isNullOrEmpty()) {
loginSalix(
user = binding.edittextUsername.text.toString(),
password = binding.edittextPassword.text.toString(),
callFunction = "login de Salix"
)
getVersion()
}
if (it.vIsAuthorized.equals("1") && !it.vMessage.isNullOrEmpty()) {
if (it.vIsAuthorized == "1" && !it.vMessage.isNullOrEmpty()) {
binding.splashProgress.visibility = View.GONE
customDialog.setTitle("Mensaje").setDescription(it.vMessage)
.setOkButton("Cerrar") {
customDialog.dismiss()
binding.splashProgress.visibility = View.VISIBLE
/* binding.splashProgress.visibility = View.VISIBLE
loginSalix(
user = binding.edittextUsername.text.toString(),
password = binding.edittextPassword.text.toString(),
"login de Salix"
)
)*/
getVersion()
}.show()
}
@ -237,7 +230,7 @@ class LoginFragment : BaseFragment<FragmentLoginBinding, LoginViewModel>(LoginVi
workerId.observe(viewLifecycleOwner, Observer {
workerId.observe(viewLifecycleOwner, {
if (!it.isError) {
saveUserFkPref(it.Id.toString())
@ -246,37 +239,8 @@ class LoginFragment : BaseFragment<FragmentLoginBinding, LoginViewModel>(LoginVi
})
loginitem.observe(viewLifecycleOwner, Observer {
binding.splashProgress.visibility = View.INVISIBLE
if (it.isError) {
customDialog.setTitle("Error").setDescription(it.errorMessage)
.setOkButton("Cerrar") {
customDialog.dismiss()
}.show()
} else {
binding.splashProgress.visibility = View.VISIBLE
saveUserFkPref(it)
if (binding.switchRemember.isChecked) {
saveRemember(true)
} else {
saveRemember(false)
}
saveUserAccesPref(
binding.edittextUsername.text.toString(),
binding.edittextPassword.text.toString()
)
loginSalix(
user = binding.edittextUsername.text.toString(),
password = binding.edittextPassword.text.toString(),
callFunction = "login de Salix"
)
}
})
devicelogresponse.observe(viewLifecycleOwner, Observer {
devicelogresponse.observe(viewLifecycleOwner, {
if (it.isError) {
customDialog.setTitle("Error")
@ -290,48 +254,46 @@ class LoginFragment : BaseFragment<FragmentLoginBinding, LoginViewModel>(LoginVi
}
})
loginsalixitem.observe(viewLifecycleOwner, Observer {
workergetSector.observe(viewLifecycleOwner, {
binding.splashProgress.visibility = View.GONE
if (it.id!=0){
d("El sector guardado es"+it.id)
d("El sector description es"+it.description.toString())
d("El sector warehouse es"+it.warehouseFk.toString())
saveDataInt("sectorFk",it.id)
saveData("sectordescrip",it.description)
it.warehouseFk?.let { it1 -> saveDataInt("warehouseFk", it1) }
}
})
loginsalixitem.observe(viewLifecycleOwner, {
if (it.isError) {
binding.splashProgress.visibility = View.GONE
saveTokenPref("")
customDialog.setTitle("Error")
.setDescription(it.errorMessage + ". Puedes continuar pero algunas funcionalidades no estarán disponibles.")
// .setDescription(it.errorMessage + ". Puedes continuar pero algunas funcionalidades no estarán disponibles.")
.setDescription(it.errorMessage)
.setOkButton(
"Entendido"
) {
customDialog.dismiss()
getVersion()
//getVersion()
//exitProcess(0)
}.show()
} else {
saveTokenPref(it.token)
getVersion()
viewModel.device_checkLogin(
binding.edittextUsername.text.toString(),
binding.edittextPassword.text.toString(),
getData(ANDROID_ID), callFunction = "device_checkLogin"
)
}
})
/* version.observe(viewLifecycleOwner, Observer {
binding.splashProgress.visibility = View.INVISIBLE
if (it) {
binding.constrainlayoutLogin.visibility=INVISIBLE
goToMain()
binding.splashProgress.visibility = View.INVISIBLE
} else {
binding.splashProgress.visibility = View.INVISIBLE
customDialog.setTitle(getString(R.string.Actualizar))
.setDescription(getString(R.string.updatemng)).setOkButton(
getString(
R.string.Actualizar
)
) {
val openURL = Intent(Intent.ACTION_VIEW)
openURL.data = Uri.parse("https://app.verdnatura.es/bin/vn-picking.apk")
startActivity(openURL)
}.setKoButton("Cancelar") {
customDialog.dismiss()
goToMain()
}.show()
}
})*/
}
super.observeViewModel()
}
@ -349,12 +311,12 @@ class LoginFragment : BaseFragment<FragmentLoginBinding, LoginViewModel>(LoginVi
editor.apply()
}
private fun saveUserFkPref(loginitem: LoginItemVO) {
/* private fun saveUserFkPref(loginitem: LoginItemVO) {
val prefs: SharedPreferences = requireActivity().getSharedPreferences(PREFS_USER, 0)
val editor = prefs.edit()
editor.putString(USERFK, loginitem.id)
editor.apply()
}
}*/
private fun saveUserFkPref(workerId: String) {
val prefs: SharedPreferences = requireActivity().getSharedPreferences(PREFS_USER, 0)
@ -395,31 +357,20 @@ class LoginFragment : BaseFragment<FragmentLoginBinding, LoginViewModel>(LoginVi
}
fun setDefaults(key: String?, value: String?, context: Context?) {
/*fun setDefaults(key: String?, value: String?, context: Context?) {
val preferences: SharedPreferences = PreferenceManager.getDefaultSharedPreferences(context)
val editor = preferences.edit()
editor.putString(key, value)
editor.commit()
}
}*/
fun getDefaults(key: String?, context: Context?): String? {
/* fun getDefaults(key: String?, context: Context?): String? {
val preferences = PreferenceManager.getDefaultSharedPreferences(context)
return preferences.getString(key, null)
}
}*/
// sergio:creada restart en BaseFragment para AjustesFragment...
fun restartapp() {
val mStartActivity = Intent(context, LoginActivity::class.java)
val mPendingIntentId = 123456
val mPendingIntent = PendingIntent.getActivity(
context,
mPendingIntentId,
mStartActivity,
PendingIntent.FLAG_CANCEL_CURRENT
)
val mgr = requireContext().getSystemService(Context.ALARM_SERVICE) as AlarmManager
mgr[AlarmManager.RTC, System.currentTimeMillis() + 100] = mPendingIntent
exitProcess(0)
}
}

View File

@ -9,36 +9,36 @@ import com.google.gson.JsonObject
import com.google.gson.reflect.TypeToken
import es.verdnatura.domain.GetLoginUserCase
import es.verdnatura.domain.NodeJsService
import es.verdnatura.presentation.base.*
import es.verdnatura.presentation.base.BaseViewModel
import es.verdnatura.presentation.base.getMessageFromAllResponse
import es.verdnatura.presentation.base.nameofFunction
import es.verdnatura.presentation.common.ResponseItemVO
import es.verdnatura.presentation.view.feature.login.model.*
import es.verdnatura.presentation.view.feature.ajustes.model.SectorItemVO
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.versionApp
import es.verdnatura.presentation.view.feature.login.model.workerId
import es.verdnatura.presentation.view.feature.paletizador.model.itemsExpeditionDynamics
import retrofit2.Call
import retrofit2.Callback
import retrofit2.Response
import timber.log.Timber
import timber.log.Timber.d
class LoginViewModel(context: Context) : BaseViewModel()
{
private val getLoginUserCase: GetLoginUserCase = GetLoginUserCase(context)
private val _loginitem by lazy { MutableLiveData<LoginItemVO>() }
val loginitem: LiveData<LoginItemVO>
get() = _loginitem
private val _loginsalixitem by lazy { MutableLiveData<LoginSalixVO>() }
val loginsalixitem: LiveData<LoginSalixVO>
get() = _loginsalixitem
/* private val _version by lazy { MutableLiveData<Boolean>() }
val version: LiveData<Boolean>
get() = _version*/
private val _devicelogresponse by lazy { MutableLiveData<ResponseItemVO>() }
val devicelogresponse: LiveData<ResponseItemVO>
get() = _devicelogresponse
//sergio: nueva version para actualizar
private val _versionappitem by lazy { MutableLiveData<versionApp>() }
val versionappitem: LiveData<versionApp>
get() = _versionappitem
@ -56,55 +56,9 @@ class LoginViewModel(context: Context) : BaseViewModel()
get() = _nodejs
//sergio:anterior login
fun login(user: String, password: String, androiid: String)
{
getLoginUserCase.login(user, password, androiid).enqueue(object : Callback<String>
{
override fun onResponse(call: Call<String>, response: Response<String>)
{
var loginItemVO: LoginItemVO?
if (response.raw().code() == 555)
{
var message = response.raw().message().toString()
if (message.contains("autorizado"))
{
loginItemVO = LoginItemVO(
id = "0",
isError = true,
errorMessage = "Usuario no autorizado para este dispositivo"
)
} else
{
loginItemVO = LoginItemVO(
id = "0",
isError = true,
errorMessage = "Usuario o contraseña incorrectos"
)
}
} else if (!response.body().isNullOrEmpty())
{
loginItemVO = response.body()?.let { LoginItemVO(id = it) }
} else
{
loginItemVO =
LoginItemVO(id = "0", isError = true, errorMessage = "Error desconocido")
}
_loginitem.value = loginItemVO!!
}
override fun onFailure(call: Call<String>, t: Throwable)
{
val loginItemVO: LoginItemVO? =
LoginItemVO(id = "0", isError = true, errorMessage = t.message!!)
_loginitem.value = loginItemVO
}
})
}
private val _workergetSector by lazy { MutableLiveData<SectorItemVO>() }
val workergetSector: LiveData<SectorItemVO>
get() = _workergetSector
fun loginSalix(user: String, password: String,callFunction:String)
{
@ -113,9 +67,10 @@ class LoginViewModel(context: Context) : BaseViewModel()
override fun onResponse(call: Call<LoginSalixVO>, response: Response<LoginSalixVO>)
{
var loginSalixVO: LoginSalixVO?
val loginSalixVO: LoginSalixVO?
if (response.body() != null)
{
loginSalixVO = response.body()?.token?.let {
LoginSalixVO(
user,
@ -127,12 +82,15 @@ class LoginViewModel(context: Context) : BaseViewModel()
}
} else
{
loginSalixVO = LoginSalixVO(
user,
password,
isError = true,
errorMessage = getMessageFromAllResponse(nameofFunction(this),response.message())
)
errorMessage = getMessageFromAllResponse(nameofFunction(this),if (response.message()=="Unauthorized"){"Revisa tu usuario y contraseña. En caso de no poder acceder contacta co Informática"}else{response.message()
}))
}
_loginsalixitem.value = loginSalixVO
@ -155,7 +113,6 @@ class LoginViewModel(context: Context) : BaseViewModel()
fun device_checkLogin(user: String, password: String, android_id: String,callFunction:String)
{
//var name=nameofFunction(object{})
getLoginUserCase.device_checkLogin(user, password, android_id)
.enqueue(object : Callback<LoginDevice>
@ -163,7 +120,7 @@ class LoginViewModel(context: Context) : BaseViewModel()
override fun onResponse(call: Call<LoginDevice>, response: Response<LoginDevice>)
{
var loginDevice: LoginDevice?
val loginDevice: LoginDevice?
if (!response.isSuccessful)
@ -201,6 +158,7 @@ class LoginViewModel(context: Context) : BaseViewModel()
override fun onFailure(call: Call<LoginDevice>, t: Throwable)
{
val loginDevice =
LoginDevice(
"",
@ -223,7 +181,7 @@ class LoginViewModel(context: Context) : BaseViewModel()
override fun onResponse(call: Call<String>, response: Response<String>)
{
var workerId: workerId?
val workerId: workerId?
if (response.body() != null)
@ -295,22 +253,6 @@ class LoginViewModel(context: Context) : BaseViewModel()
}
/*fun checkVersion_old(user:String,password:String,version:String){
getLoginUserCase.checkVersion(user,password,version).enqueue(object : Callback<Boolean>{
override fun onResponse(call: Call<Boolean>, response: Response<Boolean>) {
if (response.body() != null){
_version.value = response.body()
}else{
_version.value = true
}
}
override fun onFailure(call: Call<Boolean>, t: Throwable) {
_version.value = true
}
})
}*/
//sergio:checkVersion new
fun checkVersion(user: String, password: String, nameApp: String,callFunction: String)
{
getLoginUserCase.checkVersion(user, password, nameApp)
@ -319,12 +261,12 @@ class LoginViewModel(context: Context) : BaseViewModel()
override fun onResponse(call: Call<versionApp>, response: Response<versionApp>)
{
var versionApp: versionApp?
//var versionApp: versionApp?
if (response.body() != null)
{
versionApp = response.body()?.let {
_versionappitem.value = response.body()?.let {
versionApp(
it.appname,
@ -338,32 +280,33 @@ class LoginViewModel(context: Context) : BaseViewModel()
} else
{
versionApp = versionApp(
_versionappitem.value = versionApp(
user,
password,
isError = true,
errorMessage = getMessageFromAllResponse(nameofFunction(this),response.message())
)
}
_versionappitem.value = versionApp
// _versionappitem.value = versionApp
}
override fun onFailure(call: Call<versionApp>, t: Throwable)
{
val versionApp =
_versionappitem.value =
versionApp(
nameApp,
"",
isError = true,
errorMessage =getMessageFromAllResponse(nameofFunction(this), t.message!!)
)
_versionappitem.value = versionApp
//_versionappitem.value = versionApp
}
})
}
fun nodeJsTest(smarttag: String, wagon: String, shelving: String)
/* fun nodeJsTest(smarttag: String, wagon: String, shelving: String)
{
getLoginUserCase.nodeJsTest(smarttag, wagon, shelving)
.enqueue(object : Callback<NodeJsService.SmartTagNode>
@ -374,19 +317,20 @@ class LoginViewModel(context: Context) : BaseViewModel()
)
{
var workerId: NodeJsService.SmartTagNode?
/* if (response.isSuccessful()){
val workerId: NodeJsService.SmartTagNode?
*//* if (response.isSuccessful()){
Log.i("VERDNATURA::","OK")
}
if (!response.errorBody().toString().isEmpty()){
}*/
}*//*
if (response.body() != null)
{
Log.i("VERDNATURA::", "el valor nodejs no es nulo ")
workerId = NodeJsService.SmartTagNode(
response.body().toString(),
isError = false,
@ -399,7 +343,6 @@ class LoginViewModel(context: Context) : BaseViewModel()
isError = true,
errorMessage = "Error al llamar al servicio Node."
)
Log.i("VERDNATURA::", "el valor nodejs es NULL")
}
_nodejs.value = workerId
@ -410,13 +353,13 @@ class LoginViewModel(context: Context) : BaseViewModel()
val workerId =
NodeJsService.SmartTagNode(isError = true, errorMessage = t.message!!)
// Log.i("VERDNATURA::","el error nodejs es "+t.message+"--"+t.cause.toString()+"--"+t.stackTrace.toString())
Log.i("VERDNATURA::","el error nodejs es "+t.message+"--"+t.cause.toString()+"--"+t.stackTrace.toString())
_nodejs.value = workerId
}
})
}
}*/
fun getListFromJSON(json: JsonObject): MutableList<itemsExpeditionDynamics>
{
@ -435,5 +378,36 @@ class LoginViewModel(context: Context) : BaseViewModel()
}
return list
}
fun worker_getSector(user:String,password:String){
getLoginUserCase.worker_getSector(user,password).enqueue(object : Callback<SectorItemVO>{
override fun onFailure(call: Call<SectorItemVO>, t: Throwable) {
Timber.d("El sector failure " + t.message!!)
_workergetSector.value = SectorItemVO(0,"",0,isError = true, errorMessage = getMessageFromAllResponse(nameofFunction(this),t.message!!))
}
override fun onResponse(
call: Call<SectorItemVO>,
response: Response<SectorItemVO>
) {
if (!response.isSuccessful()){
d("El sector is not successfull")
_workergetSector.value= SectorItemVO(0,"",0,
isError = true,
errorMessage = getMessageFromAllResponse(nameofFunction(this),response.message())
)
}else{
d("El sector is successfull")
_workergetSector.value = response.body()?.let { SectorItemVO(it.id,it.description,it.warehouseFk,isError = false) }
}
}
})
}
}

View File

@ -2,11 +2,11 @@ package es.verdnatura.presentation.view.feature.login.model
class LoginItemVO(
/*class LoginItemVO(
val id: String = "",
var isError: Boolean = false,
var errorMessage: String = ""
)
)*/
class LoginSalixVO(
val user: String = "",

View File

@ -13,6 +13,7 @@ import es.verdnatura.BuildConfig
import es.verdnatura.R
import es.verdnatura.databinding.ActivityMainBinding
import es.verdnatura.domain.ConstAndValues.MAINACTIVITY
import es.verdnatura.domain.ConstAndValues.PREITEMPICKER
import es.verdnatura.domain.toast
import es.verdnatura.presentation.base.BaseActivity
import es.verdnatura.presentation.common.*
@ -43,22 +44,23 @@ import es.verdnatura.presentation.view.feature.paletizador.fragment.*
import es.verdnatura.presentation.view.feature.paletizador.model.ItemExpeditionTruckVO
import es.verdnatura.presentation.view.feature.paletizador.model.ItemPalletVO
import es.verdnatura.presentation.view.feature.parking.fragment.ParkingFragment
import es.verdnatura.presentation.view.feature.parking.fragment.ParkingSaleFragment
import es.verdnatura.presentation.view.feature.pasillero.fragment.PasilleroFragment
import es.verdnatura.presentation.view.feature.pasillero.model.PasillerosItemVO
import es.verdnatura.presentation.view.feature.precontrol.PreControladorFragment
import es.verdnatura.presentation.view.feature.showticket.ShowTicketFragment
import es.verdnatura.presentation.view.feature.presacador.fragment.EndSacadorFragment
import es.verdnatura.presentation.view.feature.presacador.fragment.InitPreSacadorFragment
import es.verdnatura.presentation.view.feature.presacador.fragment.PreSacadorFragment
import es.verdnatura.presentation.view.feature.qr.QrFragment
import es.verdnatura.presentation.view.feature.reposicion.fragment.ReposicionFragment
import es.verdnatura.presentation.view.feature.sacador.fragment.SacadorFragment
import es.verdnatura.presentation.view.feature.sacador.model.CollectionVO
import es.verdnatura.presentation.view.feature.sacador.model.SaleVO
import es.verdnatura.presentation.view.feature.shelvingparking.fragment.ShelvingParkingFragment
import es.verdnatura.presentation.view.feature.showticket.ShowTicketFragment
import es.verdnatura.presentation.view.feature.smarttag.register.RegisterSmartTagsFragment
import es.verdnatura.presentation.view.feature.smarttag.sacador.fragment.AssociateSmartTagsFragment
import es.verdnatura.presentation.view.feature.ubicador.fragment.AutomaticAddItemFragment
import es.verdnatura.presentation.view.feature.ubicador.fragment.UbicadorFragment
import es.verdnatura.presentation.view.feature.workermistake.adapter.WorkermistakeFragment
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.launch
@ -91,7 +93,7 @@ class MainActivity : BaseActivity<ActivityMainBinding>(), OnPasillerosItemClickL
if (haveSector()) addFragment(
if (haveSector() && havePrinter()) addFragment(
PasilleroFragment.newInstance("Verdnatura"),
R.id.main_frame_layout,
PasilleroFragment.TAG,
@ -116,18 +118,18 @@ class MainActivity : BaseActivity<ActivityMainBinding>(), OnPasillerosItemClickL
private fun navigationDrawer(){
val drawerLayout = binding.drawerLayout
drawerLayout.open()
/* val drawerLayout = binding.drawerLayout
drawerLayout.open()
/* val toggle = ActionBarDrawerToggle(
this,
drawerLayout,
toolbar,
"abierto",
"cerrado"
)
drawerLayout.addDrawerListener(toggle)
toggle.syncState()*/
val toggle = ActionBarDrawerToggle(
this,
drawerLayout,
toolbar,
"abierto",
"cerrado"
)
drawerLayout.addDrawerListener(toggle)
toggle.syncState()*/
}
/* private fun navigateToFragment(){
@ -142,6 +144,11 @@ class MainActivity : BaseActivity<ActivityMainBinding>(), OnPasillerosItemClickL
val sectorFk = prefs.getInt("sectorFk", -1)
return sectorFk != -1
}
private fun havePrinter(): Boolean {
val prefs: SharedPreferences = getSharedPreferences("es.verdnatura.user.prefs", 0)
val printerFk = prefs.getInt("printerFk", -1)
return printerFk != -1
}
@ -318,7 +325,7 @@ class MainActivity : BaseActivity<ActivityMainBinding>(), OnPasillerosItemClickL
true
}
bottomMenu!!.setOnNavigationItemReselectedListener {
bottomMenu.setOnNavigationItemReselectedListener {
}
}
@ -343,16 +350,16 @@ class MainActivity : BaseActivity<ActivityMainBinding>(), OnPasillerosItemClickL
}
"Registrar SmartTags" -> {
addFragmentOnTop(RegisterSmartTagsFragment.newInstance(entryPoint))
addFragmentOnTop(RegisterSmartTagsFragment.newInstance(item.title))
}
//BUFFERS
"Paletizar" -> {
addFragmentOnTop(ExpeditionTruckListFragment.newInstance())
}
"Consultar expedición" -> {
getString(R.string.ExpeditionState) -> {
// addFragment(ExpeditionStateFragment.newInstance(entryPoint),R.id.main_frame_layout, ExpeditionTruckListFragment.TAG,false)
addFragmentOnTop(ExpeditionStateFragment.newInstance(entryPoint))
addFragmentOnTop(ExpeditionStateFragment.newInstance(item.title))
}
"Escanear expedición" -> {
addFragmentOnTop(ExpeditionScanSorterFragment.newInstance(item.title))
@ -470,8 +477,13 @@ class MainActivity : BaseActivity<ActivityMainBinding>(), OnPasillerosItemClickL
"Log Shelving" -> {
addFragmentOnTop(shelvingLogFragment.newInstance("Log Shelving"))
}
"Fallo del trabajador" -> {
addFragmentOnTop(WorkermistakeFragment.newInstance(item.title))
}
// sergio: previa nuevo
"Obtener colección previa"->{
addFragmentOnTop(InitPreSacadorFragment.newInstance(item.title))
}
}
}
@ -529,45 +541,73 @@ class MainActivity : BaseActivity<ActivityMainBinding>(), OnPasillerosItemClickL
}
fun onParkingSaleSelected(sales: SaleVO) {
/* fun onParkingSaleSelected(sales: SaleVO) {
addFragmentOnTop(ParkingSaleFragment.newInstance(SaleVO = sales))
}
}*/
override fun onCollectionSelected(collection: CollectionVO, type: String) {
// fm.popBackStack()
when (type){
PREITEMPICKER->{
// d("VERDNATURA::"," entrando en preitempicker")
// d("VERDNATURA::"," entrando en preitempicker, la colecc es "+collection.collectionFk)
addFragmentOnTop(EndSacadorFragment.newInstance(collection,type))
}
"SHOWTICKET"->{
addFragmentOnTop(CollectionShowTicketFragment.newInstance(collection, type))
}
else->{
addFragmentOnTop(CollectionFragment.newInstance(collection, type))
}
}
/*if (type.equals(PREITEMPICKER)){
d("VERDNATURA::"," entrando en preitempicker")
addFragmentOnTop(PreSacadorFragment.newInstance(collection,type))
}
if (type.equals("SHOWTICKET")) {
addFragmentOnTop(CollectionShowTicketFragment.newInstance(collection, type))
} else {
addFragmentOnTop(CollectionFragment.newInstance(collection, type))
}
}*/
}
override fun onBuyerSelected(userFk: String) {
addFragmentOnTop(QaualityFragment.newInstance(userFk))
}
//sergio:se llama al pulsar sobre el coche IN desde Sacador
fun onVehicleSelected(tag: String) {
fm.popBackStack(null, FragmentManager.POP_BACK_STACK_INCLUSIVE)
// se pone a true en la pila para que cuando se vuelva atrás permanezca ya que se borran todos los fragmentos desde otras opciones
addFragment(
ControlVehiculoFragment.newInstance(tag),
R.id.main_frame_layout,
ControlVehiculoFragment.TAG,
false
true
)
//sergio: de esta manera la llamada del fragment no se vuelve a repetir.
// addFragmentOnTop(ControlVehiculoFragment.newInstance(tag))
}
fun openFragmentPickers() {
fun openFragmentPickers(delete:Boolean) {
//delete_Fragments()
fm.popBackStack(null, FragmentManager.POP_BACK_STACK_INCLUSIVE)
if (delete){delete_Fragments()}
addFragment(
SacadorFragment.newInstance(),
R.id.main_frame_layout,
SacadorFragment.TAG,
false
)
//addFragmentOnTop(SacadorFragment.newInstance())
@ -578,7 +618,7 @@ class MainActivity : BaseActivity<ActivityMainBinding>(), OnPasillerosItemClickL
// fm.popBackStack(null,FragmentManager.POP_BACK_STACK_INCLUSIVE)
// addFragment(ExpeditionStateFragment.newInstance("main"),R.id.main_frame_layout, ExpeditionStateFragment.TAG,false)
addFragmentOnTop(ExpeditionStateFragment.newInstance("main"))
addFragmentOnTop(ExpeditionStateFragment.newInstance("Consultar estado expedición"))
}
@ -586,19 +626,24 @@ class MainActivity : BaseActivity<ActivityMainBinding>(), OnPasillerosItemClickL
binding.mainBottomNavigation.visibility = visible
}
fun messageWithSound(message: String, isError: Boolean,isPlayed:Boolean?) {
fun messageWithSound(message: String, isError: Boolean,isPlayed:Boolean?,titleWithError:String="Error",isToasted:Boolean?=false) {
if (!isError) {
mpok?.start()
if (isPlayed == true)(mpok?.start())
message.toast(this, Toast.LENGTH_SHORT)
} else {
if (isPlayed == true)( mperror?.start())
customDialog.setTitle("Error").setDescription(message)
.setOkButton("Aceptar") {
customDialog.dismiss()
}.show()
if (isToasted==true){
message.toast(this, Toast.LENGTH_SHORT)
}else{
customDialog.setTitle(titleWithError).setDescription(message)
.setOkButton("Aceptar") {
customDialog.dismiss()
}.show()
}
}

View File

@ -5,19 +5,15 @@ import android.view.LayoutInflater
import android.view.ViewGroup
import androidx.recyclerview.widget.RecyclerView
import es.verdnatura.databinding.ItemExpeditionstateRowBinding
import es.verdnatura.presentation.common.OnItemExpeditionStateRowClickListener
import es.verdnatura.presentation.view.feature.articulo.model.ItemCardRowVO
import es.verdnatura.presentation.view.feature.paletizador.model.ItemExpeditionStateRow
class ExpeditionStateAdapter (
private val items: List<ItemExpeditionStateRow>,
private val OnItemExpeditionStateRowClickListener: OnItemExpeditionStateRowClickListener
): RecyclerView.Adapter<ExpeditionStateAdapter.ItemHolder> () {
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ItemHolder {
return ItemHolder(
//ItemCardRowBinding.inflate(LayoutInflater.from(parent.context),parent,false)
ItemExpeditionstateRowBinding.inflate(LayoutInflater.from(parent.context),parent,false)
)
}
@ -26,34 +22,20 @@ class ExpeditionStateAdapter (
override fun onBindViewHolder(holder: ItemHolder, position: Int) {
holder.bind(items[position])
if (items[position].isEditable){
/* if (items[position].isEditable){
holder.binding.root.setOnClickListener {
OnItemExpeditionStateRowClickListener.OnItemExpeditionStateRowClickListener(items[position])
// OnItemExpeditionStateRowClickListener.OnItemExpeditionStateRowClickListener(items[position])
}
}
}*/
}
class ItemHolder(
val binding: ItemExpeditionstateRowBinding
) : RecyclerView.ViewHolder(binding.root){
private val res = binding.root.context.resources
fun bind(item: ItemExpeditionStateRow) {
binding.apply {
if (item.barcodes.isNotEmpty()){
item.value = ""
item.barcodes.forEach {
item.value = item.value + it.code + "\n"
}
}
this.item = item
/* if (item.isEditable){
itemImage.visibility = View.VISIBLE
itemRowLayout.setBackgroundColor(res.getColor(R.color.verdnatura_black_5))
}else{
itemImage.visibility = View.INVISIBLE
itemRowLayout.setBackgroundColor(res.getColor(R.color.verdnatura_black_9))
}*/
}
}

View File

@ -32,7 +32,7 @@ class ExpeditionPalletDetailFragment(
ExpeditionPalletDetailViewModel::class) {
private var adapter : ExpeditionPalletViewAdapter? = null
private lateinit var customDialogList: CustomDialogList
// private lateinit var customDialogList: CustomDialogList
private var onPalletClickListener:OnPalletClickListener? = null
private lateinit var customDialog: CustomDialog
@ -52,11 +52,11 @@ class ExpeditionPalletDetailFragment(
override fun init() {
customDialog = CustomDialog(requireContext())
customDialogList = CustomDialogList(requireContext())
//customDialogList = CustomDialogList(requireContext())
binding.expeditionPalletDetailPallet.text = "Pallet "+itemPallet!!.Pallet
binding.splashProgress.visibility = View.VISIBLE
//requireActivity().main_bottom_navigation.visibility = View.GONE
(activity as MainActivity).hideBottomNavigation(View.GONE)
ma.hideBottomNavigation(View.GONE)
binding.mainToolbar.toolbarTitle.text = getCURDATE(itemExpeditionTruckVO!!.ETD) + " " + itemExpeditionTruckVO!!.Destino
setToolBar()
@ -105,7 +105,7 @@ class ExpeditionPalletDetailFragment(
}else if(item == iconPrint){
binding.splashProgress.visibility = View.VISIBLE
(getString(R.string.Imprimiendo)+" por " +getData(SECTORDESCRIP)).toast(requireContext())
(getString(R.string.Imprimiendo)+" por " +getData(PRINTERNAME)).toast(requireContext())
viewModel.expeditionPalletPrintSet(getData(USER),
getData(PASSWORD),itemPallet!!.Pallet,getData(SECTORFK),"expeditionPallet_PrintSet")
@ -131,9 +131,10 @@ class ExpeditionPalletDetailFragment(
response.observe(viewLifecycleOwner, Observer {
if (it.isError){
customDialog.setTitle("Error").setDescription(it.errorMessage).setOkButton("Cerrar"){
ma.messageWithSound(it.errorMessage,true,false)
/* customDialog.setTitle("Error").setDescription(it.errorMessage).setOkButton("Cerrar"){
customDialog.dismiss()
}.show()
}.show()*/
}else{
requireActivity().onBackPressed()
}

View File

@ -73,7 +73,7 @@ class ExpeditionPalletFragment(
customDialogList = CustomDialogList(requireContext())
binding.splashProgress.visibility = View.VISIBLE
//requireActivity().main_bottom_navigation.visibility = View.GONE
(activity as MainActivity).hideBottomNavigation(View.GONE)
ma.hideBottomNavigation(View.GONE)
binding.mainToolbar.toolbarTitle.text = getCURDATE(itemExpeditionTruckVO!!.ETD) + " " + itemExpeditionTruckVO!!.Destino
setToolBar()
setEvents()
@ -130,18 +130,20 @@ class ExpeditionPalletFragment(
response.observe(viewLifecycleOwner, Observer {
if (it.isError){
customDialog.setTitle("Error").setDescription(it.errorMessage).setOkButton("Cerrar"){
ma.messageWithSound(it.errorMessage,true,false)
/* customDialog.setTitle("Error").setDescription(it.errorMessage).setOkButton("Cerrar"){
customDialog.dismiss()
}.show()
}.show()*/
}
})
responseCheckexpeditionScanPut.observe(viewLifecycleOwner, Observer {
if (it.isError){
customDialog.setTitle("Error").setDescription(it.errorMessage).setOkButton("Cerrar"){
ma.messageWithSound(it.errorMessage,true,false)
/* customDialog.setTitle("Error").setDescription(it.errorMessage).setOkButton("Cerrar"){
customDialog.dismiss()
}.show()
}.show()*/
}else{
if (it.response=="0") {
@ -190,7 +192,7 @@ class ExpeditionPalletFragment(
}
customDialogList.setTitle("Expedition ("+binding.mainToolbar.toolbarTitle.text+")").setOkButton("Comprobar"){
(activity as MainActivity).hideKeyboard(customDialogList.getEditText())
ma.hideKeyboard(customDialogList.getEditText())
if (listExpeditions.size > 0){
@ -206,7 +208,7 @@ class ExpeditionPalletFragment(
}.setKoButton("Cerrar"){
(activity as MainActivity).hideKeyboard(customDialogList.getEditText())
ma.hideKeyboard(customDialogList.getEditText())
binding.splashProgress.visibility = View.VISIBLE
viewModel.expeditionPallet_List(getData(USER),
getData(PASSWORD),itemExpeditionTruckVO!!.truckFk,"expeditionPallet_List")
@ -215,7 +217,7 @@ class ExpeditionPalletFragment(
}.setValue("").show()
customDialogList.getEditText().requestFocus()
(activity as MainActivity).hideKeyboard(customDialogList.getEditText())
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) {
@ -241,7 +243,7 @@ class ExpeditionPalletFragment(
expeditionAdapter!!.notifyDataSetChanged()
}
customDialogList.setValue("")
(activity as MainActivity).hideKeyboard(customDialogList.getEditText())
ma.hideKeyboard(customDialogList.getEditText())
return@setOnEditorActionListener true
}
false

View File

@ -37,11 +37,11 @@ class ExpeditionScanFragment (
private var onComprobarPalletViewClickListener: OnComprobarPalletViewClickListener? = null
private lateinit var customDialogList: CustomDialogList
private lateinit var customDialogTwoButtons: CustomDialogTwoButtons
private var listExpeditions:ArrayList<BarcodeVO> = ArrayList()
private var expeditionAdapter : BarcodeAdapter? = null
private lateinit var customDialog: CustomDialog
var mperror: MediaPlayer? = null
var mpok: MediaPlayer? = null
companion object {
fun newInstance(item: ItemExpeditionTruckVO,itemPalletVO: ItemPalletVO) =
@ -68,8 +68,7 @@ class ExpeditionScanFragment (
customDialogTwoButtons = CustomDialogTwoButtons(requireContext())
binding.expeditionScanDetailPallet.text = "Pallet "+itemPalletVO!!.Pallet
binding.splashProgress.visibility = View.VISIBLE
//requireActivity().main_bottom_navigation.visibility = View.GONE
(activity as MainActivity).hideBottomNavigation(View.GONE)
ma.hideBottomNavigation(View.GONE)
binding.mainToolbar.toolbarTitle.text = getCURDATE(itemExpeditionTruckVO!!.ETD) + " " + itemExpeditionTruckVO!!.Destino
setToolBar()
@ -99,7 +98,6 @@ class ExpeditionScanFragment (
viewModel.expeditionScanList(getData(USER),
getData(PASSWORD),itemPalletVO!!.Pallet)
}else if(item == iconPlus){
//Log.i("VERDNATURA:","ENTRAMOS A SCAN ADD")
expeditionScanAdd ()
}
@ -128,41 +126,29 @@ class ExpeditionScanFragment (
response.observe(viewLifecycleOwner, Observer {
if (it.isError){
customDialog.setTitle("Error").setDescription(it.errorMessage).setOkButton("Cerrar"){
customDialog.dismiss()
}.show()
ma.messageWithSound(it.errorMessage,true,false)
}
})
responseCheckexpeditionScanPut.observe(viewLifecycleOwner, Observer {
if (it.isError){
customDialog.setTitle("Error").setDescription(it.errorMessage).setOkButton("Cerrar"){
customDialog.dismiss()
}.show()
ma.messageWithSound(it.errorMessage,true,false)
}else{
////Log.i("VERDNATURA:"," Resultado llamada es ${it.response.toString()}")
if (it.response=="0") {
//"Rutas iguales ${it.response}".toast(requireActivity())
////Log.i("VERDNATURA:","Rutas iguales")
}
if (it.response=="1"){
mperror?.start()
// "Resultado llamada $it.response".toast(requireActivity())
// customDialog.setTitle("Rutas distintas").setDescription(it.response).setOkButton("Cerrar"){
// customDialog.dismiss()
// }.show()
}}
})
responseDeleteScan.observe(viewLifecycleOwner, Observer {
if (it.isError){
customDialog.setTitle("Error").setDescription(it.errorMessage).setOkButton("Cerrar"){
customDialog.dismiss()
}.show()
ma.messageWithSound(it.errorMessage,true,false)
}else{
viewModel.expeditionScanList(getData(USER),
getData(PASSWORD),itemPalletVO!!.Pallet)
@ -200,28 +186,23 @@ class ExpeditionScanFragment (
binding.splashProgress.visibility = View.VISIBLE
viewModel.expeditionScanAdd(usuario = getData(USER),
getData(PASSWORD),vPalletFk = itemPalletVO!!.Pallet,vTruckFk = itemExpeditionTruckVO!!.truckFk)
//Log.i("VERDNATURA:","entramos a escanear ticket del pallet")
}
private fun showScanExpeditions(it: ItemScanList){
//sergio para smarttags:
// Log.i("VERDNATURA:","muestra expediciones y a escanear")
listExpeditions = ArrayList()
binding.splashProgress.visibility = View.GONE
it.list.forEach {
if(it.expeditionFk != "0")
listExpeditions.add(BarcodeVO(code = it.expeditionFk))
}
//sergio:Comprueba si el numero es mayor>0
customDialogList.setTitle("Pallet"+itemPalletVO!!.Pallet+" ("+binding.mainToolbar.toolbarTitle.text+")").setOkButton("Comprobar"){
//Log.i("VERDNATURA:","Añadida etiqueta")
(activity as MainActivity).hideKeyboard(customDialogList.getEditText())
ma.hideKeyboard(customDialogList.getEditText())
if (listExpeditions.size > 0){
////Log.i("VERDNATURA:","boton comprobar . si las expediciones >0 muetra DetailFragment")
onComprobarPalletViewClickListener!!.onComprobarPalletViewClickListener(itemExpeditionTruckVO!!,
ItemPalletVO(Pallet = it.list.get(0).palletFk)
)
@ -235,24 +216,18 @@ class ExpeditionScanFragment (
}.setKoButton("Cerrar"){
(activity as MainActivity).hideKeyboard(customDialogList.getEditText())
ma.hideKeyboard(customDialogList.getEditText())
listExpeditions = ArrayList()
customDialogList.dismiss()
}.setValue("").show()
customDialogList.getEditText().requestFocus()
(activity as MainActivity).hideKeyboard(customDialogList.getEditText())
ma.hideKeyboard(customDialogList.getEditText())
//sergio: seguimos escaneando id=0 -> sin especificar id=5->next
customDialogList.getEditText().setOnEditorActionListener { v, actionId, event ->
if (actionId == EditorInfo.IME_ACTION_SEARCH || actionId == EditorInfo.IME_ACTION_DONE || actionId == 0 || actionId == 5) {
if (!customDialogList.getValue().isNullOrEmpty()) {
////Log.i("VERDNATURA:", "scan put pallet ${it.list.get(0).palletFk}");
////Log.i("VERDNATURA:", "scan put list ${customDialogList.getValue()}");
listExpeditions.add(BarcodeVO(code = customDialogList.getValue()))
viewModel.expeditionScanPut(
getData(USER),
@ -260,22 +235,15 @@ class ExpeditionScanFragment (
it.list.get(0).palletFk,
customDialogList.getValue()
)
////Log.i("VERDNATURA:", "scan put pallet ${it.list.get(0).palletFk}");
////Log.i("VERDNATURA:", "scan put list ${customDialogList.getValue()}");
// ////Log.i("VERDNATURA:","misma ruta ?")
//sergio:comprueba si es de la misma ruta. Check_route_expedition.
checkRouteExpeditionScanPut(getData(USER),
getData(PASSWORD),it.list.get(0).palletFk,customDialogList.getValue())
////Log.i("VERDNATURA:", "scan put pallet ${it.list.get(0).palletFk}");
////Log.i("VERDNATURA:", "scan put list ${customDialogList.getValue()}");
expeditionAdapter!!.notifyDataSetChanged()
}
customDialogList.setValue("")
(activity as MainActivity).hideKeyboard(customDialogList.getEditText())
ma.hideKeyboard(customDialogList.getEditText())
return@setOnEditorActionListener true
}
false

View File

@ -1,60 +1,35 @@
package es.verdnatura.presentation.view.feature.paletizador.fragment
import android.content.SharedPreferences
import android.os.Bundle
import android.view.View
import android.view.View.*
import android.view.inputmethod.EditorInfo
import androidx.lifecycle.Observer
import androidx.recyclerview.widget.LinearLayoutManager
import es.verdnatura.R
import es.verdnatura.databinding.FragmentExpeditionscanSorterBinding
import es.verdnatura.presentation.base.BaseFragment
import es.verdnatura.presentation.common.*
import es.verdnatura.presentation.view.component.CustomDialog
import es.verdnatura.presentation.view.component.CustomDialogList
import es.verdnatura.presentation.view.feature.main.activity.MainActivity
import es.verdnatura.presentation.view.feature.smarttag.adapter.SmartTagAdapter
import es.verdnatura.presentation.view.feature.smarttag.model.SmartTag
/*import kotlinx.android.synthetic.main.activity_main.*
import kotlinx.android.synthetic.main.component_custom_three_dialog.*
import kotlinx.android.synthetic.main.fragment_collection.*
import kotlinx.android.synthetic.main.fragment_controlador.*
import kotlinx.android.synthetic.main.fragment_controlador.binding.splashProgress
import kotlinx.android.synthetic.main.fragment_expedition_scan.*
import kotlinx.android.synthetic.main.fragment_login.*
import kotlinx.android.synthetic.main.fragment_sacador.*
import kotlinx.android.synthetic.main.fragment_sacador_associatesmarttag.*
import kotlinx.android.synthetic.main.toolbar.**/
class ExpeditionScanSorterFragment(
var entryPoint: String = ""
var title: String = ""
) : BaseFragment<FragmentExpeditionscanSorterBinding, ExpeditionScanSorterViewModel>(
ExpeditionScanSorterViewModel::class
) {
private var user = ""
private var password = ""
private var goBack: Boolean = false
override fun getLayoutId(): Int = R.layout.fragment_expeditionscan_sorter
private lateinit var customDialog: CustomDialog
private lateinit var customDialogList: CustomDialogList
private var listExpeditionScan: ArrayList<SmartTag> = ArrayList()
private var expeditionScanAdapter: SmartTagAdapter? = null
private var listExpeditionScan: ArrayList<GeneralItem> = ArrayList()
private var expeditionScanAdapter: GeneralAdapter? = null
private var itemScaned: String = ""
companion object {
fun newInstance(entryPoint: String) = ExpeditionScanSorterFragment(entryPoint)
fun newInstance(title: String) = ExpeditionScanSorterFragment(title)
}
override fun init() {
customDialog = CustomDialog(requireContext())
customDialogList = CustomDialogList(requireContext())
goBack = false
//requireActivity().main_bottom_navigation.visibility = GONE
(activity as MainActivity).hideBottomNavigation(View.GONE)
ma.hideBottomNavigation(GONE)
binding.splashProgress.visibility = GONE
setEvents()
@ -63,64 +38,46 @@ class ExpeditionScanSorterFragment(
super.init()
}
override fun onPause() {
goBack = true
super.onPause()
}
private fun setToolBar() {
binding.mainToolbar.toolbarTitle.text = entryPoint
binding.mainToolbar.toolbarTitle.text = title
}
private fun expeditionscan(ExpeditionScan: String) {
binding.splashProgress.visibility = VISIBLE
viewModel.expedition_scan(user, password, ExpeditionScan,"expedition_scan")
viewModel.expedition_scan(getData(USER),getData(PASSWORD), ExpeditionScan,"expedition_scan")
itemScaned = ExpeditionScan
}
override fun onCreate(savedInstanceState: Bundle?) {
val prefs: SharedPreferences = requireActivity().getSharedPreferences(PREFS_USER, 0)
user = getData(USER)
password = getData(PASSWORD)
super.onCreate(savedInstanceState)
}
private fun setEvents() {
binding.mainToolbar.backButton.setOnClickListener {
binding.mainToolbar.backButton.setOnClickListener {
requireActivity().onBackPressed()
}
}
override fun observeViewModel() {
with(viewModel) {
binding.splashProgress.visibility = GONE
responsescan.observe(viewLifecycleOwner, Observer {
responsescan.observe(viewLifecycleOwner, {
if (it.isError) {
customDialog.setTitle("Error").setDescription(it.errorMessage)
.setOkButton("Cerrar") {
customDialog.dismiss()
}.show()
ma.messageWithSound(it.errorMessage,true,false)
} else {
listExpeditionScan.add(SmartTag(itemScaned, itemScaned))
listExpeditionScan.add(GeneralItem(itemScaned, itemScaned))
customDialogList.setDescription("Total:" + listExpeditionScan.size)
expeditionScanAdapter!!.notifyItemInserted(listExpeditionScan.size-1)
customDialogList.setValue("")
ma.messageWithSound("Añadida",false,true)
}
binding.splashProgress.visibility = GONE
})
}
@ -132,23 +89,16 @@ class ExpeditionScanSorterFragment(
customDialogList.setTitle("Escanea expediciones que no han pasado por el Sorter")
.setOkButton("Finalizar") {
(activity as MainActivity).hideKeyboard(customDialogList.getEditText())
/* if (listExpeditionScan.size > 0) {
customDialogList.dismiss()
backButton.performClick()
} else {*/
ma.hideKeyboard(customDialogList.getEditText())
customDialogList.dismiss()
binding.mainToolbar.backButton.performClick()
// }
}.setValue("").show()
customDialogList.getEditText().requestFocus()
(activity as MainActivity).hideKeyboard(customDialogList.getEditText())
ma.hideKeyboard(customDialogList.getEditText())
customDialogList.getEditText().setOnEditorActionListener { _, actionId, _ ->
if (actionId == EditorInfo.IME_ACTION_SEARCH || actionId == EditorInfo.IME_ACTION_DONE || actionId == 0 || actionId == 5 || actionId == 6) {
@ -156,17 +106,18 @@ class ExpeditionScanSorterFragment(
expeditionscan(customDialogList.getValue())
}
customDialogList.setValue("")
(activity as MainActivity).hideKeyboard(customDialogList.getEditText())
ma.hideKeyboard(customDialogList.getEditText())
return@setOnEditorActionListener true
}
false
}
expeditionScanAdapter =
SmartTagAdapter(listExpeditionScan, object : OnSmartTagRowClickListener {
override fun OnSmartTagRowClickListener(item: SmartTag) {
GeneralAdapter(listExpeditionScan, object : OnGeneralItemRowClickListener {
override fun OnGeneralItemRowClickListener(item: GeneralItem) {
}
}, showDelete = false)
})
customDialogList.getRecyclerView().adapter = expeditionScanAdapter
customDialogList.getRecyclerView().layoutManager =
LinearLayoutManager(requireContext(), LinearLayoutManager.VERTICAL, false)

View File

@ -1,41 +1,21 @@
package es.verdnatura.presentation.view.feature.paletizador.fragment
/*import kotlinx.android.synthetic.main.activity_main.*
import kotlinx.android.synthetic.main.buyers_fragment.*
import kotlinx.android.synthetic.main.fragment_item_card.*
import kotlinx.android.synthetic.main.fragment_item_card.binding.editItemFk
import kotlinx.android.synthetic.main.fragment_item_card.binding.itemcardImage
import kotlinx.android.synthetic.main.fragment_item_card. binding.itemcardLayout
import kotlinx.android.synthetic.main.fragment_item_card.binding.splashProgress
import kotlinx.android.synthetic.main.fragment_itemexpeditionstate_card.*
import kotlinx.android.synthetic.main.toolbar.**/
import android.content.Intent
import android.content.SharedPreferences
import android.view.View
import android.view.inputmethod.EditorInfo
import androidx.lifecycle.Observer
import androidx.recyclerview.widget.LinearLayoutManager
import es.verdnatura.R
import es.verdnatura.databinding.FragmentItemexpeditionstateCardBinding
import es.verdnatura.presentation.base.BaseFragment
import es.verdnatura.presentation.common.OnItemExpeditionStateRowClickListener
import es.verdnatura.presentation.view.component.CustomDialog
import es.verdnatura.presentation.view.feature.imageview.activity.ImageViewActivity
import es.verdnatura.presentation.view.feature.main.activity.MainActivity
import es.verdnatura.presentation.view.feature.paletizador.adapter.ExpeditionStateAdapter
import es.verdnatura.presentation.view.feature.paletizador.model.ItemExpeditionStateRow
import es.verdnatura.presentation.view.feature.paletizador.model.itemExpedetionState
class ExpeditionStateFragment(
var entryPoint: String = ""
// ) : BaseFragment<FragmentExpeditionstateBinding, ExpeditionStateViewModel>(ExpeditionStateViewModel::class) {
var title: String = ""
) : BaseFragment<FragmentItemexpeditionstateCardBinding, ExpeditionStateViewModel>(ExpeditionStateViewModel::class) {
private var urlLarge: String = ""
private var titleImage: String = ""
private var user = ""
private var password = ""
private var warehouseFk = ""
private var adapter: ExpeditionStateAdapter? = null
private var listItemsRow: ArrayList<ItemExpeditionStateRow> = ArrayList()
private var itemScan = ""
@ -44,16 +24,11 @@ class ExpeditionStateFragment(
fun newInstance(entryPoint: String) = ExpeditionStateFragment(entryPoint)
}
private lateinit var customDialog: CustomDialog
override fun getLayoutId(): Int = R.layout.fragment_itemexpeditionstate_card
override fun init() {
binding.itemcardLayout.visibility = View.GONE
customDialog = CustomDialog(requireContext())
setEvents()
setToolBar(getString(R.string.ExpeditionState))
setToolBar(title)
super.init()
}
@ -66,12 +41,12 @@ class ExpeditionStateFragment(
binding.editItemFk.requestFocus()
binding.editItemFk.setOnEditorActionListener { v, actionId, event ->
if (actionId == EditorInfo.IME_ACTION_SEARCH || actionId == EditorInfo.IME_ACTION_DONE || actionId == 0 || actionId == 5) {
if (!binding.editItemFk.text.toString().isNullOrEmpty()) {
if (binding.editItemFk.text.toString().isNotEmpty()) {
getExpedtionState(binding.editItemFk.text.toString())
itemScan = binding.editItemFk.text.toString()
}
binding.editItemFk.setText("")
(activity as MainActivity).hideKeyboard(binding.editItemFk)
ma.hideKeyboard(binding.editItemFk)
return@setOnEditorActionListener true
}
false
@ -82,58 +57,26 @@ class ExpeditionStateFragment(
requireActivity().onBackPressed()
}
binding.itemcardImage.setOnClickListener {
val i: Intent = Intent(activity, ImageViewActivity::class.java)
i.putExtra("url", urlLarge)
i.putExtra("title", titleImage)
startActivity(i)
}
}
private fun getExpedtionState(expeditionFk: String) {
val prefs: SharedPreferences = requireActivity().getSharedPreferences(PREFS_USER, 0)
user = getData(USER)
password = getData(PASSWORD)
warehouseFk = getData(WAREHOUSEFK)
// this.itemFk = itemFk
binding.splashProgress.visibility = View.VISIBLE
viewModel.expedition_getStateJSON(expeditionFk, user, password,"expedition_getState")
viewModel.expedition_getStateJSON(expeditionFk, getData(USER), getData(PASSWORD),"expedition_getState")
}
override fun observeViewModel() {
with(viewModel) {
// itemcard.observe(viewLifecycleOwner, Observer {
itemexpedition.observe(viewLifecycleOwner, Observer {
itemexpedition.observe(viewLifecycleOwner,{
binding.splashProgress.visibility = View.GONE
if (it.isError) {
binding.itemcardLayout.visibility = View.GONE
binding.mainToolbar.toolbarTitle.text = "Estado de la expedición"
customDialog.setTitle("Error")
.setDescription("No se ha podido obtener el estado de la expedición escaneada. ")
.setOkButton("Cerrar") {
customDialog.dismiss()
}.show()
binding.itemcardLayout.visibility = View.GONE
binding.mainToolbar.toolbarTitle.text = title
ma.messageWithSound("No se ha podido obtener el estado de la expedición escaneada.",true,false,"Sin resultados")
} else {
if (it != null) {
binding.itemcardLayout.visibility = View.VISIBLE
setItemExpeditionState(it)
} else {
binding.itemcardLayout.visibility = View.GONE
binding.mainToolbar.toolbarTitle.text = "Estado de la expedición"
customDialog.setTitle("Sin resultados")
.setDescription("No hemos podido encontrar el estado de la expedición.")
.setOkButton("Cerrar") {
customDialog.dismiss()
}.show()
}
}
})
@ -143,25 +86,19 @@ class ExpeditionStateFragment(
private fun setItemExpeditionState(itemInfo: itemExpedetionState) {
setToolBar(getString(R.string.expedition) + itemScan)
binding.itemcardLayout.visibility = View.VISIBLE
listItemsRow = ArrayList()
for (i in itemInfo.list) {
listItemsRow.add(
ItemExpeditionStateRow(
title = i.key,
value = i.value.replace(".0",""),
value = i.value?.replace(".0",""),
isEditable = false
)
)
}
adapter = ExpeditionStateAdapter(listItemsRow, object :
OnItemExpeditionStateRowClickListener {
override fun OnItemExpeditionStateRowClickListener(item: ItemExpeditionStateRow) {
}
})
adapter = ExpeditionStateAdapter(listItemsRow)
binding.itemexpeditionstateRecyclerview.adapter = adapter
binding.itemexpeditionstateRecyclerview.layoutManager =
LinearLayoutManager(requireContext(), LinearLayoutManager.VERTICAL, false)
@ -172,4 +109,3 @@ class ExpeditionStateFragment(
}

View File

@ -157,7 +157,7 @@ class ExpeditionStateViewModel(context: Context) : BaseViewModel() {
gson.fromJson(json, object : TypeToken<Map<String, Any>>() {}.type)
expeditionState.forEach {
list.add(itemsExpeditionDynamics(key=it.key,value=it.value.toString()))
list.add(itemsExpeditionDynamics(key=it.key,it.value?.toString()))
}
return list

View File

@ -76,7 +76,7 @@ class ExpeditionTruckListFragment : BaseFragment<FragmentExpeditionTruckListBin
addTruck()
}
if (item == iconState){
(activity as MainActivity).openFragmentExpeditionState()
ma.openFragmentExpeditionState()
}
}
})
@ -112,14 +112,14 @@ class ExpeditionTruckListFragment : BaseFragment<FragmentExpeditionTruckListBin
private fun addTruck(){
customDialogHor.setTitle("Nuevo Camión").setOkButton("Guardar"){
(activity as MainActivity).hideKeyboard(customDialogHor.getDestinoEditText())
ma.hideKeyboard(customDialogHor.getDestinoEditText())
if (!customDialogHor.getDestinoValue().isNullOrEmpty() && !customDialogHor.getHoraValue().isNullOrEmpty()){
viewModel.expeditionTruckAdd(getData(USER),
getData(PASSWORD),customDialogHor.getHoraValue(),customDialogHor.getDestinoValue(),"expeditionTruck_Add")
binding.splashProgress.visibility = View.VISIBLE
customDialogHor.dismiss()
}
(activity as MainActivity).hideKeyboard(customDialogHor.getDestinoEditText())
ma.hideKeyboard(customDialogHor.getDestinoEditText())
customDialogHor.dismiss()
}.setKoButton("Cancelar"){
customDialogHor.dismiss()
@ -137,7 +137,7 @@ class ExpeditionTruckListFragment : BaseFragment<FragmentExpeditionTruckListBin
return@setOnEditorActionListener true
}
(activity as MainActivity).hideKeyboard(customDialogHor.getDestinoEditText())
ma.hideKeyboard(customDialogHor.getDestinoEditText())
false
}
}

View File

@ -1,7 +1,6 @@
package es.verdnatura.presentation.view.feature.paletizador.model
import es.verdnatura.presentation.view.feature.articulo.model.BarcodeVO
import es.verdnatura.presentation.view.feature.articulo.model.ItemPackingType
class ItemExpeditionTruckVO (
var truckFk:String = "",
@ -17,19 +16,6 @@ class ItemExpeditionTruckList(
)
class itemExpedetionState(
/* var ticket: String = "",
var cliente : String = "",
var ciudad : String = "",
var provincia : String ="",
var zonaTicket : String = "",
var zonaRuta : String = "",
var ruta : String ="",
var ubicacion : String="",
var ETD : String="",
var camion : String="",
var ticketsPendientes : String= "",
var etiquetasTotales : String = "",
var etiquetasEscaneadas : String="",*/
var isError:Boolean = false,
var errorMessage:String = "",
var list:MutableList<itemsExpeditionDynamics>
@ -38,16 +24,9 @@ class itemExpedetionState(
class itemsExpeditionDynamics(
var key: String = "",
var value:String = ""
)
/*
class itemExpeditionDynamicsList(
var list: List<itemsExpeditionDynamics> = listOf()
var value: String? = null
)
class itemExpedetionStateList (
var list: List<itemExpedetionState> = listOf()
)*/
class ItemExpeditionStateRow (
var title:String? = "",
var value:String? = "",

View File

@ -1,7 +1,6 @@
package es.verdnatura.presentation.view.feature.parking.fragment
import android.content.SharedPreferences
import android.media.MediaPlayer
import android.os.Bundle
import android.view.View
@ -13,14 +12,13 @@ import es.verdnatura.databinding.FragmentParkingBinding
import es.verdnatura.presentation.base.BaseFragment
import es.verdnatura.presentation.common.OnBarcodeRowClickListener
import es.verdnatura.presentation.common.hideKeyboard
import es.verdnatura.presentation.view.component.CustomDialog
import es.verdnatura.presentation.view.feature.articulo.model.BarcodeVO
import es.verdnatura.presentation.view.feature.main.activity.MainActivity
import es.verdnatura.presentation.view.feature.parking.adapter.ParkingAdapter
class ParkingFragment : BaseFragment<FragmentParkingBinding,ParkingViewModel>(ParkingViewModel::class) {
private lateinit var customDialog: CustomDialog
// private lateinit var customDialog: CustomDialog
private var scanerList:ArrayList<BarcodeVO> = ArrayList()
private var adapter : ParkingAdapter? = null
private var numParking : Int = 0
@ -41,7 +39,7 @@ class ParkingFragment : BaseFragment<FragmentParkingBinding,ParkingViewModel>(Pa
//viewModel.hideProgressLoading()
binding.splashProgress.visibility=View.GONE
setList()
customDialog = CustomDialog(requireContext())
//customDialog = CustomDialog(requireContext())
super.init()
}
@ -68,11 +66,12 @@ class ParkingFragment : BaseFragment<FragmentParkingBinding,ParkingViewModel>(Pa
with(viewModel){
response.observe(viewLifecycleOwner, Observer {
if (it.isError){
mperror?.start()
// mperror?.start()
// binding.splashProgress.visibility = View.GONE
customDialog.setTitle("Error").setDescription(it.errorMessage).setOkButton("Cerrar"){
ma.messageWithSound(it.errorMessage, isError = true,isPlayed = true)
/*customDialog.setTitle("Error").setDescription(it.errorMessage).setOkButton("Cerrar"){
customDialog.dismiss()
}.show()
}.show()*/
}else{
numParking -= 1
if (numParking <= 0) {
@ -141,7 +140,7 @@ class ParkingFragment : BaseFragment<FragmentParkingBinding,ParkingViewModel>(Pa
}
override fun onCreate(savedInstanceState: Bundle?) {
val prefs: SharedPreferences = requireActivity().getSharedPreferences(PREFS_USER,0)
// val prefs: SharedPreferences = requireActivity().getSharedPreferences(PREFS_USER,0)
mperror = MediaPlayer.create((activity as MainActivity),R.raw.error)
mpok = MediaPlayer.create((activity as MainActivity),R.raw.ok)
super.onCreate(savedInstanceState)

View File

@ -66,14 +66,13 @@ class ParkingSaleFragment : BaseFragment<FragmentParkingBinding,ParkingSaleViewM
response.observe(viewLifecycleOwner, Observer {
if (it.isError){
mperror?.start()
// binding.splashProgress.visibility = View.GONE
customDialog.setTitle("Error").setDescription(it.errorMessage).setOkButton("Cerrar"){
ma.messageWithSound(it.errorMessage,true,false)
/* customDialog.setTitle("Error").setDescription(it.errorMessage).setOkButton("Cerrar"){
customDialog.dismiss()
}.show()
}.show()*/
}else{
numParking -= 1
if (numParking <= 0) {
// binding.splashProgress.visibility = View.GONE
//viewModel.hideProgressLoading()
mpok?.start()
setList()

View File

@ -8,6 +8,7 @@ import androidx.recyclerview.widget.RecyclerView
import es.verdnatura.databinding.ItemPasillerosMainMenuBinding
import es.verdnatura.presentation.common.OnPasillerosItemClickListener
import es.verdnatura.presentation.view.feature.pasillero.model.PasillerosItemVO
import timber.log.Timber.d
class PasillerosAdapter (
private val items: List<PasillerosItemVO>,
@ -40,7 +41,12 @@ class PasillerosAdapter (
binding.apply {
this.item = item
this.title = context?.getString(item.titleToShow)
itemImage.setImageResource(item.iconResource)
try {
itemImage.setImageResource(item.iconResource)
}catch(exception:Exception){
d("Exception::"+exception.message)
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
itemImage.tooltipText=item.description

View File

@ -8,7 +8,6 @@ import es.verdnatura.R
import es.verdnatura.databinding.FragmentPasilleroBinding
import es.verdnatura.presentation.base.BaseFragment
import es.verdnatura.presentation.common.OnPasillerosItemClickListener
import es.verdnatura.presentation.view.feature.main.activity.MainActivity
import es.verdnatura.presentation.view.feature.pasillero.adapter.PasillerosAdapter
@ -30,7 +29,7 @@ class PasilleroFragment(
override fun getLayoutId(): Int = R.layout.fragment_pasillero
override fun init() {
(activity as MainActivity).hideBottomNavigation(View.VISIBLE)
ma.hideBottomNavigation(View.VISIBLE)
binding.mainToolbar.toolbarTitle.text = tagName
binding.mainToolbar.backButton.visibility = View.GONE
super.init()

View File

@ -12,37 +12,32 @@ class PasilleroViewModel(context: Context) : BaseViewModel() {
fun inititializeDefaultData() {
/* _pasillerositem.add(
/* _pasillerositem.add(
PasillerosItemVO(20,
R.drawable.barcode_scan,
"Visor web",R.string.SmarttagAssociate)
_pasillerositem.add(
*/
/* _pasillerositem.add(
PasillerosItemVO(20,
R.drawable.barcode_scan,
"Asociar Sacador SmartTags",R.string.SmarttagAssociate)
)
_pasillerositem.add(
_pasillerositem.add(
PasillerosItemVO(21,
R.drawable.barcode,
R.drawable.barcode_scan,
"Registrar SmartTags",R.string.SmarttagRegister)
)
*/
)*/
//sergio para que aparezca el nuevo menu
_pasillerositem.add(
PasillerosItemVO(
7,
R.drawable.ic_streetview_black_24dp,
"Pre Sacador", R.string.PreSacador,"Carga un ticket de previa para sacarlo"
)
)
_pasillerositem.add(
PasillerosItemVO(
7,
R.drawable.ic_streetview_black_24dp,
"Obtener colección previa", R.string.PreSacador,"Obtiene colecciones para sacar en previa"
)
)
//precontrol
_pasillerositem.add(
PasillerosItemVO(7,
@ -109,6 +104,14 @@ class PasilleroViewModel(context: Context) : BaseViewModel() {
)
)
_pasillerositem.add(
PasillerosItemVO(
7,
R.drawable.worker_mistake,
"Fallo del trabajador", R.string.workermistake,"Permite añadir fallos a un trabajador"
)
)
_pasillerositem.add(
PasillerosItemVO(
10,
@ -118,7 +121,7 @@ class PasilleroViewModel(context: Context) : BaseViewModel() {
)
_pasillerositem.add(
PasillerosItemVO(7,
R.drawable.ic_history_orange_24dp,
R.drawable.ic_history_orange,
"Log Shelving",R.string.shelvingLog,"Permite conocer los movimientos en un carro"
)
)
@ -187,7 +190,7 @@ class PasilleroViewModel(context: Context) : BaseViewModel() {
PasillerosItemVO(
31,
R.drawable.ic_visibility_black_24dp,
"Consultar expedición", R.string.ExpeditionState,"Permite conocer el estado de una expedición"
"Consultar estado expedición", R.string.ExpeditionState,"Permite conocer el estado de una expedición"
)
)
_pasillerositem.add(

View File

@ -19,7 +19,6 @@ class PreControladorFragment: BaseFragment<FragmentControladorBinding,ShowTicket
private var goBack:Boolean = false
private var onCollectionSelectedListener : OnCollectionSelectedListener? = null
override fun getLayoutId(): Int = R.layout.fragment_controlador
private lateinit var customDialog: CustomDialog
private var type = ""
companion object {
@ -36,7 +35,6 @@ class PreControladorFragment: BaseFragment<FragmentControladorBinding,ShowTicket
override fun init() {
binding.splashProgress.visibility = View.GONE
customDialog = CustomDialog(requireContext())
binding.mainToolbar.toolbarTitle.text = getString(R.string.precontrolprevious)
setEvents()
super.init()
@ -76,7 +74,7 @@ class PreControladorFragment: BaseFragment<FragmentControladorBinding,ShowTicket
}
binding.scanInput.setText("")
(activity as MainActivity).hideKeyboard(binding.scanInput)
ma.hideKeyboard(binding.scanInput)
return@setOnEditorActionListener true
}
false
@ -88,9 +86,8 @@ class PreControladorFragment: BaseFragment<FragmentControladorBinding,ShowTicket
collectionTicketList.observe(viewLifecycleOwner, Observer {
binding.splashProgress.visibility = View.GONE
if (it.isError){
customDialog.setTitle("Error").setDescription(it.errorMessage).setOkButton("Aceptar"){
customDialog.dismiss()
}.show()
ma.messageWithSound(it.errorMessage,true,false)
}else{
if (!goBack)navigateToCollectionList(it)
goBack = false

View File

@ -0,0 +1,46 @@
package es.verdnatura.presentation.view.feature.presacador.adapter
import android.util.Log
import android.view.LayoutInflater
import android.view.ViewGroup
import androidx.recyclerview.widget.RecyclerView
import es.verdnatura.databinding.ItemCollectionRowBinding
import es.verdnatura.domain.ConstAndValues.PREITEMPICKER
import es.verdnatura.presentation.common.OnCollectionSelectedListener
import es.verdnatura.presentation.view.feature.sacador.model.CollectionVO
class PreCollectionAdapter (
private val items: List<CollectionVO>,
private val onCollectionSelected: OnCollectionSelectedListener
): RecyclerView.Adapter<PreCollectionAdapter.AjustesItemHolder> () {
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): AjustesItemHolder {
return AjustesItemHolder(
ItemCollectionRowBinding.inflate(LayoutInflater.from(parent.context),parent,false)
)
}
override fun getItemCount() =items.size
override fun onBindViewHolder(holder: AjustesItemHolder, position: Int) {
holder.bind(items[position])
holder.binding.root.setOnClickListener {
onCollectionSelected.onCollectionSelected(items[position],PREITEMPICKER)
Log.d("VERDNATURA::","2-Click item ${items[position].collectionFk}+PREITEMPICKER")
}
}
class AjustesItemHolder(
val binding: ItemCollectionRowBinding
) : RecyclerView.ViewHolder(binding.root){
fun bind(item: CollectionVO) {
binding.apply {
this.item = item
}
}
}
}

View File

@ -0,0 +1,190 @@
package es.verdnatura.presentation.view.feature.presacador.fragment
import android.content.Context
import android.graphics.drawable.Drawable
import android.os.Build
import android.view.View
import android.widget.ImageView
import androidx.lifecycle.Observer
import androidx.recyclerview.widget.LinearLayoutManager
import es.verdnatura.R
import es.verdnatura.databinding.FragmentSacadorBinding
import es.verdnatura.presentation.base.BaseFragment
import es.verdnatura.presentation.common.OnCollectionSelectedListener
import es.verdnatura.presentation.common.OnOptionsSelectedListener
import es.verdnatura.presentation.common.ToolBarAdapterTooltip
import es.verdnatura.presentation.view.component.CustomDialog
import es.verdnatura.presentation.view.feature.presacador.adapter.PreCollectionAdapter
import es.verdnatura.presentation.view.feature.sacador.model.CollectionVO
class InitPreSacadorFragment (
var entrypoint:String = ""
) :
BaseFragment<FragmentSacadorBinding, PreSacadorViewModel>(PreSacadorViewModel::class) {
private var onCollectionSelectedListener: OnCollectionSelectedListener? = null
private var goBack: Boolean = false
private var goBack2: Boolean = false
private lateinit var customDialog: CustomDialog
private var collectionsList: ArrayList<CollectionVO> = ArrayList()
private var adapter: PreCollectionAdapter? = null
companion object {
fun newInstance(entryPoint:String) = InitPreSacadorFragment(entryPoint)
}
override fun onAttach(context: Context) {
super.onAttach(context)
if (context is OnCollectionSelectedListener) onCollectionSelectedListener = context
}
override fun getLayoutId(): Int = R.layout.fragment_sacador
override fun init() {
customDialog = CustomDialog(requireContext())
binding.splashProgress.visibility = View.VISIBLE
binding.splashProgressTwo.visibility = View.GONE
binding.mainToolbar.toolbarTitle.text = getString(R.string.getcollection)
setToolBar()
setEvents()
viewModel.sectorCollection_get(getData(USER),getData(PASSWORD),"sectorCollection_get")
super.init()
}
override fun onPause() {
goBack = true
goBack2 = true
super.onPause()
}
private fun setToolBar() {
ma.hideBottomNavigation(View.VISIBLE)
binding.mainToolbar.backButton.visibility = View.GONE
binding.mainToolbar.toolbarTitle.text=entrypoint
val listIcons: ArrayList<ImageView> = ArrayList()
val iconAdd = ImageView(context)
iconAdd.setImageResource(R.drawable.ic_add_black_24dp)
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
iconAdd.tooltipText=getTooltip(R.drawable.ic_add_black_24dp)
}
listIcons.add(iconAdd)
binding.mainToolbar.toolbarIcons.adapter = ToolBarAdapterTooltip(listIcons, object : OnOptionsSelectedListener {
override fun onOptionsItemSelected(item: Drawable) {
when(item){
iconAdd.drawable -> {
binding.splashProgress.visibility = View.VISIBLE
viewModel.sectorCollection_new(getData(USER),
getData(PASSWORD),getData(SECTORFK),"sectorCollection_new")
}
}
}
})
binding.mainToolbar.toolbarIcons.layoutManager =
LinearLayoutManager(requireContext(), LinearLayoutManager.HORIZONTAL, false)
}
private fun setEvents() {
binding.sacadorSwipe.setOnRefreshListener {
viewModel.sectorCollection_get(getData(USER),getData(PASSWORD),"sectorCollection_get")
binding.sacadorSwipe.isRefreshing = false
}
}
override fun observeViewModel() {
with(viewModel) {
collectionList.observe(viewLifecycleOwner, Observer {
if (!goBack2) binding.splashProgress.visibility = View.GONE
createCollectionList(it.list)
binding.splashProgress.visibility = View.GONE
goBack2 = false
})
response.observe(viewLifecycleOwner, Observer {
binding.splashProgressTwo.visibility = View.GONE
binding.splashProgress.visibility = View.GONE
if (it.isError) {
ma.messageWithSound(it.errorMessage,true,false)
} else {
if (goBack) addCollectionToList(it.response)
}
goBack = false
//sergio:para asegurarnos que aparece en pantalla. En mi movil personal y trabajo no hacia falta.
//viewModel.PrecollectionGetSalix(token=getData(TOKEN))
})
responseNew.observe(viewLifecycleOwner, Observer {
binding.splashProgressTwo.visibility = View.GONE
binding.splashProgress.visibility = View.GONE
if (it.isError) {
ma.messageWithSound(it.errorMessage,true,false)
} else {
//if (goBack)
viewModel.sectorCollection_get(getData(USER),getData(PASSWORD),getData(SECTORFK))
}
goBack = false
//sergio:para asegurarnos que aparece en pantalla. En mi movil personal y trabajo no hacia falta.
//viewModel.PrecollectionGetSalix(token=getData(TOKEN))
})
}
}
private fun createCollectionList(collections: List<CollectionVO>) {
collectionsList = ArrayList()
collections.forEach {
collectionsList.add(it)
}
val lm = LinearLayoutManager(requireContext(), LinearLayoutManager.VERTICAL, false)
adapter = PreCollectionAdapter(collectionsList, onCollectionSelectedListener!!)
binding.fragmentSacadorCollections.layoutManager = lm
binding.fragmentSacadorCollections.adapter = adapter
}
private fun addCollectionToList(collection: String) {
var isNew = true
collectionsList.forEach {
if (it.collectionFk == collection) {
isNew = false
}
}
if (isNew) {
collectionsList.add(CollectionVO(collectionFk = collection, created = "Nuevo"))
adapter?.notifyDataSetChanged()
} else {
customDialog.setTitle("Atención")
.setDescription("La colección " + collection + " sigue pendiente de preparar")
.setOkButton("Aceptar") {
customDialog.dismiss()
}.show()
}
//sergio:para asegurarnos que se actualiza pantalla.
adapter?.notifyDataSetChanged()
}
}

View File

@ -1,7 +1,6 @@
package es.verdnatura.presentation.view.feature.presacador.fragment
import android.content.Context
import android.content.SharedPreferences
import android.graphics.drawable.Drawable
import android.media.MediaPlayer
import android.os.Build
@ -20,7 +19,6 @@ import androidx.recyclerview.widget.RecyclerView
import es.verdnatura.R
import es.verdnatura.databinding.FragmentPreSacadorBinding
import es.verdnatura.domain.ConstAndValues.PRESACADOR
import es.verdnatura.domain.ConstAndValues.WAREHOUSEFKDEFAULT
import es.verdnatura.domain.toast
import es.verdnatura.presentation.base.BaseFragment
import es.verdnatura.presentation.common.*
@ -30,7 +28,6 @@ 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.inventario.adapter.ToolBarAdapter
import es.verdnatura.presentation.view.feature.main.activity.MainActivity
import es.verdnatura.presentation.view.feature.pasillero.model.PasillerosItemVO
import es.verdnatura.presentation.view.feature.presacador.adapter.PreSacadorAdapter
@ -64,11 +61,19 @@ class PreSacadorFragment :
private lateinit var customDialogThreeButtons: CustomDialogThreeButtons
private var ticketFk = ""
private var originalScanned = ""
fun changevariables(){
TODO("Refactor llevar variables i deixar soles una com positionToChange i quantityToChange")
}
private var typeCollectionMissing = ""
private var positionCollectionMissing = 0
private var quantityCollectionMissing = ""
private var positionIncreaseQuantity = 0
private var quantityIncrease = ""
private var quantityCollectionSplit = ""
private var positionCollectionSplit = 0
// private val listIcons:ArrayList<ImageView> = ArrayList()
//sergio: se añada para leer el articulo leido que era el buyFk
private var originalItemScan: String = ""
@ -79,21 +84,20 @@ class PreSacadorFragment :
}
override fun onCreate(savedInstanceState: Bundle?) {
mperror = MediaPlayer.create((activity as MainActivity), R.raw.error)
mpok = MediaPlayer.create((activity as MainActivity), R.raw.ok)
super.onCreate(savedInstanceState)
}
override fun init() {
customDialog = CustomDialog(requireContext())
customDialogList = CustomDialogList(requireContext())
customDialogInput = CustomDialogInput(requireContext())
customDialogInputParking = CustomDialogInput(requireContext())
customDialogThreeButtons = CustomDialogThreeButtons(requireContext())
//requireActivity().main_bottom_navigation.visibility = View.GONE
binding.splashProgress.visibility = View.GONE
binding.mainToolbar.toolbarTitle.text = getString(R.string.getticketpre)
setToolBar()
@ -173,17 +177,18 @@ class PreSacadorFragment :
responseSalixMessage.observe(viewLifecycleOwner, Observer {
if (it.isError) {
customDialog.setTitle("Error").setDescription(it.errorMessage)
ma.messageWithSound(it.errorMessage,true,false)
/* customDialog.setTitle("Error").setDescription(it.errorMessage)
.setOkButton("Aceptar") {
customDialog.dismiss()
}.show()
}.show()*/
}
})
responseIncQuantity.observe(viewLifecycleOwner, Observer {
if (it.isError) {
(activity as MainActivity).messageWithSound(it.errorMessage, isError = true,true)
ma.messageWithSound(it.errorMessage, isError = true,true)
} else {
incresaseSuccesful()
}
@ -194,20 +199,46 @@ class PreSacadorFragment :
responseParkingAdd.observe(viewLifecycleOwner, Observer {
binding.splashProgress.visibility = GONE
if (it.isError) {
customDialog.setTitle("Error").setDescription(it.errorMessage)
ma.messageWithSound(it.errorMessage,true,false)
/* customDialog.setTitle("Error").setDescription(it.errorMessage)
.setOkButton("Aceptar") {
customDialog.dismiss()
}.show()
}.show()*/
} else {
if (mpok != null) mpok!!.start()
"Sale/s aparcada/s".toast(requireContext())
}
})
responseSaleTrackingUpdate.observe(viewLifecycleOwner, Observer {
ma.messageWithSound(it.errorMessage, isError = it.isError,true)
try {
sales.clear()
}
catch(e:Exception)
{
}
})
responseSaleMove.observe(viewLifecycleOwner, Observer {
if (it.isError) {
ma.messageWithSound(it.errorMessage, isError = true,true)
} else {
responseSaleMoveSuccesful()
}
})
responseMissingTrash.observe(viewLifecycleOwner, Observer {
if (it.isError) {
(activity as MainActivity).messageWithSound(it.errorMessage, isError = true,true)
ma.messageWithSound(it.errorMessage, isError = true,true)
} else {
missingTrashSuccesful()
@ -246,6 +277,35 @@ class PreSacadorFragment :
}
}
private fun responseSaleMoveSuccesful() {
try {
sales[positionCollectionSplit].saldo = quantityCollectionSplit.toInt()
} catch (e: Exception) {
sales[positionCollectionSplit].saldo = 0
}
//sales[position].startQuantity = quantity
if (quantityCollectionSplit == "0")
markLine(positionCollectionSplit)
saleAdapter!!.notifyDataSetChanged()
//enviar mensaje a salix
val ticket =
"[" + sales[positionCollectionSplit].id + "](https://salix.verdnatura.es/#!/ticket/" + sales[positionCollectionSplit].id + "/summary)"
val message =
"Se ha enviado a Split el articulo " + sales[positionCollectionSplit].itemFk + " del ticket " + ticket
/* viewModel.sendChekingPresence(
token = getData(TOKEN),
workerId = sales[positionCollectionSplit].salesPersonFk,
message = message,
"sendChekingPresence"
)*/
sendSalixMessageNew(message,sales[positionCollectionSplit].salesPersonFk)
}
private fun incresaseSuccesful() {
@ -348,11 +408,14 @@ class PreSacadorFragment :
private fun createSaleList(salesList: List<PreSacadorItemVO>) {
binding.splashProgress.visibility = GONE
if (salesList.isNullOrEmpty()) {
customDialog.setTitle("Pre Sacador")
ma.messageWithSound("No hemos podido obtener movimientos para el ticket escaneado",true,false,"Pre Sacador")
/* customDialog.setTitle("Pre Sacador")
.setDescription("No hemos podido obtener movimientos para el ticket escaneado")
.setKoButton("Cancelar") {
customDialog.dismiss()
}.show()
}.show()*/
} else {
binding.mainToolbar.toolbarTitle.text = ticket
sales = ArrayList()
@ -532,6 +595,7 @@ class PreSacadorFragment :
setTotalLines()
}
private fun saleTrackingReplace(position: Int) {
viewModel.saleTrackingReplace(
usuario = getData(USER),
@ -540,15 +604,20 @@ class PreSacadorFragment :
vIsChecked = if (sales[position].picked == sales[position].quantity) "1" else "0",
vOriginalQuantity = sales[position].picked.toString(),
vStateFk = PRESACADOR,
//sergio: se añade originalItemScan para
vBuyFk = originalItemScan, callFunction = "saleTrackingReplace"
)
// ////Log.i("VERDNATURA:","El id movimiento es ${sales[position].idMovimiento}")
// ////Log.i("VERDNATURA:","Checked is ${if (sales[position].picked == sales[position].quantity) "1" else "0"}")
// ////Log.i("VERDNATURA:","Position is ${position}")
viewModel.saleTrackingReplace(
usuario = getData(USER),
password = getData(PASSWORD),
saleFk = sales[position].idMovimiento,
vIsChecked = if (sales[position].picked == sales[position].quantity) "1" else "0",
vOriginalQuantity = sales[position].picked.toString(),
vStateFk = PRESACADOR,
vBuyFk = originalItemScan, callFunction = "saleTrackingReplace"
)
}
@ -874,37 +943,30 @@ class PreSacadorFragment :
val iconParking = ImageView(context)
iconParking.setImageResource(R.drawable.ic_local_parking_black_24dp)
val iconEraser = ImageView(context)
iconEraser.setImageResource(R.drawable.previous_delete)
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
iconParking.tooltipText=getTooltip(R.drawable.ic_local_parking_black_24dp)
iconEraser.tooltipText=getTooltip(R.drawable.previous_delete)
}
//listIcons.add(iconEraser)
listIcons.add(iconParking)
/*val listIcons: ArrayList<Drawable> = ArrayList()
val iconEraser: Drawable = resources.getDrawable(R.drawable.eraser, resources.newTheme())
val iconParking: Drawable =
resources.getDrawable(R.drawable.ic_local_parking_black_24dp, resources.newTheme())*/
//sergio para hacer el presacador como sacador
//val iconAdd : Drawable = resources.getDrawable(R.drawable.ic_add_black_24dp,resources.newTheme())
//val iconTransferir : Drawable = resources.getDrawable(R.drawable.ic_swap_horiz_black_24dp,resources.newTheme())
// listIcons.add(iconEraser)
//listIcons.add(iconParking)
//listIcons.add(iconAdd)
//listIcons.add(iconTransferir)
binding.mainToolbar.toolbarIcons.adapter =
ToolBarAdapterTooltip(listIcons, object : OnOptionsSelectedListener {
override fun onOptionsItemSelected(item: Drawable) {
/*if (item == iconEraser) {
// saleTracking_update()
} else*/
when (item){
iconParking.drawable-> pasillerosItemClickListener?.onPasillerosItemClickListener(
PasillerosItemVO(
title = "Parking"
), ""
)
}
}
@ -1120,6 +1182,10 @@ class PreSacadorFragment :
}
private fun split(position: Int, quantity: String) {
positionCollectionSplit=position
quantityCollectionSplit=quantity
var totalQuantity: Int = 0
try {
totalQuantity = sales[position].saldo.toInt() - quantity.toInt()
@ -1132,13 +1198,13 @@ class PreSacadorFragment :
quantity = totalQuantity.toString(),
originalQuantity = sales[position].quantity.toString(), "saleMove"
)
//sales[position].originalQuantity = quantity
/*
try {
sales[position].saldo = quantity.toInt()
} catch (e: Exception) {
sales[position].saldo = 0
}
//sales[position].startQuantity = quantity
if (quantity == "0")
markLine(position)
@ -1156,7 +1222,7 @@ class PreSacadorFragment :
message = message,
"sendChekingPresence"
)
*/
}

View File

@ -12,6 +12,9 @@ import es.verdnatura.domain.GetUbicadorUserCase
import es.verdnatura.presentation.base.*
import es.verdnatura.presentation.common.ResponseItemVO
import es.verdnatura.presentation.view.feature.presacador.model.PreSacadorItemVO
import es.verdnatura.presentation.view.feature.sacador.mapper.toDateFormat
import es.verdnatura.presentation.view.feature.sacador.model.CollectionListVO
import es.verdnatura.presentation.view.feature.sacador.model.CollectionVO
import es.verdnatura.presentation.view.feature.sacador.model.PlacementSupplyListVO
import es.verdnatura.presentation.view.feature.sacador.model.PlacementSupplyVO
import retrofit2.Call
@ -36,6 +39,15 @@ class PreSacadorViewModel(context: Context) : BaseViewModel()
get() = _response
private val _responseSaleTrackingUpdate by lazy { MutableLiveData<ResponseItemVO>() }
val responseSaleTrackingUpdate: LiveData<ResponseItemVO>
get() = _responseSaleTrackingUpdate
private val _responseSaleMove by lazy { MutableLiveData<ResponseItemVO>() }
val responseSaleMove: LiveData<ResponseItemVO>
get() = _responseSaleMove
private val _responseParkingAdd by lazy { MutableLiveData<ResponseItemVO>() }
val responseParkingAdd: LiveData<ResponseItemVO>
get() = _responseParkingAdd
@ -60,6 +72,29 @@ class PreSacadorViewModel(context: Context) : BaseViewModel()
val responseMissingTrash: LiveData<ResponseItemVO>
get() = _responseMissingTrash
//sergio: previa nuevo
private val _collectionList by lazy { MutableLiveData<CollectionListVO>() }
val collectionList: LiveData<CollectionListVO>
get() = _collectionList
private val _responseNew by lazy { MutableLiveData<ResponseItemVO>() }
val responseNew: LiveData<ResponseItemVO>
get() = _responseNew
private val _responseSaleGroupAdd by lazy { MutableLiveData<ResponseItemVO>() }
val responseSaleGroupAdd: LiveData<ResponseItemVO>
get() = _responseSaleGroupAdd
private val _responseSaleAddPrevOK by lazy { MutableLiveData<ResponseItemVO>() }
val responseSaleAddPrevOK: LiveData<ResponseItemVO>
get() = _responseSaleAddPrevOK
private val _responseSaleupdateIsChecked by lazy { MutableLiveData<ResponseItemVO>() }
val responseSaleupdateIsChecked: LiveData<ResponseItemVO>
get() = _responseSaleupdateIsChecked
fun ticketToPrePrepare(usuario: String, password: String, ticketFk: String, sectorFk: String)
{
getPreSacadorUseCase.ticketToPrePrepare(usuario, password, ticketFk, sectorFk)
@ -281,7 +316,7 @@ class PreSacadorViewModel(context: Context) : BaseViewModel()
vStateFk: String,
vIsChecked: String,
vBuyFk: String,callFunction:String
)
)
{
//Lo ultimo que se envia
//sergio: se quita el 0 que habia por defecto para la previa se añada el buyFk que sera el item escaneado.
@ -294,14 +329,14 @@ class PreSacadorViewModel(context: Context) : BaseViewModel()
vStateFk,
vIsChecked,
vBuyFk
).enqueue(object : Callback<String>
).enqueue(object : Callback<String>
{
override fun onFailure(call: Call<String>, t: Throwable)
{
_response.value = ResponseItemVO(
isError = true,
errorMessage = getMessageFromAllResponse(nameofFunction(this),t.message!!)
)
)
}
override fun onResponse(call: Call<String>, response: Response<String>)
@ -311,7 +346,7 @@ class PreSacadorViewModel(context: Context) : BaseViewModel()
_response.value = ResponseItemVO(
isError = true,
errorMessage = getMessageFromAllResponse(nameofFunction(this),response.message())
)
)
} else
{
_response.value = ResponseItemVO(isError = false, response = response.body()!!)
@ -395,7 +430,7 @@ class PreSacadorViewModel(context: Context) : BaseViewModel()
{
override fun onFailure(call: Call<String>, t: Throwable)
{
_response.value = ResponseItemVO(
_responseSaleMove.value = ResponseItemVO(
isError = true,
errorMessage = getMessageFromAllResponse(nameofFunction(this),t.message!!)
)
@ -405,12 +440,12 @@ class PreSacadorViewModel(context: Context) : BaseViewModel()
{
if (response.body() == null)
{
_response.value = ResponseItemVO(
_responseSaleMove.value = ResponseItemVO(
isError = true,
errorMessage = getMessageFromAllResponse(nameofFunction(this),response.message()))
} else
{
_response.value = ResponseItemVO(isError = false, response = response.body()!!)
_responseSaleMove.value = ResponseItemVO(isError = false, response = response.body()!!)
}
}
})
@ -537,4 +572,229 @@ class PreSacadorViewModel(context: Context) : BaseViewModel()
}
}
fun sectorCollection_get(usuario: String, password: String,callFunction:String){
getPreSacadorUseCase.sectorCollection_get(usuario, password).enqueue(object :
Callback<List<CollectionVO>> {
override fun onFailure(call: Call<List<CollectionVO>>, t: Throwable) {
val listError: ArrayList<CollectionVO> = ArrayList()
listError.add(CollectionVO(isError = true, errorMessage = getMessageFromAllResponse(nameofFunction(this),t.message!!)))
_collectionList.value = CollectionListVO(listError)
}
override fun onResponse(
call: Call<List<CollectionVO>>,
response: Response<List<CollectionVO>>
) {
if (response.body() != null) {
_collectionList.value =
response.body()?.let { CollectionListVO(it.toDateFormat()) }
} else {
val listError: ArrayList<CollectionVO> = ArrayList()
listError.add(
CollectionVO(
isError = true,
errorMessage = getMessageFromAllResponse(nameofFunction(this),response.message())
)
)
_collectionList.value = CollectionListVO(listError)
}
}
})
}
fun sectorCollection_new(usuario: String, password: String, sectorFk: String,callFunction:String){
getPreSacadorUseCase.sectorCollection_new(usuario, password, sectorFk).enqueue(
object :
Callback<Unit> {
override fun onFailure(call: Call<Unit>, t: Throwable) {
_responseNew.value =
ResponseItemVO(isError = true, errorMessage = getMessageFromAllResponse(nameofFunction(this),t.message!!))
}
override fun onResponse(
call: Call<Unit>,
response: Response<Unit>
) {
if (!response.isSuccessful){
_responseNew.value=ResponseItemVO(
isError = true,
errorMessage = "Error en la llamada al añadir colección." + getMessageFromAllResponse(
nameofFunction(this),response.message()
))
}else{
_responseNew.value=ResponseItemVO(
isError = false,
errorMessage = "" + getMessageFromAllResponse(
nameofFunction(this),response.message()
))
}
//Log.i("Salix","Mensaje enviado a salix")
/*if (response.body() != null) {
_response.value =
ResponseItemVO(isError = false, response = response.body()!!)
} else {
_response.value = ResponseItemVO(
isError = true,
errorMessage = getMessageFromAllResponse(nameofFunction(this),response.message())
)
}*/
}
})
}
fun sectorCollection_getSale(usuario: String, password: String, sectorCollectionFK:String,vSectorFk:String)
{
getPreSacadorUseCase.sectorCollection_getSale(usuario, password, sectorCollectionFK,vSectorFk)
.enqueue(object :
Callback<List<PreSacadorItemVO>>
{
override fun onFailure(call: Call<List<PreSacadorItemVO>>, t: Throwable)
{
d("VERDNATURA::","ha fallado")
_salesList.value = listOf()
}
override fun onResponse(
call: Call<List<PreSacadorItemVO>>,
response: Response<List<PreSacadorItemVO>>
)
{
if (response.body() != null)
{
d("VERDNATURA::","entra con lineas")
_salesList.value = response.body()?.let { it }
} else
{
d("VERDNATURA::","ES NULO")
_salesList.value = listOf()
}
}
})
}
fun sectorCollectionSaleGroup_add(usuario: String, password: String, vSaleGroupFk: String,vSectorCollectionFk:String,callFunction:String){
getPreSacadorUseCase.sectorCollectionSaleGroup_add(usuario, password, vSaleGroupFk,vSectorCollectionFk).enqueue(
object :
Callback<Unit> {
override fun onFailure(call: Call<Unit>, t: Throwable) {
_response.value =
ResponseItemVO(isError = true, errorMessage = getMessageFromAllResponse(nameofFunction(this),t.message!!))
}
override fun onResponse(
call: Call<Unit>,
response: Response<Unit>
) {
if (!response.isSuccessful){
_responseSaleGroupAdd.value=ResponseItemVO(
isError = true,
errorMessage = "Error al añadir ticket a la colección." + getMessageFromAllResponse(
nameofFunction(this),response.message()
))
}else{
_responseSaleGroupAdd.value=ResponseItemVO(
isError = false,
errorMessage = "" + getMessageFromAllResponse(
nameofFunction(this),response.message()
))
}
}
})
}
fun saleTracking_addPrevOK(usuario: String, password: String, vSectorCollectionFk:String,callFunction:String){
getPreSacadorUseCase.saleTracking_addPrevOK(usuario, password,vSectorCollectionFk).enqueue(
object :
Callback<Unit> {
override fun onFailure(call: Call<Unit>, t: Throwable) {
_responseSaleAddPrevOK.value =
ResponseItemVO(isError = true, errorMessage = getMessageFromAllResponse(nameofFunction(this),t.message!!))
}
override fun onResponse(
call: Call<Unit>,
response: Response<Unit>
) {
if (!response.isSuccessful){
_responseSaleAddPrevOK.value=ResponseItemVO(
isError = true,
errorMessage = "Error al cambiar el estado a la colección de previa." + getMessageFromAllResponse(
nameofFunction(this),response.message()
))
}else{
_responseSaleAddPrevOK.value=ResponseItemVO(
isError = false,
errorMessage = ""
+ getMessageFromAllResponse(
nameofFunction(this),response.message()
))
}
}
})
}
fun saleTracking_updateIsChecked(usuario: String, password: String, vSaleFk:String,vIsChecked:String,callFunction:String){
getPreSacadorUseCase.saleTracking_updateIsChecked(usuario, password,vSaleFk,vIsChecked).enqueue(
object :
Callback<Unit> {
override fun onFailure(call: Call<Unit>, t: Throwable) {
_responseSaleupdateIsChecked.value =
ResponseItemVO(isError = true, errorMessage = getMessageFromAllResponse(nameofFunction(this),t.message!!))
}
override fun onResponse(
call: Call<Unit>,
response: Response<Unit>
) {
if (!response.isSuccessful){
_responseSaleupdateIsChecked.value=ResponseItemVO(
isError = true,
errorMessage = "Error al cambiar el estado a la colección de previa." + getMessageFromAllResponse(
nameofFunction(this),response.message()
))
}else{
_responseSaleupdateIsChecked.value=ResponseItemVO(
isError = false,
errorMessage = ""
+ getMessageFromAllResponse(
nameofFunction(this),response.message()
))
}
}
})
}
}

View File

@ -20,8 +20,7 @@ fun PreSacadorItemVO.toSale() : SaleVO {
placements = carros,
agencyName = if (trabajador.isNullOrEmpty()) { "" } else trabajador,
packingType=packingType,
salePersonFk=if (salesPersonFk.isNullOrEmpty()){""}else salesPersonFk
salePersonFk=if (salesPersonFk.isNullOrEmpty()){""}else salesPersonFk,
)

View File

@ -16,7 +16,9 @@ class PreSacadorItemVO (
var carros : List<PlacementVO> = listOf(),
//var priority:Int =0, 7-1-2022
var pickingOrder:Int =0,
var salesPersonFk:String= "sergio"
var salesPersonFk:String= "",
var reference:String=""
)

View File

@ -68,7 +68,7 @@ class QrFragment(
}
binding.scanInput.setText("")
(activity as MainActivity).hideKeyboard(binding.scanInput)
ma.hideKeyboard(binding.scanInput)
return@setOnEditorActionListener true
}
// false
@ -83,10 +83,11 @@ class QrFragment(
if (it.isError) {
// getMessageFromJSON(it.errorMessage)
customDialog.setTitle("Error").setDescription( it.errorMessage+ " "+itemscaned)
ma.messageWithSound(it.errorMessage+ " "+itemscaned,true,false)
/*customDialog.setTitle("Error").setDescription( it.errorMessage+ " "+itemscaned)
.setOkButton("Aceptar") {
customDialog.dismiss()
}.show()
}.show()*/
} else {
customDialog.setTitle("Mensaje")

View File

@ -38,7 +38,6 @@ class ReposicionFragment : BaseFragment<ReposicionFragmentBinding, ReposicionVie
private lateinit var customDialog: CustomDialog
private lateinit var customDialogList: CustomDialogList
private lateinit var customDialogInput: CustomDialogInput
private lateinit var customDialogThreeButtons: CustomDialogThreeButtons
private var sales:ArrayList<PreSacadorItemVO> = ArrayList()
@ -73,9 +72,7 @@ class ReposicionFragment : BaseFragment<ReposicionFragmentBinding, ReposicionVie
customDialog = CustomDialog(requireContext())
customDialogList = CustomDialogList(requireContext())
customDialogInput = CustomDialogInput(requireContext())
customDialogThreeButtons = CustomDialogThreeButtons(requireContext())
//requireActivity().main_bottom_navigation.visibility = View.GONE
(activity as MainActivity).hideBottomNavigation(View.GONE)
ma.hideBottomNavigation(View.GONE)
binding.splashProgress.visibility = View.GONE
binding.mainToolbar.toolbarTitle.text = getString(R.string.itemPlacementSupplyGetOrder)
setToolBar()
@ -522,7 +519,6 @@ class ReposicionFragment : BaseFragment<ReposicionFragmentBinding, ReposicionVie
}
private fun showScanner(index:Int, sale:PreSacadorItemVO){
//////Log.i("VERDNATURA:","CUSTOMDIALOG para enviar")
customDialogInput.setTitle(""+sale.itemFk).setDescription("Escanea el carro para el item seleccionado").setOkButton("Aceptar"){
if (!customDialogInput.getValue().isNullOrEmpty()) {
findSale(customDialogInput.getValue(),index)

View File

@ -27,7 +27,7 @@ class CollectionAdapter (
holder.bind(items[position])
holder.binding.root.setOnClickListener {
onCollectionSelected.onCollectionSelected(items[position],SACADOR)
//////Log.i("VERDNATURA:","2-Click item ${items[position].collectionFk}")
Log.d("VERDNATURA::","2-Click item ${items[position].collectionFk}")
}
}

View File

@ -3,8 +3,11 @@ package es.verdnatura.presentation.view.feature.sacador.fragment
import android.content.Context
import android.graphics.drawable.Drawable
import android.os.Build
import android.os.Bundle
import android.util.Log
import android.view.View
import android.widget.ImageView
import androidx.fragment.app.setFragmentResultListener
import androidx.lifecycle.Observer
import androidx.recyclerview.widget.LinearLayoutManager
import es.verdnatura.R
@ -13,7 +16,6 @@ import es.verdnatura.domain.ConstAndValues.SACADOR
import es.verdnatura.presentation.base.BaseFragment
import es.verdnatura.presentation.common.*
import es.verdnatura.presentation.view.component.CustomDialog
import es.verdnatura.presentation.view.feature.main.activity.MainActivity
import es.verdnatura.presentation.view.feature.sacador.adapter.CollectionAdapter
import es.verdnatura.presentation.view.feature.sacador.model.CollectionVO
import es.verdnatura.presentation.view.feature.smarttag.sacador.fragment.AssociateSmartTagsFragment
@ -51,12 +53,36 @@ class SacadorFragment :
binding.mainToolbar.toolbarTitle.text = getString(R.string.getcollection)
setToolBar()
setEvents()
viewModel.collectionGetSalix(token = getData(TOKEN))
/*viewModel.collectionGet( getData(USER),
getData(PASSWORD),"collection_get")*/
super.init()
}
var working_in_test=false
if (!working_in_test) {
viewModel.collectionGetSalix(token = getData(TOKEN))
}else{
viewModel.collectionGet( getData(USER),
getData(PASSWORD),"collection_get")
}
super.init()
}
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
// Use the Kotlin extension in the fragment-ktx artifact
setFragmentResultListener("requestKey") { requestKey, bundle ->
val result = bundle.getString("tagMode")
resultTagMode=result
Log.d("VERDNATURA::","el result es "+result)
if (result.equals("complete") && getData(TAGSTYPE).equals("SmartTags")) {
viewModel.collectionNew(getData(USER),
getData(PASSWORD), getData(SECTORFK), getData(WAGON), getData(TAGSTYPE),"collection_new_wagon")
}
}
}
override fun onPause() {
goBack = true
goBack2 = true
@ -66,7 +92,7 @@ class SacadorFragment :
private fun setToolBar() {
// requireActivity().main_bottom_navigation.visibility = View.VISIBLE
(activity as MainActivity).hideBottomNavigation(View.VISIBLE)
ma.hideBottomNavigation(View.VISIBLE)
binding.mainToolbar.backButton.visibility = View.GONE
val listIcons: ArrayList<ImageView> = ArrayList()
@ -96,22 +122,13 @@ class SacadorFragment :
iconAdd.drawable -> {
binding.splashProgress.visibility = View.VISIBLE
// checkTagsMode()
viewModel.collectionNew(getData(USER),
getData(PASSWORD),getData(SECTORFK),getData(WAGON),getData(TAGSTYPE),"collection_new_wagon")
}
iconVehicleIn.drawable-> (activity as MainActivity).onVehicleSelected(SacadorFragment.TAG)
}
/* if (item == iconAdd) {
binding.splashProgress.visibility = View.VISIBLE
//viewModel.collectionNew(user, password, sectorFk, wagons)
viewModel.collectionNew(user,password,sectorFk,wagons,getTagsType(),"collection_new_wagon")
//checkTagsMode()
iconVehicleIn.drawable-> ma.onVehicleSelected(SacadorFragment.TAG)
}
if (item.drawable == iconVehicleIn) {
(activity as MainActivity).onVehicleSelected(SacadorFragment.TAG)
}*/
}
})
binding.mainToolbar.toolbarIcons.layoutManager =
@ -121,9 +138,9 @@ class SacadorFragment :
private fun setEvents() {
binding.sacadorSwipe.setOnRefreshListener {
viewModel.collectionGetSalix(token = getData(TOKEN))
/* viewModel.collectionGet(getData(USER),
getData(PASSWORD),"collection_get")
binding.sacadorSwipe.isRefreshing = false*/
/* viewModel.collectionGet(getData(USER),
getData(PASSWORD),"collection_get")*/
binding.sacadorSwipe.isRefreshing = false
}
}
@ -131,14 +148,13 @@ class SacadorFragment :
private fun checkTagsMode() {
// Log.i("VERDNATURA:", "Tag type: ${getTagsType()}")
if (getData(TAGSTYPE).equals("Stickers")) {
//viewModel.collectionNew(user, password, sectorFk, wagons, "Stickers")
viewModel.collectionNew(getData(USER),
getData(PASSWORD), getData(SECTORFK), getData(WAGON),"collection_new_wagon")
} else {
// Log.i("VERDNATURA:", " el resultTagmode es ${resultTagMode}")
Log.d("VERDNATURA::","ResultMode"+resultTagMode)
if (resultTagMode.equals("complete")) {
viewModel.collectionNew(getData(USER),
getData(PASSWORD), getData(SECTORFK), getData(WAGON), getData(TAGSTYPE),"collection_new_wagon")
@ -182,18 +198,41 @@ class SacadorFragment :
binding.splashProgressTwo.visibility = View.GONE
binding.splashProgress.visibility = View.GONE
if (it.isError) {
customDialog.setTitle("Error").setDescription(it.errorMessage)
.setOkButton("Aceptar") {
customDialog.dismiss()
}.show()
ma.messageWithSound(it.errorMessage,true,false)
} else {
if (goBack) addCollectionToList(it.response)
}
goBack = false
//sergio:para asegurarnos que aparece en pantalla. En mi movil personal y trabajo no hacia falta.
/* viewModel.collectionGet(getData(USER),getData(PASSWORD),"collection_get")*/
viewModel.collectionGetSalix(token=getData(TOKEN))
//sergio:para asegurarnos que aparece en pantalla.
var working_in_test=false
if (!working_in_test) {
viewModel.collectionGetSalix(token=getData(TOKEN))
}else{
viewModel.collectionGet(getData(USER),getData(PASSWORD),"collection_get")
}
/*viewModel.collectionGetSalix(token=getData(TOKEN))*/
})
registerSmarttagInsert.observe(viewLifecycleOwner, Observer {
if (!goBack){
if (it.isError) {
ma.messageWithSound(it.errorMessage,true,false)
} else {
ma.messageWithSound(it.errorMessage,false,false)
}
goBack = false}
})
}
}
@ -211,6 +250,7 @@ class SacadorFragment :
private fun addCollectionToList(collection: String) {
var isNew = true
collectionsList.forEach {
if (it.collectionFk == collection) {
isNew = false
@ -218,6 +258,9 @@ class SacadorFragment :
}
if (isNew) {
collectionsList.add(CollectionVO(collectionFk = collection, created = "Nuevo"))
Log.d("VERDNATURA::","llamada nodejs insert")
viewModel.smartTagInsertTicket(collection)
adapter?.notifyDataSetChanged()
} else {
customDialog.setTitle("Atención")

View File

@ -2,9 +2,11 @@ package es.verdnatura.presentation.view.feature.sacador.fragment
import android.content.Context
import android.util.Log
import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData
import es.verdnatura.domain.GetSacadorControladorUserCase
import es.verdnatura.domain.GetSmarttagsUserCase
import es.verdnatura.presentation.base.BaseViewModel
import es.verdnatura.presentation.base.getMessageFromAllResponse
@ -14,6 +16,7 @@ import es.verdnatura.presentation.view.feature.collection.mapper.map
import es.verdnatura.presentation.view.feature.sacador.mapper.toDateFormat
import es.verdnatura.presentation.view.feature.sacador.model.CollectionListVO
import es.verdnatura.presentation.view.feature.sacador.model.CollectionVO
import es.verdnatura.presentation.view.feature.smarttag.sacador.model.SmartTagRegister
import retrofit2.Call
import retrofit2.Callback
import retrofit2.Response
@ -26,6 +29,10 @@ class SacadorViewModel(context: Context) : BaseViewModel() {
context
)
private val GetSmarttagsUserCase: GetSmarttagsUserCase = GetSmarttagsUserCase(
context
)
private val _collectionList by lazy { MutableLiveData<CollectionListVO>() }
val collectionList: LiveData<CollectionListVO>
get() = _collectionList
@ -38,6 +45,9 @@ class SacadorViewModel(context: Context) : BaseViewModel() {
val response: LiveData<ResponseItemVO>
get() = _response
private val _registerSmarttagInsert by lazy { MutableLiveData<SmartTagRegister>() }
val registerSmarttagInsert: LiveData<SmartTagRegister>
get() = _registerSmarttagInsert
fun collectionTicketGet(
@ -207,4 +217,53 @@ class SacadorViewModel(context: Context) : BaseViewModel() {
})
}
fun smartTagInsertTicket(collectionFk: String)
{
GetSmarttagsUserCase.smartTagInsertTicket(collectionFk)
.enqueue(object : Callback<SmartTagRegister>
{
override fun onResponse(
call: Call<SmartTagRegister>,
response: Response<SmartTagRegister>
)
{
val responseSmart: SmartTagRegister
if (response.isSuccessful()){
Log.i("VERDNATURA::","El mensaje es "+response.message())
responseSmart = SmartTagRegister(
message="Ticket insertado OK.",
isError = false,
errorMessage = ""
)
}else{
responseSmart = SmartTagRegister(
isError = true,
errorMessage = response.message()
)
}
_registerSmarttagInsert.value = responseSmart
}
override fun onFailure(call: Call<SmartTagRegister>, t: Throwable)
{
val responseSmart =
SmartTagRegister(isError = true, errorMessage = t.message!!)
Log.i("VERDNATURA::","el error nodejs es "+t.message+"--"+t.cause.toString()+"--"+t.stackTrace.toString())
_registerSmarttagInsert.value = responseSmart
}
})
}
}

View File

@ -27,7 +27,7 @@ class ShelvingParkingFragment : BaseFragment<FragmentShelvingParkingBinding, She
override fun init() {
(activity as MainActivity).hideBottomNavigation(View.GONE)
ma.hideBottomNavigation(View.GONE)
binding.mainToolbar.toolbarTitle.text = getString(R.string.shelvingParking_get)
setEvents()
@ -50,7 +50,7 @@ class ShelvingParkingFragment : BaseFragment<FragmentShelvingParkingBinding, She
}
binding.shelvingText.setText("")
(activity as MainActivity).hideKeyboard(binding.shelvingText)
ma.hideKeyboard(binding.shelvingText)
return@setOnEditorActionListener true
}
@ -67,7 +67,7 @@ class ShelvingParkingFragment : BaseFragment<FragmentShelvingParkingBinding, She
binding.mainToolbar.toolbarTitle.text = binding.shelvingText.text.toString()
viewModel.shelvingParking_get( getData(USER),getData(PASSWORD),binding.shelvingText.text.toString(),getData(WAREHOUSEFK),binding.dayrange.text.toString(),"shelvingParking_get")
binding.shelvingText.setText("")
(activity as MainActivity).hideKeyboard(binding.dayrange)
ma.hideKeyboard(binding.dayrange)
return@setOnEditorActionListener true
}

View File

@ -10,7 +10,6 @@ import es.verdnatura.databinding.FragmentControladorBinding
import es.verdnatura.domain.ConstAndValues
import es.verdnatura.presentation.base.BaseFragment
import es.verdnatura.presentation.common.OnCollectionSelectedListener
import es.verdnatura.presentation.view.component.CustomDialog
import es.verdnatura.presentation.view.feature.main.activity.MainActivity
import es.verdnatura.presentation.view.feature.precontrol.ShowTicketViewModel
import es.verdnatura.presentation.view.feature.sacador.model.CollectionVO
@ -21,7 +20,6 @@ class ShowTicketFragment: BaseFragment<FragmentControladorBinding, ShowTicketVie
private var goBack:Boolean = false
private var onCollectionSelectedListener : OnCollectionSelectedListener? = null
override fun getLayoutId(): Int = R.layout.fragment_controlador
private lateinit var customDialog: CustomDialog
private var type = ""
companion object {
@ -36,7 +34,6 @@ class ShowTicketFragment: BaseFragment<FragmentControladorBinding, ShowTicketVie
override fun init() {
binding.splashProgress.visibility = View.GONE
customDialog = CustomDialog(requireContext())
binding.mainToolbar.toolbarTitle.text = getString(R.string.verticket)
setEvents()
super.init()
@ -76,7 +73,7 @@ class ShowTicketFragment: BaseFragment<FragmentControladorBinding, ShowTicketVie
)
}
binding.scanInput.setText("")
(activity as MainActivity).hideKeyboard(binding.scanInput)
ma.hideKeyboard(binding.scanInput)
return@setOnEditorActionListener true
}
false
@ -88,9 +85,7 @@ class ShowTicketFragment: BaseFragment<FragmentControladorBinding, ShowTicketVie
collectionTicketList.observe(viewLifecycleOwner, Observer {
binding.splashProgress.visibility = View.GONE
if (it.isError){
customDialog.setTitle("Error").setDescription(it.errorMessage).setOkButton("Aceptar"){
customDialog.dismiss()
}.show()
ma.messageWithSound(it.errorMessage,true,false)
}else{
if (!goBack)navigateToCollectionList(it)
goBack = false

View File

@ -2,6 +2,7 @@ package es.verdnatura.presentation.view.feature.smarttag.register
import android.content.Context
import android.util.Log
import android.view.View
import android.view.View.*
import android.view.inputmethod.EditorInfo
@ -14,9 +15,7 @@ import es.verdnatura.domain.toast
import es.verdnatura.presentation.base.BaseFragment
import es.verdnatura.presentation.common.*
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.main.activity.MainActivity
import es.verdnatura.presentation.view.feature.smarttag.adapter.SmartTagAdapter
import es.verdnatura.presentation.view.feature.smarttag.model.SmartTag
@ -29,12 +28,10 @@ class RegisterSmartTagsFragment(
) {
private var goBack: Boolean = false
//private var onCollectionSelectedListener: OnCollectionSelectedListener? = null
override fun getLayoutId(): Int = R.layout.fragment_sacador_associatesmarttag
private lateinit var customDialog: CustomDialog
private lateinit var customDialogList: CustomDialogList
private lateinit var customDialogInput: CustomDialogInput
private lateinit var customDialogThreeButtons: CustomDialogThreeButtons
private var listSmartTags: ArrayList<SmartTag> = ArrayList()
private var smartAdapter: SmartTagAdapter? = null
private var itemScaned: String = ""
@ -44,6 +41,7 @@ class RegisterSmartTagsFragment(
fun newInstance(entryPoint: String) = RegisterSmartTagsFragment(entryPoint)
}
override fun onAttach(context: Context) {
super.onAttach(context)
// sergio: en test: Log.i("VERDNATURA:","attached")
@ -70,11 +68,8 @@ class RegisterSmartTagsFragment(
customDialog = CustomDialog(requireContext())
customDialogList = CustomDialogList(requireContext())
customDialogInput = CustomDialogInput(requireContext())
customDialogThreeButtons = CustomDialogThreeButtons(requireContext())
goBack = false
//requireActivity().main_bottom_navigation.visibility = GONE
(activity as MainActivity).hideBottomNavigation(View.GONE)
ma.hideBottomNavigation(View.GONE)
binding.splashProgress.visibility = GONE
setEvents()
@ -91,9 +86,9 @@ class RegisterSmartTagsFragment(
private fun setToolBar() {
// toolbar_title.text = getString(R.string.SmarttagAssociate)
// Log.d("VERDNATURA::","Title"+entryPoint)
binding.mainToolbar.toolbarTitle.text = entryPoint
// Log.i("VERDNATURA:", "el entrypoint es ${entryPoint}")
}
@ -101,32 +96,49 @@ class RegisterSmartTagsFragment(
private fun bindShelving_add(shelvingOrSmarttag: String) {
binding.splashProgress.visibility = VISIBLE
//poner el bindshelving aqui
viewModel.workerShelving_add(getData(USER),
getData(PASSWORD), shelvingOrSmarttag)
Log.d("VERDNATURA::","El selvingORSmarttag es "+shelvingOrSmarttag)
if (listSmartTags.size < 1) {
} else {
("http://localhost:7777/bindShelving/${listSmartTags.first().code}" + "&" + shelvingOrSmarttag + "&${listSmartTags.size}").toast(
/* ("https://smart-tag.verdnatura.es/bindShelving/$shelvingOrSmarttag&${listSmartTags.first().code}&${listSmartTags.size}").toast(
requireContext()
)
)*/
viewModel.smartTagRegister(shelvingOrSmarttag,listSmartTags.first().code!!,listSmartTags.size.toString())
// Log.d("VERDNATURA::","https://smart-tag.verdnatura.es/bindShelving/$shelvingOrSmarttag&${listSmartTags.first().code}&${listSmartTags.size}")
}
itemScaned = shelvingOrSmarttag
add_item()
}
private fun add_item(){
var nameSmartTagwithWagon: String
nameSmartTagwithWagon =
getTextScaned(listSmartTags.size + 1) + itemScaned
customDialogList.setTitle(getTextToPosition(listSmartTags.size + 1))
listSmartTags.add(SmartTag(itemScaned, nameSmartTagwithWagon))
smartAdapter!!.notifyDataSetChanged()
customDialogList.setValue("")
}
private fun bindShelving_remove() {
// binding.splashProgress.visibility = VISIBLE
//ponser el unbindshleving aqui
//poner el unbindshleving aqui
//sergio:esto se debe hacer en
("http://localhost:7777/unbindShelving/${listSmartTags.first().code}" + "&" + listSmartTags.last().code + "&${listSmartTags.size}").toast(
requireContext()
)
listSmartTags.removeAt(listSmartTags.size - 1)
listSmartTags.removeAt(listSmartTags.size - 1)
smartAdapter!!.notifyDataSetChanged()
@ -149,8 +161,10 @@ class RegisterSmartTagsFragment(
private fun setEvents() {
binding.mainToolbar.backButton.setOnClickListener {
// Log.i("VERDNATURA:","PULSADO")
customDialogList.dismiss()
requireActivity().onBackPressed()
}
}
@ -161,22 +175,27 @@ class RegisterSmartTagsFragment(
with(viewModel) {
binding.splashProgress.visibility = GONE
registerSmarttagNode.observe(viewLifecycleOwner, Observer {
if (it.isError){
ma.messageWithSound(it.errorMessage,true,false)
}else{
ma.messageWithSound(it.message,false,false)
}
})
responseadd.observe(viewLifecycleOwner, Observer {
// Log.i("VERDNATURA", "Revisar llamada de las etiquetas smarttags : ${it.response}")
if (it.isError) {
ma.messageWithSound(it.errorMessage,true,false)
customDialog.setTitle("Error").setDescription(it.errorMessage)
.setOkButton("Cerrar") {
customDialog.dismiss()
}.show()
} else {
var nameSmartTagwithWagon: String
//"Etiqueta/matrícula añadida correctamente".toast(context)
//var sizeSmartTags = listSmartTags.size + 1
nameSmartTagwithWagon =
getTextScaned(listSmartTags.size + 1) + itemScaned
customDialogList.setTitle(getTextToPosition(listSmartTags.size + 1))
@ -227,28 +246,30 @@ class RegisterSmartTagsFragment(
customDialogList.setTitle("Escanea matrícula del carro y etiquetas smartTags de arriba a abajo.")
.setOkButton("Finalizar") {
(activity as MainActivity).hideKeyboard(customDialogList.getEditText())
ma.hideKeyboard(customDialogList.getEditText())
if (listSmartTags.size > 0) {
// setFragmentResult("requestkey", bundleOf("tagMode" to "SmartTag"))
customDialogList.dismiss()
// (activity as MainActivity).openFragmentPickers()
requireActivity().onBackPressed()
// ma.openFragmentPickers()
/*listSmartTags.forEach {
Log.i("VERDNATURA:","El codigo es :${it.code}")
}
workerShelving_add(userFk, it.code!!)*/
} else {
customDialog.setTitle("Atención").setDescription("No ha escaneado Smartags")
/* customDialog.setTitle("Atención").setDescription("No ha escaneado Smartags")
.setOkButton("Ok")
{
customDialog.dismiss()
{*/
customDialogList.dismiss()
requireActivity().onBackPressed()
}.show()
/* }.show()*/
}
}.setKoButton("Deshacer") {
(activity as MainActivity).hideKeyboard(customDialogList.getEditText())
/* }.setKoButton("Deshacer") {
ma.hideKeyboard(customDialogList.getEditText())
if (!listSmartTags.isEmpty()) {
@ -258,14 +279,14 @@ class RegisterSmartTagsFragment(
customDialogList.dismiss()
requireActivity().onBackPressed()
}
}*/
//
}.setValue("").show()
customDialogList.getEditText().requestFocus()
(activity as MainActivity).hideKeyboard(customDialogList.getEditText())
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 || actionId == 6) {
@ -293,7 +314,7 @@ class RegisterSmartTagsFragment(
} else {
bindShelving_add(customDialogList.getValue())
bindShelving_add(customDialogList.getValue().uppercase())
}
// showScanSmartTags(SmartTag(customDialogList.getValue()))
@ -302,7 +323,7 @@ class RegisterSmartTagsFragment(
}
customDialogList.setValue("")
(activity as MainActivity).hideKeyboard(customDialogList.getEditText())
ma.hideKeyboard(customDialogList.getEditText())
return@setOnEditorActionListener true
}
false

View File

@ -11,6 +11,8 @@ import androidx.fragment.app.setFragmentResult
import androidx.lifecycle.Observer
import androidx.recyclerview.widget.LinearLayoutManager
import es.verdnatura.R
import es.verdnatura.databinding.FragmentSacadorAssociatesmarttagBinding
import es.verdnatura.databinding.FragmentSacadorAssociatesmarttagBindingImpl
import es.verdnatura.databinding.FragmentVehiclecontrolBinding
import es.verdnatura.domain.toast
import es.verdnatura.presentation.base.BaseFragment
@ -26,7 +28,7 @@ import timber.log.Timber
class AssociateSmartTagsFragment(
var entryPoint: String = ""
) : BaseFragment<FragmentVehiclecontrolBinding, SmartTagsViewModel>(
) : BaseFragment<FragmentSacadorAssociatesmarttagBinding, SmartTagsViewModel>(
SmartTagsViewModel::class
) {
@ -73,7 +75,7 @@ class AssociateSmartTagsFragment(
customDialogThreeButtons = CustomDialogThreeButtons(requireContext())
goBack = false
//requireActivity().main_bottom_navigation.visibility = GONE
(activity as MainActivity).hideBottomNavigation(View.GONE)
ma.hideBottomNavigation(View.GONE)
binding.splashProgress.visibility = GONE
setEvents()
@ -103,13 +105,7 @@ class AssociateSmartTagsFragment(
viewModel.workerShelving_add(getData(USER),
getData(PASSWORD), shelvingOrSmarttag)
if (listSmartTags.size < 1) {
} else {
("http://localhost:7777/bindShelving/${listSmartTags.first().code}" + "&" + shelvingOrSmarttag + "&${listSmartTags.size}").toast(
requireContext()
)
}
itemScaned = shelvingOrSmarttag
}
@ -123,9 +119,9 @@ class AssociateSmartTagsFragment(
viewModel.workerShelving_delete(getData(USER),
getData(PASSWORD), listSmartTags.last().code.toString())
("http://localhost:7777/unbindShelving/${listSmartTags.first().code}" + "&" + listSmartTags.last().code + "&${listSmartTags.size}").toast(
/* ("http://localhost:7777/unbindShelving/${listSmartTags.first().code}" + "&" + listSmartTags.last().code + "&${listSmartTags.size}").toast(
requireContext()
)
)*/
}
@ -160,25 +156,11 @@ class AssociateSmartTagsFragment(
// Log.i("VERDNATURA::", "Revisar llamada de las etiquetas smarttags : ${it.response}")
if (it.isError) {
ma.messageWithSound(it.errorMessage,true,false)
customDialog.setTitle("Error").setDescription(it.errorMessage)
.setOkButton("Cerrar") {
customDialog.dismiss()
}.show()
} else {
/* if (it.response != null) {
customDialog.setTitle("Error")
.setDescription("Etiqueta o carro no válido")
.setOkButton("Cerrar") {
customDialog.dismiss()
}.show()
} else {*/
//"Etiqueta/matrícula añadida correctamente".toast(context)
//var sizeSmartTags = listSmartTags.size + 1
ma.messageWithSound("Carro/etiqueta insertado",false,false)
var nameSmartTagwithWagon =
getTextScaned(0) + itemScaned
customDialogList.setTitle(getTextToPosition(0))
@ -188,17 +170,18 @@ class AssociateSmartTagsFragment(
customDialogList.setValue("")
// }
}
binding.splashProgress.visibility = GONE
})
responseremove.observe(viewLifecycleOwner, Observer {
if (it.isError) {
customDialog.setTitle("Error").setDescription(it.errorMessage)
ma.messageWithSound(it.errorMessage,true,false)
/*customDialog.setTitle("Error").setDescription(it.errorMessage)
.setOkButton("Cerrar") {
customDialog.dismiss()
}.show()
}.show()*/
} else {
if (it.response == null) {
@ -209,18 +192,13 @@ class AssociateSmartTagsFragment(
}.show()
} else {
//var nameSmartTagwithWagon = ""
/* nameSmartTagwithWagon =
getTextScaned(listSmartTags.size + 1) + itemScaned
customDialogList.setTitle(getTextToPosition(listSmartTags.size + 1))
listSmartTags.add(SmartTag(itemScaned, nameSmartTagwithWagon))*/
listSmartTags.removeAt(listSmartTags.size - 1)
smartAdapter!!.notifyDataSetChanged()
customDialogList.setValue("")
ma.messageWithSound("Carro/etiqueta borrada",false,false)
}
}
binding.splashProgress.visibility = GONE
@ -264,31 +242,34 @@ class AssociateSmartTagsFragment(
customDialogList.setTitle("Escanea etiqueta/s electrónica/s o matrícula/s.")
.setOkButton("Finalizar") {
(activity as MainActivity).hideKeyboard(customDialogList.getEditText())
ma.hideKeyboard(customDialogList.getEditText())
if (listSmartTags.size > 0) {
// setFragmentResult("requestkey", bundleOf("tagMode" to "SmartTag"))
customDialogList.dismiss()
Log.d("VERDNATURA::","Vamos a abrrir Sacadores")
val result = "complete"
setFragmentResult("requestKey", bundleOf("tagMode" to result))
(activity as MainActivity).openFragmentPickers()
ma.openFragmentPickers(true)
/*listSmartTags.forEach {
Log.i("VERDNATURA:","El codigo es :${it.code}")
}
workerShelving_add(userFk, it.code!!)*/
} else {
customDialog.setTitle("Atención").setDescription("No ha escaneado Smartags")
/* customDialog.setTitle("Atención").setDescription("No ha escaneado Smartags")
.setOkButton("Ok")
{
customDialog.dismiss()
{*/
customDialogList.dismiss()
requireActivity().onBackPressed()
}.show()
// }.show()
}
}.setKoButton("Deshacer") {
(activity as MainActivity).hideKeyboard(customDialogList.getEditText())
ma.hideKeyboard(customDialogList.getEditText())
if (!listSmartTags.isEmpty()) {
@ -304,15 +285,15 @@ class AssociateSmartTagsFragment(
}.setValue("").show()
customDialogList.getEditText().requestFocus()
(activity as MainActivity).hideKeyboard(customDialogList.getEditText())
ma.hideKeyboard(customDialogList.getEditText())
customDialogList.getEditText().setOnEditorActionListener { _, actionId, _ ->
if (actionId == EditorInfo.IME_ACTION_SEARCH || actionId == EditorInfo.IME_ACTION_DONE || actionId == 0 || actionId == 5 || actionId == 6) {
if (!customDialogList.getValue().isNullOrEmpty()) {
bindShelving_add(customDialogList.getValue())
bindShelving_add(customDialogList.getValue().uppercase())
}
customDialogList.setValue("")
(activity as MainActivity).hideKeyboard(customDialogList.getEditText())
ma.hideKeyboard(customDialogList.getEditText())
return@setOnEditorActionListener true
}
false

View File

@ -2,12 +2,15 @@ package es.verdnatura.presentation.view.feature.smarttag.sacador.fragment
import android.content.Context
import android.os.Message
import android.util.Log
import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData
import es.verdnatura.domain.GetSmarttagsUserCase
import es.verdnatura.domain.GetVehicleControlTimeUserCase
import es.verdnatura.domain.NodeJsService
import es.verdnatura.presentation.base.BaseViewModel
import es.verdnatura.presentation.common.ResponseItemVO
import es.verdnatura.presentation.view.feature.smarttag.sacador.model.SmartTagRegister
import retrofit2.Call
import retrofit2.Callback
@ -38,6 +41,10 @@ class SmartTagsViewModel(context: Context) : BaseViewModel() {
val responselevel: LiveData<ResponseItemVO>
get() = _responselevel
private val _registerSmarttagNode by lazy { MutableLiveData<SmartTagRegister>() }
val registerSmarttagNode: LiveData<SmartTagRegister>
get() = _registerSmarttagNode
fun workerShelving_add(usuario:String,password:String,shelvingFK:String){
GetSmarttagsUserCase.workerShelving_add(usuario,password,shelvingFK).enqueue(object : Callback<Void>{
@ -100,6 +107,49 @@ class SmartTagsViewModel(context: Context) : BaseViewModel() {
})
}
fun smartTagRegister(smarttag: String, wagon: String, shelving: String)
{
GetSmarttagsUserCase.smartTagRegister(smarttag, wagon, shelving)
.enqueue(object : Callback<SmartTagRegister>
{
override fun onResponse(
call: Call<SmartTagRegister>,
response: Response<SmartTagRegister>
)
{
val responseSmart: SmartTagRegister
if (response.isSuccessful()){
Log.i("VERDNATURA::","El mensaje es "+response.message())
responseSmart = SmartTagRegister(
message="Registrada smartTag.",
isError = false,
errorMessage = ""
)
}else{
responseSmart = SmartTagRegister(
isError = true,
errorMessage = response.message()
)
}
_registerSmarttagNode.value = responseSmart
}
override fun onFailure(call: Call<SmartTagRegister>, t: Throwable)
{
val responseSmart =
SmartTagRegister(isError = true, errorMessage = t.message!!)
Log.i("VERDNATURA::","el error nodejs es "+t.message+"--"+t.cause.toString()+"--"+t.stackTrace.toString())
_registerSmarttagNode.value = responseSmart
}
})
}
}

View File

@ -11,18 +11,13 @@ class SmartTagScan (
class SmartTagScanList(
var list:List<SmartTagScan> = listOf()
)
/*
class ItemExpeditionScanVO(
var id:String = "",
var expeditionFk:String = "",
var Ruta:String = "",
var Ticket:String = "",
var Caja:String = "",
var isError:Boolean = false,
var errorMessage:String = ""
class SmartTagRegister(
var message: String = "",
var smarttag: String = "",
var wagon: String = "",
var shelving: String = "",
var isError: Boolean = false,
var errorMessage: String = ""
)
class ItemExpeditionScanList(
var list:List<ItemExpeditionScanVO> = listOf()
)*/

View File

@ -21,10 +21,7 @@ class AutomaticAddItemFragment(
) : BaseFragment<FragmentAutomaticAddItemBinding,AutomaticAddItemViewModel>(AutomaticAddItemViewModel::class) {
private var adapter : AutomaticAdapter? = null
private lateinit var customDialogInput: CustomDialogInput
private lateinit var customDialogUbicador : CustomDialogUbicador
private var listItems:ArrayList<ItemEscanerVO> = ArrayList()
private lateinit var customDialog: CustomDialog
private var deep:Int = 1
private var contador = 0
@ -36,11 +33,7 @@ class AutomaticAddItemFragment(
override fun init() {
customDialogInput = CustomDialogInput(requireContext())
customDialog = CustomDialog(requireContext())
customDialogUbicador = CustomDialogUbicador(requireContext())
(activity as MainActivity).hideBottomNavigation(View.GONE)
ma.hideBottomNavigation(View.GONE)
binding.mainToolbar.toolbarTitle.text = "itemShelvingMake"
setEvents()
setViews()
@ -83,7 +76,7 @@ class AutomaticAddItemFragment(
adapter!!.notifyDataSetChanged()
}
binding.editMatricula.setText("")
(activity as MainActivity).hideKeyboard(binding.editMatricula)
ma.hideKeyboard(binding.editMatricula)
return@setOnEditorActionListener true
}
@ -110,9 +103,10 @@ class AutomaticAddItemFragment(
response.observe(viewLifecycleOwner, Observer {
binding.splashProgress.visibility = View.GONE
if (it.isError){
customDialog.setTitle("Error").setDescription(it.errorMessage).setOkButton("Cerrar"){
ma.messageWithSound(it.errorMessage,true,false)
/*customDialog.setTitle("Error").setDescription(it.errorMessage).setOkButton("Cerrar"){
customDialog.dismiss()
}.show()
}.show()*/
}else{
requireActivity().onBackPressed()
}

View File

@ -66,7 +66,7 @@ class UbicadorFragment(
customDialogUbicador = CustomDialogUbicador(requireContext())
customDialogTwoButtons = CustomDialogTwoButtons(requireContext())
(activity as MainActivity).hideBottomNavigation(View.GONE)
ma.hideBottomNavigation(View.GONE)
binding.mainToolbar.toolbarTitle.text = getString(R.string.locator)
setEvents()
setToolBar()
@ -154,7 +154,7 @@ class UbicadorFragment(
}
binding.editMatricula.setText("")
(activity as MainActivity).hideKeyboard(binding.editMatricula)
ma.hideKeyboard(binding.editMatricula)
return@setOnEditorActionListener true
}
@ -173,7 +173,7 @@ class UbicadorFragment(
)
}
(activity as MainActivity).hideKeyboard(binding.editPrioridad)
ma.hideKeyboard(binding.editPrioridad)
return@setOnEditorActionListener true
}
@ -183,7 +183,7 @@ class UbicadorFragment(
binding.automaticImg.setOnClickListener {
if (!shelvingFk.isNullOrEmpty())
(activity as MainActivity).onPasillerosItemClickListener(
ma.onPasillerosItemClickListener(
PasillerosItemVO(title = "Automatic"),
entryPoint = shelvingFk
)
@ -210,7 +210,7 @@ class UbicadorFragment(
}.show()
customDialogInput.getEditText().requestFocus()
(activity as MainActivity).hideKeyboard(customDialogInput.getEditText())
ma.hideKeyboard(customDialogInput.getEditText())
customDialogInput.getEditText().setOnEditorActionListener { v, actionId, event ->
if (actionId == EditorInfo.IME_ACTION_SEARCH || actionId == EditorInfo.IME_ACTION_DONE || actionId == 0) {
@ -259,7 +259,7 @@ class UbicadorFragment(
}.show()
customDialogInput.getEditText().requestFocus()
(activity as MainActivity).hideKeyboard(customDialogInput.getEditText())
ma.hideKeyboard(customDialogInput.getEditText())
customDialogInput.getEditText().setOnEditorActionListener { v, actionId, event ->
if (actionId == EditorInfo.IME_ACTION_SEARCH || actionId == EditorInfo.IME_ACTION_DONE || actionId == 0) {
@ -375,17 +375,24 @@ class UbicadorFragment(
})
response.observe(viewLifecycleOwner, Observer {
if (it.isError) {
mperror!!.start()
if (it.isError) {
ma.messageWithSound(it.errorMessage,it.isError,false)
/* mperror!!.start()
customDialog.setTitle("Error").setDescription(it.errorMessage)
.setOkButton("Cerrar") {
customDialog.dismiss()
}.show()
}.show()*/
}
})
responsepriority.observe(viewLifecycleOwner, Observer {
if (it.isError) {
ma.messageWithSound(
if (it.isError) it.errorMessage else{it.response},it.isError,true)
/* if (it.isError) {
mperror!!.start()
customDialog.setTitle("Error").setDescription(it.errorMessage)
.setOkButton("Cerrar") {
@ -393,7 +400,7 @@ class UbicadorFragment(
}.show()
} else {
(it.response).toast(requireContext())
}
}*/
})
responseMake.observe(viewLifecycleOwner, Observer {
@ -439,7 +446,7 @@ class UbicadorFragment(
}.show()
customDialogUbicador.getEditItem().requestFocus()
(activity as MainActivity).hideKeyboard(customDialogUbicador.getEditItem())
ma.hideKeyboard(customDialogUbicador.getEditItem())
customDialogUbicador.getVisibleItem().setOnEditorActionListener { v, actionId, event ->
if (actionId == EditorInfo.IME_ACTION_SEARCH || actionId == EditorInfo.IME_ACTION_DONE || actionId == 0) {
@ -518,7 +525,7 @@ class UbicadorFragment(
customDialogUbicador.setItemValue("").setPackingValue("").setGroupingValue("")
.setEtiquetaValue("").setVisibleValue("")
customDialogUbicador.getEditItem().requestFocus()
(activity as MainActivity).hideKeyboard(customDialogUbicador.getEditItem())
ma.hideKeyboard(customDialogUbicador.getEditItem())
customDialogUbicador.dismiss()
} else if (!itemFk.isNullOrEmpty() && !etiquetas.isNullOrEmpty()) {
@ -547,7 +554,7 @@ class UbicadorFragment(
customDialogUbicador.setItemValue("").setPackingValue("").setGroupingValue("")
.setEtiquetaValue("").setVisibleValue("")
customDialogUbicador.getEditItem().requestFocus()
(activity as MainActivity).hideKeyboard(customDialogUbicador.getEditItem())
ma.hideKeyboard(customDialogUbicador.getEditItem())
customDialogUbicador.dismiss()
} else {
@ -582,7 +589,7 @@ class UbicadorFragment(
customDialogUbicador.setItemValue("").setPackingValue("").setGroupingValue("")
.setEtiquetaValue("").setVisibleValue("")
customDialogUbicador.getEditItem().requestFocus()
(activity as MainActivity).hideKeyboard(customDialogUbicador.getEditItem())
ma.hideKeyboard(customDialogUbicador.getEditItem())
customDialogUbicador.dismiss()
} else if (!itemFk.isNullOrEmpty() && !etiquetas.isNullOrEmpty() && updatePacking) {
@ -616,7 +623,7 @@ class UbicadorFragment(
customDialogUbicador.setItemValue("").setPackingValue("").setGroupingValue("")
.setEtiquetaValue("").setVisibleValue("")
customDialogUbicador.getEditItem().requestFocus()
(activity as MainActivity).hideKeyboard(customDialogUbicador.getEditItem())
ma.hideKeyboard(customDialogUbicador.getEditItem())
customDialogUbicador.dismiss()
} else {
@ -639,14 +646,14 @@ class UbicadorFragment(
changeOfflineValue(ItemUbicadorVO(item = itemFk,visible = visible,packing = packing))
customDialogUbicador.setItemValue("").setPackingValue("").setEtiquetaValue("").setVisibleValue("")
customDialogUbicador.getEditItem().requestFocus()
(activity as MainActivity).hideKeyboard(customDialogUbicador.getEditItem())
ma.hideKeyboard(customDialogUbicador.getEditItem())
}else if(!itemFk.isNullOrEmpty() && !etiquetas.isNullOrEmpty()){
val visible_calc = (etiquetas.toInt() * packing.toInt()).toString()
viewModel.itemShelvingMake(user,password,shelvingFk,itemFk,deep.toString(),visible_calc,packing,warehouseFk,"1","itemShelvingMake")
changeOfflineValue(ItemUbicadorVO(item = itemFk,visible = visible_calc,packing = packing,stickers = etiquetas))
customDialogUbicador.setItemValue("").setPackingValue("").setEtiquetaValue("").setVisibleValue("")
customDialogUbicador.getEditItem().requestFocus()
(activity as MainActivity).hideKeyboard(customDialogUbicador.getEditItem())
ma.hideKeyboard(customDialogUbicador.getEditItem())
}else{
"Rellena campos obligatorios".toast((activity as MainActivity), Toast.LENGTH_LONG)
}
@ -687,7 +694,7 @@ class UbicadorFragment(
customDialogInput.dismiss()
}.show()
customDialogInput.getEditText().requestFocus()
(activity as MainActivity).hideKeyboard(customDialogInput.getEditText())
ma.hideKeyboard(customDialogInput.getEditText())
customDialogInput.getEditText().setOnEditorActionListener { v, actionId, event ->
if (actionId == EditorInfo.IME_ACTION_SEARCH || actionId == EditorInfo.IME_ACTION_DONE || actionId == 0) {
viewModel.itemShelvingTransfer(

View File

@ -0,0 +1,71 @@
package es.verdnatura.presentation.view.feature.workermistake.adapter
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.core.content.ContentProviderCompat.requireContext
import androidx.recyclerview.widget.RecyclerView
import es.verdnatura.databinding.ItemInventaryRowBinding
import es.verdnatura.databinding.ItemWorkermistakeRowBinding
import es.verdnatura.domain.toast
import es.verdnatura.presentation.common.OnInvetoryNichoClickListener
import es.verdnatura.presentation.common.OnPasillerosItemClickListener
import es.verdnatura.presentation.common.onMistakeWorkerClickListener
import es.verdnatura.presentation.view.feature.inventario.model.ItemInventaryVO
import es.verdnatura.presentation.view.feature.pasillero.model.PasillerosItemVO
import es.verdnatura.presentation.view.feature.workermistake.model.WorkerFromMistake
import timber.log.Timber.d
class WorkermistakeAdapter (
private val items: List<WorkerFromMistake>,
private val onMistakeWorkerClickListener: onMistakeWorkerClickListener
//private val onPasillerosItemClickListener: OnPasillerosItemClickListener*/
): RecyclerView.Adapter<WorkermistakeAdapter.ItemHolder> () {
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ItemHolder {
return ItemHolder(
ItemWorkermistakeRowBinding.inflate(LayoutInflater.from(parent.context),parent,false)
)
}
override fun getItemCount() =items.size
override fun onBindViewHolder(holder: ItemHolder, position: Int) {
holder.bind(items[position])
}
inner class ItemHolder(
val binding: ItemWorkermistakeRowBinding
) : RecyclerView.ViewHolder(binding.root){
private val res = binding.root.context.resources
fun bind(item: WorkerFromMistake) {
binding.apply {
this.item = item
itemFirstname.visibility = View.VISIBLE
itemLastname.visibility = View.VISIBLE
}
/* itemNicho.setOnClickListener {
onInvetoryNichoClickListener.onInvetoryNichoClickListener(item)
}
itemFk.setOnClickListener {
onPasillerosItemClickListener.onPasillerosItemClickListener(PasillerosItemVO(title = "Consultar artículo"),item.itemFk)
}
itemUp.setOnClickListener {
onPasillerosItemClickListener.onPasillerosItemClickListener(PasillerosItemVO(title = "Buscar item"),item.itemFk)
}
itemDown.setOnClickListener {
onPasillerosItemClickListener.onPasillerosItemClickListener(PasillerosItemVO(title = "Buscar item"),item.itemFk)
}*/
binding.imageErrorMessage.setOnClickListener {
d("test_imageError")
onMistakeWorkerClickListener.onMistakeWorkerClickListener(item)
//false
}
}
}
}

View File

@ -0,0 +1,261 @@
package es.verdnatura.presentation.view.feature.workermistake.adapter
import android.content.Context
import android.os.Bundle
import android.view.View
import androidx.core.widget.addTextChangedListener
import androidx.recyclerview.widget.LinearLayoutManager
import es.verdnatura.R
import es.verdnatura.databinding.FragmentWorkermistakeBinding
import es.verdnatura.presentation.base.BaseFragment
import es.verdnatura.presentation.common.OnBarcodeRowClickListener
import es.verdnatura.presentation.common.OnPasillerosItemClickListener
import es.verdnatura.presentation.common.onMistakeWorkerClickListener
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.feature.articulo.adapter.BarcodeAdapter
import es.verdnatura.presentation.view.feature.articulo.model.BarcodeVO
import es.verdnatura.presentation.view.feature.inventario.fragment.InventaryViewModel
import es.verdnatura.presentation.view.feature.inventario.fragment.SearchDepartmentModel
import es.verdnatura.presentation.view.feature.workermistake.model.DepartmentMistake
import es.verdnatura.presentation.view.feature.workermistake.model.MistakeWorkerType
import es.verdnatura.presentation.view.feature.workermistake.model.WorkerFromMistake
import ir.mirrajabi.searchdialog.SimpleSearchDialogCompat
class WorkermistakeFragment( var entryPoint: String = ""
) : BaseFragment<FragmentWorkermistakeBinding, InventaryViewModel>(
InventaryViewModel::class) {
private var adapterworker:WorkermistakeAdapter? = null
private lateinit var customDialogInput: CustomDialogInput
private var listWorker:MutableList<WorkerFromMistake> = ArrayList()
private var listWorkerAuxiliary:MutableList<WorkerFromMistake> = ArrayList()
private lateinit var customDialog: CustomDialog
private var pasillerosItemClickListener: OnPasillerosItemClickListener? = null
private var layoutManager : LinearLayoutManager? = null
// private var firstVisiblePosition = 0
private lateinit var customDialogList: CustomDialogList
private var listMistakes: ArrayList<BarcodeVO> = ArrayList()
private var listMistakesAdapter: BarcodeAdapter? = null
private var workerMistakeName: WorkerFromMistake? = null
private val departments=ArrayList<SearchDepartmentModel>()
private lateinit var departmentId:String
companion object {
fun newInstance(entryPoint:String) = WorkermistakeFragment(entryPoint)
}
override fun getLayoutId(): Int = R.layout.fragment_workermistake
override fun onAttach(context: Context) {
if (context is OnPasillerosItemClickListener) pasillerosItemClickListener = context
super.onAttach(context)
}
override fun onCreate(savedInstanceState: Bundle?) {
viewModel.department_getHasMistake(usuario = getData(USER),password = getData(PASSWORD))
super.onCreate(savedInstanceState)
}
override fun init() {
binding.filterDepartment.setText(getData(DEPARTMENTMISTAKE))
binding.splashProgress.visibility = View.VISIBLE
departmentId=getData(DEPARTMENTMISTAKEID)
customDialogList = CustomDialogList(requireContext())
if (!departmentId.isEmpty()){
viewModel.worker_getFromHasMistake(getData(USER),getData(PASSWORD),getData(DEPARTMENTMISTAKEID),"worker_getFromHasMistake")
}
binding.filterDepartment.setOnClickListener{
SimpleSearchDialogCompat(context,getString(R.string.departamentos),getString(R.string.escribirparteNombre),null,departments,
{ baseSearchDialogCompat, nombre, position ->
binding.filterDepartment.setText((nombre.title))
saveData(DEPARTMENTMISTAKE,nombre.getDepartmentName())
saveData(DEPARTMENTMISTAKEID,nombre.getDepartmentId())
viewModel.worker_getFromHasMistake(getData(USER),getData(PASSWORD),nombre.getDepartmentId(),"worker_getFromHasMistake")
binding.splashProgress.visibility = View.VISIBLE
binding.filterItemFk.isEnabled = true
baseSearchDialogCompat.dismiss()
}).show()
}
customDialogInput = CustomDialogInput(requireContext())
customDialog = CustomDialog(requireContext())
ma.hideBottomNavigation(View.GONE)
binding.splashProgress.visibility = View.VISIBLE
setToolBar()
setEvents()
super.init()
}
private fun setToolBar(){
binding.mainToolbar.toolbarTitle.text=entryPoint
}
private fun setEvents(){
binding.mainToolbar.backButton.setOnClickListener {
requireActivity().onBackPressed()
}
if (binding.filterDepartment.text.isNullOrEmpty()){binding.filterItemFk.isEnabled = false}
binding.filterItemFk.addTextChangedListener{ filter()}
}
private fun filter() {
if (!listWorker.isNullOrEmpty())
{listWorker.clear()
listWorker.addAll(listWorkerAuxiliary.filter{it.firstName.uppercase().contains(binding.filterItemFk.text.toString().uppercase()) || it.lastName.uppercase().contains(binding.filterItemFk.text.toString().uppercase())} as MutableList<WorkerFromMistake>)
adapterworker!!.notifyDataSetChanged()}
}
/* override fun onPause() {
super.onPause()
firstVisiblePosition = layoutManager?.findFirstVisibleItemPosition() ?: 0
}*/
/* override fun onResume() {
super.onResume()
if (binding.workermistakeRecyclerview.layoutManager != null){
if (firstVisiblePosition <= listInvetory.size){
binding.workermistakeRecyclerview.layoutManager!!.scrollToPosition(firstVisiblePosition)
}
}
}*/
override fun observeViewModel() {
with(viewModel){
mistakeDepartmentList.observe(viewLifecycleOwner, {
binding.splashProgress.visibility = View.GONE
createDepartmentList(it.list)
})
workerFromMistakeList.observe(viewLifecycleOwner, {
binding.splashProgress.visibility = View.GONE
createWorkerList(it.list)
adapterworker= WorkermistakeAdapter(listWorker,object:onMistakeWorkerClickListener{
override fun onMistakeWorkerClickListener(item: WorkerFromMistake) {
viewModel.workerMistakeType_get(usuario = getData(USER), password = getData(PASSWORD))
workerMistakeName=WorkerFromMistake(item.id,item.firstName,item.lastName,true,"")
}
})
binding.workermistakeRecyclerview.adapter = adapterworker
layoutManager = LinearLayoutManager(requireContext(), LinearLayoutManager.VERTICAL, false)
binding.workermistakeRecyclerview.layoutManager = layoutManager
})
mistakeWorkerList.observe(viewLifecycleOwner,{
binding.splashProgress.visibility = View.GONE
showMistakeList(it.list)
//goBack = false
})
responseAddMistake.observe(viewLifecycleOwner, {
ma.messageWithSound(it.errorMessage,it.isError,true)
})
response.observe(viewLifecycleOwner, {
if (it.isError){
ma.messageWithSound(it.errorMessage,true,false)
}
})
}
}
private fun showMistakeList(list: List<MistakeWorkerType>) {
binding.splashProgress.visibility = View.GONE
listMistakes = ArrayList()
list.forEach {
listMistakes.add(BarcodeVO(code = it.description))
}
customDialogList.setTitle("Causa de error para : ${workerMistakeName!!.firstName}").setKoButton("Cancelar") {
customDialogList.dismiss()
}.hideDialog().show()
listMistakesAdapter =
BarcodeAdapter(listMistakes, object : OnBarcodeRowClickListener {
override fun onBarcodeRowClickListener(item: BarcodeVO) {
list.forEach {
if (it.description == item.code) {
viewModel.workerMistake_Add(usuario = getData(USER),
password = getData(PASSWORD),
vUserFk = workerMistakeName!!.id,
vTypeFk = it.code, callFunction ="workerMistake_Add"
)
// "Causa del error registrado".toast(requireContext())
customDialogList.dismiss()
}
}
}
}, showDelete = false)
customDialogList.getRecyclerView().adapter = listMistakesAdapter
customDialogList.getRecyclerView().layoutManager =
LinearLayoutManager(requireContext(), LinearLayoutManager.VERTICAL, false)
}
private fun createDepartmentList(list: List<DepartmentMistake>){
departments.clear()
list.forEach { department ->
if (!department.isError){
try {
departments.add(SearchDepartmentModel(department.name,department.id))
}catch (e:Exception){}
}
}}
private fun createWorkerList(list: List<WorkerFromMistake>){
listWorker.clear()
list.forEach { worker ->
if (!worker.isError){
try {
listWorker.add(worker)
}catch (e:Exception){}
}
}
listWorkerAuxiliary.clear()
listWorkerAuxiliary.addAll(listWorker)
}
}

View File

@ -0,0 +1,90 @@
package es.verdnatura.presentation.view.feature.workermistake.fragment
import android.content.Context
import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData
import es.verdnatura.domain.GetWokerMistakeUSerCase
import es.verdnatura.presentation.base.BaseViewModel
import es.verdnatura.presentation.view.feature.workermistake.model.DepartmentMistake
import es.verdnatura.presentation.view.feature.workermistake.model.departmentMistakeList
import retrofit2.Call
import retrofit2.Callback
import retrofit2.Response
class WorkermistakeViewModel (context: Context) : BaseViewModel() {
private val getWorkerMistakeUserCase: GetWokerMistakeUSerCase = GetWokerMistakeUSerCase(context)
private val _mistakeDepartmentList by lazy { MutableLiveData<departmentMistakeList>() }
val mistakeDepartmentList: LiveData<departmentMistakeList>
get() = _mistakeDepartmentList
/* fun mistakeWorker(usuario: String, password: String)
{
getWorkerMistakeUserCase.mistakeType(usuario, password)
.enqueue(object : Callback<List<mistakeWorkerType>>
{
override fun onFailure(call: Call<List<mistakeWorkerType>>, t: Throwable)
{
val listError: ArrayList<mistakeWorkerType> = ArrayList()
listError.add(mistakeWorkerType("0", ""))
_mistakeDepartmentList.value = workerMistakeTypeList(listError)
}
override fun onResponse(
call: Call<List<mistakeWorkerType>>,
response: Response<List<mistakeWorkerType>>
)
{
if (response.body() != null)
{
_mistakeDepartmentList.value = response.body()?.let { workerMistakeTypeList(it) }
} else
{
val listError: ArrayList<mistakeWorkerType> = ArrayList()
listError.add(mistakeWorkerType("0", ""))
_mistakeDepartmentList.value = workerMistakeTypeList(listError)
}
}
})
}*/
fun department_getHasMistake(usuario: String, password: String)
{
getWorkerMistakeUserCase.department_getHasMistake(usuario, password)
.enqueue(object : Callback<List<DepartmentMistake>>
{
override fun onFailure(call: Call<List<DepartmentMistake>>, t: Throwable)
{
val listError: ArrayList<DepartmentMistake> = ArrayList()
listError.add(DepartmentMistake("0", ""))
_mistakeDepartmentList.value = departmentMistakeList(listError)
}
override fun onResponse(
call: Call<List<DepartmentMistake>>,
response: Response<List<DepartmentMistake>>
)
{
if (response.body() != null)
{
_mistakeDepartmentList.value = response.body()?.let { departmentMistakeList(it) }
} else
{
val listError: ArrayList<DepartmentMistake> = ArrayList()
listError.add(DepartmentMistake("0", ""))
_mistakeDepartmentList.value = departmentMistakeList(listError)
}
}
})
}
}

View File

@ -0,0 +1,40 @@
package es.verdnatura.presentation.view.feature.workermistake.model
class MistakeWorkerType (
var id: String = "",
var code:String = "",
var description: String = "",
var isError:Boolean = false,
var errorMessage:String = ""
)
class DepartmentMistake(
var id:String ="",
var name:String="",
var isError:Boolean = false,
var errorMessage:String = ""
)
class WorkerFromMistake(
var id:String="",
var firstName: String="",
var lastName: String="",
var isError:Boolean = false,
var errorMessage:String = ""
)
class workerMistakeTypeList(
var list: List<MistakeWorkerType> = listOf()
)
class departmentMistakeList(
var list: List<DepartmentMistake> = listOf()
)
class workerFromMistakeList(
var list: List<WorkerFromMistake> = listOf()
)

View File

@ -1,7 +1,8 @@
<vector android:height="24dp"
android:viewportHeight="24.0"
android:viewportWidth="24.0"
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
<vector
android:height="24dp"
android:width="24dp"
android:viewportHeight="24"
android:viewportWidth="24"
xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="#F7931E" android:pathData="M13,3c-4.97,0 -9,4.03 -9,9L1,12l3.89,3.89 0.07,0.14L9,12L6,12c0,-3.87 3.13,-7 7,-7s7,3.13 7,7 -3.13,7 -7,7c-1.93,0 -3.68,-0.79 -4.94,-2.06l-1.42,1.42C8.27,19.99 10.51,21 13,21c4.97,0 9,-4.03 9,-9s-4.03,-9 -9,-9zM12,8v5l4.28,2.54 0.72,-1.21 -3.5,-2.08L13.5,8L12,8z"/>
</vector>

View File

@ -1,5 +1,8 @@
<vector android:height="24dp" android:tint="#FFFFFF"
android:viewportHeight="24.0" android:viewportWidth="24.0"
<vector
android:height="24dp"
android:tint="#FFFFFF"
android:viewportHeight="24.0"
android:viewportWidth="24.0"
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="#FFFFFF" android:pathData="M13,3c-4.97,0 -9,4.03 -9,9L1,12l3.89,3.89 0.07,0.14L9,12L6,12c0,-3.87 3.13,-7 7,-7s7,3.13 7,7 -3.13,7 -7,7c-1.93,0 -3.68,-0.79 -4.94,-2.06l-1.42,1.42C8.27,19.99 10.51,21 13,21c4.97,0 9,-4.03 9,-9s-4.03,-9 -9,-9zM12,8v5l4.28,2.54 0.72,-1.21 -3.5,-2.08L13.5,8L12,8z"/>
</vector>

View File

@ -0,0 +1,8 @@
<vector
android:height="24dp"
android:width="24dp"
android:viewportHeight="24"
android:viewportWidth="24"
xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="#F7931E" android:pathData="M13,3c-4.97,0 -9,4.03 -9,9L1,12l3.89,3.89 0.07,0.14L9,12L6,12c0,-3.87 3.13,-7 7,-7s7,3.13 7,7 -3.13,7 -7,7c-1.93,0 -3.68,-0.79 -4.94,-2.06l-1.42,1.42C8.27,19.99 10.51,21 13,21c4.97,0 9,-4.03 9,-9s-4.03,-9 -9,-9zM12,8v5l4.28,2.54 0.72,-1.21 -3.5,-2.08L13.5,8L12,8z"/>
</vector>

View File

@ -0,0 +1,8 @@
<!-- drawable/playlist_remove.xml -->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:height="24dp"
android:width="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path android:fillColor="#FFF" android:pathData="M2,6V8H14V6H2M2,10V12H11V10H2M14.17,10.76L12.76,12.17L15.59,15L12.76,17.83L14.17,19.24L17,16.41L19.83,19.24L21.24,17.83L18.41,15L21.24,12.17L19.83,10.76L17,13.59L14.17,10.76M2,14V16H11V14H2Z" />
</vector>

Some files were not shown because too many files have changed in this diff Show More