Compare commits
91 Commits
Author | SHA1 | Date |
---|---|---|
|
75258f1763 | |
|
091b597f34 | |
|
b26cf1b76f | |
|
d3679ae52c | |
|
3ec49358ad | |
|
028d0b85aa | |
|
e78dfdac0e | |
|
f499915ef4 | |
|
3844855b19 | |
|
4ceb51b59e | |
|
4524e3a887 | |
|
ad370ba09a | |
|
889dcd1fe8 | |
|
097db01ac3 | |
|
49d6e2801d | |
|
41993fdd07 | |
|
dd8894ff39 | |
|
2f639cc1c0 | |
|
983043382d | |
|
5153bf62a2 | |
|
54a679f0ce | |
|
36f8a43f34 | |
|
6af6f92192 | |
|
2a0b251b14 | |
|
bf5cbf37a8 | |
|
aede2d4051 | |
|
16b84ce2ec | |
|
31c715c40d | |
|
c72c76bdb3 | |
|
ebf09db00d | |
|
44053fa039 | |
|
f9e19bb9ca | |
|
c3ea43e7e1 | |
|
04380327ab | |
|
8d1110d09e | |
|
12e5241a10 | |
|
612b2ac8f2 | |
|
ad42096eca | |
|
a7f476417e | |
|
a6ad406623 | |
|
fbd7a8d95c | |
|
009c221de3 | |
|
1689d100d5 | |
|
feedd08879 | |
|
1ab7280d66 | |
|
24ec314f34 | |
|
c3a4366d7d | |
|
6d4277cf91 | |
|
54687e2e05 | |
|
e0b148ddfd | |
|
0b42a3c61b | |
|
d49d6cf0ba | |
|
df8dc7cc77 | |
|
0c8df1c7a1 | |
|
5d600359fa | |
|
f55bd3768f | |
|
6233545418 | |
|
2295497e62 | |
|
aae791f721 | |
|
f96d809afe | |
|
6f155fbe36 | |
|
a97b823695 | |
|
1943296492 | |
|
568c3e687b | |
|
ab262dc328 | |
|
ed6171da78 | |
|
b6115837ae | |
|
103df4e31e | |
|
2d9870a930 | |
|
884d6abdd9 | |
|
136d2de399 | |
|
455f72c352 | |
|
d9abe0ab08 | |
|
ff9849589e | |
|
43b1d828e8 | |
|
26151605fa | |
|
b03d1c48c5 | |
|
ab064e52aa | |
|
0fe4c3c7d3 | |
|
a0ae1e37f1 | |
|
361ebddd2f | |
|
611e6d2993 | |
|
18ebdfc92a | |
|
0cdec41ca0 | |
|
0709fe3127 | |
|
298e17210a | |
|
df764e0960 | |
|
8e413e7f60 | |
|
083317beb2 | |
|
bdbe219549 | |
|
657deb8541 |
|
@ -1,3 +1,4 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="DesignSurface">
|
||||
<option name="filePathToZoomLevelMap">
|
||||
|
|
|
@ -34,6 +34,7 @@
|
|||
<component name="AndroidLayouts">
|
||||
<shared>
|
||||
<config>
|
||||
<device id="pixel_6a" />
|
||||
<locale>es</locale>
|
||||
<pickBest>false</pickBest>
|
||||
<target>android-27</target>
|
||||
|
@ -285,6 +286,11 @@
|
|||
<theme>@style/AppTheme</theme>
|
||||
</config>
|
||||
</layout>
|
||||
<layout url="file://$PROJECT_DIR$/app/src/main/res/layout/fragment_web.xml">
|
||||
<config>
|
||||
<theme>@style/AppTheme</theme>
|
||||
</config>
|
||||
</layout>
|
||||
<layout url="file://$PROJECT_DIR$/app/src/main/res/layout/fragment_workermistake.xml">
|
||||
<config>
|
||||
<theme>@style/AppTheme</theme>
|
||||
|
@ -431,6 +437,11 @@
|
|||
<theme>@style/AppTheme</theme>
|
||||
</config>
|
||||
</layout>
|
||||
<layout url="file://$PROJECT_DIR$/app/src/main/res/layout/sale_row_fragment_reserve.xml">
|
||||
<config>
|
||||
<theme>@style/AppTheme</theme>
|
||||
</config>
|
||||
</layout>
|
||||
<layout url="file://$PROJECT_DIR$/app/src/main/res/layout/searchable_dialog.xml">
|
||||
<config>
|
||||
<theme>@style/AppTheme</theme>
|
||||
|
@ -493,12 +504,24 @@
|
|||
</select>
|
||||
</component>
|
||||
<component name="ChangeListManager">
|
||||
<list default="true" id="fa688d1c-dbee-4864-9e33-4d84ef9afca8" name="Default Changelist" comment="feat: refs#6845 userInterface">
|
||||
<change afterPath="$PROJECT_DIR$/CHANGELOG.md" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/changeLog.sh" afterDir="false" />
|
||||
<list default="true" id="fa688d1c-dbee-4864-9e33-4d84ef9afca8" name="Default Changelist" comment="feat: refs#6861 reservas">
|
||||
<change afterPath="$PROJECT_DIR$/app/lint-baseline.xml" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/app/src/main/res/layout/sale_row_fragment_reserve.xml" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/.idea/deploymentTargetSelector.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/deploymentTargetSelector.xml" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/.idea/gradle.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/gradle.xml" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/.idea/render.experimental.xml" beforeDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/app/build.gradle.kts" beforeDir="false" afterPath="$PROJECT_DIR$/app/build.gradle.kts" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/app/src/main/java/es/verdnatura/presentation/view/feature/main/activity/MainActivity.kt" beforeDir="false" afterPath="$PROJECT_DIR$/app/src/main/java/es/verdnatura/presentation/view/feature/main/activity/MainActivity.kt" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/app/src/main/java/es/verdnatura/presentation/view/feature/ubicador/model/ItemUbicadorVO.kt" beforeDir="false" afterPath="$PROJECT_DIR$/app/src/main/java/es/verdnatura/presentation/view/feature/ubicador/model/ItemUbicadorVO.kt" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/app/general/release/baselineProfiles/0/app-general-release.dm" beforeDir="false" afterPath="$PROJECT_DIR$/app/general/release/baselineProfiles/0/app-general-release.dm" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/app/general/release/baselineProfiles/1/app-general-release.dm" beforeDir="false" afterPath="$PROJECT_DIR$/app/general/release/baselineProfiles/1/app-general-release.dm" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/app/src/main/AndroidManifest.xml" beforeDir="false" afterPath="$PROJECT_DIR$/app/src/main/AndroidManifest.xml" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/app/src/main/java/es/verdnatura/domain/Extensions.kt" beforeDir="false" afterPath="$PROJECT_DIR$/app/src/main/java/es/verdnatura/domain/Extensions.kt" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/app/src/main/java/es/verdnatura/presentation/view/commom/WebFragment.kt" beforeDir="false" afterPath="$PROJECT_DIR$/app/src/main/java/es/verdnatura/presentation/view/commom/WebFragment.kt" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/app/src/main/java/es/verdnatura/presentation/view/feature/delivery/fragments/TicketsFragment.kt" beforeDir="false" afterPath="$PROJECT_DIR$/app/src/main/java/es/verdnatura/presentation/view/feature/delivery/fragments/TicketsFragment.kt" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/app/src/main/java/es/verdnatura/presentation/view/feature/workermistake/fragment/PackingMistakeFragment.kt" beforeDir="false" afterPath="$PROJECT_DIR$/app/src/main/java/es/verdnatura/presentation/view/feature/workermistake/fragment/PackingMistakeFragment.kt" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/app/src/main/res/layout/fragment_web.xml" beforeDir="false" afterPath="$PROJECT_DIR$/app/src/main/res/layout/fragment_web.xml" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/build.gradle.kts" beforeDir="false" afterPath="$PROJECT_DIR$/build.gradle.kts" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/gradle/libs.versions.toml" beforeDir="false" afterPath="$PROJECT_DIR$/gradle/libs.versions.toml" afterDir="false" />
|
||||
</list>
|
||||
<list id="7b98f93d-6980-4bf1-8e61-c7afd10e56f2" name="Change_category" comment="Change_category" />
|
||||
<option name="SHOW_DIALOG" value="false" />
|
||||
|
@ -513,7 +536,7 @@
|
|||
<component name="CodeInsightWorkspaceSettings">
|
||||
<option name="optimizeImportsOnTheFly" value="true" />
|
||||
</component>
|
||||
<component name="ExecutionTargetManager" SELECTED_TARGET="device_and_snapshot_combo_box_target[DeviceId(pluginId=LocalEmulator, isTemplate=false, identifier=path=C:\Users\sergiodt\.android\avd\Pixel_7a_API_30.avd)]" />
|
||||
<component name="ExecutionTargetManager" SELECTED_TARGET="device_and_snapshot_combo_box_target[DeviceId(pluginId=PhysicalDevice, isTemplate=false, identifier=serial=21114523025303)]" />
|
||||
<component name="ExportToHTMLSettings">
|
||||
<option name="OPEN_IN_BROWSER" value="true" />
|
||||
<option name="OUTPUT_DIRECTORY" value="C:\Program Files\Android\Android Studio\inspections" />
|
||||
|
@ -603,7 +626,7 @@
|
|||
</option>
|
||||
<option name="RECENT_BRANCH_BY_REPOSITORY">
|
||||
<map>
|
||||
<entry key="$PROJECT_DIR$" value="dev_6078" />
|
||||
<entry key="$PROJECT_DIR$" value="devLinphone" />
|
||||
</map>
|
||||
</option>
|
||||
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
|
||||
|
@ -664,60 +687,60 @@
|
|||
<option name="showLibraryContents" value="true" />
|
||||
<option name="showMembers" value="true" />
|
||||
</component>
|
||||
<component name="PropertiesComponent">{
|
||||
"keyToString": {
|
||||
"Android App.app.executor": "Run",
|
||||
"ApkExportedModule": "Gestor_Almacén.app",
|
||||
"DEBUGGABLE_DEVICE": "zebra_technologies-tc21-21114523025303",
|
||||
"DEBUGGABLE_PROCESS": "es.verdnatura.sfusion",
|
||||
"DEBUGGER_ID": "Auto",
|
||||
"ExportApk.ApkPathForGestor_Almacén.app": "C:\\Users\\sergiodt\\AndroidStudioProjects\\vn-warehouseManager\\app",
|
||||
"Gradle.vn-warehouseManager [clean].executor": "Run",
|
||||
"Gradle.vn-warehouseManager.executor": "Run",
|
||||
"KotlinFunctionFindUsagesOptions.isSearchForTextOccurrences": "true",
|
||||
"PROJECT_TRUSTED_KEY": "true",
|
||||
"RunOnceActivity.OpenProjectViewOnStart": "true",
|
||||
"RunOnceActivity.ShowReadmeOnStart": "true",
|
||||
"RunOnceActivity.cidr.known.project.marker": "true",
|
||||
"RunOnceActivity.readMode.enableVisualFormatting": "true",
|
||||
"SHARE_PROJECT_CONFIGURATION_FILES": "true",
|
||||
"SHOW_ALL_PROCESSES": "false",
|
||||
"ScreenRecorder.SavePath": "C:\\Users\\sergiodt",
|
||||
"android-custom-viewC:/Users/sergiodt/.gradle/caches/modules-2/files-2.1/androidx.recyclerview/recyclerview/1.2.1/f0f93e67af3f7417bdd560d5142f6dec4fe629c3/recyclerview-1.2.1-sources.jar!/androidx/recyclerview/widget/RecyclerView.java_SELECTED": "RecyclerView",
|
||||
"android-custom-viewC:/Users/sergiodt/AppData/Local/Android/Sdk/sources/android-29/android/widget/TextView.java_SELECTED": "TextView",
|
||||
"android-custom-viewC:/Users/sergiodt/AppData/Local/Android/Sdk/sources/android-33/android/view/View.java_SELECTED": "View",
|
||||
"android-custom-viewC:/Users/sergiodt/AppData/Local/Android/Sdk/sources/android-34/android/view/View.java_SELECTED": "View",
|
||||
"android-custom-viewC:/Users/sergiodt/AppData/Local/Android/Sdk/sources/android-34/android/widget/CompoundButton.java_SELECTED": "CompoundButton",
|
||||
"android-custom-viewC:/Users/sergiodt/AppData/Local/Android/Sdk/sources/android-34/android/widget/TextView.java_SELECTED": "TextView",
|
||||
"cf.first.check.clang-format": "false",
|
||||
"cidr.known.project.marker": "true",
|
||||
"com.developerphil.adbidea.selecteddevices": "G65TY9DQN7X4BIE6",
|
||||
"com.google.services.firebase.aqiPopupShown": "true",
|
||||
"git-widget-placeholder": "dev",
|
||||
"ignore.virus.scanning.warn.message": "true",
|
||||
"kotlin-language-version-configured": "true",
|
||||
"last_directory_selection": "C:/Users/sergiodt/AndroidStudioProjects/vn-warehouseManager/app/src/main/res/drawable",
|
||||
"last_opened_file_path": "C:/Users/sergiodt/AndroidStudioProjects/vn-warehouseManager/app/src/main/res/layout",
|
||||
"project.structure.last.edited": "Modules",
|
||||
"project.structure.proportion": "0.17",
|
||||
"project.structure.side.proportion": "0.2",
|
||||
"rearrange.code.on.save": "true",
|
||||
"run.code.analysis.last.selected.profile": "pProject Default",
|
||||
"settings.editor.selected.configurable": "preferences.pluginManager"
|
||||
<component name="PropertiesComponent"><![CDATA[{
|
||||
"keyToString": {
|
||||
"Android App.app.executor": "Run",
|
||||
"ApkExportedModule": "Gestor_Almacén.app",
|
||||
"DEBUGGABLE_DEVICE": "honeywell-eda52-23086B3FFD",
|
||||
"DEBUGGABLE_PROCESS": "es.verdnatura.sfusion",
|
||||
"DEBUGGER_ID": "Auto",
|
||||
"ExportApk.ApkPathForGestor_Almacén.app": "C:\\Users\\sergiodt\\AndroidStudioProjects\\vn-warehouseManager\\app",
|
||||
"Gradle.vn-warehouseManager [clean].executor": "Run",
|
||||
"Gradle.vn-warehouseManager.executor": "Run",
|
||||
"KotlinFunctionFindUsagesOptions.isSearchForTextOccurrences": "true",
|
||||
"PROJECT_TRUSTED_KEY": "true",
|
||||
"RunOnceActivity.OpenProjectViewOnStart": "true",
|
||||
"RunOnceActivity.ShowReadmeOnStart": "true",
|
||||
"RunOnceActivity.cidr.known.project.marker": "true",
|
||||
"RunOnceActivity.readMode.enableVisualFormatting": "true",
|
||||
"SHARE_PROJECT_CONFIGURATION_FILES": "true",
|
||||
"SHOW_ALL_PROCESSES": "false",
|
||||
"ScreenRecorder.SavePath": "C:\\Users\\sergiodt",
|
||||
"android-custom-viewC:/Users/sergiodt/.gradle/caches/modules-2/files-2.1/androidx.recyclerview/recyclerview/1.2.1/f0f93e67af3f7417bdd560d5142f6dec4fe629c3/recyclerview-1.2.1-sources.jar!/androidx/recyclerview/widget/RecyclerView.java_SELECTED": "RecyclerView",
|
||||
"android-custom-viewC:/Users/sergiodt/AppData/Local/Android/Sdk/sources/android-29/android/widget/TextView.java_SELECTED": "TextView",
|
||||
"android-custom-viewC:/Users/sergiodt/AppData/Local/Android/Sdk/sources/android-33/android/view/View.java_SELECTED": "View",
|
||||
"android-custom-viewC:/Users/sergiodt/AppData/Local/Android/Sdk/sources/android-34/android/view/View.java_SELECTED": "View",
|
||||
"android-custom-viewC:/Users/sergiodt/AppData/Local/Android/Sdk/sources/android-34/android/widget/CompoundButton.java_SELECTED": "CompoundButton",
|
||||
"android-custom-viewC:/Users/sergiodt/AppData/Local/Android/Sdk/sources/android-34/android/widget/TextView.java_SELECTED": "TextView",
|
||||
"cf.first.check.clang-format": "false",
|
||||
"cidr.known.project.marker": "true",
|
||||
"com.developerphil.adbidea.selecteddevices": "G65TY9DQN7X4BIE6",
|
||||
"com.google.services.firebase.aqiPopupShown": "true",
|
||||
"git-widget-placeholder": "dev",
|
||||
"ignore.virus.scanning.warn.message": "true",
|
||||
"kotlin-language-version-configured": "true",
|
||||
"last_directory_selection": "C:/Users/sergiodt/AndroidStudioProjects/vn-warehouseManager/app/src/main/res/drawable",
|
||||
"last_opened_file_path": "C:/Users/sergiodt/AndroidStudioProjects/vn-warehouseManager/app/src/main/res/layout",
|
||||
"project.structure.last.edited": "Dependencies",
|
||||
"project.structure.proportion": "0.17",
|
||||
"project.structure.side.proportion": "0.2",
|
||||
"rearrange.code.on.save": "true",
|
||||
"run.code.analysis.last.selected.profile": "pProject Default",
|
||||
"settings.editor.selected.configurable": "reference.settingsdialog.project.gradle"
|
||||
},
|
||||
"keyToStringList": {
|
||||
"ExportApk.BuildVariants": [
|
||||
"generalRelease"
|
||||
"keyToStringList": {
|
||||
"ExportApk.BuildVariants": [
|
||||
"generalRelease"
|
||||
],
|
||||
"com.android.tools.idea.sqlite.queryhistory": [
|
||||
"select * from expedition where routeFk=182933;",
|
||||
"select * from expedition;",
|
||||
"select * from expeditionPending;",
|
||||
"select * from expedition where id = 7753995;\n\n",
|
||||
"\nselect * from expedition where id = 7753995;"
|
||||
"com.android.tools.idea.sqlite.queryhistory": [
|
||||
"select * from expedition where routeFk=182933;",
|
||||
"select * from expedition;",
|
||||
"select * from expeditionPending;",
|
||||
"select * from expedition where id = 7753995;\n\n",
|
||||
"\nselect * from expedition where id = 7753995;"
|
||||
]
|
||||
}
|
||||
}</component>
|
||||
}]]></component>
|
||||
<component name="PsdUISettings">
|
||||
<option name="MODULE_TAB" value="Properties" />
|
||||
<option name="LAST_EDITED_SIGNING_CONFIG" value="debug" />
|
||||
|
@ -1265,7 +1288,7 @@
|
|||
<option name="project" value="LOCAL" />
|
||||
<updated>1709725795643</updated>
|
||||
</task>
|
||||
<option name="localTasksCounter" value="373" />
|
||||
<option name="localTasksCounter" value="377" />
|
||||
<servers />
|
||||
</component>
|
||||
<component name="Vcs.Log.History.Properties">
|
||||
|
@ -1405,10 +1428,6 @@
|
|||
</component>
|
||||
<component name="VcsManagerConfiguration">
|
||||
<option name="ADD_EXTERNAL_FILES_SILENTLY" value="true" />
|
||||
<MESSAGE value="feat getAddress #refs 7622" />
|
||||
<MESSAGE value="feat claimObservation refs #7541" />
|
||||
<MESSAGE value="feat reservas refs #6861" />
|
||||
<MESSAGE value="version 24.30" />
|
||||
<MESSAGE value="feat itemGetBalance refs #6769" />
|
||||
<MESSAGE value="feat: boxPickingPrepared refs #7855" />
|
||||
<MESSAGE value="feat: refactorResponse PasillerosItem refs #7827" />
|
||||
|
@ -1430,7 +1449,11 @@
|
|||
<MESSAGE value="feat: refs #7922 scanOrder" />
|
||||
<MESSAGE value="feat: refs #7920 itemShelvingGet" />
|
||||
<MESSAGE value="feat: refs#6845 userInterface" />
|
||||
<option name="LAST_COMMIT_MESSAGE" value="feat: refs#6845 userInterface" />
|
||||
<MESSAGE value="linphoneVersion" />
|
||||
<MESSAGE value="feat: refs#8301 deprecatedOlderItem" />
|
||||
<MESSAGE value="feat: refs#6413 refactorUbicador" />
|
||||
<MESSAGE value="feat: refs#6861 reservas" />
|
||||
<option name="LAST_COMMIT_MESSAGE" value="feat: refs#6861 reservas" />
|
||||
</component>
|
||||
<component name="XDebuggerManager">
|
||||
<breakpoint-manager>
|
||||
|
@ -1443,6 +1466,14 @@
|
|||
</properties>
|
||||
<option name="timeStamp" value="11" />
|
||||
</line-breakpoint>
|
||||
<line-breakpoint enabled="true" type="kotlin-function">
|
||||
<url>file://$PROJECT_DIR$/app/src/main/java/es/verdnatura/presentation/view/feature/collection/fragment/CollectionFragmentPickerPreviousNew.kt</url>
|
||||
<line>764</line>
|
||||
<properties class="es.verdnatura.presentation.view.feature.collection.fragment.CollectionFragmentPickerPreviousNew" method="customDialogTakeAction">
|
||||
<option name="WATCH_EXIT" value="false" />
|
||||
</properties>
|
||||
<option name="timeStamp" value="17" />
|
||||
</line-breakpoint>
|
||||
<line-breakpoint enabled="true" type="kotlin-line">
|
||||
<url>file://$PROJECT_DIR$/app/src/main/java/es/verdnatura/domain/SalixCallback.kt</url>
|
||||
<line>86</line>
|
||||
|
@ -1458,6 +1489,11 @@
|
|||
<line>87</line>
|
||||
<option name="timeStamp" value="14" />
|
||||
</line-breakpoint>
|
||||
<line-breakpoint enabled="true" type="kotlin-line">
|
||||
<url>file://$PROJECT_DIR$/app/src/main/java/es/verdnatura/presentation/view/feature/delivery/fragments/TicketsFragment.kt</url>
|
||||
<line>450</line>
|
||||
<option name="timeStamp" value="18" />
|
||||
</line-breakpoint>
|
||||
</breakpoints>
|
||||
</breakpoint-manager>
|
||||
<pin-to-top-manager>
|
||||
|
|
|
@ -0,0 +1,169 @@
|
|||
apply plugin: 'com.android.application'
|
||||
apply plugin: 'kotlin-android'
|
||||
apply plugin: 'kotlin-kapt'
|
||||
apply plugin: 'com.google.gms.google-services'
|
||||
apply plugin: 'com.google.firebase.crashlytics'
|
||||
apply plugin: 'com.google.devtools.ksp'
|
||||
|
||||
|
||||
android {
|
||||
namespace = "es.verdnatura"
|
||||
compileSdk 34
|
||||
defaultConfig {
|
||||
applicationId "es.verdnatura"
|
||||
minSdkVersion 26
|
||||
targetSdkVersion 33 // se deja con target si no Play Protect la bloquea
|
||||
versionCode 330
|
||||
versionName = "24.38"
|
||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||
}
|
||||
|
||||
buildTypes {
|
||||
release {
|
||||
/*debuggable false
|
||||
shrinkResources true
|
||||
minifyEnabled true*/
|
||||
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
|
||||
}
|
||||
|
||||
//package de la app general = "package_name": "es.verdnatura"
|
||||
//package de la app beta = "package_name": "es.verdnatura.sfusion"
|
||||
|
||||
applicationVariants.all { variant ->
|
||||
variant.outputs.all { output ->
|
||||
def flavorName = variant.productFlavors[0].name
|
||||
def apkName
|
||||
|
||||
if (flavorName == "beta") {
|
||||
apkName = "vn-pickingBeta.apk"
|
||||
} else if (flavorName == "general") {
|
||||
apkName = "vn-picking.apk"
|
||||
} else {
|
||||
apkName = "vn-picking.apk"
|
||||
}
|
||||
|
||||
output.outputFileName = apkName
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
flavorDimensions += "version"
|
||||
productFlavors {
|
||||
create("beta") {
|
||||
applicationIdSuffix = ".sfusion"
|
||||
}
|
||||
create("general") {
|
||||
//versionNameSuffix = "General"
|
||||
}
|
||||
}
|
||||
|
||||
buildFeatures {
|
||||
viewBinding = true
|
||||
|
||||
}
|
||||
/*kotlinOptions {
|
||||
jvmTarget = "1.8"
|
||||
}
|
||||
buildFeatures {
|
||||
compose = true
|
||||
}
|
||||
kotlin {
|
||||
jvmToolchain(8)
|
||||
}
|
||||
composeOptions {
|
||||
kotlinCompilerExtensionVersion = "1.4.3"
|
||||
}
|
||||
*/
|
||||
dataBinding {
|
||||
enabled = true
|
||||
}
|
||||
|
||||
compileOptions {
|
||||
sourceCompatibility JavaVersion.VERSION_17
|
||||
targetCompatibility JavaVersion.VERSION_17
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation fileTree(dir: 'libs', include: ['*.jar'])
|
||||
implementation 'com.google.firebase:firebase-crashlytics-ktx:19.0.3'
|
||||
implementation 'com.google.firebase:firebase-analytics-ktx:22.0.2'
|
||||
implementation 'com.google.android.gms:play-services-location:21.3.0'
|
||||
implementation 'androidx.navigation:navigation-fragment-ktx:2.7.7'
|
||||
implementation 'androidx.navigation:navigation-ui-ktx:2.7.7'
|
||||
implementation 'androidx.core:core-ktx:1.13.1'
|
||||
kapt "androidx.room:room-compiler:2.6.1"
|
||||
implementation 'androidx.room:room-ktx:2.6.1'
|
||||
debugImplementation fileTree(dir: 'libs/debug', include: ['*.jar'])
|
||||
releaseImplementation fileTree(dir: 'libs/release', include: ['*.jar'])
|
||||
|
||||
//canvas
|
||||
implementation 'com.simplify:ink:1.0.0'
|
||||
|
||||
// Kotlin and Android
|
||||
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
|
||||
implementation 'androidx.appcompat:appcompat:1.7.0'
|
||||
implementation 'androidx.core:core-ktx:1.13.1'
|
||||
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
|
||||
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
|
||||
implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0'
|
||||
|
||||
//tests
|
||||
testImplementation 'junit:junit:4.13.2'
|
||||
androidTestImplementation 'androidx.test.ext:junit:1.2.1'
|
||||
androidTestImplementation 'androidx.test.espresso:espresso-core:3.6.1'
|
||||
implementation 'com.google.android.material:material:1.12.0'
|
||||
implementation 'com.squareup.retrofit2:retrofit:2.3.0'
|
||||
implementation 'com.squareup.retrofit2:converter-gson:2.0.2'
|
||||
implementation 'com.squareup.retrofit2:converter-scalars:2.3.0'
|
||||
implementation "com.airbnb.android:lottie:$lottieVersion"
|
||||
implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.1.0'
|
||||
|
||||
//Fragments
|
||||
implementation("androidx.fragment:fragment-ktx:1.8.2")
|
||||
|
||||
// Architecture components
|
||||
implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.8.4"
|
||||
implementation "androidx.lifecycle:lifecycle-livedata-ktx:2.8.4"
|
||||
implementation "androidx.legacy:legacy-support-v4:1.0.0"
|
||||
|
||||
//Koin new resolve
|
||||
implementation "io.insert-koin:koin-core:$koin"
|
||||
implementation "io.insert-koin:koin-android:$koin"
|
||||
implementation "io.insert-koin:koin-androidx-scope:$koin"
|
||||
implementation "io.insert-koin:koin-androidx-viewmodel:$koin"
|
||||
|
||||
// Image libraries
|
||||
implementation "io.coil-kt:coil:$coil"
|
||||
implementation "com.github.bumptech.glide:glide:$glide"
|
||||
implementation "com.github.bumptech.glide:okhttp3-integration:$glide"
|
||||
//kapt "com.github.bumptech.glide:compiler:$glide"
|
||||
ksp("com.github.bumptech.glide:ksp:$glide")
|
||||
|
||||
// Add the Firebase Crashlytics SDK.
|
||||
implementation 'com.google.firebase:firebase-analytics:22.0.2'
|
||||
|
||||
//search
|
||||
implementation 'com.github.mirrajabi:search-dialog:1.1'
|
||||
|
||||
//logs
|
||||
implementation 'com.jakewharton.timber:timber:4.7.1'
|
||||
|
||||
//pickerImage
|
||||
implementation 'com.github.esafirm:android-image-picker:3.0.0-beta5'
|
||||
|
||||
//preferences
|
||||
implementation("androidx.datastore:datastore-preferences:1.1.1")
|
||||
implementation 'androidx.datastore:datastore-core:1.1.1'
|
||||
|
||||
|
||||
// Compose
|
||||
/* implementation(platform("androidx.compose:compose-bom:2024.02.01"))
|
||||
implementation("androidx.compose.ui:ui")
|
||||
implementation("androidx.compose.material:material")
|
||||
implementation("androidx.compose.runtime:runtime")
|
||||
implementation("androidx.activity:activity-compose:1.8.2")
|
||||
implementation("androidx.compose.ui:ui-graphics")
|
||||
implementation("androidx.compose.ui:ui-tooling-preview")*/
|
||||
}
|
|
@ -5,6 +5,7 @@ plugins {
|
|||
id("com.google.gms.google-services")
|
||||
id("com.google.firebase.crashlytics")
|
||||
id("com.google.devtools.ksp")
|
||||
id("org.jetbrains.kotlin.plugin.compose")
|
||||
}
|
||||
|
||||
android {
|
||||
|
@ -15,8 +16,8 @@ android {
|
|||
applicationId = "es.verdnatura"
|
||||
minSdk = 26
|
||||
targetSdk = 33 // se deja con target si no Play Protect la bloquea
|
||||
versionCode = 374
|
||||
versionName = "24.51"
|
||||
versionCode = 405
|
||||
versionName = "25.12" // REvisor para reservas
|
||||
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
|
||||
}
|
||||
|
||||
|
@ -59,7 +60,14 @@ android {
|
|||
}
|
||||
create("general") {}
|
||||
}
|
||||
kapt {
|
||||
correctErrorTypes = true
|
||||
useBuildCache = true
|
||||
|
||||
kotlinOptions {
|
||||
languageVersion = "1.9"
|
||||
}
|
||||
}
|
||||
buildFeatures {
|
||||
viewBinding = true
|
||||
//compose = true
|
||||
|
@ -76,6 +84,9 @@ android {
|
|||
}
|
||||
*/
|
||||
dataBinding = true
|
||||
|
||||
compose = true
|
||||
|
||||
}
|
||||
|
||||
compileOptions {
|
||||
|
@ -102,7 +113,9 @@ android {
|
|||
implementation(libs.androidx.core.ktx)
|
||||
implementation(libs.androidx.recyclerview)
|
||||
implementation(libs.androidx.room.ktx)
|
||||
kapt(libs.androidx.room.compiler)
|
||||
//kapt(libs.androidx.room.compiler)
|
||||
ksp(libs.androidx.room.compiler)
|
||||
implementation(libs.androidx.room.runtime)
|
||||
implementation(libs.ink)
|
||||
implementation(libs.kotlin.stdlib.jdk7)
|
||||
implementation(libs.androidx.appcompat)
|
||||
|
@ -133,15 +146,33 @@ android {
|
|||
implementation(libs.androidx.datastore.core)
|
||||
implementation(libs.zxing.android.embedded) { isTransitive = false }
|
||||
implementation(libs.core)
|
||||
//implementation(libs.koin.androidx.compose)
|
||||
|
||||
// Compose
|
||||
//implementation(libs.androidx.compose.bom)
|
||||
/* implementation("androidx.compose.ui:ui")
|
||||
implementation("androidx.compose.material:material")
|
||||
implementation("androidx.compose.runtime:runtime")
|
||||
implementation("androidx.activity:activity-compose:1.8.2")
|
||||
implementation("androidx.compose.ui:ui-graphics")
|
||||
implementation("androidx.compose.ui:ui-tooling-preview") */
|
||||
|
||||
val composeBom = platform("androidx.compose:compose-bom:2024.10.01")
|
||||
implementation(composeBom)
|
||||
androidTestImplementation(composeBom)
|
||||
// Choose one of the following:
|
||||
// Material Design 3
|
||||
implementation(libs.androidx.material3)
|
||||
implementation(libs.androidx.ui)
|
||||
// Android Studio Preview support
|
||||
implementation(libs.androidx.ui.tooling.preview)
|
||||
debugImplementation(libs.androidx.ui.tooling)
|
||||
// UI Tests
|
||||
androidTestImplementation(libs.androidx.ui.test.junit4)
|
||||
debugImplementation(libs.androidx.ui.test.manifest)
|
||||
// custom design system based on Foundation)
|
||||
//implementation(libs.androidx.material.icons.core)
|
||||
// Optional - Add full set of material icons
|
||||
implementation(libs.androidx.material.icons.extended)
|
||||
// Optional - Add window size utils
|
||||
implementation(libs.androidx.adaptive)
|
||||
implementation(libs.androidx.activity.compose)
|
||||
implementation(libs.androidx.lifecycle.viewmodel.compose)
|
||||
implementation(libs.lottie.compose)
|
||||
testImplementation(libs.junit)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -27,6 +27,12 @@
|
|||
android:name=".presentation.view.feature.articulo.fragment.ImageViewActivity"
|
||||
android:configChanges="orientation"
|
||||
android:screenOrientation="portrait" />
|
||||
|
||||
<activity
|
||||
android:name=".presentation.composable.ImageViewActivityComposable"
|
||||
android:configChanges="orientation"
|
||||
android:exported="false"
|
||||
android:screenOrientation="portrait" />
|
||||
<activity
|
||||
android:name=".presentation.view.feature.restaurant.RestaurantActivity"
|
||||
android:configChanges="orientation"
|
||||
|
@ -69,6 +75,8 @@
|
|||
android:name="android.support.FILE_PROVIDER_PATHS"
|
||||
android:resource="@xml/file_paths" />
|
||||
</provider>
|
||||
|
||||
</application>
|
||||
|
||||
|
||||
</manifest>
|
|
@ -7,6 +7,7 @@ import android.media.MediaPlayer
|
|||
import android.os.Bundle
|
||||
import android.os.Handler
|
||||
import android.os.Looper
|
||||
import android.widget.Toast
|
||||
import es.verdnatura.dataStore.DataStoreLocal
|
||||
import es.verdnatura.di.viewModelModule
|
||||
import es.verdnatura.domain.ConstAndValues
|
||||
|
@ -120,7 +121,8 @@ class MobileApplication : Application(), InteceptorListener {
|
|||
Color.RED
|
||||
} else {
|
||||
Color.BLUE
|
||||
}
|
||||
},
|
||||
duration = if (isError) Toast.LENGTH_LONG else Toast.LENGTH_SHORT
|
||||
)
|
||||
}
|
||||
|
||||
|
|
|
@ -17,7 +17,9 @@ import es.verdnatura.domain.ConstAndValues.BASEURLLILIUM
|
|||
import es.verdnatura.domain.ConstAndValues.BASEURLSALIX
|
||||
import es.verdnatura.domain.ConstAndValues.BASE_URL_LILIUM
|
||||
import es.verdnatura.domain.ConstAndValues.BASE_URL_SALIX
|
||||
import es.verdnatura.domain.ConstAndValues.COMPANYFK
|
||||
import es.verdnatura.domain.ConstAndValues.ENTRYID
|
||||
import es.verdnatura.domain.ConstAndValues.ENTRYNUMBERIMAGES
|
||||
import es.verdnatura.domain.ConstAndValues.ENTRYOBSERVATIONORIGINAL
|
||||
import es.verdnatura.domain.ConstAndValues.ENTRYOBSERVATIONS
|
||||
import es.verdnatura.domain.ConstAndValues.ITEMPACKING
|
||||
|
@ -261,11 +263,13 @@ class DataStoreLocal(var mobileApplication: MobileApplication) {
|
|||
}
|
||||
|
||||
suspend fun deleteEntryPackaging() {
|
||||
mobileApplication.dataStoreApp.editDataStoreKey(ENTRYID, "")
|
||||
mobileApplication.dataStoreApp.editDataStoreKey(SUPPLIERID, "")
|
||||
mobileApplication.dataStoreApp.editDataStoreKey(ENTRYID, -1)
|
||||
mobileApplication.dataStoreApp.editDataStoreKey(SUPPLIERID, -1)
|
||||
mobileApplication.dataStoreApp.editDataStoreKey(SUPPLIERNAME, "")
|
||||
mobileApplication.dataStoreApp.editDataStoreKey(ENTRYOBSERVATIONORIGINAL, "")
|
||||
mobileApplication.dataStoreApp.editDataStoreKey(ENTRYOBSERVATIONS, "")
|
||||
mobileApplication.dataStoreApp.editDataStoreKey(ENTRYNUMBERIMAGES, 0)
|
||||
mobileApplication.dataStoreApp.editDataStoreKey(COMPANYFK, -1)
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -6,6 +6,7 @@ import androidx.room.Database
|
|||
import androidx.room.Delete
|
||||
import androidx.room.Insert
|
||||
import androidx.room.OnConflictStrategy
|
||||
import androidx.room.ProvidedTypeConverter
|
||||
import androidx.room.Query
|
||||
import androidx.room.Room
|
||||
import androidx.room.RoomDatabase
|
||||
|
@ -46,7 +47,10 @@ abstract class DeliveryDatabase : RoomDatabase() {
|
|||
return INSTANCE ?: synchronized(this) {
|
||||
val instance = Room.databaseBuilder(
|
||||
context.applicationContext, DeliveryDatabase::class.java, "expedition_database"
|
||||
).fallbackToDestructiveMigration().build()
|
||||
).fallbackToDestructiveMigration(true)
|
||||
.addTypeConverter(MapTypeConverter())
|
||||
.fallbackToDestructiveMigration(true)
|
||||
.build()
|
||||
INSTANCE = instance
|
||||
instance
|
||||
}
|
||||
|
@ -135,6 +139,7 @@ interface ClientTicketDao {
|
|||
|
||||
}
|
||||
|
||||
@ProvidedTypeConverter
|
||||
class MapTypeConverter {
|
||||
private val gson = Gson()
|
||||
|
||||
|
@ -182,13 +187,24 @@ class MapTypeConverter {
|
|||
}
|
||||
|
||||
@TypeConverter
|
||||
fun fromTickets(tickets: MutableList<Ticket?>): String? {
|
||||
fun fromTickets(tickets: MutableList<Ticket>): String? {
|
||||
return gson.toJson(tickets)
|
||||
}
|
||||
|
||||
@TypeConverter
|
||||
fun toTickets(json: String?): MutableList<Ticket?> {
|
||||
fun toTickets(json: String?): MutableList<Ticket> {
|
||||
val type = object : TypeToken<MutableList<Ticket>>() {}.type
|
||||
return gson.fromJson(json, type)
|
||||
}
|
||||
|
||||
@TypeConverter
|
||||
fun fromNullableMap(map: MutableMap<String?, String?>): String {
|
||||
return gson.toJson(map)
|
||||
}
|
||||
|
||||
@TypeConverter
|
||||
fun toNullableMap(json: String): MutableMap<String?, String?> {
|
||||
val type = object : TypeToken<MutableMap<String?, String?>>() {}.type
|
||||
return gson.fromJson(json, type)
|
||||
}
|
||||
}
|
|
@ -4,6 +4,7 @@ import es.verdnatura.presentation.view.feature.ajustes.fragment.AjustesViewModel
|
|||
import es.verdnatura.presentation.view.feature.articulo.fragment.ItemCardViewModel
|
||||
import es.verdnatura.presentation.view.feature.boxPicking.BoxPickingViewModel
|
||||
import es.verdnatura.presentation.view.feature.buffer.fragment.BufferFragmentViewModel
|
||||
import es.verdnatura.presentation.view.feature.buscaritem.fragment.BuscarItemComposeViewModel
|
||||
import es.verdnatura.presentation.view.feature.buscaritem.fragment.BuscarItemViewModel
|
||||
import es.verdnatura.presentation.view.feature.category.ChangeCategoryViewModel
|
||||
import es.verdnatura.presentation.view.feature.claim.fragment.ubication.ClaimViewModel
|
||||
|
@ -13,10 +14,9 @@ import es.verdnatura.presentation.view.feature.collection.fragment.CollectionVie
|
|||
import es.verdnatura.presentation.view.feature.controlvehiculo.fragment.ControlVehiculoViewModel
|
||||
import es.verdnatura.presentation.view.feature.delivery.viewmodels.DeliveryViewModel
|
||||
import es.verdnatura.presentation.view.feature.diadeventa.fragment.DayOfSaleViewModel
|
||||
import es.verdnatura.presentation.view.feature.diadeventa.fragment.DayOfSaleViewModelCompose
|
||||
import es.verdnatura.presentation.view.feature.historicoarticulo.fragment.HistoricoArticuloViewModel
|
||||
import es.verdnatura.presentation.view.feature.historicoshelving.fragment.ItemShelvingLogViewModel
|
||||
import es.verdnatura.presentation.view.feature.historicoshelvinglog.fragment.ShelvingLogViewModel
|
||||
import es.verdnatura.presentation.view.feature.historicovehiculo.fragment.HistoricoVehiculoViewModel
|
||||
import es.verdnatura.presentation.view.feature.inventario.fragment.InventaryViewModel
|
||||
import es.verdnatura.presentation.view.feature.login.fragment.LoginViewModel
|
||||
import es.verdnatura.presentation.view.feature.packaging.fragment.SupplierViewModel
|
||||
|
@ -24,6 +24,7 @@ import es.verdnatura.presentation.view.feature.packingHolland.fragment.PackingHo
|
|||
import es.verdnatura.presentation.view.feature.paletizador.fragment.CmrExpeditionPalletViewModel
|
||||
import es.verdnatura.presentation.view.feature.paletizador.fragment.ExpeditionPalletDetailViewModel
|
||||
import es.verdnatura.presentation.view.feature.paletizador.fragment.ExpeditionScanSorterViewModel
|
||||
import es.verdnatura.presentation.view.feature.paletizador.fragment.ExpeditionScanSorterViewModelCompose
|
||||
import es.verdnatura.presentation.view.feature.paletizador.fragment.ExpeditionScanViewModel
|
||||
import es.verdnatura.presentation.view.feature.paletizador.fragment.ExpeditionStateViewModel
|
||||
import es.verdnatura.presentation.view.feature.paletizador.fragment.ExpeditionTruckListViewModel
|
||||
|
@ -37,15 +38,17 @@ import es.verdnatura.presentation.view.feature.sacador.fragment.SacadorViewModel
|
|||
import es.verdnatura.presentation.view.feature.sacador.fragment.showticket.ShowTicketViewModel
|
||||
import es.verdnatura.presentation.view.feature.ticket.fragment.TicketViewModel
|
||||
import es.verdnatura.presentation.view.feature.ubicador.fragment.UbicadorViewModel
|
||||
import es.verdnatura.presentation.view.feature.workermistake.fragment.WorkerMistakeViewModel
|
||||
import org.koin.android.ext.koin.androidApplication
|
||||
import org.koin.android.ext.koin.androidContext
|
||||
import org.koin.androidx.viewmodel.dsl.viewModel
|
||||
import org.koin.dsl.module
|
||||
|
||||
val viewModelModule = module {
|
||||
|
||||
/* viewModel {
|
||||
WorkermistakeViewModel()
|
||||
}*/
|
||||
viewModel {
|
||||
WorkerMistakeViewModel(androidApplication())
|
||||
}
|
||||
|
||||
// Login
|
||||
viewModel {
|
||||
|
@ -60,6 +63,9 @@ val viewModelModule = module {
|
|||
viewModel {
|
||||
DayOfSaleViewModel(androidContext())
|
||||
}
|
||||
viewModel {
|
||||
DayOfSaleViewModelCompose(androidApplication())
|
||||
}
|
||||
|
||||
// Pasilleros / Item Card
|
||||
viewModel {
|
||||
|
@ -76,6 +82,10 @@ val viewModelModule = module {
|
|||
BuscarItemViewModel(androidContext())
|
||||
}
|
||||
|
||||
viewModel {
|
||||
BuscarItemComposeViewModel(androidApplication())
|
||||
}
|
||||
|
||||
// Pasilleros / Buscar Item 2
|
||||
|
||||
viewModel {
|
||||
|
@ -103,6 +113,10 @@ val viewModelModule = module {
|
|||
ExpeditionScanSorterViewModel(androidContext())
|
||||
}
|
||||
|
||||
viewModel {
|
||||
ExpeditionScanSorterViewModelCompose(androidApplication())
|
||||
}
|
||||
|
||||
|
||||
viewModel {
|
||||
CmrExpeditionPalletViewModel(androidContext())
|
||||
|
@ -158,13 +172,6 @@ val viewModelModule = module {
|
|||
ControlVehiculoViewModel(androidContext())
|
||||
}
|
||||
|
||||
viewModel {
|
||||
HistoricoVehiculoViewModel(androidContext())
|
||||
}
|
||||
|
||||
viewModel {
|
||||
ItemShelvingLogViewModel(androidContext())
|
||||
}
|
||||
viewModel {
|
||||
ShelvingLogViewModel(androidContext())
|
||||
}
|
||||
|
|
|
@ -42,6 +42,7 @@ object ConstAndValues {
|
|||
const val SUPPLIERID = "SUPPLIERID"
|
||||
const val SUPPLIERNAME = "SUPPLIERNAME"
|
||||
const val ENTRYID = "ENTRYID"
|
||||
const val COMPANYFK = "COMPANYFK"
|
||||
const val ENTRYOBSERVATIONORIGINAL = "ENTRYOBSERVATIONORIGINAL"
|
||||
const val ITEMPACKING = "itemPackingType"
|
||||
const val ITEMPACKINGFK = "itemPackingTypeFk"
|
||||
|
@ -70,6 +71,10 @@ object ConstAndValues {
|
|||
const val LIMITRECORDSSHELVINGLOG = 50
|
||||
const val RESERVATIONMODE = "operatorReservationMode"
|
||||
const val MODELWORKERTYPEACTIVITY = "APP"
|
||||
const val FLINGTHRESHOLDVELOCITY = 2000f
|
||||
const val FLINGTHRESHOLDVERTICAL = 500f
|
||||
const val SCANNER_THRESHOLD_SPEED: Int = 60
|
||||
const val HUMAN_CHARACTERS_SECOND: Int = 100
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -1,16 +1,16 @@
|
|||
package es.verdnatura.domain
|
||||
|
||||
import android.app.Activity
|
||||
import android.content.Context
|
||||
import android.graphics.Color
|
||||
import android.graphics.drawable.GradientDrawable
|
||||
import android.os.Build
|
||||
import android.text.Html
|
||||
import android.view.Gravity
|
||||
import android.view.LayoutInflater
|
||||
import android.view.ViewGroup
|
||||
import android.widget.EditText
|
||||
import android.widget.FrameLayout
|
||||
import android.widget.TextView
|
||||
import android.widget.Toast
|
||||
import androidx.annotation.RequiresApi
|
||||
import es.verdnatura.R
|
||||
import java.text.SimpleDateFormat
|
||||
import java.time.ZonedDateTime
|
||||
|
@ -30,7 +30,6 @@ fun List<Any?>.formatWithQuotes(): String {
|
|||
} + "]"
|
||||
}
|
||||
|
||||
@RequiresApi(Build.VERSION_CODES.N)
|
||||
fun Any.toast(
|
||||
context: Context?,
|
||||
duration: Int = Toast.LENGTH_SHORT,
|
||||
|
@ -41,30 +40,37 @@ fun Any.toast(
|
|||
Html.fromHtml("<font color='$color' ><b>$this</b></font>", 0),
|
||||
duration
|
||||
)
|
||||
//toast2.setGravity(Gravity.TOP, 0, 0)
|
||||
toast.show()
|
||||
return toast.apply { show() }
|
||||
}
|
||||
|
||||
fun Context.showToastCenterWithBackground(textToShow: String) {
|
||||
val inflater = LayoutInflater.from(this)
|
||||
val layout = inflater.inflate(R.layout.ticket_toast_layout, null)
|
||||
val text = layout.findViewById<TextView>(R.id.toast_text)
|
||||
text.text = "$textToShow"
|
||||
text.setTextColor(this.getColor(R.color.verdnatura_orange_salix))
|
||||
text.textSize = 18f
|
||||
|
||||
val background = GradientDrawable().apply {
|
||||
setColor(Color.parseColor("#000000"))
|
||||
(this as? Activity)?.window?.decorView?.let { rootView ->
|
||||
TextView(this).apply {
|
||||
text = textToShow
|
||||
setTextColor(getColor(R.color.verdnatura_orange_salix))
|
||||
textSize = 22f
|
||||
gravity = Gravity.CENTER
|
||||
setPadding(32, 16, 32, 16)
|
||||
background = GradientDrawable().apply {
|
||||
setColor(Color.BLACK)
|
||||
cornerRadius = 16f
|
||||
alpha = 220
|
||||
}
|
||||
layout.background = background
|
||||
layoutParams = FrameLayout.LayoutParams(
|
||||
ViewGroup.LayoutParams.WRAP_CONTENT,
|
||||
ViewGroup.LayoutParams.WRAP_CONTENT
|
||||
).apply { gravity = Gravity.CENTER }
|
||||
alpha = 0f
|
||||
|
||||
Toast(this).apply {
|
||||
duration = Toast.LENGTH_LONG
|
||||
view = layout
|
||||
setGravity(Gravity.CENTER, 0, 0)
|
||||
show()
|
||||
(rootView as ViewGroup).addView(this)
|
||||
|
||||
animate().alpha(1f).setDuration(300).withEndAction {
|
||||
animate().alpha(0f).setStartDelay(1000).setDuration(300)
|
||||
.withEndAction { (rootView).removeView(this) }
|
||||
.start()
|
||||
}.start()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -95,7 +101,6 @@ fun toDateString(date: Date): String {
|
|||
return format.format(date)
|
||||
}
|
||||
|
||||
@RequiresApi(Build.VERSION_CODES.O)
|
||||
fun String?.isoToString(returnOnlyDate: Boolean = false): String {
|
||||
|
||||
return if (!this.isNullOrEmpty() && this.contains("T")) {
|
||||
|
|
|
@ -6,7 +6,6 @@ import com.google.gson.Gson
|
|||
import com.google.gson.JsonObject
|
||||
import es.verdnatura.MobileApplication
|
||||
import es.verdnatura.R
|
||||
import es.verdnatura.presentation.base.nameofFunction
|
||||
import es.verdnatura.presentation.view.feature.login.activity.LoginActivity
|
||||
import org.json.JSONObject
|
||||
import retrofit2.Call
|
||||
|
@ -51,7 +50,7 @@ abstract class SalixCallback<T>(val context: Context) : Callback<T> {
|
|||
}
|
||||
}
|
||||
|
||||
private fun defaultErrorHandler(t: Throwable) {
|
||||
fun defaultErrorHandler(t: Throwable) {
|
||||
//println("ErrorSalixx${t.message}")
|
||||
// (nameofFunction((this)) + t.message).toast(context)
|
||||
(context as MobileApplication).messageToast(
|
||||
|
@ -96,3 +95,24 @@ abstract class SalixCallback<T>(val context: Context) : Callback<T> {
|
|||
|
||||
}
|
||||
}
|
||||
|
||||
fun nameofFunction(function: Any): String {
|
||||
return try {
|
||||
function.javaClass.enclosingMethod!!.name + "->"
|
||||
} catch (e: Exception) {
|
||||
"ActivityMain->"
|
||||
}
|
||||
}
|
||||
|
||||
fun getMessageFromAllResponse(callFunction: String, responseMessage: String): String {
|
||||
|
||||
var messageFromError: String = try {
|
||||
val answerError = JSONObject(responseMessage)
|
||||
answerError.get("Message").toString()
|
||||
} catch (e: Exception) {
|
||||
responseMessage
|
||||
}
|
||||
|
||||
return "$messageFromError.\r${"Callback: $callFunction."}"
|
||||
|
||||
}
|
||||
|
|
|
@ -5,8 +5,8 @@ import es.verdnatura.presentation.common.ExpeditionPrintOut
|
|||
import es.verdnatura.presentation.common.ItemBarCodeSalix
|
||||
import es.verdnatura.presentation.common.ItemShelving
|
||||
import es.verdnatura.presentation.common.PackingSiteSalix
|
||||
import es.verdnatura.presentation.common.PickupResponse
|
||||
import es.verdnatura.presentation.common.SaleTrackingSalix
|
||||
import es.verdnatura.presentation.common.TicketPickupResponse
|
||||
import es.verdnatura.presentation.common.TicketState
|
||||
import es.verdnatura.presentation.view.feature.ajustes.model.Printers
|
||||
import es.verdnatura.presentation.view.feature.ajustes.model.SectorItemVO
|
||||
|
@ -16,7 +16,7 @@ import es.verdnatura.presentation.view.feature.articulo.model.ItemCardVO
|
|||
import es.verdnatura.presentation.view.feature.articulo.model.ItemDetails
|
||||
import es.verdnatura.presentation.view.feature.articulo.model.ItemPackingType
|
||||
import es.verdnatura.presentation.view.feature.articulo.model.ItemProposal
|
||||
import es.verdnatura.presentation.view.feature.buscaritem.model.ItemLocationVO
|
||||
import es.verdnatura.presentation.view.feature.buscaritem.model.ItemShelvings
|
||||
import es.verdnatura.presentation.view.feature.calidad.model.Buyer
|
||||
import es.verdnatura.presentation.view.feature.calidad.model.BuyerVO
|
||||
import es.verdnatura.presentation.view.feature.claim.fragment.reubication.model.Reubication
|
||||
|
@ -36,9 +36,7 @@ import es.verdnatura.presentation.view.feature.delivery.model.RouteInfo
|
|||
import es.verdnatura.presentation.view.feature.delivery.model.TicketObservation
|
||||
import es.verdnatura.presentation.view.feature.diadeventa.model.ItemShelvingSaleDate
|
||||
import es.verdnatura.presentation.view.feature.historicoarticulo.model.ItemHistoricoVO
|
||||
import es.verdnatura.presentation.view.feature.historicoshelving.model.ItemShelvingLog
|
||||
import es.verdnatura.presentation.view.feature.historicoshelvinglog.model.ShelvingLogSalix
|
||||
import es.verdnatura.presentation.view.feature.historicovehiculo.model.ItemHistoricoVehiculo
|
||||
import es.verdnatura.presentation.view.feature.inventario.model.ItemInventaryVO
|
||||
import es.verdnatura.presentation.view.feature.inventario.model.ItemInventoryParking
|
||||
import es.verdnatura.presentation.view.feature.login.model.AccessConfigSalix
|
||||
|
@ -52,6 +50,7 @@ import es.verdnatura.presentation.view.feature.login.model.OperatorSalix
|
|||
import es.verdnatura.presentation.view.feature.login.model.RenewToken
|
||||
import es.verdnatura.presentation.view.feature.login.model.VersionApp
|
||||
import es.verdnatura.presentation.view.feature.login.model.WorkerData
|
||||
import es.verdnatura.presentation.view.feature.packaging.model.DmsType
|
||||
import es.verdnatura.presentation.view.feature.packaging.model.EntrySalix
|
||||
import es.verdnatura.presentation.view.feature.packaging.model.ItemSupplier
|
||||
import es.verdnatura.presentation.view.feature.packaging.model.NotificationQueue
|
||||
|
@ -70,6 +69,7 @@ import es.verdnatura.presentation.view.feature.roadmap.model.RoadStopMapTruck
|
|||
import es.verdnatura.presentation.view.feature.roadmap.model.StopMapTruckPallet
|
||||
import es.verdnatura.presentation.view.feature.sacador.model.CollectionTicket
|
||||
import es.verdnatura.presentation.view.feature.sacador.model.CollectionVO
|
||||
import es.verdnatura.presentation.view.feature.sacador.model.ItemShelvingSale
|
||||
import es.verdnatura.presentation.view.feature.sacador.model.MistakeTypeVO
|
||||
import es.verdnatura.presentation.view.feature.sacador.model.PlacementSupplyVO
|
||||
import es.verdnatura.presentation.view.feature.sacador.model.TicketStateSalix
|
||||
|
@ -210,6 +210,11 @@ interface SalixService {
|
|||
|
||||
): Call<Any>
|
||||
|
||||
@GET("Sips/findOne")
|
||||
fun sipGetExtension(
|
||||
@Query("filter") filter: String,
|
||||
): Call<Any>
|
||||
|
||||
@GET("Workers/Summary")
|
||||
fun getNameWorker(
|
||||
@Query("filter") filter: String
|
||||
|
@ -403,7 +408,8 @@ interface SalixService {
|
|||
fun addSale(
|
||||
@Path("id") id: Number,
|
||||
@Query("quantity") quantity: Number,
|
||||
@Query("barcode") barcode: String
|
||||
@Query("barcode") barcode: String,
|
||||
@Query("isAdded") isAdded: Boolean = true
|
||||
): Call<Any>
|
||||
|
||||
@POST("Collections/assign")
|
||||
|
@ -414,6 +420,11 @@ interface SalixService {
|
|||
fun collectionAssigned(
|
||||
): Call<Int>
|
||||
|
||||
@GET("ItemShelvings")
|
||||
fun itemShelvingsGet(
|
||||
@Query("filter") filter: String
|
||||
): Call<List<ItemShelvings>>
|
||||
|
||||
@POST("ItemShelvings/updateFromSale")
|
||||
fun itemShelvingUpdateFromSale(
|
||||
@Body params: Any
|
||||
|
@ -434,16 +445,6 @@ interface SalixService {
|
|||
@Body params: Any
|
||||
): Call<Any>
|
||||
|
||||
@POST("MachineWorkers/updateInTime")
|
||||
fun machineWorkerUpdateInTime(
|
||||
@Body params: Any
|
||||
): Call<Any>
|
||||
|
||||
@POST("MachineWorkers/add")
|
||||
fun machineWorkerAdd(
|
||||
@Query("plate") plate: Any
|
||||
): Call<Any>
|
||||
|
||||
@POST("SaleTrackings/updateTracking")
|
||||
fun saleTrackingUpdate(
|
||||
@Body params: Any
|
||||
|
@ -456,7 +457,7 @@ interface SalixService {
|
|||
|
||||
@GET("ItemShelvings/getAlternative")
|
||||
fun itemShelvingAlternative(
|
||||
@Query("shelvingFk") shelvingFk: String
|
||||
@Query("shelvingCode") shelvingFk: String
|
||||
): Call<ArrayList<Reubication>>
|
||||
|
||||
@GET("MobileAppVersionControls/getVersion")
|
||||
|
@ -480,11 +481,6 @@ interface SalixService {
|
|||
@Query("params") params: Any? = null, @Query("schema") schema: String = "vn"
|
||||
): Call<List<PlacementSupplyVO>>
|
||||
|
||||
@POST("Applications/machineWorker_getHistorical/execute-proc")
|
||||
fun machineWorkerGetHistorical(
|
||||
@Query("params") params: Any? = null, @Query("schema") schema: String = "vn"
|
||||
): Call<List<ItemHistoricoVehiculo>>
|
||||
|
||||
@POST("Applications/expedition_getFromRoute/execute-proc")
|
||||
fun expeditionGetFromRoute(
|
||||
@Query("params") params: Any? = null, @Query("schema") schema: String = "vn"
|
||||
|
@ -530,18 +526,6 @@ interface SalixService {
|
|||
@Query("params") params: Any? = null, @Query("schema") schema: String = "vn"
|
||||
): Call<Any>
|
||||
|
||||
@GET("ItemShelvings/getListItemNewer")
|
||||
fun getListItemNewer(
|
||||
@Query("shelvingFk") shelvingFkIn: Any, @Query("parking") parking: Any? = null
|
||||
): Call<List<ItemShelvingNewer>>
|
||||
|
||||
@GET("ItemShelvings/getListItemNewer")
|
||||
fun getListItemNewerNew(
|
||||
@Query("shelvingFk") shelvingFkIn: Any,
|
||||
@Query("parking") parking: Any? = null,
|
||||
@Query("itemFk") itemFk: Any? = null
|
||||
): Call<List<ItemShelvingNewer>>
|
||||
|
||||
@GET("ItemShelvings/getItemsByReviewOrder")
|
||||
fun getItemsByReviewOrder(
|
||||
@Query("shelving") shelvingFkIn: Any,
|
||||
|
@ -564,11 +548,6 @@ interface SalixService {
|
|||
@Query("params") params: Any? = null, @Query("schema") schema: String = "vn"
|
||||
): Call<Any>
|
||||
|
||||
/* @POST("Applications/machine_getWorkerPlate/execute-proc")
|
||||
fun machineGetWorkerPlate(
|
||||
@Query("params") params: Any? = null, @Query("schema") schema: String = "vn"
|
||||
): Call<List<JsonObject>>*/
|
||||
|
||||
@POST("Applications/sectorCollection_get/execute-proc")
|
||||
fun sectorCollectionGet(
|
||||
@Query("params") params: Any? = null, @Query("schema") schema: String = "vn"
|
||||
|
@ -637,12 +616,7 @@ interface SalixService {
|
|||
@GET("Tickets")
|
||||
fun ticketIsPickup(
|
||||
@Query("filter") filter: Any, @Query("schema") schema: String = "vn"
|
||||
): Call<List<PickupResponse>>
|
||||
|
||||
@POST("Applications/workerMachinery_isRegistered/execute-func")
|
||||
fun workerMachineryIsRegistered(
|
||||
@Query("params") params: Any, @Query("schema") schema: String = "vn"
|
||||
): Call<String>
|
||||
): Call<List<TicketPickupResponse>>
|
||||
|
||||
@POST("Applications/ticket_printLabelPrevious/execute-proc")
|
||||
fun ticketPrintLabelPrevious(
|
||||
|
@ -711,17 +685,6 @@ interface SalixService {
|
|||
@Query("params") params: Any,
|
||||
): Call<Any>
|
||||
|
||||
@GET("ItemShelvingLogs")
|
||||
fun itemShelvingLogGet(
|
||||
@Query("filter") filter: String,
|
||||
): Call<List<ItemShelvingLog>>
|
||||
|
||||
@POST("Applications/itemshelving_getInfo/execute-proc")
|
||||
fun itemshelvingGetInfo(
|
||||
@Query("schema") schema: String = "vn",
|
||||
@Query("params") params: Any,
|
||||
): Call<List<ItemLocationVO>>
|
||||
|
||||
@POST("Applications/itemShelving_get/execute-proc")
|
||||
fun itemShelvingListNew(
|
||||
@Query("schema") schema: String = "vn",
|
||||
|
@ -935,6 +898,11 @@ interface SalixService {
|
|||
@Body parms: PackingSiteSalix
|
||||
): Call<Unit>
|
||||
|
||||
@GET("Tickets/{id}/exists")
|
||||
fun ticketExists(
|
||||
@Path("id") id: Number,
|
||||
): Call<JsonObject>
|
||||
|
||||
@PUT("ItemBarCodes")
|
||||
fun barcodesEdit(
|
||||
@Body params: ItemBarCodeSalix
|
||||
|
@ -960,6 +928,11 @@ interface SalixService {
|
|||
fun getWithPackaging(
|
||||
): Call<List<Supplier>>
|
||||
|
||||
@GET("DmsTypes/findOne")
|
||||
fun getDmsType(
|
||||
@Query("filter") filter: String
|
||||
): Call<DmsType>
|
||||
|
||||
@GET("Entries")
|
||||
fun getEntriesFromSupplier(
|
||||
@Query("filter") filter: String
|
||||
|
@ -1067,6 +1040,11 @@ interface SalixService {
|
|||
@Path("id") id: Number,
|
||||
): Call<JsonObject>
|
||||
|
||||
@GET("ItemShelvingSales")
|
||||
fun itemShelvingSaleTotalBySale(
|
||||
@Query("filter") filter: String,
|
||||
): Call<List<ItemShelvingSale>>
|
||||
|
||||
@PATCH("ItemShelvingSales/{id}")
|
||||
fun itemShelvingsReservedUpdate(
|
||||
@Path("id") id: Number, @Body params: Any
|
||||
|
@ -1077,10 +1055,16 @@ interface SalixService {
|
|||
@Path("id") id: Number
|
||||
): Call<ItemShelving>
|
||||
|
||||
@POST("ItemShelvingSales/itemShelvingSale_addByCollection")
|
||||
@POST("Applications/itemShelvingSale_addByCollection/execute-proc")
|
||||
fun itemShelvingSaleAddByCollection(
|
||||
@Query("schema") schema: String = "vn",
|
||||
@Query("params") params: Any? = null
|
||||
): Call<Any>
|
||||
|
||||
/* @POST("ItemShelvingSales/itemShelvingSale_addByCollection")
|
||||
fun itemShelvingSaleAddByCollection(
|
||||
@Body params: Any,
|
||||
): Call<Any>
|
||||
): Call<Any>*/
|
||||
|
||||
@POST("ItemShelvings/getInventory")
|
||||
fun getInventoryParking(
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
package es.verdnatura.domain.userCases
|
||||
|
||||
import es.verdnatura.domain.SalixService
|
||||
import es.verdnatura.presentation.view.feature.packaging.model.NotificationQueue
|
||||
import es.verdnatura.presentation.view.feature.pasillero.model.WorkerActionSalix
|
||||
import retrofit2.Call
|
||||
|
||||
class GetItemFromBarcodeUseCase(private val salixService: SalixService) {
|
||||
|
@ -18,3 +20,24 @@ class GetItemPrintItemUseCase(private val salixService: SalixService) {
|
|||
return salixService.buyGetLastWithoutInventory(params)
|
||||
}
|
||||
}
|
||||
|
||||
class NotiticationUseCase(private val salixService: SalixService) {
|
||||
fun executeSendNotification(notificationQueue: NotificationQueue): Call<Void> {
|
||||
return salixService.notificationQueues(notificationQueue)
|
||||
}
|
||||
}
|
||||
|
||||
class WorkerActivityUseCase(private val salixService: SalixService) {
|
||||
fun addWorkerActivity(workerActionSalix: WorkerActionSalix): Call<Any> {
|
||||
return salixService.workerActivityAdd(workerActionSalix)
|
||||
}
|
||||
}
|
||||
|
||||
class OperatorUseCase(private val salixService: SalixService) {
|
||||
fun updateOperator(workerFk: Number, update: HashMap<String, Number>): Call<Unit> {
|
||||
return salixService.updateOperator(
|
||||
id = workerFk,
|
||||
params = update
|
||||
)
|
||||
}
|
||||
}
|
|
@ -17,6 +17,7 @@ import es.verdnatura.MobileApplication
|
|||
import es.verdnatura.R
|
||||
import es.verdnatura.databinding.ToolbarFragmentBinding
|
||||
import es.verdnatura.db.DeliveryDatabase
|
||||
import es.verdnatura.db.MapTypeConverter
|
||||
import es.verdnatura.presentation.view.feature.main.activity.MainActivity
|
||||
import org.koin.androidx.viewmodel.ext.android.viewModel
|
||||
import kotlin.reflect.KClass
|
||||
|
@ -135,6 +136,8 @@ abstract class BaseFragment<T : ViewDataBinding, V : BaseViewModel>(
|
|||
R.drawable.ic_sign_ticket -> getString(R.string.signed)
|
||||
R.drawable.ic_send -> getString(R.string.sendDriverRoute)
|
||||
R.drawable.ic_add_multiple -> getString(R.string.addItemMultipleShelvings)
|
||||
R.drawable.ic_clean_shelving -> getString(R.string.activityOrganize)
|
||||
R.drawable.ic_booking -> getString(R.string.bookingNewSalesCollection)
|
||||
else -> {
|
||||
""
|
||||
}
|
||||
|
@ -170,7 +173,8 @@ fun database(myContext: Context): DeliveryDatabase {
|
|||
return Room.databaseBuilder(
|
||||
myContext,
|
||||
DeliveryDatabase::class.java, "expediciones.db"
|
||||
).build()
|
||||
).addTypeConverter(MapTypeConverter())
|
||||
.build()
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -5,7 +5,6 @@ import androidx.lifecycle.LifecycleObserver
|
|||
import androidx.lifecycle.ViewModel
|
||||
import es.verdnatura.MobileApplication
|
||||
import es.verdnatura.domain.SalixService
|
||||
import org.json.JSONObject
|
||||
|
||||
abstract class BaseViewModel : ViewModel, LifecycleObserver {
|
||||
lateinit var app: MobileApplication
|
||||
|
@ -18,23 +17,3 @@ abstract class BaseViewModel : ViewModel, LifecycleObserver {
|
|||
}
|
||||
}
|
||||
|
||||
fun nameofFunction(function: Any): String {
|
||||
return try {
|
||||
function.javaClass.enclosingMethod!!.name + "->"
|
||||
} catch (e: Exception) {
|
||||
"ActivityMain->"
|
||||
}
|
||||
}
|
||||
|
||||
fun getMessageFromAllResponse(callFunction: String, responseMessage: String): String {
|
||||
|
||||
var messageFromError: String = try {
|
||||
val answerError = JSONObject(responseMessage)
|
||||
answerError.get("Message").toString()
|
||||
} catch (e: Exception) {
|
||||
responseMessage
|
||||
}
|
||||
|
||||
return "$messageFromError.\r${"Callback: $callFunction."}"
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
package es.verdnatura.presentation.base
|
||||
|
||||
import android.app.Application
|
||||
import androidx.lifecycle.LifecycleObserver
|
||||
import androidx.lifecycle.ViewModel
|
||||
import es.verdnatura.MobileApplication
|
||||
import es.verdnatura.domain.SalixService
|
||||
|
||||
abstract class BaseViewModelCompose(application: Application) : ViewModel(), LifecycleObserver {
|
||||
protected val app: MobileApplication = application as MobileApplication
|
||||
protected val salix: SalixService = app.salix
|
||||
|
||||
}
|
|
@ -4,13 +4,18 @@ import android.app.AlertDialog
|
|||
import android.content.Context
|
||||
import android.text.InputType
|
||||
import android.view.View
|
||||
import android.view.inputmethod.EditorInfo
|
||||
import es.verdnatura.R
|
||||
import es.verdnatura.domain.toast
|
||||
import es.verdnatura.presentation.view.component.CustomDialogInput
|
||||
import es.verdnatura.presentation.view.component.CustomDialogList
|
||||
|
||||
class PrinterDialogManager(private val context: Context) {
|
||||
fun showPrintDialog(
|
||||
item: Long, itemName: String, onPrintClick: (Long, String, Int?, Int) -> Unit
|
||||
item: Long,
|
||||
itemName: String,
|
||||
onPrintClick: (Long, String, Int?, Int) -> Unit,
|
||||
onPrintChange: (String) -> Unit
|
||||
) {
|
||||
val customDialogList = CustomDialogList(context)
|
||||
customDialogList.getEditText().setRawInputType(InputType.TYPE_CLASS_NUMBER)
|
||||
|
@ -23,7 +28,9 @@ class PrinterDialogManager(private val context: Context) {
|
|||
}.setOkTwoButton(context.getString(R.string.printBarcode)) {
|
||||
handlePrintClick(item, customDialogList, onPrintClick, "barcode")
|
||||
customDialogList.dismiss()
|
||||
|
||||
//Tarea 7823
|
||||
}.setOkThreeButton(context.getString(R.string.changePrinter)) {
|
||||
readQrPrinter(onPrintChange)
|
||||
}.setKoButton(context.getString(R.string.cancel)) {
|
||||
customDialogList.dismiss()
|
||||
}.setHintValueThree(context.getString(R.string.labelNumber))
|
||||
|
@ -32,6 +39,30 @@ class PrinterDialogManager(private val context: Context) {
|
|||
customDialogList.getFocusThree()
|
||||
}
|
||||
|
||||
private fun readQrPrinter(onPrintChange: (String) -> Unit) {
|
||||
val customDialogInput = CustomDialogInput(context)
|
||||
|
||||
customDialogInput.setTitle(context.getString(R.string.changePrinter))
|
||||
.setDescription(context.getString(R.string.scanQrPrinter))
|
||||
.setOkButton(context.getString(R.string.save)) {
|
||||
onPrintChange(customDialogInput.getValue())
|
||||
customDialogInput.dismiss()
|
||||
|
||||
}.setKoButton(context.getString(R.string.cancel)) {
|
||||
customDialogInput.dismiss()
|
||||
}.setValue("").show()
|
||||
customDialogInput.getEditText().requestFocus()
|
||||
customDialogInput.getEditText().setOnEditorActionListener { _, actionId, _ ->
|
||||
if (actionId == EditorInfo.IME_ACTION_SEARCH || actionId == EditorInfo.IME_ACTION_DONE || actionId == 0) {
|
||||
onPrintChange(customDialogInput.getValue())
|
||||
println("printerrr ${customDialogInput.getValue()}")
|
||||
customDialogInput.dismiss()
|
||||
return@setOnEditorActionListener true
|
||||
}
|
||||
false
|
||||
}
|
||||
}
|
||||
|
||||
private fun handlePrintClick(
|
||||
item: Long,
|
||||
customDialogList: CustomDialogList,
|
||||
|
|
|
@ -26,9 +26,9 @@ data class SaleTrackingSalix(
|
|||
|
||||
)
|
||||
|
||||
class PackingSiteSalix(
|
||||
var ticketFk: Int,
|
||||
var workerFk: Int
|
||||
data class PackingSiteSalix(
|
||||
val ticketFk: Number,
|
||||
val workerFk: Number
|
||||
|
||||
)
|
||||
|
||||
|
@ -43,7 +43,10 @@ data class ItemShelving(
|
|||
var itemFk: Int,
|
||||
var shelvingFk: String,
|
||||
var position: Int,
|
||||
var quantity: Int
|
||||
var quantity: Int,
|
||||
var visible: Int? = null,
|
||||
var available: Int? = null
|
||||
|
||||
)
|
||||
|
||||
data class ItemShelvingSalix(
|
||||
|
@ -98,14 +101,8 @@ data class ExpeditionPrintOut(
|
|||
val isChecked: Boolean
|
||||
)
|
||||
|
||||
data class PickupResponse(
|
||||
val routeFk: Int,
|
||||
val route: Route?
|
||||
)
|
||||
|
||||
data class Route(
|
||||
data class TicketPickupResponse(
|
||||
val id: Int,
|
||||
val agencyModeFk: Int,
|
||||
val agencyMode: AgencyMode?
|
||||
)
|
||||
|
||||
|
|
|
@ -6,7 +6,6 @@ import es.verdnatura.presentation.view.feature.ajustes.model.AjustesItemVO
|
|||
import es.verdnatura.presentation.view.feature.articulo.model.BarcodeVO
|
||||
import es.verdnatura.presentation.view.feature.articulo.model.ItemCardRowVO
|
||||
import es.verdnatura.presentation.view.feature.articulo.model.ItemProposal
|
||||
import es.verdnatura.presentation.view.feature.buscaritem.model.ItemLocationVO
|
||||
import es.verdnatura.presentation.view.feature.claim.fragment.reubication.model.Reubication
|
||||
import es.verdnatura.presentation.view.feature.delivery.model.ClientTicketSalix
|
||||
import es.verdnatura.presentation.view.feature.delivery.model.ExpeditionInfoSummary
|
||||
|
@ -140,10 +139,6 @@ interface OnTrashItemRowClickListener {
|
|||
fun onTrashItemRowClickListener(item: WorkForms)
|
||||
}
|
||||
|
||||
interface OnLocationRowClickListener {
|
||||
fun onLocationRowClickListener(item: ItemLocationVO)
|
||||
}
|
||||
|
||||
interface OnInvetoryNichoClickListener {
|
||||
fun onInvetoryNichoClickListener(item: ItemInventaryVO)
|
||||
}
|
||||
|
@ -160,6 +155,10 @@ interface OnClientHistoricItemClickListener {
|
|||
fun onClientHistoricItemClickListener(item: ItemHistoricoVO)
|
||||
}
|
||||
|
||||
interface OnOutQuantityHistoricItemClickListener {
|
||||
fun onOutQuantityHistoricItemClickListener(item: ItemHistoricoVO)
|
||||
}
|
||||
|
||||
interface OnVisibleClickListener {
|
||||
fun onVisibleClickListener(item: ItemUbicadorVO)
|
||||
}
|
||||
|
|
|
@ -12,7 +12,6 @@ import android.os.Build
|
|||
import android.os.Bundle
|
||||
import android.os.Handler
|
||||
import android.os.Looper
|
||||
import android.text.InputType
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.view.ViewTreeObserver
|
||||
|
@ -169,7 +168,7 @@ fun Context.hideKeyboard(view: View) {
|
|||
|
||||
fun Context.showKeyboard() {
|
||||
val imm = getSystemService(Activity.INPUT_METHOD_SERVICE) as InputMethodManager?
|
||||
imm!!.toggleSoftInput(InputType.TYPE_CLASS_NUMBER, 0)
|
||||
imm!!.toggleSoftInput(InputMethodManager.SHOW_FORCED, 0)
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@ import java.text.SimpleDateFormat
|
|||
import java.util.Calendar
|
||||
import java.util.Locale
|
||||
|
||||
class FunctionUtils{
|
||||
class FunctionUtils {
|
||||
fun getMessageFromJSON(json: String): String {
|
||||
val gson = Gson()
|
||||
var message = ""
|
||||
|
@ -38,9 +38,11 @@ class FunctionUtils{
|
|||
|
||||
private fun getCurdate(date: String, context: Context): String {
|
||||
val c = Calendar.getInstance()
|
||||
val df = SimpleDateFormat(context.getString(R.string.dateCompleteFormat), Locale.getDefault())
|
||||
val df =
|
||||
SimpleDateFormat(context.getString(R.string.dateCompleteFormat), Locale.getDefault())
|
||||
val df2 = SimpleDateFormat(context.getString(R.string.timeFormat), Locale.getDefault())
|
||||
c.time = df.parse(date)!!
|
||||
return df2.format(c.time)
|
||||
}
|
||||
|
||||
}
|
|
@ -55,10 +55,15 @@ fun itemScanValue(value: String, table: Array<String>, field: String): Any {
|
|||
"more" -> return item.more
|
||||
}
|
||||
}
|
||||
|
||||
"expeditionPallet" -> {
|
||||
return item.id
|
||||
}
|
||||
|
||||
"printer" -> {
|
||||
return item.id
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
throw Exception("QR no válido")
|
||||
|
|
|
@ -0,0 +1,264 @@
|
|||
package es.verdnatura.presentation.composable
|
||||
|
||||
import androidx.compose.foundation.background
|
||||
import androidx.compose.foundation.border
|
||||
import androidx.compose.foundation.layout.Arrangement
|
||||
import androidx.compose.foundation.layout.Box
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.Row
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.foundation.layout.height
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.layout.wrapContentSize
|
||||
import androidx.compose.foundation.lazy.LazyRow
|
||||
import androidx.compose.foundation.lazy.items
|
||||
import androidx.compose.foundation.shape.RoundedCornerShape
|
||||
import androidx.compose.foundation.text.KeyboardActions
|
||||
import androidx.compose.foundation.text.KeyboardOptions
|
||||
import androidx.compose.material3.ExperimentalMaterial3Api
|
||||
import androidx.compose.material3.HorizontalDivider
|
||||
import androidx.compose.material3.Icon
|
||||
import androidx.compose.material3.IconButton
|
||||
import androidx.compose.material3.PlainTooltip
|
||||
import androidx.compose.material3.Switch
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.material3.TextField
|
||||
import androidx.compose.material3.TextFieldDefaults
|
||||
import androidx.compose.material3.TooltipBox
|
||||
import androidx.compose.material3.TooltipDefaults
|
||||
import androidx.compose.material3.rememberTooltipState
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.runtime.setValue
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Alignment.Companion.CenterVertically
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.platform.LocalSoftwareKeyboardController
|
||||
import androidx.compose.ui.res.colorResource
|
||||
import androidx.compose.ui.res.dimensionResource
|
||||
import androidx.compose.ui.res.painterResource
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.text.TextStyle
|
||||
import androidx.compose.ui.text.font.FontWeight
|
||||
import androidx.compose.ui.text.input.ImeAction
|
||||
import androidx.compose.ui.text.style.TextAlign
|
||||
import androidx.compose.ui.tooling.preview.Preview
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.compose.ui.unit.sp
|
||||
import es.verdnatura.R
|
||||
|
||||
@OptIn(ExperimentalMaterial3Api::class)
|
||||
@Composable
|
||||
fun CustomToolbar(
|
||||
title: String,
|
||||
subtitle: String? = null,
|
||||
showBackButton: Boolean = true,
|
||||
showSwitch: Boolean = false,
|
||||
iconList: List<IconToolBar> = emptyList(),
|
||||
onBackClick: () -> Unit = {},
|
||||
onSwitchChange: (Boolean) -> Unit = {},
|
||||
) {
|
||||
Column(
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.background(Color.Black)
|
||||
) {
|
||||
|
||||
Row(
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.height(56.dp),
|
||||
verticalAlignment = CenterVertically,
|
||||
horizontalArrangement = Arrangement.SpaceBetween
|
||||
|
||||
) {
|
||||
if (showBackButton) {
|
||||
IconButton(
|
||||
onClick = { onBackClick() },
|
||||
modifier = Modifier.padding(start = 0.dp),
|
||||
) {
|
||||
Icon(
|
||||
painter = painterResource(id = R.drawable.ic_chevron_left),
|
||||
contentDescription = "Back",
|
||||
tint = Color.White
|
||||
)
|
||||
}
|
||||
}
|
||||
Text(
|
||||
modifier = Modifier.weight(1f),
|
||||
text = title,
|
||||
color = Color.White,
|
||||
fontSize = dimensionResource(id = R.dimen.title).value.sp,
|
||||
fontWeight = FontWeight.Bold,
|
||||
|
||||
)
|
||||
|
||||
if (!subtitle.isNullOrEmpty()) {
|
||||
Text(
|
||||
modifier = Modifier.weight(1f),
|
||||
text = subtitle,
|
||||
color = Color.White.copy(alpha = 0.7f),
|
||||
fontSize = dimensionResource(id = R.dimen.subtitle).value.sp
|
||||
)
|
||||
}
|
||||
|
||||
if (iconList.isNotEmpty()) {
|
||||
LazyRow(
|
||||
horizontalArrangement = Arrangement.End, // Esto asegura que los iconos estén a la derecha
|
||||
) {
|
||||
items(iconList) { iconToolBar ->
|
||||
TooltipBox(
|
||||
positionProvider = TooltipDefaults.rememberPlainTooltipPositionProvider(),
|
||||
tooltip = {
|
||||
PlainTooltip {
|
||||
Text(iconToolBar.toolTip)
|
||||
}
|
||||
},
|
||||
state = rememberTooltipState()
|
||||
) {
|
||||
IconButton(
|
||||
onClick = { iconToolBar.onClickIcon() },
|
||||
) {
|
||||
|
||||
Icon(
|
||||
painter = painterResource(id = iconToolBar.idRes),
|
||||
contentDescription = iconToolBar.toolTip,
|
||||
tint = Color.White
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (showSwitch) {
|
||||
var switchState by remember { mutableStateOf(false) }
|
||||
Switch(
|
||||
checked = switchState,
|
||||
onCheckedChange = {
|
||||
switchState = it
|
||||
onSwitchChange(it)
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
HorizontalDivider(
|
||||
thickness = 1.dp,
|
||||
color = colorResource(id = R.color.verdnatura_brown_grey)
|
||||
)
|
||||
}
|
||||
|
||||
data class IconToolBar(
|
||||
val idRes: Int,
|
||||
val toolTip: String = "",
|
||||
val tint: Color = Color.White,
|
||||
val onClickIcon: () -> Unit,
|
||||
|
||||
)
|
||||
|
||||
@Composable
|
||||
fun ScanLineTextSearch(
|
||||
value: String,
|
||||
onValueChange: (String) -> Unit,
|
||||
onImeAction: () -> Unit,
|
||||
modifier: Modifier = Modifier.wrapContentSize(),
|
||||
) {
|
||||
|
||||
val keyboardController = LocalSoftwareKeyboardController.current
|
||||
|
||||
Box(
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
contentAlignment = Alignment.Center
|
||||
) {
|
||||
TextField(
|
||||
value = value,
|
||||
onValueChange = onValueChange,
|
||||
textStyle = TextStyle(
|
||||
color = Color.White,
|
||||
textAlign = TextAlign.Center
|
||||
),
|
||||
placeholder = {
|
||||
Box(
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
contentAlignment = Alignment.Center
|
||||
) {
|
||||
Text(
|
||||
text = stringResource(id = R.string.Escaneaetiqueta),
|
||||
textAlign = TextAlign.Center,
|
||||
color = Color.White,
|
||||
modifier = Modifier.fillMaxWidth()
|
||||
)
|
||||
}
|
||||
},
|
||||
singleLine = true,
|
||||
keyboardActions = KeyboardActions(
|
||||
onDone = {
|
||||
onImeAction()
|
||||
keyboardController?.hide()
|
||||
}
|
||||
|
||||
),
|
||||
keyboardOptions = KeyboardOptions.Default.copy(
|
||||
imeAction = ImeAction.Done
|
||||
),
|
||||
colors = TextFieldDefaults.colors(
|
||||
focusedContainerColor = Color.DarkGray, // Fondo cuando está enfocado
|
||||
unfocusedContainerColor = Color.DarkGray, // Fondo cuando NO está enfocado
|
||||
cursorColor = Color.White, // Color del cursor
|
||||
focusedTextColor = Color.White, // Color del texto cuando está enfocado
|
||||
unfocusedTextColor = Color.White, // Color del texto cuando NO está enfocado
|
||||
focusedPlaceholderColor = Color.Black, // Color del placeholder cuando está enfocado
|
||||
unfocusedPlaceholderColor = Color.Black // Color del placeholder cuando NO está enfocado
|
||||
),
|
||||
modifier = modifier
|
||||
.fillMaxWidth(fraction = 0.67f)
|
||||
.border(2.dp, Color.White, RoundedCornerShape(8.dp))
|
||||
.height(52.dp)
|
||||
/* .onFocusEvent {
|
||||
if (it.isFocused) {
|
||||
keyboardController?.hide()
|
||||
}
|
||||
}*/
|
||||
)
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Preview
|
||||
@Composable
|
||||
fun PreviewToolbar() {
|
||||
CustomToolbar(
|
||||
title = "Mi Toolbar",
|
||||
subtitle = "10/20",
|
||||
showBackButton = true,
|
||||
showSwitch = true,
|
||||
iconList = listOf(
|
||||
IconToolBar(
|
||||
R.drawable.ic_parking_ui, "", tint = Color.Blue,
|
||||
onClickIcon = { }
|
||||
)
|
||||
),
|
||||
onBackClick = { /* Acción de volver atrás */ },
|
||||
onSwitchChange = { /* Acción del switch */ }
|
||||
)
|
||||
}
|
||||
|
||||
@Preview
|
||||
@Composable
|
||||
fun PreviewScanLineTextSearch() {
|
||||
ScanLineTextSearch(
|
||||
value = stringResource(R.string.scanLabel),
|
||||
onValueChange = {},
|
||||
onImeAction = {})
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
package es.verdnatura.presentation.composable
|
||||
|
||||
import android.os.Bundle
|
||||
import androidx.activity.ComponentActivity
|
||||
import androidx.activity.compose.setContent
|
||||
import es.verdnatura.R
|
||||
|
||||
class ImageViewActivityComposable : ComponentActivity() {
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
setContent {
|
||||
val imageUrl = intent.getStringExtra(getString(R.string.url)) ?: ""
|
||||
val title = intent.getStringExtra(getString(R.string.title)) ?: ""
|
||||
ImageViewScreen(imageUrl = imageUrl, titleToolBar = title, onBackClick = { finish() })
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,59 @@
|
|||
package es.verdnatura.presentation.composable
|
||||
|
||||
import android.widget.ImageView
|
||||
import androidx.compose.foundation.layout.Arrangement
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.Spacer
|
||||
import androidx.compose.foundation.layout.fillMaxSize
|
||||
import androidx.compose.foundation.layout.height
|
||||
import androidx.compose.material3.ExperimentalMaterial3Api
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.tooling.preview.Preview
|
||||
import androidx.compose.ui.unit.dp
|
||||
import com.bumptech.glide.Glide
|
||||
|
||||
@OptIn(ExperimentalMaterial3Api::class)
|
||||
@Composable
|
||||
fun ImageViewScreen(imageUrl: String, titleToolBar:String ="",onBackClick: () -> Unit ) {
|
||||
|
||||
CustomToolbar(
|
||||
title = titleToolBar,
|
||||
subtitle = "",
|
||||
showBackButton = true,
|
||||
showSwitch = false,
|
||||
iconList = listOf(),
|
||||
onBackClick = onBackClick ,
|
||||
onSwitchChange = { }
|
||||
)
|
||||
Column(
|
||||
modifier = Modifier.fillMaxSize(),
|
||||
horizontalAlignment = Alignment.CenterHorizontally,
|
||||
verticalArrangement = Arrangement.Top
|
||||
) {
|
||||
|
||||
Spacer(modifier = Modifier.height(16.dp))
|
||||
GlideImage(imageUrl = imageUrl)
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
fun GlideImage(imageUrl: String) {
|
||||
androidx.compose.ui.viewinterop.AndroidView(
|
||||
factory = { context ->
|
||||
ImageView(context).apply {
|
||||
Glide.with(context)
|
||||
.load(imageUrl)
|
||||
.into(this)
|
||||
}
|
||||
},
|
||||
modifier = Modifier.fillMaxSize()
|
||||
)
|
||||
}
|
||||
|
||||
@Preview(showBackground = true)
|
||||
@Composable
|
||||
fun DefaultPreview() {
|
||||
ImageViewScreen(imageUrl = "https://example.com/image.jpg", "titleToolbar") {}
|
||||
}
|
|
@ -0,0 +1,38 @@
|
|||
package es.verdnatura.presentation.composable
|
||||
|
||||
import androidx.compose.animation.AnimatedVisibility
|
||||
import androidx.compose.animation.fadeIn
|
||||
import androidx.compose.animation.fadeOut
|
||||
import androidx.compose.foundation.layout.height
|
||||
import androidx.compose.foundation.layout.wrapContentWidth
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.res.dimensionResource
|
||||
import com.airbnb.lottie.compose.LottieAnimation
|
||||
import com.airbnb.lottie.compose.LottieCompositionSpec
|
||||
import com.airbnb.lottie.compose.LottieConstants
|
||||
import com.airbnb.lottie.compose.rememberLottieComposition
|
||||
import es.verdnatura.R
|
||||
|
||||
@Composable
|
||||
fun LottieLoadingAnimation(isVisible: Boolean = true) {
|
||||
AnimatedVisibility(
|
||||
visible = isVisible,
|
||||
enter = fadeIn(),
|
||||
exit = fadeOut()
|
||||
) {
|
||||
val composition by rememberLottieComposition(
|
||||
spec = LottieCompositionSpec.RawRes(R.raw.orange_loading)
|
||||
)
|
||||
|
||||
LottieAnimation(
|
||||
composition = composition,
|
||||
iterations = LottieConstants.IterateForever,
|
||||
speed = 2f,
|
||||
modifier = Modifier
|
||||
.wrapContentWidth()
|
||||
.height(dimensionResource(id = R.dimen.verdnatura_logo_large_height))
|
||||
)
|
||||
}
|
||||
}
|
|
@ -0,0 +1,72 @@
|
|||
package es.verdnatura.presentation.composable.ui
|
||||
|
||||
import androidx.compose.ui.graphics.Color
|
||||
|
||||
object VerdnaturaColors {
|
||||
|
||||
val OrangeSalix = Color(0xFFEC8916)
|
||||
val BlackCustomDialog = Color(0xFF1A1A1A)
|
||||
val BlackTextInput = Color(0xFF666666)
|
||||
val White = Color(0xFFFFFFFF)
|
||||
|
||||
// Colores principales
|
||||
val ColorPrimary = Color(0xFFF7931E)
|
||||
val ColorPrimaryDark = Color(0xFF8B4200)
|
||||
|
||||
// Negros
|
||||
/* val Black = Color(0xFF000000)
|
||||
val Black1 = Color(0xFF1D1D1D)
|
||||
val Black2 = Color(0xFF171717)
|
||||
val Black3 = Color(0xFF292929)
|
||||
val Black4 = Color(0xFF242424)
|
||||
val Black5 = Color(0xFF323232)
|
||||
val Black6 = Color(0xFF333333)
|
||||
val Black7 = Color(0xFF282828)
|
||||
val Black8 = Color(0xFF1A1A1A)
|
||||
val BlackCustomDialog = Color(0xFF464446)
|
||||
val Black8Alpha6 = Color(0x991A1A1A) // Con transparencia
|
||||
|
||||
// Grises
|
||||
val WarmGrey = Color(0xFF707070)
|
||||
val BrownGrey = Color(0xFF8F8F8F)
|
||||
val BrownGreyLight = Color(0xFFB8ADAD)
|
||||
|
||||
// Colores vivos
|
||||
val Red = Color(0xFFE74C3C)
|
||||
val WarmBrown = Color(0xFF8B4200)
|
||||
val PumpkinOrange = Color(0xFFF7931E)
|
||||
val PumpkinLight = Color(0xFFF77956)
|
||||
val PinkSalix = Color(0xFFFF99CC)
|
||||
val SunflowerYellow = Color(0xFFFFD400)
|
||||
val DarkSkyBlue = Color(0xFF4AB4E6)
|
||||
val DarkGreenVerdnatura = Color(0xFFA3D131)
|
||||
val DarkMint = Color(0xFF50BE87)
|
||||
val DarkMintLight = Color(0xFF80BE87)
|
||||
val DarkMintLightPrecontrolled = Color(0xFFB8DABA)
|
||||
val LightTeal = Color(0xFFB8ECD6)
|
||||
val White = Color(0xFFFFFFFF)
|
||||
val RedSalix = Color(0xFFFB5252)
|
||||
val OrangeSalix = Color(0xFFEC8916)
|
||||
|
||||
// Fondos
|
||||
val BackgroundItemPicker = Color(0xFF4D4D4D)
|
||||
val BackgroundSubtitleSettings = Color(0xFF1A1A1A)
|
||||
val BackgroundItemsMenus = Color(0xFF333333)
|
||||
|
||||
// Colores SALIX
|
||||
val SalixSuccessLight = Color(0xFFA3D131)
|
||||
val ColorHeader = Color(0xFF3D3D3D)
|
||||
val ColorMenuHeader = Color(0xFF3D3D3D)
|
||||
val ColorBg = Color(0xFF222222)
|
||||
val ColorBgDark = Color(0xFF222222)
|
||||
val ColorActive = Color(0xFF666666)
|
||||
val ColorActiveFont = Color(0xFFFFFFFF)
|
||||
val ColorBgPanel = Color(0xFF3C3B3B)
|
||||
val ColorMain = ColorPrimary
|
||||
val ColorMarginal = Color(0xFF222222)
|
||||
val ColorSuccess = Color(0xFFA3D131)
|
||||
val ColorNotice = Color(0xFF32B1CE)
|
||||
val ColorAlert = Color(0xFFFA3939)
|
||||
val ColorPink = Color(0xFFFF99CC)
|
||||
val ColorYellow = Color(0xFFFFFF00)*/
|
||||
}
|
|
@ -0,0 +1,168 @@
|
|||
package es.verdnatura.presentation.composable.ui
|
||||
|
||||
import androidx.compose.foundation.background
|
||||
import androidx.compose.foundation.border
|
||||
import androidx.compose.foundation.layout.PaddingValues
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.foundation.layout.height
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.text.KeyboardActions
|
||||
import androidx.compose.foundation.text.KeyboardOptions
|
||||
import androidx.compose.material3.Button
|
||||
import androidx.compose.material3.ButtonDefaults
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.material3.TextField
|
||||
import androidx.compose.material3.TextFieldDefaults
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.LaunchedEffect
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.focus.FocusRequester
|
||||
import androidx.compose.ui.focus.focusRequester
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.platform.LocalSoftwareKeyboardController
|
||||
import androidx.compose.ui.text.font.FontWeight
|
||||
import androidx.compose.ui.text.input.ImeAction
|
||||
import androidx.compose.ui.text.input.KeyboardType
|
||||
import androidx.compose.ui.text.input.TextFieldValue
|
||||
import androidx.compose.ui.text.style.TextAlign
|
||||
import androidx.compose.ui.text.style.TextOverflow
|
||||
import androidx.compose.ui.tooling.preview.Preview
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.compose.ui.unit.sp
|
||||
|
||||
@Composable
|
||||
fun DefaultButtonCustomDialog(
|
||||
text: String,
|
||||
onClick: () -> Unit = {},
|
||||
enabled: Boolean = true,
|
||||
leadingIcon: @Composable (() -> Unit)? = null
|
||||
) {
|
||||
Button(
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
onClick = onClick,
|
||||
enabled = enabled,
|
||||
contentPadding = PaddingValues(
|
||||
start = if (leadingIcon == null) 16.dp else 8.dp,
|
||||
end = 16.dp
|
||||
),
|
||||
shape = MaterialTheme.shapes.small,
|
||||
colors = ButtonDefaults.buttonColors(
|
||||
containerColor = VerdnaturaColors.ColorPrimary,
|
||||
contentColor = VerdnaturaColors.White
|
||||
)
|
||||
) {
|
||||
if (leadingIcon != null) {
|
||||
leadingIcon()
|
||||
}
|
||||
|
||||
Text(
|
||||
text = text.uppercase(),
|
||||
fontSize = 14.sp,
|
||||
fontWeight = FontWeight.Bold,
|
||||
textAlign = TextAlign.Center,
|
||||
maxLines = 1,
|
||||
overflow = TextOverflow.Ellipsis
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
fun TitleTextCustomDialog(
|
||||
title: String,
|
||||
) {
|
||||
Text(
|
||||
text = title,
|
||||
style = MaterialTheme.typography.titleLarge.copy(
|
||||
fontWeight = FontWeight.Bold
|
||||
),
|
||||
color = VerdnaturaColors.White,
|
||||
textAlign = TextAlign.Center,
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.padding(bottom = 8.dp)
|
||||
)
|
||||
}
|
||||
|
||||
@Composable
|
||||
fun DescriptionTextCustomDialog(
|
||||
description: String,
|
||||
) {
|
||||
Text(
|
||||
text = description,
|
||||
color = VerdnaturaColors.White,
|
||||
style = MaterialTheme.typography.bodyLarge,
|
||||
modifier = Modifier.padding(bottom = 8.dp)
|
||||
)
|
||||
}
|
||||
|
||||
@Composable
|
||||
fun ScanTextCustomDialog(
|
||||
value: TextFieldValue,
|
||||
onValueChange: (TextFieldValue) -> Unit,
|
||||
hint: String,
|
||||
onEnterPressed: (String) -> Unit = {},
|
||||
focusRequester: FocusRequester
|
||||
) {
|
||||
val keyboardController = LocalSoftwareKeyboardController.current
|
||||
|
||||
TextField(
|
||||
value = value,
|
||||
onValueChange = onValueChange,
|
||||
label = {
|
||||
Text(
|
||||
text = hint,
|
||||
textAlign = TextAlign.Center,
|
||||
color = Color.White,
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.padding(horizontal = 16.dp),
|
||||
)
|
||||
},
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.focusRequester(focusRequester)
|
||||
.border(1.dp, Color.White, shape = MaterialTheme.shapes.small)
|
||||
.background(Color.Transparent)
|
||||
.height(VerdnaturaDimens.minHeight),
|
||||
textStyle = CustomTextStyle,
|
||||
keyboardOptions =
|
||||
KeyboardOptions.Default.copy(
|
||||
imeAction = ImeAction.Done,
|
||||
keyboardType = KeyboardType.Number
|
||||
),
|
||||
singleLine = true,
|
||||
keyboardActions = KeyboardActions(
|
||||
onDone = {
|
||||
onEnterPressed(value.text)
|
||||
onValueChange(TextFieldValue(""))
|
||||
keyboardController?.hide()
|
||||
}
|
||||
),
|
||||
colors = TextFieldDefaults.colors(
|
||||
focusedContainerColor = Color.Transparent,
|
||||
unfocusedContainerColor = Color.Transparent,
|
||||
focusedTextColor = VerdnaturaColors.White,
|
||||
unfocusedTextColor = VerdnaturaColors.White
|
||||
)
|
||||
)
|
||||
LaunchedEffect(Unit) {
|
||||
focusRequester.requestFocus()
|
||||
}
|
||||
}
|
||||
|
||||
@Preview(showBackground = true)
|
||||
@Composable
|
||||
fun PreviewCustomTextField() {
|
||||
val sampleText = remember { mutableStateOf(TextFieldValue("Texto de ejemplo")) }
|
||||
val focusRequester = remember { FocusRequester() }
|
||||
ScanTextCustomDialog(
|
||||
value = sampleText.value,
|
||||
onValueChange = { sampleText.value = it },
|
||||
hint = "Escribe algo...",
|
||||
onEnterPressed = { text -> println("Texto ingresado: $text") },
|
||||
focusRequester = focusRequester
|
||||
)
|
||||
}
|
|
@ -0,0 +1,23 @@
|
|||
package es.verdnatura.presentation.composable.ui
|
||||
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.compose.ui.unit.sp
|
||||
|
||||
object VerdnaturaDimens {
|
||||
|
||||
/* val h1 = 96.sp
|
||||
val h2 = 60.sp
|
||||
val h3 = 48.sp
|
||||
val h4 = 34.sp
|
||||
val h5 = 24.sp
|
||||
val h6 = 20.sp
|
||||
val h7 = 18.sp
|
||||
val h9 = 14.sp*/
|
||||
|
||||
// Text sizes
|
||||
val fontSizeCustomDialogs = 16.sp
|
||||
|
||||
// Height Scan Text
|
||||
val minHeight = 48.dp
|
||||
|
||||
}
|
|
@ -0,0 +1,10 @@
|
|||
package es.verdnatura.presentation.composable.ui
|
||||
|
||||
import androidx.compose.ui.text.TextStyle
|
||||
import androidx.compose.ui.text.style.TextAlign
|
||||
|
||||
val CustomTextStyle = TextStyle(
|
||||
color = VerdnaturaColors.White,
|
||||
fontSize = VerdnaturaDimens.fontSizeCustomDialogs,
|
||||
textAlign = TextAlign.Center
|
||||
)
|
|
@ -16,7 +16,8 @@ import es.verdnatura.domain.toast
|
|||
class SearchableAdapter(
|
||||
private var listElements: MutableList<NameWithId>,
|
||||
private var context: Context,
|
||||
private val onItemClick: (NameWithId) -> Unit,
|
||||
private val listColorElements: List<Int> = listOf(),
|
||||
private val onItemClick: (NameWithId) -> Unit
|
||||
) : RecyclerView.Adapter<SearchableAdapter.NameViewHolder>() {
|
||||
|
||||
private var listElementsFiltered = listElements.toMutableList()
|
||||
|
@ -48,6 +49,13 @@ class SearchableAdapter(
|
|||
} catch (ex: Exception) {
|
||||
ex.message?.toast(context)
|
||||
}
|
||||
if (listColorElements.isNotEmpty()) {
|
||||
if (nameWithId.id in listColorElements) {
|
||||
nameText.setTextColor(Color.BLACK)
|
||||
} else {
|
||||
nameText.setTextColor(Color.GRAY)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,14 +1,11 @@
|
|||
package es.verdnatura.presentation.view.commom
|
||||
package es.verdnatura.presentation.view.commom.webview
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.content.Context
|
||||
import android.graphics.drawable.Drawable
|
||||
import android.os.Bundle
|
||||
import android.print.PrintAttributes
|
||||
import android.print.PrintManager
|
||||
import android.view.GestureDetector
|
||||
import android.view.LayoutInflater
|
||||
import android.view.MotionEvent
|
||||
import android.view.VelocityTracker
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.webkit.WebChromeClient
|
||||
|
@ -18,12 +15,13 @@ import android.webkit.WebViewClient
|
|||
import android.widget.ImageView
|
||||
import androidx.activity.OnBackPressedCallback
|
||||
import androidx.activity.OnBackPressedDispatcher
|
||||
import androidx.core.view.GestureDetectorCompat
|
||||
import androidx.databinding.DataBindingUtil
|
||||
import androidx.fragment.app.Fragment
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import es.verdnatura.R
|
||||
import es.verdnatura.databinding.FragmentWebBinding
|
||||
import es.verdnatura.domain.ConstAndValues.FLINGTHRESHOLDVELOCITY
|
||||
import es.verdnatura.domain.ConstAndValues.FLINGTHRESHOLDVERTICAL
|
||||
import es.verdnatura.presentation.common.OnBackPressedListener
|
||||
import es.verdnatura.presentation.common.OnOptionsSelectedListener
|
||||
import es.verdnatura.presentation.common.ToolBarAdapterTooltip
|
||||
|
@ -32,15 +30,14 @@ import es.verdnatura.presentation.view.feature.main.activity.MainActivity
|
|||
import org.json.JSONObject
|
||||
import kotlin.math.abs
|
||||
|
||||
@Suppress("UNUSED_ANONYMOUS_PARAMETER")
|
||||
class WebFragment(
|
||||
var entryPoint: String = ""
|
||||
) : Fragment(), OnBackPressedListener {
|
||||
private lateinit var gestureDetector: GestureDetectorCompat
|
||||
fun getLayoutId(): Int = R.layout.fragment_web
|
||||
private lateinit var customDialog: CustomDialog
|
||||
private lateinit var backDispatcher: OnBackPressedDispatcher
|
||||
private lateinit var binding: FragmentWebBinding
|
||||
private var velocityTracker: VelocityTracker? = null
|
||||
|
||||
companion object {
|
||||
fun newInstance(entryPoint: String) = WebFragment(entryPoint)
|
||||
|
@ -50,12 +47,11 @@ class WebFragment(
|
|||
customDialog = CustomDialog(requireContext())
|
||||
setToolbar()
|
||||
setWeb()
|
||||
|
||||
}
|
||||
|
||||
override fun onCreateView(
|
||||
inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?
|
||||
): View? {
|
||||
): View {
|
||||
binding = DataBindingUtil.inflate(inflater, R.layout.fragment_web, container, false)
|
||||
binding.lifecycleOwner = this
|
||||
return binding.root
|
||||
|
@ -63,7 +59,6 @@ class WebFragment(
|
|||
}
|
||||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
|
||||
requireActivity().onBackPressedDispatcher.addCallback(viewLifecycleOwner,
|
||||
|
@ -76,132 +71,104 @@ class WebFragment(
|
|||
}
|
||||
})
|
||||
|
||||
gestureDetector = GestureDetectorCompat(requireActivity(),
|
||||
object : GestureDetector.SimpleOnGestureListener() {
|
||||
override fun onFling(
|
||||
e1: MotionEvent?, e2: MotionEvent, velocityX: Float, velocityY: Float
|
||||
): Boolean {
|
||||
val deltaX = (e2.x - e1?.x!!)
|
||||
val deltaY = (e2.y - e1.y)
|
||||
val deltaAbsX = abs(deltaX)
|
||||
val deltaAbsY = abs(deltaY)
|
||||
if (deltaAbsX > deltaAbsY) {
|
||||
if (velocityX > 2000 && velocityY < 500 && velocityY >= 0) {
|
||||
|
||||
binding.webView.goBack()
|
||||
return true
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
return false
|
||||
}
|
||||
})
|
||||
init()
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
|
||||
}
|
||||
|
||||
@SuppressLint("ClickableViewAccessibility", "SetJavaScriptEnabled")
|
||||
@SuppressLint("ClickableViewAccessibility", "javaScriptEnabled")
|
||||
private fun setWeb() {
|
||||
binding.webView.apply {
|
||||
webChromeClient = WebChromeClient()
|
||||
|
||||
binding.webView.webChromeClient = WebChromeClient(
|
||||
|
||||
)
|
||||
|
||||
val webSettings = binding.webView.settings
|
||||
webSettings.javaScriptEnabled = true
|
||||
webSettings.domStorageEnabled = true
|
||||
webSettings.loadWithOverviewMode = true
|
||||
webSettings.useWideViewPort = true
|
||||
webSettings.builtInZoomControls = true
|
||||
webSettings.displayZoomControls = false
|
||||
webSettings.setSupportZoom(true)
|
||||
webSettings.allowFileAccess = true
|
||||
|
||||
binding.webView.setOnTouchListener { v, event ->
|
||||
gestureDetector.onTouchEvent(event)
|
||||
settings.apply {
|
||||
javaScriptEnabled = true
|
||||
domStorageEnabled = true
|
||||
loadWithOverviewMode = true
|
||||
useWideViewPort = true
|
||||
builtInZoomControls = true
|
||||
displayZoomControls = false
|
||||
setSupportZoom(true)
|
||||
allowFileAccess = true
|
||||
}
|
||||
binding.webView.webViewClient = object : WebViewClient() {
|
||||
|
||||
setOnTouchListener { _, event ->
|
||||
when (event.actionMasked) {
|
||||
MotionEvent.ACTION_DOWN -> {
|
||||
velocityTracker?.clear()
|
||||
velocityTracker = velocityTracker ?: VelocityTracker.obtain()
|
||||
velocityTracker?.addMovement(event)
|
||||
}
|
||||
|
||||
MotionEvent.ACTION_MOVE -> {
|
||||
velocityTracker?.addMovement(event)
|
||||
}
|
||||
|
||||
MotionEvent.ACTION_UP -> {
|
||||
velocityTracker?.let { tracker ->
|
||||
tracker.computeCurrentVelocity(1000) // velocidad en píxeles por segundo
|
||||
val velocityX = tracker.xVelocity
|
||||
val velocityY = abs(tracker.yVelocity)
|
||||
|
||||
if (velocityX > FLINGTHRESHOLDVELOCITY &&
|
||||
velocityY < FLINGTHRESHOLDVERTICAL
|
||||
) {
|
||||
binding.webView.goBack()
|
||||
return@setOnTouchListener true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
MotionEvent.ACTION_CANCEL -> {
|
||||
velocityTracker?.recycle()
|
||||
velocityTracker = null
|
||||
}
|
||||
}
|
||||
false
|
||||
}
|
||||
|
||||
webViewClient = object : WebViewClient() {
|
||||
override fun shouldOverrideUrlLoading(
|
||||
view: WebView?, request: WebResourceRequest?
|
||||
view: WebView?,
|
||||
request: WebResourceRequest?
|
||||
): Boolean {
|
||||
binding.webView.loadUrl(request?.url.toString())
|
||||
request?.url?.toString()?.let { loadUrl(it) }
|
||||
return true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
val dataScanned = JSONObject(entryPoint)
|
||||
|
||||
if (dataScanned.toString().contains("cmr?")) {
|
||||
val pdfUrl = "${dataScanned.get("web")}"
|
||||
val googleDocsViewerUrl = "https://docs.google.com/gview?embedded=true&url=$pdfUrl"
|
||||
binding.webView.loadUrl(googleDocsViewerUrl)
|
||||
} else {
|
||||
binding.webView.loadUrl(dataScanned.get("web").toString())
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private fun setToolbar() {
|
||||
|
||||
binding.mainToolbar.toolbarTitle.text = buildString {
|
||||
append(getString(R.string.item))
|
||||
append(JSONObject(entryPoint).get("entryPoint").toString())
|
||||
}
|
||||
|
||||
val listIcons: ArrayList<ImageView> = ArrayList()
|
||||
val iconPrint = ImageView(context)
|
||||
iconPrint.setImageResource(R.drawable.ic_print_black_24dp)
|
||||
iconPrint.tooltipText = getString(R.string.print)
|
||||
|
||||
//listIcons.add(iconPrint)
|
||||
|
||||
binding.mainToolbar.toolbarIcons.adapter =
|
||||
ToolBarAdapterTooltip(listIcons, object : OnOptionsSelectedListener {
|
||||
override fun onOptionsItemSelected(item: Drawable) {
|
||||
|
||||
when (item) {
|
||||
iconPrint.drawable -> createWebPrintJob(binding.webView)
|
||||
}
|
||||
|
||||
}
|
||||
})
|
||||
binding.mainToolbar.toolbarIcons.layoutManager =
|
||||
LinearLayoutManager(requireContext(), LinearLayoutManager.HORIZONTAL, false)
|
||||
|
||||
}
|
||||
|
||||
private fun createWebPrintJob(webView: WebView) {
|
||||
|
||||
// Get a PrintManager instance
|
||||
(activity?.getSystemService(Context.PRINT_SERVICE) as? PrintManager)?.let { printManager ->
|
||||
|
||||
val jobName = "${getString(R.string.app_name)} Document"
|
||||
|
||||
// Get a print adapter instance
|
||||
val printAdapter = webView.createPrintDocumentAdapter(jobName)
|
||||
|
||||
// Create a print job with name and adapter instance
|
||||
printManager.print(
|
||||
jobName, printAdapter, PrintAttributes.Builder().build()
|
||||
).also { printJob ->
|
||||
println("job printed")
|
||||
// Save the job object for later status checking
|
||||
// printJobs += printJob
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onBackPressedHandled(): Boolean {
|
||||
|
||||
if (binding.webView.canGoBack()) {
|
||||
binding.webView.goBack()
|
||||
} else {
|
||||
(context as MainActivity).onMyBackPressed()
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
override fun onDestroy() {
|
||||
super.onDestroy()
|
||||
velocityTracker?.recycle()
|
||||
velocityTracker = null
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,180 @@
|
|||
package es.verdnatura.presentation.view.commom.webview
|
||||
|
||||
import android.os.Bundle
|
||||
import android.view.LayoutInflater
|
||||
import android.view.MotionEvent
|
||||
import android.view.VelocityTracker
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.webkit.WebResourceRequest
|
||||
import android.webkit.WebView
|
||||
import android.webkit.WebViewClient
|
||||
import androidx.activity.OnBackPressedCallback
|
||||
import androidx.activity.OnBackPressedDispatcher
|
||||
import androidx.compose.runtime.LaunchedEffect
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.ui.platform.ComposeView
|
||||
import androidx.fragment.app.Fragment
|
||||
import androidx.fragment.app.viewModels
|
||||
import androidx.lifecycle.compose.collectAsStateWithLifecycle
|
||||
import es.verdnatura.presentation.common.OnBackPressedListener
|
||||
import es.verdnatura.presentation.view.commom.webview.data.WebViewEvent
|
||||
import es.verdnatura.presentation.view.commom.webview.data.WebViewScreen
|
||||
import org.json.JSONObject
|
||||
import kotlin.math.abs
|
||||
|
||||
class WebFragmentCompose(
|
||||
var entryPoint: String = ""
|
||||
) : Fragment(), OnBackPressedListener {
|
||||
private val viewModel: WebViewViewModel by viewModels()
|
||||
private var velocityTracker: VelocityTracker? = null
|
||||
private lateinit var backDispatcher: OnBackPressedDispatcher
|
||||
private var webView: WebView? = null
|
||||
|
||||
companion object {
|
||||
private const val FLING_THRESHOLD_VELOCITY = 2000
|
||||
private const val FLING_THRESHOLD_VERTICAL = 1000
|
||||
fun newInstance(entryPoint: String) = WebFragmentCompose(entryPoint)
|
||||
|
||||
}
|
||||
|
||||
override fun onCreateView(
|
||||
inflater: LayoutInflater,
|
||||
container: ViewGroup?,
|
||||
savedInstanceState: Bundle?
|
||||
): View {
|
||||
return ComposeView(requireContext()).apply {
|
||||
setContent {
|
||||
val state by viewModel.state.collectAsStateWithLifecycle()
|
||||
|
||||
// Recolectar acciones del ViewModel
|
||||
LaunchedEffect(Unit) {
|
||||
viewModel.webViewActions.collect { event ->
|
||||
when (event) {
|
||||
is WebViewEvent.OnBackGesture -> {
|
||||
webView?.goBack()
|
||||
}
|
||||
// Manejar otros eventos si es necesario
|
||||
is WebViewEvent.LoadUrl -> println("")
|
||||
is WebViewEvent.OnPageFinished -> println("")
|
||||
is WebViewEvent.OnUrlLoading -> println("")
|
||||
is WebViewEvent.ToggleToolbar -> println("")
|
||||
is WebViewEvent.UpdateTitle -> println("")
|
||||
else -> {}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
WebViewScreen(
|
||||
state = state,
|
||||
onWebViewCreated = { webView ->
|
||||
this@WebFragmentCompose.webView = webView
|
||||
setupWebView(webView)
|
||||
},
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun setupWebView(webView: WebView) {
|
||||
webView.webViewClient = object : WebViewClient() {
|
||||
override fun shouldOverrideUrlLoading(
|
||||
view: WebView?,
|
||||
request: WebResourceRequest?
|
||||
): Boolean {
|
||||
request?.url?.toString()?.let {
|
||||
viewModel.processEvent(WebViewEvent.OnUrlLoading(it))
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
override fun onPageFinished(view: WebView?, url: String?) {
|
||||
super.onPageFinished(view, url)
|
||||
viewModel.processEvent(WebViewEvent.OnPageFinished(url ?: ""))
|
||||
viewModel.processEvent(WebViewEvent.UpdateTitle(webView.title ?: ""))
|
||||
}
|
||||
}
|
||||
|
||||
webView.setOnTouchListener { _, event ->
|
||||
handleTouchEvent(event)
|
||||
}
|
||||
|
||||
// Cargar URL inicial si existe
|
||||
// if (state.value.initialUrl.isNotEmpty()) {
|
||||
// }
|
||||
}
|
||||
|
||||
private fun handleTouchEvent(event: MotionEvent): Boolean {
|
||||
when (event.actionMasked) {
|
||||
MotionEvent.ACTION_DOWN -> {
|
||||
velocityTracker?.clear()
|
||||
velocityTracker = velocityTracker ?: VelocityTracker.obtain()
|
||||
velocityTracker?.addMovement(event)
|
||||
}
|
||||
|
||||
MotionEvent.ACTION_MOVE -> {
|
||||
velocityTracker?.addMovement(event)
|
||||
}
|
||||
|
||||
MotionEvent.ACTION_UP -> {
|
||||
velocityTracker?.let { tracker ->
|
||||
tracker.computeCurrentVelocity(1000)
|
||||
val velocityX = tracker.xVelocity
|
||||
val velocityY = abs(tracker.yVelocity)
|
||||
|
||||
if (velocityX > FLING_THRESHOLD_VELOCITY &&
|
||||
velocityY < FLING_THRESHOLD_VERTICAL &&
|
||||
webView?.canGoBack() == true
|
||||
) {
|
||||
viewModel.processEvent(WebViewEvent.OnBackGesture)
|
||||
return true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
MotionEvent.ACTION_CANCEL -> {
|
||||
velocityTracker?.recycle()
|
||||
velocityTracker = null
|
||||
}
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
|
||||
requireActivity().onBackPressedDispatcher.addCallback(viewLifecycleOwner,
|
||||
object : OnBackPressedCallback(true) {
|
||||
override fun handleOnBackPressed() {
|
||||
if (!onBackPressedHandled()) {
|
||||
isEnabled = false
|
||||
requireActivity().onBackPressedDispatcher
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
val dataScanned = JSONObject(entryPoint)
|
||||
viewModel.setInitialUrl(dataScanned.get("web").toString())
|
||||
|
||||
}
|
||||
|
||||
override fun onDestroy() {
|
||||
super.onDestroy()
|
||||
velocityTracker?.recycle()
|
||||
velocityTracker = null
|
||||
webView = null
|
||||
}
|
||||
|
||||
override fun onBackPressedHandled(): Boolean {
|
||||
|
||||
viewModel.processEvent(WebViewEvent.OnBackGesture)
|
||||
|
||||
/* if (webView!!.canGoBack()) {
|
||||
webView!!.goBack()
|
||||
} else {
|
||||
(context as MainActivity).onMyBackPressed()
|
||||
}*/
|
||||
return true
|
||||
}
|
||||
}
|
|
@ -0,0 +1,64 @@
|
|||
package es.verdnatura.presentation.view.commom.webview
|
||||
|
||||
import androidx.lifecycle.ViewModel
|
||||
import androidx.lifecycle.viewModelScope
|
||||
import es.verdnatura.presentation.view.commom.webview.data.WebViewEvent
|
||||
import es.verdnatura.presentation.view.commom.webview.data.WebViewState
|
||||
import kotlinx.coroutines.channels.Channel
|
||||
import kotlinx.coroutines.flow.MutableStateFlow
|
||||
import kotlinx.coroutines.flow.asStateFlow
|
||||
import kotlinx.coroutines.flow.receiveAsFlow
|
||||
import kotlinx.coroutines.flow.update
|
||||
import kotlinx.coroutines.launch
|
||||
|
||||
class WebViewViewModel : ViewModel() {
|
||||
private val _state = MutableStateFlow(WebViewState())
|
||||
val state = _state.asStateFlow()
|
||||
|
||||
private val _webViewActions = Channel<WebViewEvent>()
|
||||
val webViewActions = _webViewActions.receiveAsFlow()
|
||||
|
||||
fun processEvent(event: WebViewEvent) {
|
||||
when (event) {
|
||||
is WebViewEvent.LoadUrl -> {
|
||||
_state.update { it.copy(url = event.url, isLoading = true) }
|
||||
viewModelScope.launch {
|
||||
_webViewActions.send(event)
|
||||
}
|
||||
}
|
||||
|
||||
is WebViewEvent.UpdateTitle -> {
|
||||
_state.update { it.copy(title = event.title) }
|
||||
}
|
||||
|
||||
is WebViewEvent.OnPageFinished -> {
|
||||
_state.update { it.copy(isLoading = false) }
|
||||
}
|
||||
|
||||
is WebViewEvent.ToggleToolbar -> {
|
||||
_state.update { it.copy(showToolbar = event.show) }
|
||||
}
|
||||
|
||||
is WebViewEvent.OnBackGesture -> {
|
||||
viewModelScope.launch {
|
||||
_webViewActions.send(event)
|
||||
}
|
||||
}
|
||||
|
||||
is WebViewEvent.OnUrlLoading -> {
|
||||
processEvent(WebViewEvent.LoadUrl(event.url))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun setInitialUrl(webURL: String) {
|
||||
try {
|
||||
|
||||
println("webURL $webURL")
|
||||
_state.update { it.copy(initialUrl = webURL) }
|
||||
processEvent(WebViewEvent.LoadUrl("https://salix.verdnatura.es"))
|
||||
} catch (e: Exception) {
|
||||
// Manejar error
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,67 @@
|
|||
package es.verdnatura.presentation.view.commom.webview.data
|
||||
|
||||
import android.webkit.WebChromeClient
|
||||
import android.webkit.WebView
|
||||
import androidx.compose.foundation.layout.Box
|
||||
import androidx.compose.foundation.layout.fillMaxSize
|
||||
import androidx.compose.foundation.layout.statusBarsPadding
|
||||
import androidx.compose.material3.CircularProgressIndicator
|
||||
import androidx.compose.material3.ExperimentalMaterial3Api
|
||||
import androidx.compose.material3.Surface
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.viewinterop.AndroidView
|
||||
|
||||
@OptIn(ExperimentalMaterial3Api::class)
|
||||
@Composable
|
||||
fun WebViewScreen(
|
||||
state: WebViewState,
|
||||
onWebViewCreated: (WebView) -> Unit
|
||||
) {
|
||||
Surface(
|
||||
modifier = Modifier.fillMaxSize() // Asegura que ocupe toda la pantalla
|
||||
) {
|
||||
Box(
|
||||
modifier = Modifier
|
||||
.fillMaxSize()
|
||||
.statusBarsPadding() // Evita que la WebView quede debajo de la barra de estado
|
||||
) {
|
||||
AndroidView(
|
||||
modifier = Modifier.fillMaxSize(),
|
||||
factory = { context ->
|
||||
WebView(context).apply {
|
||||
settings.apply {
|
||||
javaScriptEnabled = true
|
||||
domStorageEnabled = true
|
||||
loadWithOverviewMode = true
|
||||
useWideViewPort = true
|
||||
builtInZoomControls = true
|
||||
displayZoomControls = false
|
||||
setSupportZoom(true)
|
||||
allowFileAccess = true
|
||||
}
|
||||
webChromeClient = object : WebChromeClient() {
|
||||
override fun onProgressChanged(view: WebView?, newProgress: Int) {
|
||||
super.onProgressChanged(view, newProgress)
|
||||
|
||||
}
|
||||
}
|
||||
onWebViewCreated(this)
|
||||
}
|
||||
},
|
||||
update = { webView ->
|
||||
if (state.url.isNotEmpty() && state.url != webView.url) {
|
||||
webView.loadUrl(state.url)
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
if (state.isLoading) {
|
||||
CircularProgressIndicator(
|
||||
modifier = Modifier.align(Alignment.Center)
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,18 @@
|
|||
package es.verdnatura.presentation.view.commom.webview.data
|
||||
|
||||
data class WebViewState(
|
||||
val title: String = "",
|
||||
val url: String = "",
|
||||
val isLoading: Boolean = false,
|
||||
val showToolbar: Boolean = true,
|
||||
val initialUrl: String = ""
|
||||
)
|
||||
|
||||
sealed class WebViewEvent {
|
||||
data class LoadUrl(val url: String) : WebViewEvent()
|
||||
data class UpdateTitle(val title: String) : WebViewEvent()
|
||||
data class OnPageFinished(val url: String) : WebViewEvent()
|
||||
data class ToggleToolbar(val show: Boolean) : WebViewEvent()
|
||||
data object OnBackGesture : WebViewEvent()
|
||||
data class OnUrlLoading(val url: String) : WebViewEvent()
|
||||
}
|
|
@ -100,15 +100,15 @@ class CustomDialogInput(context: Context) : Dialog(context, R.style.DialogTheme)
|
|||
fun setFocusText() {
|
||||
binding.customDialogValue.requestFocus()
|
||||
}
|
||||
|
||||
fun setFocusTextTwo() {
|
||||
binding.customDialogValueTwo.requestFocus()
|
||||
}
|
||||
|
||||
fun plusTextButton(view: View) {
|
||||
private fun plusTextButton(view: View) {
|
||||
|
||||
var sum = 0
|
||||
try {
|
||||
sum = getValue().toInt() + Integer.parseInt(view.tag.toString())
|
||||
val sum = getValue().toInt() + Integer.parseInt(view.tag.toString())
|
||||
setValue(sum.toString())
|
||||
} catch (ex: Exception) {
|
||||
setValue(view.tag.toString())
|
||||
|
|
|
@ -69,6 +69,12 @@ class CustomDialogList(context: Context) : Dialog(context, R.style.DialogTheme)
|
|||
return this
|
||||
}
|
||||
|
||||
fun setTitleSpannable(title: CharSequence): CustomDialogList {
|
||||
binding.customDialogTitle.visibility = View.VISIBLE
|
||||
binding.customDialogTitle.text = title
|
||||
return this
|
||||
}
|
||||
|
||||
fun setDescription(title: String): CustomDialogList {
|
||||
binding.customDialogDescription.visibility = View.VISIBLE
|
||||
binding.customDialogDescription.text = title
|
||||
|
@ -90,6 +96,13 @@ class CustomDialogList(context: Context) : Dialog(context, R.style.DialogTheme)
|
|||
return this
|
||||
}
|
||||
|
||||
fun setOkThreeButton(text: String, onButtonClicked: () -> Unit): CustomDialogList {
|
||||
binding.customDialogButtonOkThree.visibility = View.VISIBLE
|
||||
binding.customDialogButtonOkThree.text = text
|
||||
binding.customDialogButtonOkThree.setOnClickListener { onButtonClicked() }
|
||||
return this
|
||||
}
|
||||
|
||||
fun setKoButton(text: String, onButtonClicked: () -> Unit): CustomDialogList {
|
||||
binding.customDialogButtonKo.visibility = View.VISIBLE
|
||||
binding.customDialogButtonKo.text = text
|
||||
|
@ -148,4 +161,9 @@ class CustomDialogList(context: Context) : Dialog(context, R.style.DialogTheme)
|
|||
fun getFocusThree() {
|
||||
binding.customDialogValueThree.requestFocus()
|
||||
}
|
||||
|
||||
fun setTextSize(size: Float): CustomDialogList {
|
||||
binding.customDialogValue.textSize = size
|
||||
return this
|
||||
}
|
||||
}
|
|
@ -0,0 +1,130 @@
|
|||
package es.verdnatura.presentation.view.component
|
||||
|
||||
import androidx.compose.foundation.background
|
||||
import androidx.compose.foundation.clickable
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.Spacer
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.foundation.layout.height
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.layout.wrapContentWidth
|
||||
import androidx.compose.foundation.lazy.LazyColumn
|
||||
import androidx.compose.foundation.lazy.items
|
||||
import androidx.compose.material3.HorizontalDivider
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.runtime.setValue
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.focus.FocusRequester
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.platform.LocalSoftwareKeyboardController
|
||||
import androidx.compose.ui.text.input.TextFieldValue
|
||||
import androidx.compose.ui.tooling.preview.Preview
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.compose.ui.window.Dialog
|
||||
import es.verdnatura.presentation.composable.ui.DefaultButtonCustomDialog
|
||||
import es.verdnatura.presentation.composable.ui.DescriptionTextCustomDialog
|
||||
import es.verdnatura.presentation.composable.ui.ScanTextCustomDialog
|
||||
import es.verdnatura.presentation.composable.ui.TitleTextCustomDialog
|
||||
import es.verdnatura.presentation.composable.ui.VerdnaturaColors
|
||||
|
||||
@Composable
|
||||
fun CustomDialogListComposable(
|
||||
title: String = "",
|
||||
description: String = "",
|
||||
buttonOkText: String = "",
|
||||
onOkClick: () -> Unit = {},
|
||||
showRecyclerView: Boolean = true,
|
||||
recyclerViewItems: List<Any> = listOf(),
|
||||
onItemSelected: (Any) -> Unit = {},
|
||||
hintOne: String = "",
|
||||
showTextInput: Boolean = true,
|
||||
onEnterPressed: (String) -> Unit = {}
|
||||
) {
|
||||
var valueOne by remember { mutableStateOf(TextFieldValue()) }
|
||||
val showDialog = remember { mutableStateOf(true) }
|
||||
val keyboardController = LocalSoftwareKeyboardController.current
|
||||
val focusRequester = remember { FocusRequester() }
|
||||
|
||||
if (showDialog.value) {
|
||||
Dialog(
|
||||
onDismissRequest = { showDialog.value = false },
|
||||
) {
|
||||
|
||||
Column(
|
||||
modifier = Modifier
|
||||
.background(VerdnaturaColors.BlackCustomDialog)
|
||||
.padding(16.dp),
|
||||
horizontalAlignment = Alignment.CenterHorizontally,
|
||||
) {
|
||||
if (title.isNotEmpty()) {
|
||||
TitleTextCustomDialog(title)
|
||||
}
|
||||
if (description.isNotEmpty()) {
|
||||
DescriptionTextCustomDialog(description)
|
||||
}
|
||||
|
||||
if (showTextInput)
|
||||
ScanTextCustomDialog(
|
||||
value = valueOne,
|
||||
onValueChange = { valueOne = it },
|
||||
hint = hintOne,
|
||||
onEnterPressed = onEnterPressed,
|
||||
focusRequester = focusRequester
|
||||
)
|
||||
|
||||
Spacer(modifier = Modifier.height(8.dp))
|
||||
|
||||
if (showRecyclerView && recyclerViewItems.isNotEmpty()) {
|
||||
LazyColumn(
|
||||
modifier = Modifier.wrapContentWidth(align = Alignment.CenterHorizontally)
|
||||
) {
|
||||
items(recyclerViewItems) { item ->
|
||||
HorizontalDivider(thickness = 1.dp, color = Color.DarkGray)
|
||||
Text(
|
||||
text = item.toString(),
|
||||
style = MaterialTheme.typography.bodyLarge,
|
||||
color = VerdnaturaColors.White,
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.padding(16.dp)
|
||||
.clickable {
|
||||
onItemSelected(item.toString())
|
||||
}
|
||||
.align(Alignment.CenterHorizontally)
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
DefaultButtonCustomDialog(buttonOkText, onClick = {
|
||||
onOkClick()
|
||||
keyboardController?.hide()
|
||||
})
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Preview
|
||||
@Composable
|
||||
fun PreviewCustomDialogList() {
|
||||
|
||||
CustomDialogListComposable(
|
||||
title = "Custom Dialog Title",
|
||||
description = "This is a description.",
|
||||
buttonOkText = "OK",
|
||||
onOkClick = { /* Handle OK click */ },
|
||||
showRecyclerView = true,
|
||||
recyclerViewItems = listOf(1, 2, 3),
|
||||
onItemSelected = { item -> println("Item selected: $item") },
|
||||
hintOne = "Hint for input one",
|
||||
|
||||
)
|
||||
}
|
|
@ -1,12 +1,16 @@
|
|||
package es.verdnatura.presentation.view.feature.ajustes.fragment
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.app.AlertDialog
|
||||
import android.content.Intent
|
||||
import android.content.pm.PackageInfo
|
||||
import android.content.pm.PackageManager
|
||||
import android.graphics.Color
|
||||
import android.graphics.drawable.Drawable
|
||||
import android.os.Build
|
||||
import android.os.Bundle
|
||||
import android.os.Handler
|
||||
import android.os.Looper
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.ArrayAdapter
|
||||
|
@ -42,6 +46,7 @@ import es.verdnatura.presentation.view.feature.ajustes.model.SectorItemVO
|
|||
import es.verdnatura.presentation.view.feature.ajustes.model.Train
|
||||
import es.verdnatura.presentation.view.feature.articulo.model.ItemPackingType
|
||||
import es.verdnatura.presentation.view.feature.login.fragment.LoginViewModel
|
||||
import es.verdnatura.presentation.view.feature.main.activity.MainActivity
|
||||
import es.verdnatura.presentation.view.feature.pasillero.fragment.PasilleroViewModel
|
||||
import es.verdnatura.presentation.view.feature.pasillero.model.CodeWorkerAction
|
||||
import es.verdnatura.presentation.view.feature.pasillero.model.PasillerosItemVO
|
||||
|
@ -82,12 +87,19 @@ class AjustesFragment :
|
|||
super.init()
|
||||
}
|
||||
|
||||
private fun setSearchable(listNames: MutableList<NameWithId>) {
|
||||
private fun setSearchable(
|
||||
listNames: MutableList<NameWithId>,
|
||||
type: String = "sector",
|
||||
listColorsElements: List<Int> = listOf()
|
||||
) {
|
||||
val adapter =
|
||||
SearchableAdapter(
|
||||
listElements = listNames,
|
||||
context = requireContext()
|
||||
context = requireContext(),
|
||||
listColorElements = listColorsElements,
|
||||
) { elementSelected ->
|
||||
when (type) {
|
||||
"sector" -> {
|
||||
sectorListVO.forEach {
|
||||
if (it.id == elementSelected.id) {
|
||||
runBlocking {
|
||||
|
@ -116,25 +128,60 @@ class AjustesFragment :
|
|||
return@forEach
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
"printer" -> {
|
||||
println("selected $elementSelected")
|
||||
val printer = printersList.find { it.name == elementSelected.name }
|
||||
println("selected printer $elementSelected")
|
||||
if (printer != null) {
|
||||
if (printer.sector?.backupPrinterFk == printer.id) {
|
||||
showWarningPrinter(printer.name, printer.id)
|
||||
} else {
|
||||
savePrinter(printer.name, printer.id)
|
||||
}
|
||||
}
|
||||
printersList.clear()
|
||||
}
|
||||
}
|
||||
val searchView =
|
||||
binding.searchableRecyclerView.findViewById<androidx.appcompat.widget.SearchView>(
|
||||
R.id.search_view
|
||||
)
|
||||
searchView?.setQuery("", false)
|
||||
binding.searchableRecyclerView.visibility = View.GONE
|
||||
}
|
||||
|
||||
binding.searchableRecyclerView.setAdapter(adapter, listNames)
|
||||
binding.searchableRecyclerView.visibility = View.VISIBLE
|
||||
binding.searchableRecyclerView.setSearchHint(getString(R.string.sectorSearch))
|
||||
binding.searchableRecyclerView.setSearchHint(
|
||||
if (type == "sector") getString(R.string.sectorSearch) else
|
||||
getString(R.string.printerSearch)
|
||||
)
|
||||
ma.hideKeyboard(binding.searchableRecyclerView)
|
||||
}
|
||||
|
||||
private fun setToolBar() {
|
||||
|
||||
val listIcons: ArrayList<ImageView> = ArrayList()
|
||||
|
||||
val iconInfo = ImageView(context)
|
||||
iconInfo.setImageResource(R.drawable.ic_info_delivery)
|
||||
|
||||
val iconLogout = ImageView(context)
|
||||
iconLogout.setImageResource(R.drawable.ic_logout)
|
||||
|
||||
val iconPhone = ImageView(context)
|
||||
iconPhone.setImageResource(R.drawable.phone_call)
|
||||
|
||||
val iconSettings = ImageView(context)
|
||||
iconSettings.setImageResource(R.drawable.ic_setting_ui)
|
||||
|
||||
listIcons.add(iconInfo)
|
||||
listIcons.add(iconLogout)
|
||||
// listIcons.add(iconPhone)
|
||||
//listIcons.add(iconSettings)
|
||||
|
||||
binding.mainToolbar.toolbarIcons.adapter =
|
||||
ToolBarAdapterTooltip(listIcons, object : OnOptionsSelectedListener {
|
||||
override fun onOptionsItemSelected(item: Drawable) {
|
||||
|
@ -165,8 +212,60 @@ class AjustesFragment :
|
|||
}
|
||||
|
||||
iconLogout.drawable -> {
|
||||
/* println("test incoming warehouse close")
|
||||
val intent = Intent("org.linphone.CLOSE_APP")
|
||||
intent.setPackage("org.linphone.incomingcall") // Reemplaza con el paquete de la app receptora
|
||||
requireContext().sendBroadcast(intent)*/
|
||||
ma.onMyBackPressed()
|
||||
}
|
||||
|
||||
iconSettings.drawable -> {
|
||||
println("test incoming warehouse opening")
|
||||
val intent = Intent()
|
||||
intent.setClassName(
|
||||
"org.linphone.incomingcall",
|
||||
"org.linphone.incomingcall.IncomingCallActivity"
|
||||
)
|
||||
intent.putExtra("server", "pbx.verdnatura.es")
|
||||
intent.putExtra("username", "1007")
|
||||
intent.putExtra("password", "delatorre.1234")
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
|
||||
startActivity(intent)
|
||||
|
||||
Handler(Looper.getMainLooper()).postDelayed({
|
||||
val intentIncoming =
|
||||
Intent(requireContext(), MainActivity::class.java)
|
||||
intentIncoming.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT)
|
||||
startActivity(intentIncoming)
|
||||
}, 2000)
|
||||
}
|
||||
|
||||
iconPhone.drawable -> {
|
||||
println("test incoming warehouse calling")
|
||||
val intentIncoming =
|
||||
Intent(requireContext(), MainActivity::class.java)
|
||||
intentIncoming.putExtra(
|
||||
"phoneNumber",
|
||||
"sip:651353889@pbx.verdnatura.es"
|
||||
)
|
||||
|
||||
/* intentIncoming.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT)
|
||||
startActivity(intentIncoming)*/
|
||||
val intent = Intent("org.linphone.CALLING")
|
||||
intent.setClassName(
|
||||
"org.linphone.incomingcall",
|
||||
"org.linphone.incomingcall.IncomingCallActivity"
|
||||
)
|
||||
intent.putExtra("server", "pbx.verdnatura.es")
|
||||
intent.putExtra("username", "1007")
|
||||
intent.putExtra("password", "*******")
|
||||
intent.putExtra("phoneNumber", "sip:651353889@pbx.verdnatura.es")
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT)
|
||||
startActivity(intent)
|
||||
requireContext().sendBroadcast(intent)
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
})
|
||||
|
@ -205,11 +304,7 @@ class AjustesFragment :
|
|||
getString(R.string.closeSession) -> ma.onMyBackPressed()
|
||||
getString(R.string.printerLabel) -> {
|
||||
messagePrinter = getString(R.string.SelectPrinter)
|
||||
viewModel.printerGet(
|
||||
mobileApplication.dataStoreApp.readDataStoreKey(
|
||||
SECTORFK
|
||||
)
|
||||
)
|
||||
viewModel.printerGet()
|
||||
}
|
||||
|
||||
getString(R.string.vehicleControl) -> ma.onPasillerosItemClickListener(
|
||||
|
@ -253,7 +348,7 @@ class AjustesFragment :
|
|||
event.getContentIfNotHandled().notNull {
|
||||
messagePrinter =
|
||||
getString(R.string.SelectPrinter) + "\n" + getString(R.string.printerRemoved)
|
||||
viewModel.printerGet(mobileApplication.dataStoreApp.readDataStoreKey(SECTORFK))
|
||||
viewModel.printerGet()
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -315,20 +410,53 @@ class AjustesFragment :
|
|||
}
|
||||
}
|
||||
loadPrintersList.observe(viewLifecycleOwner) { event ->
|
||||
event.getContentIfNotHandled().notNull { it ->
|
||||
event.getContentIfNotHandled()?.let { it ->
|
||||
|
||||
if (it.list.isNotEmpty()) {
|
||||
val listPrinters: ArrayList<String> = ArrayList()
|
||||
it.list.forEach {
|
||||
listPrinters.add(it.name)
|
||||
printersList.clear()
|
||||
|
||||
|
||||
printersList.addAll(it.list.sortedWith(compareBy(
|
||||
{ printer ->
|
||||
when {
|
||||
printer.sector?.id == mobileApplication.dataStoreApp.readDataStoreKey<Int>(
|
||||
SECTORFK
|
||||
) -> 0
|
||||
|
||||
printer.sector?.id != null -> 1
|
||||
else -> 2
|
||||
}
|
||||
},
|
||||
{ printer -> printer.name }
|
||||
)))
|
||||
|
||||
printersList.forEach { printer ->
|
||||
listPrinters.add(printer.name)
|
||||
}
|
||||
|
||||
val array = arrayOfNulls<String>(listPrinters.size)
|
||||
printersList = it.list
|
||||
showDialogForAll(listPrinters.toArray(array), messagePrinter ?: "")
|
||||
// showDialogForAll(listPrinters.toArray(array), messagePrinter ?: "")
|
||||
//Tarea7823
|
||||
val listColorsElements = printersList.mapIndexed { _, printer ->
|
||||
if (printer.sector?.id == mobileApplication.dataStoreApp.readDataStoreKey<Int>(
|
||||
SECTORFK
|
||||
)
|
||||
) printer.id else null
|
||||
}.filterNotNull()
|
||||
|
||||
setSearchable(printersList.map {
|
||||
NameWithId(
|
||||
id = it.id,
|
||||
name = it.name
|
||||
)
|
||||
} as MutableList<NameWithId>,
|
||||
type = "printer",
|
||||
listColorsElements = listColorsElements)
|
||||
|
||||
} else {
|
||||
viewModel.settingsItem[2].selected = getString(R.string.noprinter)
|
||||
settingsAdapter!!.notifyItemChanged(2)
|
||||
settingsAdapter?.notifyItemChanged(2)
|
||||
customDialog.setTitle(getString(R.string.printers))
|
||||
.setDescription(getString(R.string.Noprinters))
|
||||
.setOkButton(getString(R.string.Close)) {
|
||||
|
@ -336,7 +464,6 @@ class AjustesFragment :
|
|||
handleUserCall()
|
||||
}.show()
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
loadTrainList.observe(viewLifecycleOwner) { event ->
|
||||
|
@ -361,14 +488,19 @@ class AjustesFragment :
|
|||
super.observeViewModel()
|
||||
}
|
||||
|
||||
@SuppressLint("NotifyDataSetChanged")
|
||||
private fun getUserData() {
|
||||
|
||||
loginViewModel = LoginViewModel(requireActivity().applicationContext)
|
||||
handleUserCall()
|
||||
loginViewModel.handleUserResponse.observe(this@AjustesFragment) { iti ->
|
||||
runBlocking { mobileApplication.dataStoreApp.saveWorkerData(iti) }
|
||||
}
|
||||
runBlocking {
|
||||
mobileApplication.dataStoreApp.saveWorkerData(iti)
|
||||
setSettings()
|
||||
binding.setttingsItems.adapter!!.notifyDataSetChanged()
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private fun handleUserCall() {
|
||||
|
@ -436,12 +568,26 @@ class AjustesFragment :
|
|||
val positionPrinterEmergency =
|
||||
printersList.indexOfFirst { printer -> printer.sector?.backupPrinterFk == printer.id }
|
||||
|
||||
if (position == positionPrinterEmergency) {
|
||||
val positions = printersList.mapIndexed { index, printer ->
|
||||
if (printer.sector?.id == mobileApplication.dataStoreApp.readDataStoreKey<Int>(
|
||||
SECTORFK
|
||||
)
|
||||
) index else null
|
||||
}.filterNotNull()
|
||||
|
||||
when (position) {
|
||||
positionPrinterEmergency -> {
|
||||
textView.setTextColor(Color.RED)
|
||||
} else {
|
||||
}
|
||||
|
||||
in positions -> {
|
||||
textView.setTextColor(Color.BLACK)
|
||||
}
|
||||
|
||||
else -> {
|
||||
textView.setTextColor(Color.GRAY)
|
||||
}
|
||||
}
|
||||
|
||||
return view
|
||||
}
|
||||
|
|
|
@ -156,9 +156,10 @@ class AjustesViewModel(val context: Context) : BaseViewModel(context) {
|
|||
})
|
||||
}
|
||||
|
||||
fun printerGet(sectorFk: Int) {
|
||||
fun printerGet() {
|
||||
//Tarea 7823*/
|
||||
salix.getprinters(
|
||||
"""{"fields":["id","name","sectorFk"],"where":{"sectorFk":$sectorFk,"isLabeler":{"neq":false}},"include": [ { "relation": "sector", "scope": { "fields": ["backupPrinterFk"]}}]}"""
|
||||
"""{"fields":["id","name","sectorFk"],"where":{"isLabeler":{"neq":false}},"include": [ { "relation": "sector", "scope": { "fields": ["backupPrinterFk"]}}]}"""
|
||||
).enqueue(object : SalixCallback<MutableList<Printers>>(context) {
|
||||
override fun onSuccess(response: Response<MutableList<Printers>>) {
|
||||
_printerList.value = response.body()?.let { PrintersList(it) }
|
||||
|
|
|
@ -6,26 +6,21 @@ import es.verdnatura.domain.toast
|
|||
import es.verdnatura.presentation.base.BaseActivity
|
||||
import es.verdnatura.presentation.common.loadUrl
|
||||
|
||||
class ImageViewActivity : BaseActivity<ActivityImageviewBinding>(){
|
||||
class ImageViewActivity : BaseActivity<ActivityImageviewBinding>() {
|
||||
|
||||
override fun getLayoutId(): Int = R.layout.activity_imageview
|
||||
|
||||
|
||||
override fun init() {
|
||||
binding.mainToolbar.toolbarTitle.text = intent.getStringExtra(getString(R.string.title))
|
||||
try {
|
||||
binding.imgView.loadUrl(intent.getStringExtra(getString(R.string.url))!!)
|
||||
}catch(ex:Exception){
|
||||
} catch (ex: Exception) {
|
||||
getString(R.string.errorImage).toast(this)
|
||||
finish()
|
||||
}
|
||||
|
||||
|
||||
binding.mainToolbar.backButton.setOnClickListener {
|
||||
finish()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -25,8 +25,10 @@ import es.verdnatura.presentation.common.OnOptionsSelectedListener
|
|||
import es.verdnatura.presentation.common.PrinterDialogManager
|
||||
import es.verdnatura.presentation.common.ToolBarAdapterTooltip
|
||||
import es.verdnatura.presentation.common.hideKeyboard
|
||||
import es.verdnatura.presentation.common.itemScanIsQr
|
||||
import es.verdnatura.presentation.common.itemScanValue
|
||||
import es.verdnatura.presentation.common.loadUrl
|
||||
import es.verdnatura.presentation.composable.ImageViewActivityComposable
|
||||
import es.verdnatura.presentation.view.component.CustomDialogDynamicButtons
|
||||
import es.verdnatura.presentation.view.component.CustomDialogInput
|
||||
import es.verdnatura.presentation.view.component.CustomDialogList
|
||||
|
@ -39,6 +41,7 @@ import es.verdnatura.presentation.view.feature.articulo.model.ItemCardRowVO
|
|||
import es.verdnatura.presentation.view.feature.articulo.model.ItemCardVO
|
||||
import es.verdnatura.presentation.view.feature.articulo.model.ItemPackingType
|
||||
import es.verdnatura.presentation.view.feature.pasillero.model.PasillerosItemVO
|
||||
import kotlinx.coroutines.runBlocking
|
||||
import org.json.JSONObject
|
||||
|
||||
class ItemCardFragment(
|
||||
|
@ -132,10 +135,36 @@ class ItemCardFragment(
|
|||
val printerDialogManager = PrinterDialogManager(requireContext())
|
||||
printerDialogManager.showPrintDialog(
|
||||
buyToPrint ?: itemInfoG!!.id.toLong(),
|
||||
itemInfoG?.longName ?: ""
|
||||
) { id, labelType, copies, packing ->
|
||||
itemInfoG?.longName ?: "",
|
||||
onPrintClick = { id, labelType, copies, packing ->
|
||||
printItem(id, labelType, copies, packing)
|
||||
},
|
||||
onPrintChange = { text ->
|
||||
if (itemScanIsQr(text)) {
|
||||
val labeler = itemScanValue(
|
||||
text,
|
||||
arrayOf("printer"),
|
||||
"id"
|
||||
).toString().toInt()
|
||||
viewModel.operatorUpdate(
|
||||
workerFk = mobileApplication.userId!!,
|
||||
labelerFK = labeler
|
||||
)
|
||||
runBlocking {
|
||||
mobileApplication.dataStoreApp.editDataStoreKey(
|
||||
PRINTERFK,
|
||||
labeler
|
||||
)
|
||||
}
|
||||
} else {
|
||||
ma.messageWithSound(
|
||||
getString(R.string.qrPrinterNotvalid),
|
||||
isPlayed = true,
|
||||
isError = true,
|
||||
isToasted = false
|
||||
)
|
||||
}
|
||||
})
|
||||
} else ma.messageWithSound(
|
||||
getString(R.string.errorPrintBuy),
|
||||
isError = true,
|
||||
|
@ -272,7 +301,9 @@ class ItemCardFragment(
|
|||
}
|
||||
binding.itemcardImage.setOnClickListener {
|
||||
|
||||
val i = Intent(activity, ImageViewActivity::class.java)
|
||||
//JETPACKCOMPOSE
|
||||
// val i = Intent(activity, ImageViewActivity::class.java)
|
||||
val i = Intent(activity, ImageViewActivityComposable::class.java)
|
||||
i.putExtra(getString(R.string.url), urlLarge)
|
||||
i.putExtra(getString(R.string.title), titleImage)
|
||||
startActivity(i)
|
||||
|
@ -340,6 +371,17 @@ class ItemCardFragment(
|
|||
buyToPrint = it
|
||||
}
|
||||
}
|
||||
|
||||
loadChangePrinterResponse.observe(viewLifecycleOwner) { event ->
|
||||
event.getContentIfNotHandled().notNull {
|
||||
runBlocking {
|
||||
mobileApplication.dataStoreApp.editDataStoreKey(
|
||||
PRINTERFK,
|
||||
it
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -8,6 +8,7 @@ import es.verdnatura.domain.SalixCallback
|
|||
import es.verdnatura.domain.formatWithQuotes
|
||||
import es.verdnatura.domain.userCases.GetItemFromBarcodeUseCase
|
||||
import es.verdnatura.domain.userCases.GetItemPrintItemUseCase
|
||||
import es.verdnatura.domain.userCases.OperatorUseCase
|
||||
import es.verdnatura.presentation.base.BaseViewModel
|
||||
import es.verdnatura.presentation.common.Event
|
||||
import es.verdnatura.presentation.common.ItemBarCodeSalix
|
||||
|
@ -27,6 +28,7 @@ class ItemCardViewModel(var context: Context) : BaseViewModel(context) {
|
|||
|
||||
private val getItemFromBarcodeUseCase = GetItemFromBarcodeUseCase(salix)
|
||||
private val printItemUseCase = GetItemPrintItemUseCase(salix)
|
||||
private val operatorUseCase = OperatorUseCase(salix)
|
||||
|
||||
private val _itemCard by lazy { MutableLiveData<ItemCardVO>() }
|
||||
val itemCard: LiveData<ItemCardVO>
|
||||
|
@ -54,6 +56,10 @@ class ItemCardViewModel(var context: Context) : BaseViewModel(context) {
|
|||
val buyUltimateResponse: LiveData<Long> = _buyUltimateResponse
|
||||
val loadBuyUltimateResponse: LiveData<Event<Long>> = _buyUltimateResponse.map { Event(it) }
|
||||
|
||||
private val _changePrinterResponse by lazy { MutableLiveData<Int>() }
|
||||
val changePrinterResponse: LiveData<Int> = _changePrinterResponse
|
||||
val loadChangePrinterResponse: LiveData<Event<Int>> = _changePrinterResponse.map { Event(it) }
|
||||
|
||||
fun getItemCard(
|
||||
itemFk: Number,
|
||||
warehouseFk: Int,
|
||||
|
@ -69,6 +75,18 @@ class ItemCardViewModel(var context: Context) : BaseViewModel(context) {
|
|||
})
|
||||
}
|
||||
|
||||
fun operatorUpdate(workerFk: Number, labelerFK: Number) {
|
||||
|
||||
operatorUseCase.updateOperator(workerFk = workerFk, hashMapOf("labelerFk" to labelerFK))
|
||||
.enqueue(object : SalixCallback<Unit>(context) {
|
||||
override fun onSuccess(response: Response<Unit>) {
|
||||
super.onSuccess(response)
|
||||
_changePrinterResponse.value = labelerFK.toInt()
|
||||
}
|
||||
|
||||
})
|
||||
}
|
||||
|
||||
fun printItem(
|
||||
reportName: String,
|
||||
printerFk: Int,
|
||||
|
|
|
@ -2,41 +2,52 @@ package es.verdnatura.presentation.view.feature.buscaritem.adapter
|
|||
|
||||
import android.view.LayoutInflater
|
||||
import android.view.ViewGroup
|
||||
import android.widget.Toast
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import es.verdnatura.R
|
||||
import es.verdnatura.databinding.ItemLocationRowBinding
|
||||
import es.verdnatura.domain.toast
|
||||
import es.verdnatura.presentation.common.OnPasillerosItemClickListener
|
||||
import es.verdnatura.presentation.view.feature.buscaritem.model.ItemLocationVO
|
||||
import es.verdnatura.presentation.view.feature.buscaritem.model.ItemShelvings
|
||||
import es.verdnatura.presentation.view.feature.pasillero.model.PasillerosItemVO
|
||||
|
||||
class LocationAdapter (
|
||||
private val items: List<ItemLocationVO>,
|
||||
class LocationAdapter(
|
||||
private val items: List<ItemShelvings>,
|
||||
private val onPasillerosItemClickListener: OnPasillerosItemClickListener
|
||||
): RecyclerView.Adapter<LocationAdapter.ItemHolder> () {
|
||||
|
||||
) : RecyclerView.Adapter<LocationAdapter.ItemHolder>() {
|
||||
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ItemHolder {
|
||||
return ItemHolder(
|
||||
ItemLocationRowBinding.inflate(LayoutInflater.from(parent.context),parent,false)
|
||||
ItemLocationRowBinding.inflate(LayoutInflater.from(parent.context), parent, false)
|
||||
)
|
||||
}
|
||||
|
||||
override fun getItemCount() =items.size
|
||||
override fun getItemCount() = items.size
|
||||
|
||||
override fun onBindViewHolder(holder: ItemHolder, position: Int) {
|
||||
holder.bind(items[position])
|
||||
holder.binding.root.setOnClickListener {
|
||||
onPasillerosItemClickListener.onPasillerosItemClickListener(PasillerosItemVO(title =
|
||||
R.string.titleUbicator),items[position].Matricula)
|
||||
onPasillerosItemClickListener.onPasillerosItemClickListener(
|
||||
PasillerosItemVO(
|
||||
title =
|
||||
R.string.titleUbicator
|
||||
), items[position].shelving.code
|
||||
)
|
||||
}
|
||||
holder.binding.root.setOnLongClickListener {
|
||||
items[position].shelving.parking!!.sector.description.toast(
|
||||
holder.binding.root.context,
|
||||
Toast.LENGTH_SHORT
|
||||
)
|
||||
true
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class ItemHolder(
|
||||
val binding: ItemLocationRowBinding
|
||||
) : RecyclerView.ViewHolder(binding.root){
|
||||
//private val res = binding.root.context.resources
|
||||
fun bind(item: ItemLocationVO) {
|
||||
) : RecyclerView.ViewHolder(binding.root) {
|
||||
fun bind(item: ItemShelvings) {
|
||||
binding.apply {
|
||||
this.item = item
|
||||
}
|
||||
|
|
|
@ -0,0 +1,62 @@
|
|||
package es.verdnatura.presentation.view.feature.buscaritem.fragment
|
||||
|
||||
import es.verdnatura.domain.SalixCallback
|
||||
import es.verdnatura.domain.userCases.GetItemFromBarcodeUseCase
|
||||
import es.verdnatura.presentation.base.BaseViewModelCompose
|
||||
import es.verdnatura.presentation.view.feature.buscaritem.model.ItemShelvings
|
||||
import kotlinx.coroutines.flow.MutableStateFlow
|
||||
import kotlinx.coroutines.flow.asStateFlow
|
||||
import kotlinx.coroutines.flow.update
|
||||
import retrofit2.Response
|
||||
|
||||
data class UiState(
|
||||
val itemFk: String? = null,
|
||||
val items: List<ItemShelvings> = emptyList(),
|
||||
val isLoading: Boolean = false
|
||||
)
|
||||
|
||||
class BuscarItemComposeViewModel(var application: android.app.Application) :
|
||||
BaseViewModelCompose(application) {
|
||||
private val getItemFromBarcodeUseCase = GetItemFromBarcodeUseCase(salix)
|
||||
|
||||
private val _uiState = MutableStateFlow(UiState())
|
||||
val uiState = _uiState.asStateFlow()
|
||||
|
||||
fun getIdFromCodeSalix(code: String) {
|
||||
_uiState.update { it.copy(itemFk = code, isLoading = true) }
|
||||
getItemFromBarcodeUseCase.execute(code)
|
||||
.enqueue(object : SalixCallback<Int?>(application.applicationContext) {
|
||||
override fun onSuccess(response: Response<Int?>) {
|
||||
response.body()?.let { id ->
|
||||
itemshelvingsGet(id)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onError(t: Throwable) {
|
||||
super.onError(t)
|
||||
_uiState.update { it.copy(isLoading = false) }
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
fun itemshelvingsGet(itemFk: Any) {
|
||||
salix.itemShelvingsGet(
|
||||
filter = """{"where":{"itemFk":$itemFk},"fields":["created","visible","available","shelvingFk"],
|
||||
|"include":[{"relation":"shelving","scope":{"fields":["code","priority","parkingFk"],
|
||||
|"include":{"relation":"parking","scope":{"fields":["code","sectorFk"]}}}}]}""".trimMargin()
|
||||
)
|
||||
.enqueue(object : SalixCallback<List<ItemShelvings>>(application.applicationContext) {
|
||||
override fun onSuccess(response: Response<List<ItemShelvings>>) {
|
||||
response.body()?.let { list ->
|
||||
_uiState.update { it.copy(items = list, isLoading = false) }
|
||||
}
|
||||
}
|
||||
|
||||
override fun onError(t: Throwable) {
|
||||
super.onError(t)
|
||||
_uiState.update { it.copy(isLoading = false) }
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
|
@ -10,6 +10,7 @@ import es.verdnatura.presentation.base.BaseFragment
|
|||
import es.verdnatura.presentation.common.OnPasillerosItemClickListener
|
||||
import es.verdnatura.presentation.common.itemScanValue
|
||||
import es.verdnatura.presentation.view.feature.buscaritem.adapter.LocationAdapter
|
||||
import es.verdnatura.presentation.view.feature.buscaritem.model.ItemShelvings
|
||||
|
||||
class BuscarItemFragment(
|
||||
var itemFk: Any? = null
|
||||
|
@ -30,10 +31,10 @@ class BuscarItemFragment(
|
|||
override fun getLayoutId(): Int = R.layout.fragment_buscar_item
|
||||
|
||||
override fun init() {
|
||||
binding.mainToolbar.toolbarTitle.text = getString(R.string.getubicaition)
|
||||
binding.mainToolbar.toolbarTitle.text = getString(R.string.getubication)
|
||||
setEvents()
|
||||
if (itemFk != null) {
|
||||
getLocations(itemFk!!)
|
||||
viewModel.getIdFromCodeSalix(itemFk!!.toString())
|
||||
}
|
||||
super.init()
|
||||
}
|
||||
|
@ -66,17 +67,22 @@ class BuscarItemFragment(
|
|||
|
||||
private fun getLocations(itemFk: Any) {
|
||||
this.itemFk = itemFk
|
||||
viewModel.itemshelvingGetInfo(itemFk)
|
||||
viewModel.getIdFromCodeSalix(itemFk.toString())
|
||||
}
|
||||
|
||||
override fun observeViewModel() {
|
||||
with(viewModel) {
|
||||
loadLocationList.observe(viewLifecycleOwner) { event ->
|
||||
|
||||
loadItemShelvingsList.observe(viewLifecycleOwner) { event ->
|
||||
|
||||
event.getContentIfNotHandled().notNull { itemResponse ->
|
||||
|
||||
try {
|
||||
adapter = LocationAdapter(itemResponse.list, pasillerosItemClickListener!!)
|
||||
val sortedList = itemResponse.list.sortedWith(
|
||||
compareByDescending<ItemShelvings> { it.shelving.priority }
|
||||
.thenBy { it.created }
|
||||
)
|
||||
adapter = LocationAdapter(sortedList, pasillerosItemClickListener!!)
|
||||
binding.locationRecyclerview.adapter = adapter
|
||||
binding.locationRecyclerview.layoutManager =
|
||||
LinearLayoutManager(
|
||||
|
@ -85,6 +91,7 @@ class BuscarItemFragment(
|
|||
false
|
||||
)
|
||||
} catch (ex: Exception) {
|
||||
println("errorrrr ${ex.message}")
|
||||
ma.messageWithSound(
|
||||
message = ex.message.toString(),
|
||||
isError = true,
|
||||
|
|
|
@ -0,0 +1,74 @@
|
|||
package es.verdnatura.presentation.view.feature.buscaritem.fragment
|
||||
|
||||
import android.content.Context
|
||||
import android.os.Bundle
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import androidx.compose.ui.platform.ComposeView
|
||||
import androidx.fragment.app.Fragment
|
||||
import es.verdnatura.R
|
||||
import es.verdnatura.domain.toast
|
||||
import es.verdnatura.presentation.common.OnPasillerosItemClickListener
|
||||
import es.verdnatura.presentation.view.feature.main.activity.MainActivity
|
||||
import es.verdnatura.presentation.view.feature.pasillero.model.PasillerosItemVO
|
||||
import org.koin.androidx.viewmodel.ext.android.viewModel
|
||||
|
||||
class BuscarItemFragmentCompose(
|
||||
var itemFk: Any? = null
|
||||
) : Fragment() {
|
||||
private var pasillerosItemClickListener: OnPasillerosItemClickListener? = null
|
||||
private val viewModel: BuscarItemComposeViewModel by viewModel()
|
||||
|
||||
companion object {
|
||||
fun newInstance(entryPoint: Int?) = BuscarItemFragmentCompose(entryPoint)
|
||||
}
|
||||
|
||||
override fun onAttach(context: Context) {
|
||||
super.onAttach(context)
|
||||
if (context is OnPasillerosItemClickListener) pasillerosItemClickListener = context
|
||||
}
|
||||
|
||||
override fun onCreateView(
|
||||
inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?
|
||||
): View {
|
||||
return ComposeView(requireContext()).apply {
|
||||
setContent {
|
||||
BuscarItemScreen(
|
||||
viewModel = viewModel,
|
||||
onBackClick = { (context as MainActivity).onMyBackPressed() },
|
||||
onItemLongClick = { sector -> sector.toast(requireContext()) },
|
||||
onItemClick = { shelving ->
|
||||
pasillerosItemClickListener?.onPasillerosItemClickListener(
|
||||
PasillerosItemVO(title = R.string.titleUbicator),
|
||||
shelving
|
||||
)
|
||||
},
|
||||
title = getString(R.string.getubication)
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
itemFk?.let {
|
||||
viewModel.getIdFromCodeSalix(it.toString())
|
||||
}
|
||||
}
|
||||
|
||||
private fun showSector(item: LocationItem) {
|
||||
item.sector.toast(requireContext())
|
||||
|
||||
}
|
||||
|
||||
private fun openUbicadorFragment(item: LocationItem) {
|
||||
pasillerosItemClickListener!!.onPasillerosItemClickListener(
|
||||
PasillerosItemVO(
|
||||
title =
|
||||
R.string.titleUbicator
|
||||
), item.matricula
|
||||
)
|
||||
}
|
||||
|
||||
}
|
|
@ -5,24 +5,49 @@ import androidx.lifecycle.LiveData
|
|||
import androidx.lifecycle.MutableLiveData
|
||||
import androidx.lifecycle.map
|
||||
import es.verdnatura.domain.SalixCallback
|
||||
import es.verdnatura.domain.formatWithQuotes
|
||||
import es.verdnatura.domain.userCases.GetItemFromBarcodeUseCase
|
||||
import es.verdnatura.presentation.base.BaseViewModel
|
||||
import es.verdnatura.presentation.common.Event
|
||||
import es.verdnatura.presentation.view.feature.buscaritem.model.ItemLocationVO
|
||||
import es.verdnatura.presentation.view.feature.buscaritem.model.LocationListVO
|
||||
import es.verdnatura.presentation.view.feature.buscaritem.model.ItemShelvings
|
||||
import es.verdnatura.presentation.view.feature.buscaritem.model.ItemShelvingsList
|
||||
import retrofit2.Response
|
||||
|
||||
class BuscarItemViewModel(val context: Context) : BaseViewModel(context) {
|
||||
private val _locationList by lazy { MutableLiveData<LocationListVO>() }
|
||||
val locationList: LiveData<LocationListVO>
|
||||
get() = _locationList
|
||||
val loadLocationList: LiveData<Event<LocationListVO>> = _locationList.map { Event(it) }
|
||||
|
||||
fun itemshelvingGetInfo(itemFk: Any) {
|
||||
salix.itemshelvingGetInfo(params = arrayListOf(itemFk).formatWithQuotes())
|
||||
.enqueue(object : SalixCallback<List<ItemLocationVO>>(context) {
|
||||
override fun onSuccess(response: Response<List<ItemLocationVO>>) {
|
||||
_locationList.value = response.body()?.let { LocationListVO(it) }
|
||||
private val getItemFromBarcodeUseCase = GetItemFromBarcodeUseCase(salix)
|
||||
|
||||
private val _itemShelvingsList by lazy { MutableLiveData<ItemShelvingsList>() }
|
||||
val itemShelvingsList: LiveData<ItemShelvingsList> = _itemShelvingsList
|
||||
val loadItemShelvingsList: LiveData<Event<ItemShelvingsList>> =
|
||||
_itemShelvingsList.map { Event(it) }
|
||||
|
||||
fun getIdFromCodeSalix(code: String) {
|
||||
getItemFromBarcodeUseCase.execute(code)
|
||||
.enqueue(object : SalixCallback<Int?>(context) {
|
||||
|
||||
override fun onSuccess(response: Response<Int?>) {
|
||||
if (response.body() != null) {
|
||||
itemshelvingsGet(response.body()!!)
|
||||
}
|
||||
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
fun itemshelvingsGet(itemFk: Any) {
|
||||
salix.itemShelvingsGet(
|
||||
filter = """{"where":{"itemFk":$itemFk},"fields":["created","visible","available","shelvingFk"],
|
||||
|"include":[{"relation":"shelving","scope":{"fields":["code","priority","parkingFk"],
|
||||
|"include":{"relation":"parking","scope":{"fields":["code","sectorFk"]}}}}]}""".trimMargin()
|
||||
)
|
||||
.enqueue(object : SalixCallback<List<ItemShelvings>>(context) {
|
||||
override fun onSuccess(response: Response<List<ItemShelvings>>) {
|
||||
_itemShelvingsList.value = response.body()?.let {
|
||||
val filteredList = it.filter { itemShelving ->
|
||||
itemShelving.shelving.parking != null
|
||||
}
|
||||
ItemShelvingsList(filteredList)
|
||||
}
|
||||
}
|
||||
|
||||
})
|
||||
|
|
|
@ -0,0 +1,378 @@
|
|||
package es.verdnatura.presentation.view.feature.buscaritem.fragment
|
||||
|
||||
import androidx.compose.foundation.ExperimentalFoundationApi
|
||||
import androidx.compose.foundation.background
|
||||
import androidx.compose.foundation.combinedClickable
|
||||
import androidx.compose.foundation.layout.Arrangement
|
||||
import androidx.compose.foundation.layout.Box
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.Row
|
||||
import androidx.compose.foundation.layout.Spacer
|
||||
import androidx.compose.foundation.layout.fillMaxSize
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.foundation.layout.height
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.lazy.LazyColumn
|
||||
import androidx.compose.foundation.lazy.items
|
||||
import androidx.compose.material3.HorizontalDivider
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.LaunchedEffect
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.runtime.setValue
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.focus.FocusRequester
|
||||
import androidx.compose.ui.focus.focusRequester
|
||||
import androidx.compose.ui.focus.onFocusEvent
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.platform.LocalContext
|
||||
import androidx.compose.ui.platform.LocalSoftwareKeyboardController
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.text.style.TextAlign
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.compose.ui.unit.sp
|
||||
import androidx.lifecycle.compose.collectAsStateWithLifecycle
|
||||
import es.verdnatura.R
|
||||
import es.verdnatura.presentation.composable.CustomToolbar
|
||||
import es.verdnatura.presentation.composable.LottieLoadingAnimation
|
||||
import es.verdnatura.presentation.composable.ScanLineTextSearch
|
||||
|
||||
@Composable
|
||||
fun BuscarItemScreen(
|
||||
viewModel: BuscarItemComposeViewModel,
|
||||
onBackClick: () -> Unit,
|
||||
onItemLongClick: (sector: String) -> Unit,
|
||||
onItemClick: (matricula: String) -> Unit,
|
||||
title: String
|
||||
) {
|
||||
val uiState by viewModel.uiState.collectAsStateWithLifecycle()
|
||||
|
||||
val locationItems = uiState.items
|
||||
.filter { it.shelving.parking != null }
|
||||
.map {
|
||||
LocationItem(
|
||||
parking = it.shelving.parking!!.code,
|
||||
matricula = it.shelving.code,
|
||||
visible = it.visible.toString(),
|
||||
reserve = it.available.toString(),
|
||||
priority = it.shelving.priority.toString(),
|
||||
fecha = it.created,
|
||||
sector = it.shelving.parking.sector.description
|
||||
)
|
||||
}
|
||||
|
||||
LocationScreenContent(
|
||||
items = locationItems,
|
||||
isLoading = uiState.isLoading,
|
||||
titleToolBar = if (uiState.itemFk != null) {
|
||||
LocalContext.current.getString(
|
||||
R.string.itemsTotal,
|
||||
uiState.itemFk,
|
||||
LocalContext.current.getString(R.string.visibleTotal),
|
||||
uiState.items
|
||||
.filter { it.shelving.parking != null }
|
||||
.sumOf { it.visible }
|
||||
)
|
||||
} else title,
|
||||
onTextChange = { input -> viewModel.getIdFromCodeSalix(input) },
|
||||
onBackClick = onBackClick,
|
||||
onLongClick = onItemLongClick,
|
||||
onClick = onItemClick,
|
||||
modifier = Modifier
|
||||
)
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun LocationScreenContent(
|
||||
items: List<LocationItem>,
|
||||
isLoading: Boolean,
|
||||
titleToolBar: String,
|
||||
onTextChange: (String) -> Unit,
|
||||
onBackClick: () -> Unit,
|
||||
onLongClick: (String) -> Unit,
|
||||
onClick: (String) -> Unit,
|
||||
modifier: Modifier
|
||||
) {
|
||||
var searchText by remember { mutableStateOf("") }
|
||||
val focusRequester = remember { FocusRequester() }
|
||||
val keyboardController = LocalSoftwareKeyboardController.current
|
||||
|
||||
val onImeAction: () -> Unit = {
|
||||
onTextChange(searchText)
|
||||
searchText = ""
|
||||
keyboardController?.hide()
|
||||
}
|
||||
Box(
|
||||
modifier = modifier
|
||||
.fillMaxSize()
|
||||
.background(Color.Black)
|
||||
) {
|
||||
Column(
|
||||
modifier = modifier
|
||||
.fillMaxSize()
|
||||
.background(Color.Black)
|
||||
|
||||
) {
|
||||
|
||||
CustomToolbar(
|
||||
title = titleToolBar,
|
||||
subtitle = "",
|
||||
showBackButton = true,
|
||||
showSwitch = false,
|
||||
iconList = listOf(),
|
||||
onBackClick = onBackClick,
|
||||
onSwitchChange = { },
|
||||
|
||||
)
|
||||
Spacer(modifier = Modifier.height(8.dp))
|
||||
|
||||
|
||||
ScanLineTextSearch(
|
||||
value = searchText,
|
||||
onValueChange = {
|
||||
searchText = it
|
||||
},
|
||||
onImeAction,
|
||||
modifier = Modifier
|
||||
.focusRequester(focusRequester)
|
||||
.onFocusEvent {
|
||||
if (it.isFocused) {
|
||||
keyboardController?.hide() // Asegura que el teclado no se abra
|
||||
}
|
||||
}
|
||||
)
|
||||
LaunchedEffect(Unit) {
|
||||
focusRequester.requestFocus()
|
||||
keyboardController?.hide()
|
||||
}
|
||||
|
||||
Row(
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.padding(vertical = 8.dp),
|
||||
horizontalArrangement = Arrangement.Start
|
||||
) {
|
||||
listOf(
|
||||
R.string.parking,
|
||||
R.string.Matrícula,
|
||||
R.string.Visible,
|
||||
R.string.reserve,
|
||||
R.string.priority,
|
||||
R.string.date
|
||||
).forEach { textRes ->
|
||||
Text(
|
||||
text = stringResource(id = textRes),
|
||||
color = Color.White,
|
||||
fontSize = 14.sp,
|
||||
modifier = Modifier.weight(1f)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
HorizontalDivider(thickness = 1.dp, color = Color.White)
|
||||
LazyColumn(
|
||||
modifier = Modifier.fillMaxSize()
|
||||
) {
|
||||
|
||||
items(items) { item ->
|
||||
|
||||
LocationRow(
|
||||
item = item,
|
||||
onLongClick = { selectedItem ->
|
||||
onLongClick(selectedItem.sector)
|
||||
},
|
||||
onClick = { selectedItem ->
|
||||
onClick(selectedItem.matricula)
|
||||
},
|
||||
)
|
||||
HorizontalDivider(thickness = 1.dp, color = Color.White)
|
||||
}
|
||||
}
|
||||
}
|
||||
if (isLoading) {
|
||||
Box(
|
||||
modifier = Modifier
|
||||
.fillMaxSize()
|
||||
.background(Color.Black.copy(alpha = 0.7f)),
|
||||
contentAlignment = Alignment.Center
|
||||
) {
|
||||
LottieLoadingAnimation(true)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// Como estaba
|
||||
|
||||
/*@Composable
|
||||
fun LocationScreen(
|
||||
//viewModel: ViewModel?, // Falta ver de arreglar con koin o viewmodel → No necesario, en el Fragment observa
|
||||
items: List<LocationItem>,
|
||||
onTextChange: (String) -> Unit,
|
||||
titleToolBar: String,
|
||||
onBackClick: () -> Unit = {},
|
||||
modifier: Modifier = Modifier,
|
||||
onLongClick: (LocationItem) -> Unit,
|
||||
onClick: (LocationItem) -> Unit
|
||||
) {
|
||||
|
||||
var searchText by remember { mutableStateOf("") }
|
||||
val focusRequester = remember { FocusRequester() }
|
||||
val keyboardController = LocalSoftwareKeyboardController.current
|
||||
var showLoading by remember { mutableStateOf(false) }
|
||||
|
||||
val onImeAction: () -> Unit = {
|
||||
onTextChange(searchText)
|
||||
searchText = ""
|
||||
keyboardController?.hide()
|
||||
}
|
||||
Box(
|
||||
modifier = modifier
|
||||
.fillMaxSize()
|
||||
.background(Color.Black)
|
||||
) {
|
||||
Column(
|
||||
modifier = modifier
|
||||
.fillMaxSize()
|
||||
.background(Color.Black)
|
||||
|
||||
) {
|
||||
if (showLoading) {
|
||||
LottieLoadingAnimation(true)
|
||||
}
|
||||
CustomToolbar(
|
||||
title = titleToolBar,
|
||||
subtitle = "",
|
||||
showBackButton = true,
|
||||
showSwitch = false,
|
||||
iconList = listOf(),
|
||||
onBackClick = onBackClick,
|
||||
onSwitchChange = { },
|
||||
|
||||
)
|
||||
Spacer(modifier = Modifier.height(8.dp))
|
||||
|
||||
|
||||
ScanLineTextSearch(
|
||||
value = searchText,
|
||||
onValueChange = {
|
||||
searchText = it
|
||||
showLoading = true
|
||||
},
|
||||
onImeAction,
|
||||
modifier = Modifier
|
||||
.focusRequester(focusRequester)
|
||||
.onFocusEvent {
|
||||
if (it.isFocused) {
|
||||
keyboardController?.hide() // Asegura que el teclado no se abra
|
||||
}
|
||||
}
|
||||
)
|
||||
LaunchedEffect(Unit) {
|
||||
focusRequester.requestFocus()
|
||||
keyboardController?.hide()
|
||||
}
|
||||
|
||||
Row(
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.padding(vertical = 8.dp),
|
||||
horizontalArrangement = Arrangement.Start
|
||||
) {
|
||||
listOf(
|
||||
R.string.parking,
|
||||
R.string.Matrícula,
|
||||
R.string.Visible,
|
||||
R.string.reserve,
|
||||
R.string.priority,
|
||||
R.string.date
|
||||
).forEach { textRes ->
|
||||
Text(
|
||||
text = stringResource(id = textRes),
|
||||
color = Color.White,
|
||||
fontSize = 14.sp,
|
||||
modifier = Modifier.weight(1f)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
HorizontalDivider(thickness = 1.dp, color = Color.White)
|
||||
LazyColumn(
|
||||
modifier = Modifier.fillMaxSize()
|
||||
) {
|
||||
|
||||
items(items) { item ->
|
||||
|
||||
LocationRow(
|
||||
item = item,
|
||||
onLongClick = { selectedItem ->
|
||||
onLongClick(selectedItem)
|
||||
},
|
||||
onClick = { selectedItem ->
|
||||
onClick(selectedItem)
|
||||
},
|
||||
)
|
||||
HorizontalDivider(thickness = 1.dp, color = Color.White)
|
||||
}
|
||||
}
|
||||
showLoading = false
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
@OptIn(ExperimentalFoundationApi::class)
|
||||
@Composable
|
||||
fun LocationRow(
|
||||
item: LocationItem, onLongClick: (LocationItem) -> Unit, onClick: (LocationItem) -> Unit
|
||||
) {
|
||||
Row(modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.padding(vertical = 4.dp)
|
||||
.combinedClickable(onClick = { onClick(item) }, onLongClick = { onLongClick(item) }
|
||||
|
||||
), horizontalArrangement = Arrangement.SpaceEvenly) {
|
||||
Text(text = item.parking, color = Color.White, modifier = Modifier.weight(1f))
|
||||
Text(text = item.matricula, color = Color.White, modifier = Modifier.weight(1f))
|
||||
Text(text = item.visible, color = Color.White, modifier = Modifier.weight(1f))
|
||||
Text(text = item.reserve, color = Color.White, modifier = Modifier.weight(1f))
|
||||
Text(text = item.priority, color = Color.White, modifier = Modifier.weight(1f))
|
||||
Text(
|
||||
text = item.fecha,
|
||||
color = Color.White,
|
||||
modifier = Modifier.weight(1f),
|
||||
textAlign = TextAlign.Center
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
// Modelo de datos
|
||||
data class LocationItem(
|
||||
val parking: String,
|
||||
val matricula: String,
|
||||
val visible: String,
|
||||
val reserve: String,
|
||||
val priority: String,
|
||||
val fecha: String,
|
||||
val sector: String
|
||||
)
|
||||
|
||||
// Vista previa
|
||||
/*@Preview(showBackground = true)
|
||||
@Composable
|
||||
fun PreviewLocationScreen() {
|
||||
LocationScreen(
|
||||
items = listOf(
|
||||
LocationItem("P1", "1234ABC", "Sí", "No", "Alta", "12/02/2025", "previa"),
|
||||
LocationItem("P2", "5678DEF", "No", "Sí", "Baja", "13/02/2025", "previa")
|
||||
),
|
||||
onTextChange = {},
|
||||
titleToolBar = "Buscar Item",
|
||||
onBackClick = {},
|
||||
onLongClick = {},
|
||||
onClick = {})
|
||||
|
||||
}*/
|
|
@ -2,21 +2,27 @@ package es.verdnatura.presentation.view.feature.buscaritem.model
|
|||
|
||||
import es.verdnatura.domain.isoToString
|
||||
|
||||
class ItemLocationVO(
|
||||
var Parking: String = "",
|
||||
var Matricula: String = "",
|
||||
var visible: Int = 0,
|
||||
var itemFk: Int = 0,
|
||||
var priority: Int = 0
|
||||
class ItemShelvingsList(
|
||||
var list: List<ItemShelvings> = listOf()
|
||||
)
|
||||
|
||||
data class ItemShelvings(
|
||||
val visible: Int, val available: Int, val shelving: Shelving
|
||||
) {
|
||||
var created: String = ""
|
||||
get() {
|
||||
return field.isoToString()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class LocationListVO(
|
||||
var list: List<ItemLocationVO> = listOf()
|
||||
data class Shelving(
|
||||
val code: String, val priority: Int, val parking: Parking?
|
||||
)
|
||||
|
||||
data class Parking(
|
||||
val code: String, val sector: Sector
|
||||
)
|
||||
|
||||
data class Sector(
|
||||
val description: String
|
||||
)
|
|
@ -181,9 +181,11 @@ class ReubicationCollectionFragment(
|
|||
private fun customDialogMerge(itemReubication: Reubication) {
|
||||
|
||||
if (customDialogInputTwoValues.getValueTwo().isNotEmpty()) {
|
||||
viewModel.itemShelvingMerge(
|
||||
itemReubication.id, customDialogInputTwoValues.getValueTwo().uppercase()
|
||||
viewModel.getMergeFromCode(
|
||||
itemReubication.id,
|
||||
customDialogInputTwoValues.getValueTwo().uppercase()
|
||||
)
|
||||
|
||||
} else {
|
||||
ma.messageWithSound(
|
||||
getString(R.string.returnScan), isError = true, isPlayed = true, isToasted = true
|
||||
|
|
|
@ -56,6 +56,8 @@ class ReubicationFragment(var entrypoint: String) :
|
|||
if (!binding.scanInput.text.isNullOrEmpty()) {
|
||||
|
||||
shelvingScaned = binding.scanInput.text.toString()
|
||||
|
||||
|
||||
viewModel.itemShelvingAlternative(
|
||||
shelvingFk = binding.scanInput.text.toString(),
|
||||
)
|
||||
|
|
|
@ -1,28 +1,31 @@
|
|||
package es.verdnatura.presentation.view.feature.collection.adapter
|
||||
|
||||
import android.content.Context
|
||||
import android.graphics.Paint
|
||||
import android.view.LayoutInflater
|
||||
import android.view.ViewGroup
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import es.verdnatura.R
|
||||
import es.verdnatura.databinding.ItemPlacementRowBinding
|
||||
import es.verdnatura.domain.ConstAndValues.CONTROLADOR
|
||||
import es.verdnatura.presentation.common.OnPasillerosItemClickListener
|
||||
import es.verdnatura.presentation.view.feature.pasillero.model.PasillerosItemVO
|
||||
import es.verdnatura.presentation.view.feature.sacador.model.PlacementVO
|
||||
|
||||
class PlacementAdapter (
|
||||
class PlacementAdapter(
|
||||
private val items: List<PlacementVO>,
|
||||
private val onPasillerosItemClickListener: OnPasillerosItemClickListener
|
||||
): RecyclerView.Adapter<PlacementAdapter.AjustesItemHolder> () {
|
||||
private val onPasillerosItemClickListener: OnPasillerosItemClickListener,
|
||||
private val type: String? = null
|
||||
) : RecyclerView.Adapter<PlacementAdapter.AjustesItemHolder>() {
|
||||
var context: Context? = null
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): AjustesItemHolder {
|
||||
this.context = parent.context
|
||||
return AjustesItemHolder(
|
||||
ItemPlacementRowBinding.inflate(LayoutInflater.from(parent.context),parent,false)
|
||||
ItemPlacementRowBinding.inflate(LayoutInflater.from(parent.context), parent, false)
|
||||
)
|
||||
}
|
||||
|
||||
override fun getItemCount() =items.size
|
||||
override fun getItemCount() = items.size
|
||||
|
||||
override fun onBindViewHolder(holder: AjustesItemHolder, position: Int) {
|
||||
holder.bind(items[position])
|
||||
|
@ -30,19 +33,26 @@ class PlacementAdapter (
|
|||
|
||||
inner class AjustesItemHolder(
|
||||
val binding: ItemPlacementRowBinding
|
||||
) : RecyclerView.ViewHolder(binding.root){
|
||||
) : RecyclerView.ViewHolder(binding.root) {
|
||||
fun bind(placement: PlacementVO) {
|
||||
binding.apply {
|
||||
if (placement.placement.isNullOrEmpty())
|
||||
placement.placement = placement.parking
|
||||
if (placement.visible.isNullOrEmpty())
|
||||
placement.visible = "("+placement.stockTotal+")"
|
||||
if (placement.placement.isNullOrEmpty()) placement.placement = placement.parking
|
||||
if (placement.visible.isNullOrEmpty()) placement.visible =
|
||||
"(" + placement.stockTotal + ")"
|
||||
this.item = placement
|
||||
|
||||
itemRootLayout.setOnClickListener {
|
||||
onPasillerosItemClickListener.onPasillerosItemClickListener(PasillerosItemVO(title =
|
||||
R.string.titleUbicator),placement.shelving)
|
||||
onPasillerosItemClickListener.onPasillerosItemClickListener(
|
||||
PasillerosItemVO(
|
||||
title = R.string.titleUbicator
|
||||
), placement.shelving
|
||||
)
|
||||
}
|
||||
if (type == CONTROLADOR) {
|
||||
placementcode.paintFlags = placementcode.paintFlags or Paint.UNDERLINE_TEXT_FLAG
|
||||
placementcode.paintFlags = placementcode.paintFlags or Paint.UNDERLINE_TEXT_FLAG
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,10 +3,12 @@ package es.verdnatura.presentation.view.feature.collection.adapter
|
|||
import android.content.Context
|
||||
import android.content.res.ColorStateList
|
||||
import android.graphics.Color
|
||||
import android.graphics.Paint
|
||||
import android.graphics.drawable.Drawable
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.View.GONE
|
||||
import android.view.View.INVISIBLE
|
||||
import android.view.View.VISIBLE
|
||||
import android.view.ViewGroup
|
||||
import androidx.core.content.ContextCompat.getColor
|
||||
|
@ -83,7 +85,7 @@ class SaleAdapter(
|
|||
|
||||
itemArticlePlacements.apply {
|
||||
layoutManager = childLayoutManager
|
||||
adapter = PlacementAdapter(sale.placements, onPasillerosItemClickListener)
|
||||
adapter = PlacementAdapter(sale.placements, onPasillerosItemClickListener, type)
|
||||
}
|
||||
|
||||
//CLICK EVENTS
|
||||
|
@ -132,9 +134,12 @@ class SaleAdapter(
|
|||
|
||||
//ERROR
|
||||
if (sale.originalQuantity != sale.quantity) {
|
||||
layoutError.visibility = View.VISIBLE
|
||||
layoutError.visibility = VISIBLE
|
||||
txtError.text =
|
||||
binding.root.context.getString(R.string.originalQuantity) + sale.originalQuantity
|
||||
buildString {
|
||||
append(binding.root.context.getString(R.string.originalQuantity))
|
||||
append(sale.originalQuantity)
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -145,7 +150,7 @@ class SaleAdapter(
|
|||
// d("VERDNATURA::","La quantity de ${sale.saleFk} es ${sale.pickedQuantity} y está ${sale.isPrepared}")
|
||||
|
||||
if (sale.isNew) {
|
||||
layoutError.visibility = View.VISIBLE
|
||||
layoutError.visibility = VISIBLE
|
||||
txtError.text = binding.root.context.getString(R.string.newItem)
|
||||
|
||||
}
|
||||
|
@ -157,7 +162,7 @@ class SaleAdapter(
|
|||
val backgroundDrawableCon: Drawable = binding.itemArticleRowSemaforoCon.background
|
||||
|
||||
if (!sale.isNew && sale.originalQuantity == sale.quantity) {
|
||||
layoutError.visibility = View.GONE
|
||||
layoutError.visibility = GONE
|
||||
}
|
||||
|
||||
//SEMAFORO
|
||||
|
@ -278,10 +283,10 @@ class SaleAdapter(
|
|||
)*/
|
||||
} else if (sale.isPreviousPrepared == "1") {
|
||||
contentLayout.setBackgroundColor(
|
||||
getColor(
|
||||
if (sale.picked == null) getColor(
|
||||
context!!,
|
||||
R.color.verdnatura_dark_sky_blue
|
||||
)
|
||||
R.color.verdnatura_black
|
||||
) else getColor(context!!, R.color.verdnatura_dark_sky_blue)
|
||||
)
|
||||
} else {
|
||||
contentLayout.setBackgroundColor(getColor(context!!, R.color.verdnatura_black))
|
||||
|
@ -308,53 +313,53 @@ class SaleAdapter(
|
|||
}
|
||||
|
||||
if (isExpanded) {
|
||||
itemArticlePlacements.visibility = View.VISIBLE
|
||||
itemArticlePlacements.visibility = VISIBLE
|
||||
ivArrow.setImageResource(R.drawable.ic_arrow_down)
|
||||
|
||||
} else {
|
||||
itemArticlePlacements.visibility = View.GONE
|
||||
itemArticlePlacements.visibility = GONE
|
||||
ivArrow.setImageResource(R.drawable.ic_arrow_up)
|
||||
}
|
||||
|
||||
itemArticlePlacements.visibility = if (isExpanded) View.VISIBLE else {
|
||||
View.GONE
|
||||
itemArticlePlacements.visibility = if (isExpanded) VISIBLE else {
|
||||
GONE
|
||||
}
|
||||
|
||||
if (sale.isParent) {
|
||||
itemArticleItemFk.visibility = View.INVISIBLE
|
||||
itemArticleItemFk.visibility = INVISIBLE
|
||||
//itemPackingText.visibility = View.INVISIBLE
|
||||
//itemPackingItemFk.visibility = View.INVISIBLE
|
||||
itemArticleCel1.visibility = View.INVISIBLE
|
||||
itemArticleCel2.visibility = View.INVISIBLE
|
||||
itemArticleCel3.visibility = View.INVISIBLE
|
||||
itemArticleQuantity.visibility = View.INVISIBLE
|
||||
txtdeNew.visibility = View.INVISIBLE
|
||||
itemArticleQuantityPicked.visibility = View.INVISIBLE
|
||||
itemArticleQuantityLine3.visibility = View.VISIBLE
|
||||
imageErrorMessage.visibility = View.INVISIBLE
|
||||
ivArrow.visibility = View.VISIBLE
|
||||
itemArticleCel1.visibility = INVISIBLE
|
||||
itemArticleCel2.visibility = INVISIBLE
|
||||
itemArticleCel3.visibility = INVISIBLE
|
||||
itemArticleQuantity.visibility = INVISIBLE
|
||||
txtdeNew.visibility = INVISIBLE
|
||||
itemArticleQuantityPicked.visibility = INVISIBLE
|
||||
itemArticleQuantityLine3.visibility = VISIBLE
|
||||
imageErrorMessage.visibility = INVISIBLE
|
||||
ivArrow.visibility = VISIBLE
|
||||
|
||||
} else {
|
||||
itemArticleItemFk.visibility = View.VISIBLE
|
||||
itemArticleItemFk.visibility = VISIBLE
|
||||
//itemPackingText.visibility = View.VISIBLE
|
||||
//itemPackingItemFk.visibility = View.VISIBLE
|
||||
itemArticleCel1.visibility = View.VISIBLE
|
||||
itemArticleCel2.visibility = View.VISIBLE
|
||||
itemArticleCel3.visibility = View.VISIBLE
|
||||
itemArticleQuantity.visibility = View.VISIBLE
|
||||
txtdeNew.visibility = View.VISIBLE
|
||||
itemArticleQuantityPicked.visibility = View.VISIBLE
|
||||
itemArticleQuantityLine3.visibility = View.VISIBLE
|
||||
itemArticleCel1.visibility = VISIBLE
|
||||
itemArticleCel2.visibility = VISIBLE
|
||||
itemArticleCel3.visibility = VISIBLE
|
||||
itemArticleQuantity.visibility = VISIBLE
|
||||
txtdeNew.visibility = VISIBLE
|
||||
itemArticleQuantityPicked.visibility = VISIBLE
|
||||
itemArticleQuantityLine3.visibility = VISIBLE
|
||||
if (type != SACADOR) {
|
||||
val colorRes =
|
||||
if (sale.hasMistake == true || sale.hasMistake == 1) R.color.verdnatura_red_salix else R.color.verdnatura_black
|
||||
imageErrorMessage.imageTintList =
|
||||
ColorStateList.valueOf(getColor(context!!, colorRes))
|
||||
imageErrorMessage.visibility = View.VISIBLE
|
||||
imageErrorMessage.visibility = VISIBLE
|
||||
} else {
|
||||
imageErrorMessage.visibility = View.INVISIBLE
|
||||
imageErrorMessage.visibility = INVISIBLE
|
||||
}
|
||||
ivArrow.visibility = View.INVISIBLE
|
||||
ivArrow.visibility = INVISIBLE
|
||||
}
|
||||
|
||||
if (!sale.sonSales.isNullOrEmpty()) {
|
||||
|
@ -372,7 +377,7 @@ class SaleAdapter(
|
|||
|
||||
} else {
|
||||
//revisar porque incosistencia
|
||||
itemArticlePlacements.visibility = View.VISIBLE
|
||||
itemArticlePlacements.visibility = VISIBLE
|
||||
}
|
||||
|
||||
/* rvHeadlines.adapter=SaleAdapter(sale.sonSales,onPasillerosItemClickListener,onQuantityClick,onSaleClickListener,onMistakeClickListener,onPackingClick)
|
||||
|
@ -383,11 +388,11 @@ class SaleAdapter(
|
|||
|
||||
if (isExpanded) {
|
||||
ivArrow.setImageResource(R.drawable.ic_arrow_up)
|
||||
itemArticlePlacements.visibility = View.GONE
|
||||
itemArticlePlacements.visibility = GONE
|
||||
} else {
|
||||
|
||||
ivArrow.setImageResource(R.drawable.ic_arrow_down)
|
||||
itemArticlePlacements.visibility = View.VISIBLE
|
||||
itemArticlePlacements.visibility = VISIBLE
|
||||
}
|
||||
isExpanded = !isExpanded
|
||||
|
||||
|
@ -395,7 +400,7 @@ class SaleAdapter(
|
|||
}
|
||||
|
||||
//Tarea 6607
|
||||
itemArticleCel2Count.visibility = View.GONE
|
||||
itemArticleCel2Count.visibility = GONE
|
||||
/*itemArticleCel2Count.visibility = if (type == CONTROLADOR) {
|
||||
View.VISIBLE
|
||||
} else {
|
||||
|
@ -418,13 +423,15 @@ class SaleAdapter(
|
|||
itemTicketColor.setOnClickListener {
|
||||
onTicketColorClickListener?.onTicketColorListener(sale)
|
||||
}
|
||||
if (type == SACADOR || type == CONTROLADOR) {
|
||||
if (type == CONTROLADOR) {
|
||||
itemTicketColor.tooltipText = context!!.getString(R.string.filterLevelColor)
|
||||
ticketFk.paintFlags = ticketFk.paintFlags or Paint.UNDERLINE_TEXT_FLAG
|
||||
itemArticleItemFk.paintFlags =
|
||||
itemArticleItemFk.paintFlags or Paint.UNDERLINE_TEXT_FLAG
|
||||
}
|
||||
|
||||
/* ticketFk.paintFlags = ticketFk.paintFlags or Paint.UNDERLINE_TEXT_FLAG
|
||||
itemArticleItemFk.paintFlags =
|
||||
itemArticleItemFk.paintFlags or Paint.UNDERLINE_TEXT_FLAG*/
|
||||
|
||||
|
||||
|
||||
|
||||
this.sale = sale
|
||||
|
@ -503,8 +510,4 @@ class SaleAdapter(
|
|||
notifyDataSetChanged() // Notifica al adaptador que los datos han cambiado
|
||||
}
|
||||
|
||||
fun orderSales(newSales: List<SaleVO>) {
|
||||
|
||||
notifyDataSetChanged() // Notifica al adaptador que los datos han cambiado
|
||||
}
|
||||
}
|
|
@ -354,7 +354,15 @@ class SaleAdapterNew(
|
|||
|
||||
println("parkingCodePrevia ${sale.parkingCodePrevia}")
|
||||
println("parkingCode ${sale.parkingCode}")
|
||||
|
||||
if (type == PREITEMPICKERTEST) {
|
||||
binding.level.visibility = GONE
|
||||
binding.levelTxt.visibility = GONE
|
||||
binding.ticketOrder.visibility = VISIBLE
|
||||
} else {
|
||||
binding.level.visibility = VISIBLE
|
||||
binding.levelTxt.visibility = VISIBLE
|
||||
binding.ticketOrder.visibility = GONE
|
||||
}
|
||||
this.sale = sale
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,366 @@
|
|||
package es.verdnatura.presentation.view.feature.collection.adapter
|
||||
|
||||
import android.content.Context
|
||||
import android.content.res.ColorStateList
|
||||
import android.graphics.Color
|
||||
import android.graphics.drawable.Drawable
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View.GONE
|
||||
import android.view.View.INVISIBLE
|
||||
import android.view.View.VISIBLE
|
||||
import android.view.ViewGroup
|
||||
import androidx.core.content.ContextCompat.getColor
|
||||
import androidx.core.graphics.drawable.DrawableCompat
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import es.verdnatura.R
|
||||
import es.verdnatura.databinding.SaleRowFragmentReserveBinding
|
||||
import es.verdnatura.domain.ConstAndValues.PREITEMPICKERTEST
|
||||
import es.verdnatura.domain.ConstAndValues.PREPARED
|
||||
import es.verdnatura.domain.ConstAndValues.SACADOR
|
||||
import es.verdnatura.presentation.common.OnAddItemClickListener
|
||||
import es.verdnatura.presentation.common.OnMistakeClickListener
|
||||
import es.verdnatura.presentation.common.OnPackingClickSaleListener
|
||||
import es.verdnatura.presentation.common.OnPasillerosItemClickListener
|
||||
import es.verdnatura.presentation.common.OnSaleClickSaleListener
|
||||
import es.verdnatura.presentation.common.OnSaleReserveClickListener
|
||||
import es.verdnatura.presentation.common.OnTicketClickSaleListener
|
||||
import es.verdnatura.presentation.view.feature.pasillero.model.PasillerosItemVO
|
||||
import es.verdnatura.presentation.view.feature.sacador.model.Sale
|
||||
|
||||
class SaleAdapterReserve(
|
||||
private val items: List<Sale>,
|
||||
private val onPasillerosItemClickListener: OnPasillerosItemClickListener,
|
||||
private val onSaleClickListener: OnSaleClickSaleListener,
|
||||
private val onMistakeClickListener: OnMistakeClickListener,
|
||||
private val onPackingClick: OnPackingClickSaleListener,
|
||||
private var onTicketClick: OnTicketClickSaleListener? = null,
|
||||
private var saleAdapter: SaleAdapterReserve? = null,
|
||||
private var onReserveSaleClick: OnSaleReserveClickListener? = null,
|
||||
private var onAddItemClickListener: OnAddItemClickListener? = null,
|
||||
private var type: String? = null,
|
||||
|
||||
) : RecyclerView.Adapter<SaleAdapterReserve.AjustesItemHolder>() {
|
||||
var context: Context? = null
|
||||
var position: Int = 0
|
||||
|
||||
var isExpanded: Boolean = type == "PRECHECKER"
|
||||
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): AjustesItemHolder {
|
||||
this.context = parent.context
|
||||
|
||||
|
||||
return AjustesItemHolder(
|
||||
|
||||
SaleRowFragmentReserveBinding.inflate(
|
||||
LayoutInflater.from(parent.context), parent, false
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
override fun getItemCount() = items.size
|
||||
|
||||
override fun onBindViewHolder(holder: AjustesItemHolder, position: Int) {
|
||||
this.position = position
|
||||
val item = items[position]
|
||||
val calculatedValues = precalculateDisplayValues(item)
|
||||
holder.bind(item, calculatedValues)
|
||||
}
|
||||
|
||||
inner class AjustesItemHolder(
|
||||
val binding: SaleRowFragmentReserveBinding
|
||||
) : RecyclerView.ViewHolder(binding.root) {
|
||||
fun bind(sale: Sale, calculatedValues: Pair<String, String>) {
|
||||
binding.apply {
|
||||
println("type $type ")
|
||||
println("type isExpanded $isExpanded")
|
||||
/* val childLayoutManager =
|
||||
LinearLayoutManager(context!!, RecyclerView.HORIZONTAL, false)
|
||||
*/
|
||||
val childLayoutManagerV =
|
||||
LinearLayoutManager(context!!, RecyclerView.VERTICAL, false)
|
||||
|
||||
/* itemArticlePlacements.apply {
|
||||
layoutManager = childLayoutManager
|
||||
|
||||
}*/
|
||||
|
||||
//CLICK EVENTS
|
||||
contentLayout.setOnClickListener {
|
||||
if (!sale.isParent) {
|
||||
onSaleClickListener.onSaleClick(sale)
|
||||
}
|
||||
}
|
||||
txtColor.setOnClickListener {
|
||||
if (!sale.isParent) {
|
||||
onSaleClickListener.onSaleClick(sale)
|
||||
}
|
||||
}
|
||||
txtDescrip.setOnClickListener {
|
||||
if (!sale.isParent) {
|
||||
onSaleClickListener.onSaleClick(sale)
|
||||
}
|
||||
}
|
||||
ticketFk.setOnClickListener {
|
||||
onTicketClick?.onTicketClickListener(sale)
|
||||
}
|
||||
|
||||
txtParking.setOnClickListener {
|
||||
onPasillerosItemClickListener.onPasillerosItemClickListener(
|
||||
PasillerosItemVO(
|
||||
title = R.string.titleItemSearch
|
||||
), sale.itemFk.toString()
|
||||
)
|
||||
}
|
||||
txtShelving.setOnClickListener {
|
||||
onPackingClick.onPackingClick(sale)
|
||||
}
|
||||
|
||||
txtItem.setOnClickListener {
|
||||
onPasillerosItemClickListener.onPasillerosItemClickListener(
|
||||
PasillerosItemVO(
|
||||
title = R.string.titleItemConsult
|
||||
), sale.itemFk.toString()
|
||||
)
|
||||
}
|
||||
|
||||
//ERROR
|
||||
|
||||
if (sale.originalQuantity != sale.saleQuantity && sale.originalQuantity != null && !sale.isParent) {
|
||||
layoutError.visibility = VISIBLE
|
||||
txtError.text =
|
||||
binding.root.context.getString(R.string.originalQuantity) + sale.originalQuantity
|
||||
binding.addItem.visibility = VISIBLE
|
||||
|
||||
} else {
|
||||
layoutError.visibility = GONE
|
||||
binding.addItem.visibility = GONE
|
||||
|
||||
}
|
||||
|
||||
binding.deleteReserve.visibility = if (sale.isAdded == 1) VISIBLE else GONE
|
||||
|
||||
if (sale.isAdded == 1) {
|
||||
layoutError.visibility = VISIBLE
|
||||
txtError.text = binding.root.context.getString(R.string.newItem)
|
||||
binding.deleteReserve.setOnClickListener {
|
||||
onReserveSaleClick!!.onSaleReserveListener(sale)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (isExpanded) {
|
||||
itemArticlePlacements.visibility = VISIBLE
|
||||
ivArrow.setImageResource(R.drawable.ic_arrow_down)
|
||||
|
||||
} else {
|
||||
itemArticlePlacements.visibility = GONE
|
||||
ivArrow.setImageResource(R.drawable.ic_arrow_up)
|
||||
}
|
||||
|
||||
itemArticlePlacements.visibility = if (isExpanded) VISIBLE else {
|
||||
GONE
|
||||
}
|
||||
|
||||
if (sale.isParent) {
|
||||
txtQuantity.visibility = INVISIBLE
|
||||
txtQuantityReserved.visibility = INVISIBLE
|
||||
txtReserveToComplete.visibility = GONE
|
||||
imageErrorMessage.visibility = GONE
|
||||
ivArrow.visibility = VISIBLE
|
||||
|
||||
} else {
|
||||
|
||||
imageErrorMessage.visibility = GONE
|
||||
if (type != SACADOR && type != PREITEMPICKERTEST) {
|
||||
val colorRes =
|
||||
if (sale.hasMistake == true) R.color.verdnatura_red_salix else R.color.verdnatura_black
|
||||
imageErrorMessage.imageTintList =
|
||||
ColorStateList.valueOf(getColor(context!!, colorRes))
|
||||
imageErrorMessage.visibility = VISIBLE
|
||||
} else {
|
||||
imageErrorMessage.visibility = GONE
|
||||
}
|
||||
ivArrow.visibility = INVISIBLE
|
||||
}
|
||||
println("sonSales ${sale.sonSales}")
|
||||
|
||||
if (!sale.sonSales.isNullOrEmpty()) {
|
||||
|
||||
itemArticlePlacements.apply {
|
||||
layoutManager = childLayoutManagerV
|
||||
adapter = SaleAdapterReserve(
|
||||
sale.sonSales,
|
||||
onPasillerosItemClickListener,
|
||||
onSaleClickListener,
|
||||
onMistakeClickListener,
|
||||
onPackingClick,
|
||||
|
||||
)
|
||||
}
|
||||
} else {
|
||||
itemArticlePlacements.visibility = VISIBLE
|
||||
}
|
||||
|
||||
ivArrow.setOnClickListener {
|
||||
|
||||
if (isExpanded) {
|
||||
ivArrow.setImageResource(R.drawable.ic_arrow_up)
|
||||
itemArticlePlacements.visibility = GONE
|
||||
} else {
|
||||
ivArrow.setImageResource(R.drawable.ic_arrow_down)
|
||||
itemArticlePlacements.visibility = VISIBLE
|
||||
}
|
||||
isExpanded = !isExpanded
|
||||
|
||||
}
|
||||
|
||||
if (sale.saleGroupFk == null) {
|
||||
previous.visibility = INVISIBLE
|
||||
} else {
|
||||
previous.visibility = VISIBLE
|
||||
previous.text = "PREV:${sale.saleGroupFk}"
|
||||
}
|
||||
|
||||
binding.txtQuantityReserved.text = calculatedValues.first
|
||||
if (sale.totalItemShelving > 1) {
|
||||
binding.txtQuantityReserved.text = calculatedValues.first
|
||||
binding.txtQuantity.text = calculatedValues.second
|
||||
binding.txtReserveToComplete.text =
|
||||
"${sale.currentItemShelving}/${sale.totalItemShelving}"
|
||||
binding.txtReserveToComplete.visibility = VISIBLE
|
||||
binding.txtQuantity.text =
|
||||
"${sale.reservedQuantity}"
|
||||
} else {
|
||||
binding.txtQuantity.text =
|
||||
if (sale.itemShelvingFk == 0 && sale.itemShelvingSaleFk == 0) {
|
||||
"${sale.saleQuantity}"
|
||||
} else "${sale.reservedQuantity}"
|
||||
binding.txtReserveToComplete.visibility = GONE
|
||||
|
||||
}
|
||||
binding.txtReserveToComplete.text =
|
||||
"${sale.currentItemShelving}/${sale.totalItemShelving}"
|
||||
|
||||
//COLORES
|
||||
paintTicketcolor(sale.rgb, binding.itemTicketColor.background)
|
||||
if (sale.isPicked == 1) {
|
||||
if (type == PREPARED) {
|
||||
contentLayout.setBackgroundColor(
|
||||
|
||||
if (sale.saleGroupFk == null) {
|
||||
getColor(
|
||||
context!!, R.color.verdnatura_orange_salix
|
||||
)
|
||||
} else {
|
||||
println("stateCode ${sale.stateCode}")
|
||||
if (sale.stateCode != null && sale.stateCode == "PREPARED") {
|
||||
getColor(
|
||||
context!!, R.color.verdnatura_orange_salix
|
||||
)
|
||||
} else {
|
||||
if (sale.stateCode != null && sale.stateCode == "OK PREVIOUS") {
|
||||
getColor(
|
||||
context!!, R.color.verdnatura_dark_sky_blue
|
||||
)
|
||||
} else {
|
||||
if (sale.stateCode != null && sale.stateCode == "PREVIOUS_CONTROLLED") {
|
||||
getColor(
|
||||
context!!, R.color.verdnatura_dark_mint_light
|
||||
)
|
||||
} else {
|
||||
getColor(
|
||||
context!!, R.color.verdnatura_black
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
)
|
||||
} else {
|
||||
contentLayout.setBackgroundColor(
|
||||
getColor(
|
||||
context!!, R.color.verdnatura_dark_sky_blue
|
||||
)
|
||||
)
|
||||
}
|
||||
} else {
|
||||
contentLayout.setBackgroundColor(
|
||||
getColor(
|
||||
context!!, R.color.verdnatura_black
|
||||
)
|
||||
)
|
||||
|
||||
}
|
||||
|
||||
binding.txtParking.text =
|
||||
// if (type == PREPARED) sale.parkingCodePrevia else sale.parkingCode
|
||||
sale.parkingCode ?: sale.parkingCodePrevia
|
||||
|
||||
binding.addItem.setOnClickListener {
|
||||
onAddItemClickListener!!.onAddItemClickListener(sale)
|
||||
}
|
||||
|
||||
if (type == PREITEMPICKERTEST) {
|
||||
binding.level.visibility = GONE
|
||||
binding.levelTxt.visibility = GONE
|
||||
binding.ticketOrder.visibility = VISIBLE
|
||||
binding.txtPoints.visibility = GONE
|
||||
} else {
|
||||
binding.level.visibility = VISIBLE
|
||||
binding.levelTxt.visibility = VISIBLE
|
||||
binding.ticketOrder.visibility = GONE
|
||||
binding.txtPoints.visibility = VISIBLE
|
||||
|
||||
}
|
||||
|
||||
|
||||
this.sale = sale
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun paintTicketcolor(color: String?, backgroundDrawableTicket: Drawable) {
|
||||
|
||||
if (color.isNullOrBlank()) {
|
||||
DrawableCompat.setTint(
|
||||
backgroundDrawableTicket, Color.TRANSPARENT
|
||||
)
|
||||
} else {
|
||||
DrawableCompat.setTint(
|
||||
backgroundDrawableTicket, Color.parseColor(color)
|
||||
)
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private fun precalculateDisplayValues(sale: Sale): Pair<String, String> {
|
||||
try {
|
||||
val result = sale.reservedQuantity % (sale.packing ?: (sale.saleQuantity + 1))
|
||||
val textToConcat = if (result != 0) {
|
||||
"${sale.reservedQuantity / (sale.grouping ?: 1)} x ${sale.grouping ?: "1"}"
|
||||
} else {
|
||||
"${sale.reservedQuantity / (sale.packing ?: 1)} pack de ${sale.packing ?: "1"}"
|
||||
}
|
||||
|
||||
val result2 = sale.accumulatedQuantity % (sale.packing ?: (sale.saleQuantity + 1))
|
||||
val textToConcat2 = if (result2 != 0) {
|
||||
"${(sale.saleQuantity - sale.accumulatedQuantity) / (sale.grouping ?: 1)} x ${sale.grouping ?: "1"}"
|
||||
} else {
|
||||
"${(sale.saleQuantity - sale.accumulatedQuantity) / (sale.packing ?: 1)} pack de ${sale.packing ?: "1"}"
|
||||
}
|
||||
return if (sale.itemShelvingSaleFk == 0 && sale.itemShelvingFk == 0) Pair(
|
||||
"-",
|
||||
"0"
|
||||
) else {
|
||||
Pair(textToConcat, textToConcat2)
|
||||
}
|
||||
} catch (ex: Exception) {
|
||||
return Pair("Error", "Error")
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,367 @@
|
|||
package es.verdnatura.presentation.view.feature.collection.adapter
|
||||
|
||||
import android.content.Context
|
||||
import android.content.res.ColorStateList
|
||||
import android.graphics.Color
|
||||
import android.graphics.drawable.Drawable
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View.GONE
|
||||
import android.view.View.INVISIBLE
|
||||
import android.view.View.VISIBLE
|
||||
import android.view.ViewGroup
|
||||
import androidx.core.content.ContextCompat.getColor
|
||||
import androidx.core.graphics.drawable.DrawableCompat
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import es.verdnatura.R
|
||||
import es.verdnatura.databinding.SaleRowFragmentReserveSacadorBinding
|
||||
import es.verdnatura.domain.ConstAndValues.PREITEMPICKERTEST
|
||||
import es.verdnatura.domain.ConstAndValues.PREPARED
|
||||
import es.verdnatura.domain.ConstAndValues.SACADOR
|
||||
import es.verdnatura.presentation.common.OnAddItemClickListener
|
||||
import es.verdnatura.presentation.common.OnMistakeClickListener
|
||||
import es.verdnatura.presentation.common.OnPackingClickSaleListener
|
||||
import es.verdnatura.presentation.common.OnPasillerosItemClickListener
|
||||
import es.verdnatura.presentation.common.OnSaleClickSaleListener
|
||||
import es.verdnatura.presentation.common.OnSaleReserveClickListener
|
||||
import es.verdnatura.presentation.common.OnTicketClickSaleListener
|
||||
import es.verdnatura.presentation.view.feature.pasillero.model.PasillerosItemVO
|
||||
import es.verdnatura.presentation.view.feature.sacador.model.Sale
|
||||
|
||||
class SaleAdapterReserveSacador(
|
||||
private val items: List<Sale>,
|
||||
private val onPasillerosItemClickListener: OnPasillerosItemClickListener,
|
||||
private val onSaleClickListener: OnSaleClickSaleListener,
|
||||
private val onMistakeClickListener: OnMistakeClickListener,
|
||||
private val onPackingClick: OnPackingClickSaleListener,
|
||||
private var onTicketClick: OnTicketClickSaleListener? = null,
|
||||
private var saleAdapter: SaleAdapterReserveSacador? = null,
|
||||
private var onReserveSaleClick: OnSaleReserveClickListener? = null,
|
||||
private var onAddItemClickListener: OnAddItemClickListener? = null,
|
||||
private var type: String? = null,
|
||||
|
||||
) : RecyclerView.Adapter<SaleAdapterReserveSacador.AjustesItemHolder>() {
|
||||
var context: Context? = null
|
||||
var position: Int = 0
|
||||
|
||||
var isExpanded: Boolean = false
|
||||
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): AjustesItemHolder {
|
||||
this.context = parent.context
|
||||
|
||||
|
||||
return AjustesItemHolder(
|
||||
|
||||
SaleRowFragmentReserveSacadorBinding.inflate(
|
||||
LayoutInflater.from(parent.context), parent, false
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
override fun getItemCount() = items.size
|
||||
|
||||
override fun onBindViewHolder(holder: AjustesItemHolder, position: Int) {/* this.position = position
|
||||
holder.bind(items[position])*/
|
||||
this.position = position
|
||||
val item = items[position]
|
||||
val calculatedValues = precalculateDisplayValues(item)
|
||||
holder.bind(item, calculatedValues)
|
||||
|
||||
}
|
||||
|
||||
inner class AjustesItemHolder(
|
||||
val binding: SaleRowFragmentReserveSacadorBinding
|
||||
) : RecyclerView.ViewHolder(binding.root) {
|
||||
fun bind(sale: Sale, calculatedValues: Pair<String, String>) {
|
||||
binding.apply {
|
||||
|
||||
val childLayoutManagerV =
|
||||
LinearLayoutManager(context!!, RecyclerView.VERTICAL, false)
|
||||
|
||||
//CLICK EVENTS
|
||||
contentLayout.setOnClickListener {
|
||||
if (!sale.isParent) {
|
||||
onSaleClickListener.onSaleClick(sale)
|
||||
}
|
||||
}
|
||||
txtColor.setOnClickListener {
|
||||
if (!sale.isParent) {
|
||||
onSaleClickListener.onSaleClick(sale)
|
||||
}
|
||||
}
|
||||
txtDescrip.setOnClickListener {
|
||||
if (!sale.isParent) {
|
||||
onSaleClickListener.onSaleClick(sale)
|
||||
}
|
||||
}
|
||||
ticketFk.setOnClickListener {
|
||||
onTicketClick?.onTicketClickListener(sale)
|
||||
}
|
||||
|
||||
txtParking.setOnClickListener {
|
||||
onPasillerosItemClickListener.onPasillerosItemClickListener(
|
||||
PasillerosItemVO(
|
||||
title = R.string.titleItemSearch
|
||||
), sale.itemFk.toString()
|
||||
)
|
||||
}
|
||||
txtShelving.setOnClickListener {
|
||||
onPackingClick.onPackingClick(sale)
|
||||
}
|
||||
|
||||
txtItem.setOnClickListener {
|
||||
onPasillerosItemClickListener.onPasillerosItemClickListener(
|
||||
PasillerosItemVO(
|
||||
title = R.string.titleItemConsult
|
||||
), sale.itemFk.toString()
|
||||
)
|
||||
}
|
||||
|
||||
//ERROR
|
||||
|
||||
if (sale.originalQuantity != sale.saleQuantity && sale.originalQuantity != null && !sale.isParent) {
|
||||
layoutError.visibility = VISIBLE
|
||||
txtError.text =
|
||||
binding.root.context.getString(R.string.originalQuantity) + sale.originalQuantity
|
||||
binding.addItem.visibility = VISIBLE
|
||||
|
||||
} else {
|
||||
layoutError.visibility = GONE
|
||||
binding.addItem.visibility = GONE
|
||||
|
||||
}
|
||||
|
||||
binding.deleteReserve.visibility = if (sale.isAdded == 1) VISIBLE else GONE
|
||||
|
||||
if (sale.isAdded == 1) {
|
||||
layoutError.visibility = VISIBLE
|
||||
txtError.text = binding.root.context.getString(R.string.newItem)
|
||||
binding.deleteReserve.setOnClickListener {
|
||||
onReserveSaleClick!!.onSaleReserveListener(sale)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (sale.isParent) {
|
||||
txtQuantity.visibility = INVISIBLE
|
||||
txtQuantityReserved.visibility = INVISIBLE
|
||||
txtReserveToComplete.visibility = GONE
|
||||
imageErrorMessage.visibility = GONE
|
||||
ivArrow.visibility = VISIBLE
|
||||
sale.color = sale.username ?: "" //mostrar en campo del colo el usuario
|
||||
} else {
|
||||
|
||||
imageErrorMessage.visibility = GONE
|
||||
if (type != SACADOR && type != PREITEMPICKERTEST) {
|
||||
val colorRes =
|
||||
if (sale.hasMistake == true) R.color.verdnatura_red_salix else R.color.verdnatura_black
|
||||
imageErrorMessage.imageTintList =
|
||||
ColorStateList.valueOf(getColor(context!!, colorRes))
|
||||
imageErrorMessage.visibility = VISIBLE
|
||||
} else {
|
||||
imageErrorMessage.visibility = GONE
|
||||
}
|
||||
ivArrow.visibility = INVISIBLE
|
||||
}
|
||||
|
||||
if (!sale.sonSales.isNullOrEmpty()) {
|
||||
|
||||
itemArticlePlacements.apply {
|
||||
layoutManager = childLayoutManagerV
|
||||
adapter = SaleAdapterReserveSacadorSaleGroup(
|
||||
sale.sonSales,
|
||||
onPasillerosItemClickListener,
|
||||
onSaleClickListener,
|
||||
onMistakeClickListener,
|
||||
onPackingClick,
|
||||
type = "PREPARED"
|
||||
|
||||
)
|
||||
}
|
||||
} else {
|
||||
itemArticlePlacements.visibility = GONE
|
||||
}
|
||||
if (isExpanded) {
|
||||
if (sale.isParent) {
|
||||
itemArticlePlacements.visibility = VISIBLE
|
||||
} else {
|
||||
itemArticlePlacements.visibility = GONE
|
||||
}
|
||||
ivArrow.setImageResource(R.drawable.ic_arrow_down)
|
||||
|
||||
} else {
|
||||
itemArticlePlacements.visibility = GONE
|
||||
ivArrow.setImageResource(R.drawable.ic_arrow_up)
|
||||
}
|
||||
|
||||
itemArticlePlacements.visibility = if (isExpanded) VISIBLE else {
|
||||
GONE
|
||||
}
|
||||
ivArrow.setOnClickListener {
|
||||
|
||||
if (isExpanded) {
|
||||
ivArrow.setImageResource(R.drawable.ic_arrow_up)
|
||||
itemArticlePlacements.visibility = GONE
|
||||
|
||||
} else {
|
||||
ivArrow.setImageResource(R.drawable.ic_arrow_down)
|
||||
if (sale.isParent) {
|
||||
itemArticlePlacements.visibility = VISIBLE
|
||||
} else {
|
||||
itemArticlePlacements.visibility = GONE
|
||||
}
|
||||
}
|
||||
isExpanded = !isExpanded
|
||||
|
||||
}
|
||||
|
||||
if (sale.saleGroupFk == null) {
|
||||
previous.visibility = INVISIBLE
|
||||
} else {
|
||||
previous.visibility = VISIBLE
|
||||
previous.text = "PREV:${sale.saleGroupFk}"
|
||||
|
||||
}
|
||||
binding.txtQuantityReserved.text = calculatedValues.first
|
||||
if (sale.totalItemShelving > 1) {
|
||||
binding.txtQuantityReserved.text = calculatedValues.first
|
||||
binding.txtQuantity.text = calculatedValues.second
|
||||
binding.txtReserveToComplete.text =
|
||||
"${sale.currentItemShelving}/${sale.totalItemShelving}"
|
||||
binding.txtReserveToComplete.visibility = VISIBLE
|
||||
binding.txtQuantity.text = "${sale.reservedQuantity}"
|
||||
} else {
|
||||
binding.txtQuantity.text =
|
||||
if (sale.itemShelvingFk == 0 && sale.itemShelvingSaleFk == 0) {
|
||||
"${sale.saleQuantity}"
|
||||
} else "${sale.reservedQuantity}"
|
||||
binding.txtReserveToComplete.visibility = GONE
|
||||
|
||||
}
|
||||
|
||||
binding.txtReserveToComplete.text =
|
||||
"${sale.currentItemShelving}/${sale.totalItemShelving}"
|
||||
|
||||
//COLORES
|
||||
paintTicketcolor(sale.rgb, binding.itemTicketColor.background)
|
||||
if (sale.isPicked == 1) {
|
||||
if (type == PREPARED) {
|
||||
contentLayout.setBackgroundColor(
|
||||
|
||||
if (sale.saleGroupFk == null) {
|
||||
getColor(
|
||||
context!!, R.color.verdnatura_orange_salix
|
||||
)
|
||||
} else {
|
||||
|
||||
if (sale.stateCode != null && sale.stateCode == "PREPARED") {
|
||||
getColor(
|
||||
context!!, R.color.verdnatura_orange_salix
|
||||
)
|
||||
} else {
|
||||
if (sale.stateCode != null && sale.stateCode == "OK PREVIOUS") {
|
||||
getColor(
|
||||
context!!, R.color.verdnatura_dark_sky_blue
|
||||
)
|
||||
} else {
|
||||
if (sale.stateCode != null && sale.stateCode == "PREVIOUS_CONTROLLED") {
|
||||
getColor(
|
||||
context!!,
|
||||
R.color.verdnatura_dark_mint_light_precontrolled
|
||||
)/* getColor(
|
||||
context!!, R.color.verdnatura_dark_sky_blue
|
||||
)*/
|
||||
} else {
|
||||
getColor(
|
||||
context!!, R.color.verdnatura_black
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
)
|
||||
} else {
|
||||
contentLayout.setBackgroundColor(
|
||||
getColor(
|
||||
context!!, R.color.verdnatura_dark_sky_blue
|
||||
)
|
||||
)
|
||||
}
|
||||
} else {
|
||||
contentLayout.setBackgroundColor(
|
||||
getColor(
|
||||
context!!, R.color.verdnatura_black
|
||||
)
|
||||
)
|
||||
|
||||
}
|
||||
|
||||
binding.txtParking.text =
|
||||
// if (type == PREPARED) sale.parkingCodePrevia else sale.parkingCode
|
||||
sale.parkingCode ?: sale.parkingCodePrevia
|
||||
|
||||
binding.addItem.setOnClickListener {
|
||||
onAddItemClickListener!!.onAddItemClickListener(sale)
|
||||
}
|
||||
|
||||
if (type == PREITEMPICKERTEST) {
|
||||
binding.level.visibility = GONE
|
||||
binding.levelTxt.visibility = GONE
|
||||
binding.ticketOrder.visibility = VISIBLE
|
||||
binding.txtPoints.visibility = GONE
|
||||
} else {
|
||||
binding.level.visibility = VISIBLE
|
||||
binding.levelTxt.visibility = VISIBLE
|
||||
binding.ticketOrder.visibility = GONE
|
||||
binding.txtPoints.visibility = VISIBLE
|
||||
|
||||
}
|
||||
|
||||
this.sale = sale
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun paintTicketcolor(color: String?, backgroundDrawableTicket: Drawable) {
|
||||
|
||||
if (color.isNullOrBlank()) {
|
||||
DrawableCompat.setTint(
|
||||
backgroundDrawableTicket, Color.TRANSPARENT
|
||||
)
|
||||
} else {
|
||||
DrawableCompat.setTint(
|
||||
backgroundDrawableTicket, Color.parseColor(color)
|
||||
)
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private fun precalculateDisplayValues(sale: Sale): Pair<String, String> {
|
||||
try {
|
||||
val result = sale.reservedQuantity % (sale.packing ?: (sale.saleQuantity + 1))
|
||||
val textToConcat = if (result != 0) {
|
||||
"${sale.reservedQuantity / (sale.grouping ?: 1)} x ${sale.grouping ?: "1"}"
|
||||
} else {
|
||||
"${sale.reservedQuantity / (sale.packing ?: 1)} pack de ${sale.packing ?: "1"}"
|
||||
}
|
||||
|
||||
val result2 = sale.accumulatedQuantity % (sale.packing ?: (sale.saleQuantity + 1))
|
||||
val textToConcat2 = if (result2 != 0) {
|
||||
"${(sale.saleQuantity - sale.accumulatedQuantity) / (sale.grouping ?: 1)} x ${sale.grouping ?: "1"}"
|
||||
} else {
|
||||
"${(sale.saleQuantity - sale.accumulatedQuantity) / (sale.packing ?: 1)} pack de ${sale.packing ?: "1"}"
|
||||
}
|
||||
println("reserva sale $sale")
|
||||
return if (sale.itemShelvingSaleFk == 0 && sale.itemShelvingFk == 0) Pair(
|
||||
"-",
|
||||
"0"
|
||||
) else {
|
||||
Pair(textToConcat, textToConcat2)
|
||||
}
|
||||
} catch (ex: Exception) {
|
||||
return Pair("Error", "Error")
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,308 @@
|
|||
package es.verdnatura.presentation.view.feature.collection.adapter
|
||||
|
||||
import android.content.Context
|
||||
import android.content.res.ColorStateList
|
||||
import android.graphics.Color
|
||||
import android.graphics.drawable.Drawable
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View.GONE
|
||||
import android.view.View.INVISIBLE
|
||||
import android.view.View.VISIBLE
|
||||
import android.view.ViewGroup
|
||||
import androidx.core.content.ContextCompat.getColor
|
||||
import androidx.core.graphics.drawable.DrawableCompat
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import es.verdnatura.R
|
||||
import es.verdnatura.databinding.SaleRowFragmentReserveSacadorBinding
|
||||
import es.verdnatura.domain.ConstAndValues.PREITEMPICKERTEST
|
||||
import es.verdnatura.domain.ConstAndValues.PREPARED
|
||||
import es.verdnatura.domain.ConstAndValues.SACADOR
|
||||
import es.verdnatura.domain.toast
|
||||
import es.verdnatura.presentation.common.OnAddItemClickListener
|
||||
import es.verdnatura.presentation.common.OnMistakeClickListener
|
||||
import es.verdnatura.presentation.common.OnPackingClickSaleListener
|
||||
import es.verdnatura.presentation.common.OnPasillerosItemClickListener
|
||||
import es.verdnatura.presentation.common.OnSaleClickSaleListener
|
||||
import es.verdnatura.presentation.common.OnSaleReserveClickListener
|
||||
import es.verdnatura.presentation.common.OnTicketClickSaleListener
|
||||
import es.verdnatura.presentation.view.feature.pasillero.model.PasillerosItemVO
|
||||
import es.verdnatura.presentation.view.feature.sacador.model.Sale
|
||||
|
||||
class SaleAdapterReserveSacadorSaleGroup(
|
||||
private val items: List<Sale>,
|
||||
private val onPasillerosItemClickListener: OnPasillerosItemClickListener,
|
||||
private val onSaleClickListener: OnSaleClickSaleListener,
|
||||
private val onMistakeClickListener: OnMistakeClickListener,
|
||||
private val onPackingClick: OnPackingClickSaleListener,
|
||||
private var onTicketClick: OnTicketClickSaleListener? = null,
|
||||
private var saleAdapter: SaleAdapterReserveSacadorSaleGroup? = null,
|
||||
private var onReserveSaleClick: OnSaleReserveClickListener? = null,
|
||||
private var onAddItemClickListener: OnAddItemClickListener? = null,
|
||||
private var type: String? = null,
|
||||
|
||||
) : RecyclerView.Adapter<SaleAdapterReserveSacadorSaleGroup.AjustesItemHolder>() {
|
||||
var context: Context? = null
|
||||
var position: Int = 0
|
||||
|
||||
var isExpanded: Boolean = false
|
||||
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): AjustesItemHolder {
|
||||
this.context = parent.context
|
||||
|
||||
|
||||
return AjustesItemHolder(
|
||||
|
||||
SaleRowFragmentReserveSacadorBinding.inflate(
|
||||
LayoutInflater.from(parent.context), parent, false
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
override fun getItemCount() = items.size
|
||||
|
||||
override fun onBindViewHolder(holder: AjustesItemHolder, position: Int) {
|
||||
this.position = position
|
||||
holder.bind(items[position])
|
||||
}
|
||||
|
||||
inner class AjustesItemHolder(
|
||||
val binding: SaleRowFragmentReserveSacadorBinding
|
||||
) : RecyclerView.ViewHolder(binding.root) {
|
||||
fun bind(sale: Sale) {
|
||||
binding.apply {
|
||||
|
||||
//CLICK EVENTS
|
||||
contentLayout.setOnClickListener {
|
||||
if (!sale.isParent) {
|
||||
onSaleClickListener.onSaleClick(sale)
|
||||
}
|
||||
}
|
||||
txtColor.setOnClickListener {
|
||||
if (!sale.isParent) {
|
||||
onSaleClickListener.onSaleClick(sale)
|
||||
}
|
||||
}
|
||||
txtDescrip.setOnClickListener {
|
||||
if (!sale.isParent) {
|
||||
onSaleClickListener.onSaleClick(sale)
|
||||
}
|
||||
}
|
||||
ticketFk.setOnClickListener {
|
||||
onTicketClick?.onTicketClickListener(sale)
|
||||
}
|
||||
|
||||
txtParking.setOnClickListener {
|
||||
onPasillerosItemClickListener.onPasillerosItemClickListener(
|
||||
PasillerosItemVO(
|
||||
title = R.string.titleItemSearch
|
||||
), sale.itemFk.toString()
|
||||
)
|
||||
}
|
||||
txtShelving.setOnClickListener {
|
||||
onPackingClick.onPackingClick(sale)
|
||||
}
|
||||
|
||||
txtItem.setOnClickListener {
|
||||
onPasillerosItemClickListener.onPasillerosItemClickListener(
|
||||
PasillerosItemVO(
|
||||
title = R.string.titleItemConsult
|
||||
), sale.itemFk.toString()
|
||||
)
|
||||
}
|
||||
|
||||
//ERROR
|
||||
|
||||
if (sale.originalQuantity != sale.saleQuantity && sale.originalQuantity != null && !sale.isParent) {
|
||||
layoutError.visibility = VISIBLE
|
||||
txtError.text =
|
||||
binding.root.context.getString(R.string.originalQuantity) + sale.originalQuantity
|
||||
binding.addItem.visibility = VISIBLE
|
||||
|
||||
} else {
|
||||
layoutError.visibility = GONE
|
||||
binding.addItem.visibility = GONE
|
||||
|
||||
}
|
||||
|
||||
binding.deleteReserve.visibility = if (sale.isAdded == 1) VISIBLE else GONE
|
||||
|
||||
if (sale.isAdded == 1) {
|
||||
layoutError.visibility = VISIBLE
|
||||
txtError.text = binding.root.context.getString(R.string.newItem)
|
||||
binding.deleteReserve.setOnClickListener {
|
||||
onReserveSaleClick!!.onSaleReserveListener(sale)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (sale.isParent) {
|
||||
txtQuantity.visibility = INVISIBLE
|
||||
txtQuantityReserved.visibility = INVISIBLE
|
||||
txtReserveToComplete.visibility = GONE
|
||||
imageErrorMessage.visibility = GONE
|
||||
ivArrow.visibility = VISIBLE
|
||||
|
||||
} else {
|
||||
|
||||
imageErrorMessage.visibility = GONE
|
||||
if (type != SACADOR && type != PREITEMPICKERTEST) {
|
||||
val colorRes =
|
||||
if (sale.hasMistake == true) R.color.verdnatura_red_salix else R.color.verdnatura_black
|
||||
imageErrorMessage.imageTintList =
|
||||
ColorStateList.valueOf(getColor(context!!, colorRes))
|
||||
imageErrorMessage.visibility = VISIBLE
|
||||
} else {
|
||||
imageErrorMessage.visibility = GONE
|
||||
}
|
||||
ivArrow.visibility = INVISIBLE
|
||||
}
|
||||
println("sonSales RESERVESACADORSALEGROUP ${sale.sonSales}")
|
||||
|
||||
|
||||
if (sale.saleGroupFk == null) {
|
||||
previous.visibility = INVISIBLE
|
||||
} else {
|
||||
previous.visibility = VISIBLE
|
||||
previous.text = "PREV:${sale.saleGroupFk}"
|
||||
}
|
||||
|
||||
val result: Int
|
||||
val textToConcat: String
|
||||
|
||||
try {
|
||||
|
||||
result = sale.reservedQuantity % (sale.packing ?: (sale.saleQuantity + 1))
|
||||
textToConcat = if (result != 0) {
|
||||
"${sale.reservedQuantity / (sale.grouping ?: 1)} x ${sale.grouping ?: "1"}"
|
||||
} else {
|
||||
"${sale.reservedQuantity / (sale.packing ?: 1)} pack de ${sale.packing ?: "1"}"
|
||||
}
|
||||
binding.txtQuantityReserved.text = textToConcat
|
||||
|
||||
val textToConcat2: String
|
||||
|
||||
val result2: Int =
|
||||
sale.accumulatedQuantity % (sale.packing ?: (sale.saleQuantity + 1))
|
||||
textToConcat2 = if (result2 != 0) {
|
||||
"${(sale.saleQuantity - sale.accumulatedQuantity) / (sale.grouping ?: 1)} x ${sale.grouping ?: "1"}"
|
||||
} else {
|
||||
"${(sale.saleQuantity - sale.accumulatedQuantity) / (sale.packing ?: 1)} pack de ${sale.packing ?: "1"}"
|
||||
}
|
||||
|
||||
|
||||
if (sale.totalItemShelving > 1) {
|
||||
binding.txtQuantityReserved.text = textToConcat
|
||||
binding.txtQuantity.text = textToConcat2
|
||||
binding.txtReserveToComplete.text =
|
||||
"${sale.currentItemShelving}/${sale.totalItemShelving}"
|
||||
binding.txtReserveToComplete.visibility = VISIBLE
|
||||
binding.txtQuantity.text =
|
||||
"${sale.reservedQuantity}"
|
||||
} else {
|
||||
binding.txtQuantity.text = "${sale.reservedQuantity}"
|
||||
binding.txtReserveToComplete.visibility = GONE
|
||||
|
||||
}
|
||||
|
||||
} catch (ex: Exception) {
|
||||
ex.message!!.toast(context)
|
||||
}
|
||||
|
||||
|
||||
binding.txtReserveToComplete.text =
|
||||
"${sale.currentItemShelving}/${sale.totalItemShelving}"
|
||||
|
||||
//COLORES
|
||||
paintTicketcolor(sale.rgb, binding.itemTicketColor.background)
|
||||
if (sale.isPicked == 1) {
|
||||
if (type == PREPARED) {
|
||||
contentLayout.setBackgroundColor(
|
||||
|
||||
if (sale.saleGroupFk == null) {
|
||||
getColor(
|
||||
context!!, R.color.verdnatura_orange_salix
|
||||
)
|
||||
} else {
|
||||
println("stateCode ${sale.stateCode}")
|
||||
if (sale.stateCode != null && sale.stateCode == "PREPARED") {
|
||||
getColor(
|
||||
context!!, R.color.verdnatura_orange_salix
|
||||
)
|
||||
} else {
|
||||
if (sale.stateCode != null && sale.stateCode == "OK PREVIOUS") {
|
||||
getColor(
|
||||
context!!, R.color.verdnatura_dark_sky_blue
|
||||
)
|
||||
} else {
|
||||
if (sale.stateCode != null && sale.stateCode == "PREVIOUS_CONTROLLED") {
|
||||
getColor(
|
||||
context!!, R.color.verdnatura_dark_mint_light
|
||||
)
|
||||
} else {
|
||||
getColor(
|
||||
context!!, R.color.verdnatura_black
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
)
|
||||
} else {
|
||||
contentLayout.setBackgroundColor(
|
||||
getColor(
|
||||
context!!, R.color.verdnatura_dark_sky_blue
|
||||
)
|
||||
)
|
||||
}
|
||||
} else {
|
||||
contentLayout.setBackgroundColor(
|
||||
getColor(
|
||||
context!!, R.color.verdnatura_black
|
||||
)
|
||||
)
|
||||
|
||||
}
|
||||
|
||||
binding.txtParking.text =
|
||||
// if (type == PREPARED) sale.parkingCodePrevia else sale.parkingCode
|
||||
sale.parkingCode ?: sale.parkingCodePrevia
|
||||
|
||||
binding.addItem.setOnClickListener {
|
||||
onAddItemClickListener!!.onAddItemClickListener(sale)
|
||||
}
|
||||
|
||||
if (type == PREITEMPICKERTEST) {
|
||||
binding.level.visibility = GONE
|
||||
binding.levelTxt.visibility = GONE
|
||||
binding.ticketOrder.visibility = VISIBLE
|
||||
binding.txtPoints.visibility = GONE
|
||||
} else {
|
||||
binding.level.visibility = VISIBLE
|
||||
binding.levelTxt.visibility = VISIBLE
|
||||
binding.ticketOrder.visibility = GONE
|
||||
binding.txtPoints.visibility = VISIBLE
|
||||
|
||||
}
|
||||
|
||||
this.sale = sale
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun paintTicketcolor(color: String?, backgroundDrawableTicket: Drawable) {
|
||||
|
||||
if (color.isNullOrBlank()) {
|
||||
DrawableCompat.setTint(
|
||||
backgroundDrawableTicket, Color.TRANSPARENT
|
||||
)
|
||||
} else {
|
||||
DrawableCompat.setTint(
|
||||
backgroundDrawableTicket, Color.parseColor(color)
|
||||
)
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -8,25 +8,28 @@ import com.google.gson.JsonObject
|
|||
import es.verdnatura.MobileApplication
|
||||
import es.verdnatura.domain.SalixCallback
|
||||
import es.verdnatura.domain.formatWithQuotes
|
||||
import es.verdnatura.domain.getMessageFromAllResponse
|
||||
import es.verdnatura.domain.nameofFunction
|
||||
import es.verdnatura.domain.toast
|
||||
import es.verdnatura.domain.userCases.GetItemFromBarcodeUseCase
|
||||
import es.verdnatura.presentation.base.BaseViewModel
|
||||
import es.verdnatura.presentation.base.getMessageFromAllResponse
|
||||
import es.verdnatura.presentation.base.nameofFunction
|
||||
import es.verdnatura.presentation.common.Event
|
||||
import es.verdnatura.presentation.common.PickupResponse
|
||||
import es.verdnatura.presentation.common.SaleTrackingReplaceSalix
|
||||
import es.verdnatura.presentation.common.TicketPickupResponse
|
||||
import es.verdnatura.presentation.common.TicketState
|
||||
import es.verdnatura.presentation.view.feature.collection.SalixSaleQuantity
|
||||
import es.verdnatura.presentation.view.feature.collection.mapper.map
|
||||
import es.verdnatura.presentation.view.feature.sacador.model.CollectionVO
|
||||
import es.verdnatura.presentation.view.feature.sacador.model.MistakeTypeListVO
|
||||
import es.verdnatura.presentation.view.feature.sacador.model.MistakeTypeVO
|
||||
import es.verdnatura.presentation.view.feature.ticket.fragment.TicketViewModel
|
||||
import es.verdnatura.presentation.view.feature.workermistake.model.SaleMistakeSalix
|
||||
import retrofit2.Response
|
||||
|
||||
class CollectionCheckerViewModel(val context: Context) : BaseViewModel(context) {
|
||||
private val getItemFromBarcodeUseCase = GetItemFromBarcodeUseCase(salix)
|
||||
private val collectionViewModelChecker = CollectionViewModel(context)
|
||||
private val ticketViewModel = TicketViewModel(context)
|
||||
|
||||
//var isPaused: Boolean = false
|
||||
|
||||
|
@ -303,22 +306,21 @@ class CollectionCheckerViewModel(val context: Context) : BaseViewModel(context)
|
|||
fun ticketIsPickup(
|
||||
ticketFk: Number
|
||||
) {
|
||||
|
||||
salix.ticketIsPickup(
|
||||
"""{
|
||||
"where": {
|
||||
"id": $ticketFk
|
||||
},
|
||||
"fields": ["id", "routeFk"],
|
||||
"fields": ["id", "agencyModeFk"],
|
||||
"include": [
|
||||
{
|
||||
"relation": "route",
|
||||
"scope": {
|
||||
"fields": ["id", "agencyModeFk"],
|
||||
"include": {
|
||||
"relation": "agencyMode",
|
||||
"scope": {
|
||||
"fields": ["id", "deliveryMethodFk","code"],
|
||||
"where": {"code": "REC_ALG"},
|
||||
"fields": ["id", "deliveryMethodFk", "code"],
|
||||
"where": {
|
||||
"code": { "inq": ["REC_ALG", "PICKUP"] }
|
||||
},
|
||||
"include": {
|
||||
"relation": "deliveryMethod",
|
||||
"scope": {
|
||||
|
@ -327,17 +329,14 @@ class CollectionCheckerViewModel(val context: Context) : BaseViewModel(context)
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}""".trim()
|
||||
|
||||
).enqueue(object : SalixCallback<List<PickupResponse>>(context) {
|
||||
override fun onSuccess(response: Response<List<PickupResponse>>) {
|
||||
).enqueue(object : SalixCallback<List<TicketPickupResponse>>(context) {
|
||||
override fun onSuccess(response: Response<List<TicketPickupResponse>>) {
|
||||
|
||||
_responseTicketIsPickup.value =
|
||||
response.body()
|
||||
?.firstOrNull()?.route?.agencyMode?.deliveryMethod?.code == "PICKUP"
|
||||
?.firstOrNull()?.agencyMode?.deliveryMethod?.code == "PICKUP"
|
||||
|
||||
}
|
||||
|
||||
|
@ -359,4 +358,18 @@ class CollectionCheckerViewModel(val context: Context) : BaseViewModel(context)
|
|||
_isPaused.value = paused
|
||||
}
|
||||
|
||||
fun itemShelvingSaleBySale(
|
||||
saleFk: Number, quantityDiff: Int
|
||||
|
||||
) {
|
||||
collectionViewModelChecker.itemShelvingSaleBySale(
|
||||
saleFk = saleFk,
|
||||
quantityDiff = quantityDiff
|
||||
)
|
||||
}
|
||||
|
||||
fun ticketAdvance(ticketFk: Number, workerFk: Number) {
|
||||
ticketViewModel.ticketExits(ticketFk, workerFk)
|
||||
}
|
||||
|
||||
}
|
|
@ -20,6 +20,7 @@ import es.verdnatura.databinding.FragmentCollectionBinding
|
|||
import es.verdnatura.domain.ConstAndValues
|
||||
import es.verdnatura.domain.ConstAndValues.CONTROLADOR
|
||||
import es.verdnatura.domain.ConstAndValues.PRINTERNAME
|
||||
import es.verdnatura.domain.ConstAndValues.SECTORFK
|
||||
import es.verdnatura.domain.notNull
|
||||
import es.verdnatura.domain.showToastCenterWithBackground
|
||||
import es.verdnatura.domain.toast
|
||||
|
@ -54,7 +55,6 @@ import es.verdnatura.presentation.view.feature.sacador.model.PlacementVO
|
|||
import es.verdnatura.presentation.view.feature.sacador.model.SaleVO
|
||||
import org.json.JSONObject
|
||||
|
||||
// FALTA TESTEAR REVISORES DESPUÉS DE CAMPAÑA Y VER HOLDPOSITION
|
||||
@Suppress("UNUSED_ANONYMOUS_PARAMETER")
|
||||
class CollectionFragmentChecker(
|
||||
var collection: CollectionVO = CollectionVO(0), var type: String = CONTROLADOR
|
||||
|
@ -79,6 +79,7 @@ class CollectionFragmentChecker(
|
|||
private var mistakeSale: SaleVO? = null
|
||||
private var positionIncreaseQuantity = 0
|
||||
private var quantityIncrease: Int = 0
|
||||
private var quantityIncreaseDiff: Int = 0
|
||||
private var isMarking = false
|
||||
private lateinit var ticketScanTxt: String
|
||||
private var lastScanned: Int = 0
|
||||
|
@ -123,6 +124,7 @@ class CollectionFragmentChecker(
|
|||
if (collection.tickets.isNotEmpty()) {
|
||||
createCollectionList()
|
||||
}
|
||||
|
||||
super.init()
|
||||
}
|
||||
|
||||
|
@ -137,7 +139,7 @@ class CollectionFragmentChecker(
|
|||
binding.mainToolbar.toolbarSubtitle.visibility = VISIBLE
|
||||
binding.mainToolbar.toolbarIcons.visibility = VISIBLE
|
||||
binding.mainToolbar.backButton.visibility = VISIBLE
|
||||
binding.previaButton.visibility = INVISIBLE
|
||||
|
||||
binding.mainToolbar.toolbarTitle.text =
|
||||
if (collection.collectionFk == 0) getString(R.string.review) else collection.collectionFk.toString()
|
||||
|
||||
|
@ -166,10 +168,11 @@ class CollectionFragmentChecker(
|
|||
listIcons.add(iconWorker)
|
||||
listIcons.add(iconAdd)
|
||||
binding.previaButton.setOnClickListener {
|
||||
showPrevia()
|
||||
showDialog(isAdvanceTicket = false)
|
||||
}
|
||||
binding.ticketAdvanceButton.setOnClickListener {
|
||||
showDialog(isAdvanceTicket = true)
|
||||
}
|
||||
|
||||
|
||||
binding.mainToolbar.toolbarIcons.adapter =
|
||||
ToolBarAdapterTooltip(listIcons, object : OnOptionsSelectedListener {
|
||||
override fun onOptionsItemSelected(item: Drawable) {
|
||||
|
@ -209,11 +212,20 @@ class CollectionFragmentChecker(
|
|||
}
|
||||
}
|
||||
|
||||
private fun showPrevia() {
|
||||
private fun showDialog(isAdvanceTicket: Boolean) {
|
||||
customDialogList.getEditText().setRawInputType(TYPE_CLASS_NUMBER)
|
||||
customDialogList.setTitle(getString(R.string.scanPreviousTicket))
|
||||
customDialogList.setTitle(
|
||||
if (isAdvanceTicket) getString(R.string.ticketAdvance) else getString(
|
||||
R.string.scanPreviousTicket
|
||||
)
|
||||
)
|
||||
.setOkButton(getString(R.string.end)) {
|
||||
takeActionPrevia(customDialogList)
|
||||
if (customDialogList.getValue().isNotEmpty()) {
|
||||
takeAction(customDialogList, isAdvanceTicket)
|
||||
} else {
|
||||
ma.hideKeyboard(customDialogList.getEditText())
|
||||
customDialogList.dismiss()
|
||||
}
|
||||
|
||||
}.setValue("").show()
|
||||
|
||||
|
@ -225,7 +237,8 @@ class CollectionFragmentChecker(
|
|||
if (customDialogList.getValue().isNotEmpty()) {
|
||||
isScanned =
|
||||
event != null && event.action == ACTION_DOWN && event.keyCode == KeyEvent.KEYCODE_ENTER
|
||||
takeActionPrevia(customDialogList)
|
||||
takeAction(customDialogList, isAdvanceTicket)
|
||||
ma.hideKeyboard(customDialogList.getEditText())
|
||||
}
|
||||
customDialogList.setValue("")
|
||||
ma.hideKeyboard(customDialogList.getEditText())
|
||||
|
@ -236,14 +249,18 @@ class CollectionFragmentChecker(
|
|||
hideKeyboard()
|
||||
}
|
||||
|
||||
private fun takeActionPrevia(customDialogList: CustomDialogList) {
|
||||
private fun takeAction(customDialogList: CustomDialogList, isAdvanceTicket: Boolean) {
|
||||
ma.hideKeyboard(customDialogList.getEditText())
|
||||
try {
|
||||
val saleGroupScanned = itemScanValue(
|
||||
customDialogList.getValue(), arrayOf("saleGroup"), "id"
|
||||
val itemScanned = itemScanValue(
|
||||
customDialogList.getValue(), if (isAdvanceTicket) {
|
||||
arrayOf("ticket")
|
||||
} else arrayOf("saleGroup"), "id"
|
||||
).toString()
|
||||
|
||||
markPrevia(saleGroupScanned)
|
||||
if (isAdvanceTicket) {
|
||||
viewModel.ticketAdvance(itemScanned.toInt(), mobileApplication.userId!!)
|
||||
} else markPrevia(itemScanned)
|
||||
customDialogList.dismiss()
|
||||
} catch (ex: Exception) {
|
||||
ma.messageWithSound(
|
||||
|
@ -304,8 +321,13 @@ class CollectionFragmentChecker(
|
|||
val myQr = ItemScanned(JSONObject(binding.scanInput.text.toString()))
|
||||
|
||||
when (myQr.table) {
|
||||
|
||||
"saleGroup" -> {
|
||||
if (sales.any { it.saleGroupFk == myQr.id.toString() }) {
|
||||
markPrevia(myQr.id.toString())
|
||||
} else {
|
||||
findSale(myQr.id.toString())
|
||||
}
|
||||
}
|
||||
|
||||
"buy" -> binding.scanInput.setText(myQr.more)
|
||||
|
@ -354,6 +376,7 @@ class CollectionFragmentChecker(
|
|||
if (it.tickets.isNotEmpty()) {
|
||||
collection = it
|
||||
binding.previaButton.visibility = VISIBLE
|
||||
binding.ticketAdvanceButton.visibility = VISIBLE
|
||||
binding.fragmentSacadorCollections.visibility = VISIBLE
|
||||
createCollectionList()
|
||||
} else {
|
||||
|
@ -362,6 +385,7 @@ class CollectionFragmentChecker(
|
|||
getString(R.string.summaryCount, 0, 0)
|
||||
binding.fragmentSacadorCollections.visibility = INVISIBLE
|
||||
binding.previaButton.visibility = INVISIBLE
|
||||
binding.ticketAdvanceButton.visibility = INVISIBLE
|
||||
}
|
||||
} else {
|
||||
customDialog.setTitle(getString(R.string.error))
|
||||
|
@ -549,15 +573,48 @@ class CollectionFragmentChecker(
|
|||
observations.takeIf { it.isNotBlank() }?.plus(" ${ticket.observations}") ?: ""
|
||||
}
|
||||
|
||||
if (!buttonPushedGetCollection) {
|
||||
sales = salesList.sortedWith(compareBy { it.picked })
|
||||
myGroupList = groupSaleGroup(salesList).sortedWith(compareBy { it.picked })
|
||||
val isOnReservationMode = mobileApplication.dataStoreApp.readDataStoreKey<Boolean>(
|
||||
ConstAndValues.RESERVATIONMODE
|
||||
) || (mobileApplication.dataStoreApp.readDataStoreKey<Boolean?>(
|
||||
ConstAndValues.SECTORISONRESERVATIONMODE
|
||||
) == true)
|
||||
|
||||
sales = if (isOnReservationMode) {
|
||||
salesList.filter {
|
||||
it.sectorFk == mobileApplication.dataStoreApp.readDataStoreKey<Int>(SECTORFK)
|
||||
}.sortedWith(compareBy({ it.saleOrder }))
|
||||
} else {
|
||||
sales = salesList.sortedWith(
|
||||
salesList.filter {
|
||||
it.sectorFk == mobileApplication.dataStoreApp.readDataStoreKey<Int>(SECTORFK)
|
||||
}.sortedWith(compareBy({ it.picked }))
|
||||
}
|
||||
|
||||
if (!buttonPushedGetCollection) {
|
||||
println("Reorden lineas sin boton pulsado")
|
||||
sales =
|
||||
if (!isOnReservationMode) salesList.sortedWith(compareBy { it.picked }) else salesList.sortedWith(
|
||||
compareBy { it.pickedOrder })
|
||||
myGroupList =
|
||||
if (!isOnReservationMode) groupSaleGroup(salesList).sortedWith(compareBy { it.picked }) else groupSaleGroup(
|
||||
salesList
|
||||
).sortedWith(compareBy { it.pickedOrder })
|
||||
|
||||
for (m in myGroupList) {
|
||||
println("Linea ${m.itemFk}-${m.pickedOrder} ")
|
||||
}
|
||||
} else {
|
||||
sales = if (!isOnReservationMode) salesList.sortedWith(
|
||||
compareBy({ it.isControlled }, { it.picked })
|
||||
) else salesList.sortedWith(
|
||||
compareBy({ it.isControlled }, { it.pickedOrder })
|
||||
)
|
||||
myGroupList = groupSaleGroup(salesList).sortedWith(
|
||||
|
||||
//para la nueva revisión : hay que poner el saleOrder si no no podrán revisar correctamente
|
||||
println("Reorden lineas con boton pulsado")
|
||||
myGroupList = if (!isOnReservationMode) groupSaleGroup(salesList).sortedWith(
|
||||
compareBy({ it.isControlled }, { it.picked })
|
||||
) else groupSaleGroup(salesList).sortedWith(
|
||||
compareBy({ it.isControlled }, { it.pickedOrder })
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -1101,28 +1158,30 @@ class CollectionFragmentChecker(
|
|||
if (listItemSon.saleFk == saleFk) {
|
||||
myGroupList[parentIndex].sonSales[childIndex].quantity =
|
||||
quantityIncrease
|
||||
saleAdapter?.notifyDataSetChanged()
|
||||
|
||||
break
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (myGroupList[parentIndex].saleFk == saleFk) myGroupList[parentIndex].quantity =
|
||||
quantityIncrease
|
||||
|
||||
if (myGroupList[parentIndex].saleFk == saleFk) {
|
||||
myGroupList[parentIndex].quantity = quantityIncrease
|
||||
// myGroupList[positionIncreaseQuantity].quantity = quantityIncrease
|
||||
break
|
||||
}
|
||||
}/* } else {
|
||||
myGroupList[positionIncreaseQuantity].quantity = quantityIncrease
|
||||
saleAdapter?.notifyDataSetChanged()
|
||||
}*/
|
||||
}
|
||||
}
|
||||
viewModel.itemShelvingSaleBySale(saleFk = saleFk, quantityDiff = quantityIncreaseDiff)
|
||||
} catch (e: Exception) {
|
||||
e.message!!.toast(requireContext())
|
||||
}
|
||||
|
||||
saleAdapter?.notifyDataSetChanged()
|
||||
}
|
||||
|
||||
private fun increaseQuantity(position: Int, quantity: Int) {
|
||||
positionIncreaseQuantity = position
|
||||
quantityIncrease = quantity
|
||||
quantityIncreaseDiff = (myGroupList[position].quantity!!.minus(quantity))
|
||||
viewModel.collectionIncreaseQuantitySalix(
|
||||
saleFk = myGroupList[position].saleFk, quantity = quantity.toString()
|
||||
)
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package es.verdnatura.presentation.view.feature.collection.fragment
|
||||
|
||||
import android.content.Context
|
||||
import android.graphics.PorterDuff
|
||||
import android.graphics.drawable.Drawable
|
||||
import android.media.MediaPlayer
|
||||
import android.os.Build
|
||||
|
@ -18,6 +19,7 @@ import android.view.inputmethod.InputMethodManager
|
|||
import android.widget.ImageView
|
||||
import android.widget.Toast
|
||||
import androidx.annotation.RequiresApi
|
||||
import androidx.core.content.ContextCompat
|
||||
import androidx.lifecycle.Observer
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
|
@ -62,6 +64,8 @@ import es.verdnatura.presentation.view.feature.articulo.model.BarcodeVO
|
|||
import es.verdnatura.presentation.view.feature.collection.ItemVO
|
||||
import es.verdnatura.presentation.view.feature.collection.adapter.SaleAdapter
|
||||
import es.verdnatura.presentation.view.feature.main.activity.MainActivity
|
||||
import es.verdnatura.presentation.view.feature.pasillero.model.CleanAction
|
||||
import es.verdnatura.presentation.view.feature.pasillero.model.CodeWorkerAction
|
||||
import es.verdnatura.presentation.view.feature.pasillero.model.PasillerosItemVO
|
||||
import es.verdnatura.presentation.view.feature.sacador.model.CollectionVO
|
||||
import es.verdnatura.presentation.view.feature.sacador.model.MistakeTypeVO
|
||||
|
@ -69,6 +73,7 @@ import es.verdnatura.presentation.view.feature.sacador.model.PlacementSupplyList
|
|||
import es.verdnatura.presentation.view.feature.sacador.model.PlacementSupplyVO
|
||||
import es.verdnatura.presentation.view.feature.sacador.model.PlacementVO
|
||||
import es.verdnatura.presentation.view.feature.sacador.model.SaleVO
|
||||
import kotlinx.coroutines.runBlocking
|
||||
import org.json.JSONObject
|
||||
|
||||
@Suppress("UNUSED_ANONYMOUS_PARAMETER")
|
||||
|
@ -134,6 +139,7 @@ class CollectionFragmentPicker(
|
|||
private var isVerifiedCollection = false
|
||||
|
||||
private var hasFilterByLevel = false
|
||||
private lateinit var iconClean: ImageView
|
||||
|
||||
companion object {
|
||||
fun newInstance(collection: CollectionVO, type: String) =
|
||||
|
@ -207,8 +213,8 @@ class CollectionFragmentPicker(
|
|||
collection.collectionFk.let {
|
||||
binding.mainToolbar.toolbarTitle.text = collection.collectionFk.toString()
|
||||
}
|
||||
|
||||
val listIcons: ArrayList<ImageView> = ArrayList()
|
||||
|
||||
val iconPrint = ImageView(context)
|
||||
iconPrint.setImageResource(R.drawable.ic_print_black_24dp)
|
||||
val iconAdd = ImageView(context)
|
||||
|
@ -221,6 +227,9 @@ class CollectionFragmentPicker(
|
|||
iconPhone.setImageResource(R.drawable.phone_call)
|
||||
val iconParking = ImageView(context)
|
||||
iconParking.setImageResource(R.drawable.ic_local_parking_black_24dp)
|
||||
iconClean = ImageView(context)
|
||||
iconClean.setImageResource(R.drawable.ic_clean_shelving)
|
||||
|
||||
val iconUpdate = ImageView(context)
|
||||
iconUpdate.setImageResource(R.drawable.ic_autorenew_black_24dp)
|
||||
|
||||
|
@ -231,7 +240,7 @@ class CollectionFragmentPicker(
|
|||
iconPhone.tooltipText = getTooltip(R.drawable.phone_call)
|
||||
iconParking.tooltipText = getTooltip(R.drawable.ic_local_parking_black_24dp)
|
||||
iconUpdate.tooltipText = getTooltip(R.drawable.ic_autorenew_black_24dp)
|
||||
|
||||
iconClean.tooltipText = getTooltip(R.drawable.ic_clean_shelving)
|
||||
}
|
||||
listIcons.add(iconPrint)
|
||||
if (type == CONTROLADOR) {
|
||||
|
@ -246,6 +255,8 @@ class CollectionFragmentPicker(
|
|||
listIcons.add(iconAdd)
|
||||
|
||||
if (type == SACADOR) {
|
||||
//Tarea 8624
|
||||
listIcons.add(iconClean)
|
||||
listIcons.add(iconUpdate)
|
||||
listIcons.remove(iconWorker)
|
||||
}
|
||||
|
@ -260,6 +271,7 @@ class CollectionFragmentPicker(
|
|||
override fun onOptionsItemSelected(item: Drawable) {
|
||||
|
||||
when (item) {
|
||||
iconClean.drawable -> clean()
|
||||
iconPrint.drawable -> print()
|
||||
iconAdd.drawable -> addItem()
|
||||
iconWorker.drawable -> showUser()
|
||||
|
@ -272,9 +284,86 @@ class CollectionFragmentPicker(
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
})
|
||||
binding.mainToolbar.toolbarIcons.layoutManager =
|
||||
LinearLayoutManager(requireContext(), LinearLayoutManager.HORIZONTAL, false)
|
||||
updateIconColor()
|
||||
}
|
||||
|
||||
private fun updateIconColor() {
|
||||
val newColor =
|
||||
ContextCompat.getColor(
|
||||
requireContext(),
|
||||
if (mobileApplication.dataStoreApp.readDataStoreKey<String>("SHELVINGACTION")
|
||||
.isNotBlank()
|
||||
) R.color.verdnatura_orange_salix else R.color.verdnatura_white
|
||||
)
|
||||
iconClean.setColorFilter(newColor, PorterDuff.Mode.SRC_IN)
|
||||
binding.mainToolbar.toolbarIcons.adapter?.notifyDataSetChanged()
|
||||
|
||||
}
|
||||
|
||||
private fun addWorkerActivity(codeWorkerAction: CodeWorkerAction, shelving: String) {
|
||||
viewModel.addWorkerActivity(
|
||||
CleanAction(
|
||||
codeWorkerAction = codeWorkerAction,
|
||||
shelving = shelving.uppercase(),
|
||||
description = shelving.uppercase()
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
private fun clean() {
|
||||
|
||||
val shelving = mobileApplication.dataStoreApp.readDataStoreKey<String>(
|
||||
"SHELVINGACTION"
|
||||
)
|
||||
if (
|
||||
shelving.isNotBlank()
|
||||
) {
|
||||
addWorkerActivity(
|
||||
CodeWorkerAction.SHELVING_CLEAN_STOP,
|
||||
shelving = shelving
|
||||
)
|
||||
|
||||
} else {
|
||||
customDialogInput.setTitle(getString(R.string.titleCleanShelving))
|
||||
.setDescription(getString(R.string.descripOrganize))
|
||||
.setOkButton(getString(R.string.organize)) {
|
||||
ma.hideKeyboard(customDialogInput.getEditText())
|
||||
actionOrganizeClean(customDialogInput.getValue())
|
||||
|
||||
}.setKoButton(getString(R.string.cancel)) {
|
||||
customDialogInput.dismiss()
|
||||
}.setValue("").show()
|
||||
customDialogInput.getEditText().requestFocus()
|
||||
customDialogInput.getEditText().setOnEditorActionListener { _, actionId, _ ->
|
||||
if (actionId == EditorInfo.IME_ACTION_SEARCH || actionId == EditorInfo.IME_ACTION_DONE || actionId == 0 || actionId == 5) {
|
||||
|
||||
actionOrganizeClean(customDialogInput.getValue())
|
||||
return@setOnEditorActionListener true
|
||||
}
|
||||
false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun actionOrganizeClean(input: String) {
|
||||
if (input.isShelving()) {
|
||||
addWorkerActivity(
|
||||
CodeWorkerAction.SHELVING_CLEAN_START,
|
||||
shelving = input
|
||||
)
|
||||
} else {
|
||||
ma.messageWithSound(
|
||||
message = getString(R.string.errorInput),
|
||||
isError = true,
|
||||
isPlayed = true,
|
||||
isToasted = true
|
||||
)
|
||||
}
|
||||
customDialogInput.dismiss()
|
||||
}
|
||||
|
||||
private fun updateScreen() {
|
||||
|
@ -331,9 +420,7 @@ class CollectionFragmentPicker(
|
|||
ma.hideKeyboard(customDialogList.getEditText())
|
||||
try {
|
||||
val saleGroupScanned = itemScanValue(
|
||||
customDialogList.getValue(),
|
||||
arrayOf("saleGroup"),
|
||||
"id"
|
||||
customDialogList.getValue(), arrayOf("saleGroup"), "id"
|
||||
).toString()
|
||||
isScanned =
|
||||
event != null && event.action == KeyEvent.ACTION_DOWN && event.keyCode == KeyEvent.KEYCODE_ENTER
|
||||
|
@ -464,7 +551,22 @@ class CollectionFragmentPicker(
|
|||
|
||||
@RequiresApi(Build.VERSION_CODES.O)
|
||||
override fun observeViewModel() {
|
||||
|
||||
with(viewModel) {
|
||||
loadResponseActivity.observe(viewLifecycleOwner) { event ->
|
||||
event.getContentIfNotHandled().notNull {
|
||||
|
||||
println("shelvinAction ${it}")
|
||||
runBlocking {
|
||||
mobileApplication.dataStoreApp.editDataStoreKey(
|
||||
"SHELVINGACTION",
|
||||
if (it.codeWorkerAction == CodeWorkerAction.SHELVING_CLEAN_START) it.shelving else ""
|
||||
)
|
||||
}
|
||||
|
||||
updateIconColor()
|
||||
}
|
||||
}
|
||||
collectionTicketList.observe(viewLifecycleOwner, Observer {
|
||||
|
||||
if (!it.isError) {
|
||||
|
@ -844,7 +946,8 @@ class CollectionFragmentPicker(
|
|||
} else {
|
||||
// pintar línea
|
||||
saleAdapter!!.notifyDataSetChanged()
|
||||
myPosition = storedBackPosition
|
||||
//se modifica tenia storedBackPosition
|
||||
myPosition = storedPosition
|
||||
|
||||
ReviewQuantityForRefreshingAndSorting(
|
||||
sales[storedPosition].quantity!!.toInt(),
|
||||
|
@ -928,8 +1031,7 @@ class CollectionFragmentPicker(
|
|||
|
||||
}
|
||||
|
||||
saleAdapter = SaleAdapter(
|
||||
myGroupList as MutableList,
|
||||
saleAdapter = SaleAdapter(myGroupList as MutableList,
|
||||
pasillerosItemClickListener!!,
|
||||
object : OnQuantityClickListener {
|
||||
|
||||
|
@ -1007,18 +1109,9 @@ class CollectionFragmentPicker(
|
|||
type = type,
|
||||
onTicketColorClickListener = object : OnTicketColorListener {
|
||||
override fun onTicketColorListener(sale: SaleVO) {
|
||||
hasFilterByLevel = !hasFilterByLevel
|
||||
|
||||
if (hasFilterByLevel) {
|
||||
saleAdapter!!.updateSales(myGroupList.filter { it.level == sale.level } as MutableList)
|
||||
myGroupList = myGroupList.filter { it.level == sale.level }
|
||||
} else {
|
||||
createCollectionList()
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
)
|
||||
})
|
||||
|
||||
|
||||
lm = LinearLayoutManager(requireContext(), LinearLayoutManager.VERTICAL, false)
|
||||
|
@ -1046,7 +1139,7 @@ class CollectionFragmentPicker(
|
|||
}
|
||||
|
||||
printObservations(observations)
|
||||
if (!isVerifiedCollection) {
|
||||
if (!isVerifiedCollection && mobileApplication.userId != 19591) {
|
||||
binding.fragmentSacadorCollections.visibility = View.INVISIBLE
|
||||
verifyCollection()
|
||||
}
|
||||
|
@ -1923,6 +2016,7 @@ class CollectionFragmentPicker(
|
|||
if (listPlacementSupply.size == 1) {
|
||||
ticketSelected = listPlacementSupply[0].code!!.toInt()
|
||||
}
|
||||
customDialogList = CustomDialogList(requireContext())
|
||||
customDialogList.window?.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE)
|
||||
customDialogList.getEditTextTwo().inputType = InputType.TYPE_CLASS_NUMBER
|
||||
customDialogList.getEditText().setRawInputType(InputType.TYPE_CLASS_NUMBER)
|
||||
|
@ -2354,18 +2448,15 @@ class CollectionFragmentPicker(
|
|||
}
|
||||
if (isTicket) {
|
||||
val labelDialogHelper = LabelDialogHelper(requireContext())
|
||||
labelDialogHelper.showLabelDialog(
|
||||
onItemSelected = { labelCount ->
|
||||
labelDialogHelper.showLabelDialog(onItemSelected = { labelCount ->
|
||||
viewModel.collectionStickerPrint(
|
||||
collectionFk = collection.collectionFk,
|
||||
labelCount = labelCount
|
||||
collectionFk = collection.collectionFk, labelCount = labelCount
|
||||
)
|
||||
|
||||
(getString(R.string.Imprimiendo) + mobileApplication.dataStoreApp.readDataStoreKey<String>(
|
||||
PRINTERNAME
|
||||
)).toast(requireContext())
|
||||
}
|
||||
)
|
||||
})
|
||||
} else {
|
||||
viewModel.collectionStickerPrint(
|
||||
collectionFk = collection.collectionFk, null
|
||||
|
|
|
@ -7,7 +7,11 @@ import android.os.Bundle
|
|||
import android.os.Handler
|
||||
import android.os.Looper
|
||||
import android.text.InputType
|
||||
import android.text.Spannable
|
||||
import android.text.SpannableString
|
||||
import android.text.style.AbsoluteSizeSpan
|
||||
import android.util.Log.d
|
||||
import android.util.TypedValue
|
||||
import android.view.KeyEvent
|
||||
import android.view.View
|
||||
import android.view.View.VISIBLE
|
||||
|
@ -55,7 +59,7 @@ import es.verdnatura.presentation.view.component.CustomDialogThreeButtons
|
|||
import es.verdnatura.presentation.view.feature.articulo.adapter.BarcodeAdapter
|
||||
import es.verdnatura.presentation.view.feature.articulo.model.BarcodeVO
|
||||
import es.verdnatura.presentation.view.feature.collection.ItemVO
|
||||
import es.verdnatura.presentation.view.feature.collection.adapter.SaleAdapterNew
|
||||
import es.verdnatura.presentation.view.feature.collection.adapter.SaleAdapterReserve
|
||||
import es.verdnatura.presentation.view.feature.collection.mapper.map
|
||||
import es.verdnatura.presentation.view.feature.main.activity.MainActivity
|
||||
import es.verdnatura.presentation.view.feature.pasillero.model.PasillerosItemVO
|
||||
|
@ -78,7 +82,7 @@ import org.json.JSONObject
|
|||
variables:
|
||||
isVerifiedCollection
|
||||
*/
|
||||
class CollectionFragmentPickerPreviousNew(
|
||||
class CollectionFragmentPickerPreviousNewInterface(
|
||||
var collection: CollectionTicket,
|
||||
var type: String = PRESACADOR,
|
||||
private var hasPickingOrder: Boolean = false
|
||||
|
@ -86,7 +90,7 @@ class CollectionFragmentPickerPreviousNew(
|
|||
CollectionViewModel::class
|
||||
) {
|
||||
private var sales: List<Sale> = listOf()
|
||||
private var saleAdapter: SaleAdapterNew? = null
|
||||
private var saleAdapter: SaleAdapterReserve? = null
|
||||
private var lm: LinearLayoutManager? = null
|
||||
private var storedPosition: Int = 0
|
||||
private var pasillerosItemClickListener: OnPasillerosItemClickListener? = null
|
||||
|
@ -115,7 +119,7 @@ class CollectionFragmentPickerPreviousNew(
|
|||
companion object {
|
||||
fun newInstance(
|
||||
collection: CollectionTicket, type: String, hasPickingOrder: Boolean = false
|
||||
) = CollectionFragmentPickerPreviousNew(collection, type, hasPickingOrder)
|
||||
) = CollectionFragmentPickerPreviousNewInterface(collection, type, hasPickingOrder)
|
||||
}
|
||||
|
||||
override fun onAttach(context: Context) {
|
||||
|
@ -137,6 +141,7 @@ class CollectionFragmentPickerPreviousNew(
|
|||
}
|
||||
|
||||
override fun init() {
|
||||
println("El tipo es $type ")
|
||||
customDialogList = CustomDialogList(requireContext())
|
||||
customDialogInput = CustomDialogInput(requireContext())
|
||||
customDialog = CustomDialog(requireContext())
|
||||
|
@ -154,9 +159,9 @@ class CollectionFragmentPickerPreviousNew(
|
|||
}
|
||||
|
||||
private fun setToolBar() {
|
||||
binding.mainToolbar.toolbarSubtitle.visibility = View.VISIBLE
|
||||
binding.mainToolbar.toolbarIcons.visibility = View.VISIBLE
|
||||
binding.mainToolbar.backButton.visibility = View.VISIBLE
|
||||
binding.mainToolbar.toolbarSubtitle.visibility = VISIBLE
|
||||
binding.mainToolbar.toolbarIcons.visibility = VISIBLE
|
||||
binding.mainToolbar.backButton.visibility = VISIBLE
|
||||
collection.collectionFk.let {
|
||||
binding.mainToolbar.toolbarTitle.text = collection.collectionFk.toString()
|
||||
}
|
||||
|
@ -233,6 +238,7 @@ class CollectionFragmentPickerPreviousNew(
|
|||
when (myQr.table) {
|
||||
"saleGroup" -> {
|
||||
binding.scanInput.setText(myQr.id.toString())
|
||||
findSale(binding.scanInput.text.toString())
|
||||
}
|
||||
|
||||
"buy" -> binding.scanInput.setText(myQr.more)
|
||||
|
@ -336,6 +342,7 @@ class CollectionFragmentPickerPreviousNew(
|
|||
lm!!.scrollToPositionWithOffset(positionConfirm, 0)
|
||||
//lm!!.scrollToPositionWithOffset(storedBackPosition + 1, 0)
|
||||
setTotalLines()
|
||||
saleAdapter!!.notifyItemChanged(positionConfirm)
|
||||
} else {
|
||||
updateScreen()
|
||||
}
|
||||
|
@ -358,8 +365,7 @@ class CollectionFragmentPickerPreviousNew(
|
|||
}
|
||||
}
|
||||
loadResponseReserveAddPrevOK.observe(viewLifecycleOwner) { event ->
|
||||
event.getContentIfNotHandled().notNull {
|
||||
}
|
||||
event.getContentIfNotHandled().notNull {}
|
||||
}
|
||||
loadSetStateResponse.observe(viewLifecycleOwner) { event ->
|
||||
event.getContentIfNotHandled().notNull {
|
||||
|
@ -395,6 +401,18 @@ class CollectionFragmentPickerPreviousNew(
|
|||
binding.mainToolbar.toolbarTitle.text = collection.collectionFk.toString()
|
||||
|
||||
collection.map(requireContext())
|
||||
|
||||
val sectorFk = mobileApplication.dataStoreApp.readDataStoreKey<Int>(SECTORFK)
|
||||
if (collection.sectorFk != null && collection.sectorFk != sectorFk) {
|
||||
|
||||
ma.messageWithSound(
|
||||
getString(R.string.cambia_el_sector_vas_a_preparar_una_previa_que_no_es_de_tu_sector),
|
||||
isError = true,
|
||||
isPlayed = true,
|
||||
isToasted = false
|
||||
)
|
||||
} else {
|
||||
|
||||
val salesList: ArrayList<Sale> = ArrayList()
|
||||
|
||||
tickets = ArrayList()
|
||||
|
@ -403,7 +421,8 @@ class CollectionFragmentPickerPreviousNew(
|
|||
val myPickingTo = mobileApplication.dataStoreApp.readDataStoreKey<Int>("PICKING_TO")
|
||||
collection.tickets.forEach { ticket ->
|
||||
|
||||
if (observations.isNotEmpty()) observations = observations + " " + ticket.observations
|
||||
if (observations.isNotEmpty()) observations =
|
||||
observations + " " + ticket.observations
|
||||
ticket.sales.forEach { sale ->
|
||||
|
||||
if (hasPickingOrder) {
|
||||
|
@ -433,19 +452,28 @@ class CollectionFragmentPickerPreviousNew(
|
|||
}
|
||||
|
||||
|
||||
saleAdapter = SaleAdapterNew(myGroupList, pasillerosItemClickListener!!,
|
||||
saleAdapter = SaleAdapterReserve(myGroupList, pasillerosItemClickListener!!,
|
||||
|
||||
object : OnSaleClickSaleListener {
|
||||
override fun onSaleClick(sale: Sale) {
|
||||
|
||||
println("sale ${sale.saleFk} ${sale.itemFk} ${sale.isPicked}")
|
||||
val position =
|
||||
myGroupList.indexOfFirst { it.itemShelvingSaleFk == sale.itemShelvingSaleFk }
|
||||
if (position > -1) {
|
||||
if (position > -1 && !myGroupList[position].isParent) {
|
||||
if (sale.isPicked == 1) {
|
||||
unMarkLine(position, myGroupList[position])
|
||||
} else {
|
||||
|
||||
if (sale.itemShelvingSaleFk == 0 && sale.itemShelvingFk == 0 && sale.code.isNullOrEmpty())
|
||||
showManagement(sale)
|
||||
else {
|
||||
showScanner(position, sale)
|
||||
}
|
||||
|
||||
}
|
||||
} else {
|
||||
//TODO desmarcamos una linea de previa ?
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -507,6 +535,7 @@ class CollectionFragmentPickerPreviousNew(
|
|||
verifyCollection()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun showDeleteItemShelving(sale: Sale) {
|
||||
customDialog.setTitle(getString(R.string.deleteSale)).setDescription(
|
||||
|
@ -559,14 +588,27 @@ class CollectionFragmentPickerPreviousNew(
|
|||
isFoundSale = true
|
||||
storedPosition = indice
|
||||
viewModel.itemShelvingSaleSetSaleGroup(txtscan.toInt())
|
||||
setStateSaleGroup(txtscan.toInt())
|
||||
//actualizamos padre
|
||||
myGroupList[indice].stateCode =
|
||||
if (myGroupList[indice].stateCode == "PREPARED") {
|
||||
"OK PREVIOUS"
|
||||
} else {
|
||||
"PREPARED"
|
||||
}
|
||||
saleAdapter!!.notifyDataSetChanged()
|
||||
//actualizamos hijos
|
||||
myGroupList[indice].sonSales.forEach {
|
||||
it.stateCode = myGroupList[indice].stateCode
|
||||
}
|
||||
//actualizamos saleGroup
|
||||
setStateSaleGroup(
|
||||
txtscan.toInt(), if (myGroupList[indice].stateCode == "PREPARED") {
|
||||
14
|
||||
} else {
|
||||
28
|
||||
}
|
||||
)
|
||||
|
||||
// saleAdapter!!.notifyDataSetChanged()
|
||||
break
|
||||
|
||||
}
|
||||
|
@ -590,7 +632,10 @@ class CollectionFragmentPickerPreviousNew(
|
|||
for (indice in sales.indices) {
|
||||
if (sales[indice].saleGroupFk != null && sales[indice].saleGroupFk == saleGroupScanned.toInt()) {
|
||||
viewModel.itemShelvingSaleSetSaleGroup(saleGroupScanned.toInt())
|
||||
setStateSaleGroup(saleGroupScanned.toInt())
|
||||
setStateSaleGroup(
|
||||
saleGroupScanned.toInt(),
|
||||
if (sales[indice].stateCode == "PREPARED") 28 else 14
|
||||
)
|
||||
storedPosition = indice
|
||||
mpok!!.start()
|
||||
return true
|
||||
|
@ -708,8 +753,18 @@ class CollectionFragmentPickerPreviousNew(
|
|||
val longName = myGroupList[pos].longName
|
||||
val totalReserved = myGroupList[pos].reservedQuantity
|
||||
|
||||
val spannable = SpannableString("$item\n$longName")
|
||||
|
||||
spannable.setSpan(
|
||||
AbsoluteSizeSpan(
|
||||
TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP, 16f, resources.displayMetrics)
|
||||
.toInt(), true
|
||||
), 0, item.toString().length, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE
|
||||
)
|
||||
|
||||
try {
|
||||
customDialogList.setTitle("$shelving($item) $totalReserved de $longName").setOkButton(
|
||||
customDialogList.setTitleSpannable(spannable)
|
||||
customDialogList.setOkButton(
|
||||
getString(
|
||||
R.string.take
|
||||
)
|
||||
|
@ -721,8 +776,9 @@ class CollectionFragmentPickerPreviousNew(
|
|||
customDialogList.dismiss()
|
||||
scanRequest()
|
||||
|
||||
}.setHintValue(getString(R.string.quantitySelect)).setValue(totalReserved.toString())
|
||||
.setHintValueTwo(getString(R.string.scanItem)).setValueTwo("").show()
|
||||
}.setHintValue(getString(R.string.quantitySelect)).setTextSize(20f)
|
||||
.setValue(totalReserved.toString()).setHintValueTwo(getString(R.string.scanItem))
|
||||
.setValueTwo("").show()
|
||||
|
||||
customDialogList.getEditTextTwo().setOnEditorActionListener { v, actionId, event ->
|
||||
if (actionId == EditorInfo.IME_ACTION_SEARCH || actionId == EditorInfo.IME_ACTION_DONE || actionId == 0 || actionId == 5) {
|
||||
|
@ -784,7 +840,11 @@ class CollectionFragmentPickerPreviousNew(
|
|||
mpok?.start()
|
||||
ma.hideKeyboard(customDialogList.getEditTextTwo())
|
||||
customDialogList.dismiss()
|
||||
requireContext().showToastCenterWithBackground(myGroupList[position].ticketFk.toString())
|
||||
requireContext().showToastCenterWithBackground(
|
||||
if (type == PREITEMPICKERTEST) "(" + myGroupList[position].ticketOrder + ")" + myGroupList[position].ticketFk.toString() else {
|
||||
myGroupList[position].ticketFk.toString()
|
||||
}
|
||||
)
|
||||
scanRequest()
|
||||
|
||||
} else {
|
||||
|
@ -1057,18 +1117,22 @@ class CollectionFragmentPickerPreviousNew(
|
|||
println("No hay salegroup")
|
||||
}
|
||||
}
|
||||
if (distinctSaleGroups.isNotEmpty())
|
||||
distinctSaleGroups.forEach { saleGroup ->
|
||||
setStateSaleGroup(saleGroup)
|
||||
try {
|
||||
if (distinctSaleGroups.isNotEmpty()) distinctSaleGroups.forEach { saleGroup ->
|
||||
setStateSaleGroup(saleGroup, stateCodeId!!)
|
||||
}
|
||||
} catch (ex: Exception) {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun setStateSaleGroup(saleGroup: Number) {
|
||||
viewModel.saleGroupUpdateState(saleGroup, stateCodeId!!)
|
||||
private fun setStateSaleGroup(saleGroup: Number, stateCode: Number) {
|
||||
viewModel.saleGroupUpdateState(saleGroup, stateCode)
|
||||
}
|
||||
|
||||
private fun showScanner(index: Int, sale: Sale) {
|
||||
|
@ -1123,6 +1187,8 @@ class CollectionFragmentPickerPreviousNew(
|
|||
}
|
||||
} else { // si tiene saleGroup se crea el padre con el tamaño e indicando que es padre, como ejemplo se toma el primer elemento
|
||||
/*crea padre*/
|
||||
|
||||
println("saleGroup $key lineas ${value.size}")
|
||||
if (value.size > 1) {
|
||||
val mySale = //= value[0]
|
||||
Sale(
|
||||
|
@ -1143,8 +1209,11 @@ class CollectionFragmentPickerPreviousNew(
|
|||
origin = value[0].origin,
|
||||
size = value[0].size,
|
||||
itemShelvingSaleFk = value[0].itemShelvingSaleFk,
|
||||
longName = value[0].parkingCode ?: "",
|
||||
itemShelvingFk = 0
|
||||
longName = value[0].parkingCodePrevia ?: "",
|
||||
itemShelvingFk = 0,
|
||||
ticketOrder = value[0].ticketOrder ?: null,
|
||||
parkingCodePrevia = value[0].parkingCodePrevia,
|
||||
stateCode = value[0].stateCode
|
||||
)
|
||||
|
||||
//prime elemento//hay que hacer una copia si no queda la referencia
|
||||
|
@ -1204,7 +1273,7 @@ class CollectionFragmentPickerPreviousNew(
|
|||
if (foundTicketInCollection != null) {
|
||||
isVerifiedCollection = true
|
||||
ma.hideKeyboard(customDialogList.getEditText())
|
||||
binding.fragmentSacadorCollections.visibility = View.VISIBLE
|
||||
binding.fragmentSacadorCollections.visibility = VISIBLE
|
||||
customDialogList.dismiss()
|
||||
binding.scanInput.requestFocus()
|
||||
} else {
|
||||
|
@ -1272,4 +1341,40 @@ class CollectionFragmentPickerPreviousNew(
|
|||
|
||||
}
|
||||
}
|
||||
|
||||
private fun showManagement(sale: Sale) {
|
||||
customDialogThreeButtons = CustomDialogThreeButtons(requireContext())
|
||||
customDialogThreeButtons.setCustomDialogValue(View.GONE)
|
||||
customDialogThreeButtons.setTitle("Gestionar línea artículo ${sale.itemFk}")
|
||||
.setDescription("Selecciona RESERVAR para añadir reserva y que muestre ubicación")
|
||||
.setOkButton("Reservar") {
|
||||
viewModel.itemShelvingSaleAddByCollection(collection.collectionFk)
|
||||
closeCustomDialogManagement(binding.scanInput, customDialogThreeButtons)
|
||||
}/*.setOkButtonTwo("Poner a cero la cantidad") {
|
||||
viewModel.collectionIncreaseQuantitySalix(sale.saleFk, "0")
|
||||
closeCustomDialogManagement(binding.scanInput, customDialogThreeButtons)
|
||||
}*/
|
||||
.setKoButton(getString(R.string.cancel)) {
|
||||
closeCustomDialogManagement(binding.scanInput, customDialogThreeButtons)
|
||||
}.setValue("").show()
|
||||
|
||||
/* customDialogThreeButtons.getEditText().setOnEditorActionListener { v, actionId, event ->
|
||||
if (actionId == EditorInfo.IME_ACTION_SEARCH || actionId == EditorInfo.IME_ACTION_DONE || actionId == 0) {
|
||||
findSaleAction(index, sale)
|
||||
return@setOnEditorActionListener false
|
||||
}
|
||||
false
|
||||
}*/
|
||||
customDialogThreeButtons.getEditText().requestFocus()
|
||||
}
|
||||
|
||||
private fun closeCustomDialogManagement(
|
||||
scanInput: EditText,
|
||||
customDialogInput: CustomDialogThreeButtons
|
||||
) {
|
||||
requireContext().hideKeyboard(customDialogInput.getEditText())
|
||||
scanInput.requestFocus()
|
||||
customDialogInput.dismiss()
|
||||
scanInput.requestFocus()
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load Diff
|
@ -103,6 +103,7 @@ class CollectionFragmentPreChecker(
|
|||
private var positionIncreaseQuantity = 0
|
||||
private var positionReject = 0
|
||||
private var quantityIncrease: Int = 0
|
||||
private var quantityIncreaseDiff: Int = 0
|
||||
private var quantityReject = ""
|
||||
private var typeCollectionMissing = ""
|
||||
private var positionCollectionMissing = 0
|
||||
|
@ -687,7 +688,8 @@ class CollectionFragmentPreChecker(
|
|||
|
||||
})
|
||||
|
||||
responseIncQuantity.observe(viewLifecycleOwner, Observer {
|
||||
loadIncQuantity.observe(viewLifecycleOwner) { event ->
|
||||
event.getContentIfNotHandled().notNull {
|
||||
|
||||
if (it.isError) {
|
||||
ma.messageWithSound(it.errorMessage, isError = true, true)
|
||||
|
@ -700,7 +702,8 @@ class CollectionFragmentPreChecker(
|
|||
}
|
||||
}
|
||||
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
responseSaleMistakeAdd.observe(viewLifecycleOwner, Observer {
|
||||
|
||||
|
@ -981,10 +984,11 @@ class CollectionFragmentPreChecker(
|
|||
sales = salesList.sortedWith(compareBy({ it.picked }))
|
||||
}
|
||||
}
|
||||
|
||||
saleAdapter =
|
||||
SaleAdapter(
|
||||
sales as MutableList,
|
||||
if (sales.isEmpty()) sales.toMutableList() else {
|
||||
sales as MutableList
|
||||
},
|
||||
pasillerosItemClickListener!!,
|
||||
object : OnQuantityClickListener {
|
||||
|
||||
|
@ -1088,10 +1092,11 @@ class CollectionFragmentPreChecker(
|
|||
setListPosition(storedBackPosition, true)
|
||||
|
||||
}
|
||||
}
|
||||
// }
|
||||
|
||||
printObservations(observations)
|
||||
}
|
||||
}
|
||||
|
||||
private fun setScrollListener(lm: LinearLayoutManager) {
|
||||
binding.fragmentSacadorCollections.clearOnScrollListeners()
|
||||
|
@ -1533,7 +1538,6 @@ class CollectionFragmentPreChecker(
|
|||
)
|
||||
}
|
||||
|
||||
@RequiresApi(Build.VERSION_CODES.O)
|
||||
private fun printShelvingResult(placementSupplyListVO: PlacementSupplyListVO) {
|
||||
var shelving = ""
|
||||
var item = ""
|
||||
|
@ -1630,7 +1634,7 @@ class CollectionFragmentPreChecker(
|
|||
requireActivity().getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager
|
||||
lManager.hideSoftInputFromWindow(
|
||||
customDialogList.getEditTextTwo().windowToken,
|
||||
InputMethodManager.SHOW_IMPLICIT
|
||||
InputMethodManager.HIDE_IMPLICIT_ONLY
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -2024,8 +2028,22 @@ class CollectionFragmentPreChecker(
|
|||
|
||||
changeTicketState()
|
||||
|
||||
//cambiamos estado de previas para saber que está PREVIOUS_CONTROLLED
|
||||
val distinctSaleGroups = mutableSetOf<Int>()
|
||||
sales.forEach { sale ->
|
||||
sale.saleGroupFk?.let {
|
||||
distinctSaleGroups.add(it.toInt())
|
||||
} ?: run {
|
||||
println("No hay salegroup")
|
||||
}
|
||||
}
|
||||
if (distinctSaleGroups.isNotEmpty())
|
||||
distinctSaleGroups.forEach { saleGroup ->
|
||||
viewModel.saleGroupUpdateState(saleGroup, 37)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private fun ticketCollection_setUsedShelves() {
|
||||
|
||||
|
@ -2087,49 +2105,19 @@ class CollectionFragmentPreChecker(
|
|||
private fun showQuantityDialog(position: Int) {
|
||||
customDialogThreeButtons.setDescription(getString(R.string.itemSaleQuantity))
|
||||
.setValue("")
|
||||
|
||||
//Tarea4495
|
||||
// if (type != SACADOR) {
|
||||
/* customDialogThreeButtons.setOkButton(getString(R.string.titleFaults)) {
|
||||
checkAndCall(
|
||||
position,
|
||||
customDialogThreeButtons.getValue(),
|
||||
getString(R.string.titleFaults)
|
||||
)
|
||||
|
||||
}.setOkButtonTwo(getString(R.string.BasuraRechazar)) {
|
||||
|
||||
checkAndCall(
|
||||
position,
|
||||
customDialogThreeButtons.getValue(),
|
||||
getString(R.string.BasuraRechazar)
|
||||
)
|
||||
}
|
||||
// }
|
||||
|
||||
customDialogThreeButtons.setOkButtonThree(getString(R.string.Reject)) {
|
||||
checkAndCall(
|
||||
position,
|
||||
customDialogThreeButtons.getValue(),
|
||||
getString(R.string.Reject)
|
||||
)
|
||||
|
||||
}.setOkButtonFour(getString(R.string.Split)) {
|
||||
checkAndCall(
|
||||
position,
|
||||
customDialogThreeButtons.getValue(),
|
||||
getString(R.string.Split)
|
||||
)*/
|
||||
|
||||
.setOkButtonAdd(getString(R.string.Agregar)) {
|
||||
/* checkAndCall(
|
||||
position,
|
||||
customDialogThreeButtons.getValue(),
|
||||
getString(R.string.Agregar)
|
||||
)*/
|
||||
if (customDialogThreeButtons.getValue().isNotEmpty()) {
|
||||
increaseQuantity(position, customDialogThreeButtons.getValue().toInt())
|
||||
scanRequest()
|
||||
customDialogThreeButtons.dismiss()
|
||||
} else {
|
||||
ma.messageWithSound(
|
||||
getString(R.string.errorInputQuantity),
|
||||
isError = true,
|
||||
isPlayed = true,
|
||||
isToasted = true
|
||||
)
|
||||
}
|
||||
|
||||
}.setKoButton(getString(R.string.cancel)) {
|
||||
scanRequest()
|
||||
|
@ -2175,15 +2163,21 @@ class CollectionFragmentPreChecker(
|
|||
|
||||
} catch (e: Exception) {
|
||||
}
|
||||
saleAdapter?.notifyDataSetChanged()
|
||||
|
||||
sales[positionIncreaseQuantity].originalQuantity = quantityIncrease
|
||||
saleAdapter?.notifyDataSetChanged()
|
||||
|
||||
viewModel.itemShelvingSaleBySale(
|
||||
sales[positionIncreaseQuantity].saleFk,
|
||||
quantityIncreaseDiff
|
||||
)
|
||||
|
||||
}
|
||||
|
||||
private fun increaseQuantity(position: Int, quantity: Int) {
|
||||
positionIncreaseQuantity = position
|
||||
quantityIncrease = quantity
|
||||
quantityIncreaseDiff = sales[position].quantity!!.minus(quantityIncrease)
|
||||
|
||||
viewModel.collectionIncreaseQuantitySalix(
|
||||
saleFk = sales[position].saleFk,
|
||||
|
|
|
@ -6,13 +6,15 @@ import androidx.lifecycle.MutableLiveData
|
|||
import androidx.lifecycle.map
|
||||
import com.google.gson.JsonObject
|
||||
import es.verdnatura.MobileApplication
|
||||
import es.verdnatura.R
|
||||
import es.verdnatura.domain.SalixCallback
|
||||
import es.verdnatura.domain.formatWithQuotes
|
||||
import es.verdnatura.domain.getMessageFromAllResponse
|
||||
import es.verdnatura.domain.nameofFunction
|
||||
import es.verdnatura.domain.toast
|
||||
import es.verdnatura.domain.userCases.GetItemFromBarcodeUseCase
|
||||
import es.verdnatura.domain.userCases.WorkerActivityUseCase
|
||||
import es.verdnatura.presentation.base.BaseViewModel
|
||||
import es.verdnatura.presentation.base.getMessageFromAllResponse
|
||||
import es.verdnatura.presentation.base.nameofFunction
|
||||
import es.verdnatura.presentation.common.Event
|
||||
import es.verdnatura.presentation.common.ItemShelving
|
||||
import es.verdnatura.presentation.common.ResponseItemVO
|
||||
|
@ -22,18 +24,23 @@ import es.verdnatura.presentation.common.TicketState
|
|||
import es.verdnatura.presentation.view.feature.collection.ItemVO
|
||||
import es.verdnatura.presentation.view.feature.collection.SalixSaleQuantity
|
||||
import es.verdnatura.presentation.view.feature.collection.mapper.map
|
||||
import es.verdnatura.presentation.view.feature.pasillero.model.CleanAction
|
||||
import es.verdnatura.presentation.view.feature.pasillero.model.WorkerActionSalix
|
||||
import es.verdnatura.presentation.view.feature.sacador.model.CollectionTicket
|
||||
import es.verdnatura.presentation.view.feature.sacador.model.CollectionVO
|
||||
import es.verdnatura.presentation.view.feature.sacador.model.ItemShelvingSale
|
||||
import es.verdnatura.presentation.view.feature.sacador.model.MistakeTypeListVO
|
||||
import es.verdnatura.presentation.view.feature.sacador.model.MistakeTypeVO
|
||||
import es.verdnatura.presentation.view.feature.sacador.model.PlacementSupplyListVO
|
||||
import es.verdnatura.presentation.view.feature.sacador.model.PlacementSupplyVO
|
||||
import es.verdnatura.presentation.view.feature.ubicador.model.ItemUbicador
|
||||
import es.verdnatura.presentation.view.feature.workermistake.model.SaleMistakeSalix
|
||||
import es.verdnatura.presentation.view.feature.workermistake.model.SaleTrackingDelSalix
|
||||
import retrofit2.Response
|
||||
|
||||
class CollectionViewModel(val context: Context) : BaseViewModel(context) {
|
||||
private val getItemFromBarcodeUseCase = GetItemFromBarcodeUseCase(salix)
|
||||
private val getWokerActivityUseCase = WorkerActivityUseCase(salix)
|
||||
private val contextApp = context
|
||||
|
||||
private val _responseState by lazy { MutableLiveData<ResponseItemVO>() }
|
||||
|
@ -192,6 +199,11 @@ class CollectionViewModel(val context: Context) : BaseViewModel(context) {
|
|||
val responseStateId: LiveData<Number> = _responseStateId
|
||||
val loadResponseStateId: LiveData<Event<Number>> = _responseStateId.map { Event(it) }
|
||||
|
||||
private val _responseStatePreparedId by lazy { MutableLiveData<Number>() }
|
||||
val responseStatePreparedId: LiveData<Number> = _responseStatePreparedId
|
||||
val loadResponseStatePreparedId: LiveData<Event<Number>> =
|
||||
_responseStatePreparedId.map { Event(it) }
|
||||
|
||||
private val _mistakeList by lazy { MutableLiveData<MistakeTypeListVO>() }
|
||||
val mistakeList: LiveData<MistakeTypeListVO>
|
||||
get() = _mistakeList
|
||||
|
@ -225,6 +237,16 @@ class CollectionViewModel(val context: Context) : BaseViewModel(context) {
|
|||
val loadSetStateResponse: LiveData<Event<Boolean>> =
|
||||
_setStateResponse.map { Event(it) }
|
||||
|
||||
private val _responseActivity by lazy { MutableLiveData<CleanAction>() }
|
||||
val responseActivity: LiveData<CleanAction> = _responseActivity
|
||||
val loadResponseActivity: LiveData<Event<CleanAction>> =
|
||||
_responseActivity.map { Event(it) }
|
||||
|
||||
private val _itemShelvingSaleAddByCollection by lazy { MutableLiveData<Boolean>() }
|
||||
val itemShelvingSaleAddByCollection: LiveData<Boolean> = _itemShelvingSaleAddByCollection
|
||||
val loadItemShelvingSaleAddByCollection: LiveData<Event<Boolean>> =
|
||||
_itemShelvingSaleAddByCollection.map { Event(it) }
|
||||
|
||||
fun getSales(
|
||||
collectionFk: Number, print: String, source: String
|
||||
|
||||
|
@ -347,6 +369,54 @@ class CollectionViewModel(val context: Context) : BaseViewModel(context) {
|
|||
})
|
||||
}
|
||||
|
||||
fun itemShelvingSaleBySale(
|
||||
saleFk: Number, quantityDiff: Int
|
||||
|
||||
) {
|
||||
salix.itemShelvingSaleTotalBySale(
|
||||
filter = """{"where":{"saleFk":$saleFk},"limit":2}"""
|
||||
).enqueue(object : SalixCallback<List<ItemShelvingSale>>(context) {
|
||||
|
||||
override fun onSuccess(response: Response<List<ItemShelvingSale>>) {
|
||||
|
||||
if (!response.body().isNullOrEmpty()) {
|
||||
if (response.body()!!.size == 1) {
|
||||
val itemList = response.body()
|
||||
val itemShelvingFk = itemList?.firstOrNull()?.itemShelvingFk
|
||||
salix.itemShelvingGet(
|
||||
id = itemShelvingFk!!
|
||||
).enqueue(object : SalixCallback<ItemShelving>(context) {
|
||||
|
||||
override fun onSuccess(response: Response<ItemShelving>) {
|
||||
|
||||
if (response.body() != null) {
|
||||
val visible = response.body()!!.visible!!.toInt()
|
||||
val differenceVisible = (visible + quantityDiff)
|
||||
val available = response.body()!!.available!!.toInt()
|
||||
val differenceAvailable = (available + quantityDiff)
|
||||
|
||||
val updateParams = mapOf(
|
||||
"visible" to (differenceVisible),
|
||||
"available" to (differenceAvailable)
|
||||
)
|
||||
|
||||
salix.itemShelvingUpdate(
|
||||
id = itemShelvingFk, params = updateParams
|
||||
).enqueue(object : SalixCallback<ItemUbicador?>(context) {
|
||||
|
||||
})
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
})
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
fun itemShelvingGet(
|
||||
itemShelvingFk: Number, position: Int, quantity: Int
|
||||
|
||||
|
@ -502,6 +572,10 @@ class CollectionViewModel(val context: Context) : BaseViewModel(context) {
|
|||
_responseCollectionAddItem.value = true
|
||||
}
|
||||
|
||||
override fun onError(t: Throwable) {
|
||||
|
||||
super.onError(Throwable(context.getString(R.string.errorAddItemReserva)))
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -519,6 +593,20 @@ class CollectionViewModel(val context: Context) : BaseViewModel(context) {
|
|||
})
|
||||
}
|
||||
|
||||
fun getStatePreparedId(stateCode: String) {
|
||||
|
||||
salix.getStateId(
|
||||
filter = """{"where":{"code":"$stateCode"}, "fields":["id"]}""".trimMargin()
|
||||
).enqueue(object : SalixCallback<JsonObject>(context) {
|
||||
override fun onSuccess(response: Response<JsonObject>) {
|
||||
_responseStatePreparedId.value =
|
||||
response.body()?.get("id").toString().toInt()
|
||||
|
||||
}
|
||||
|
||||
})
|
||||
}
|
||||
|
||||
fun setStateSaleGroup(
|
||||
saleGroups: List<Number>, stateCode: Int
|
||||
) {
|
||||
|
@ -802,10 +890,17 @@ class CollectionViewModel(val context: Context) : BaseViewModel(context) {
|
|||
})
|
||||
}
|
||||
|
||||
fun getIdFromCodeSalix(code: String) {
|
||||
getItemFromBarcodeUseCase.execute(code).enqueue(object : SalixCallback<Int?>(context) {
|
||||
override fun onSuccess(response: Response<Int?>) {
|
||||
_responseCode.value = response.body()
|
||||
fun addWorkerActivity(activity: CleanAction) {
|
||||
getWokerActivityUseCase.addWorkerActivity(
|
||||
WorkerActionSalix(
|
||||
code = activity.codeWorkerAction.toString(),
|
||||
description = activity.description
|
||||
)
|
||||
)
|
||||
.enqueue(object : SalixCallback<Any>(context) {
|
||||
override fun onSuccess(response: Response<Any>) {
|
||||
println("shelvinAction onResposne${activity}")
|
||||
_responseActivity.value = activity
|
||||
|
||||
}
|
||||
})
|
||||
|
@ -1052,4 +1147,23 @@ class CollectionViewModel(val context: Context) : BaseViewModel(context) {
|
|||
})
|
||||
}
|
||||
|
||||
fun getIdFromCodeSalix(code: String) {
|
||||
getItemFromBarcodeUseCase.execute(code).enqueue(object : SalixCallback<Int?>(context) {
|
||||
override fun onSuccess(response: Response<Int?>) {
|
||||
_responseCode.value = response.body()
|
||||
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
fun itemShelvingSaleAddByCollection(collection: Number) {
|
||||
salix.itemShelvingSaleAddByCollection(params = collection)
|
||||
.enqueue(
|
||||
object :
|
||||
SalixCallback<Any>(context) {
|
||||
override fun onSuccess(response: Response<Any>) {
|
||||
_itemShelvingSaleAddByCollection.value = true
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,11 +8,11 @@ import com.google.gson.JsonObject
|
|||
import es.verdnatura.MobileApplication
|
||||
import es.verdnatura.domain.SalixCallback
|
||||
import es.verdnatura.domain.formatWithQuotes
|
||||
import es.verdnatura.domain.getMessageFromAllResponse
|
||||
import es.verdnatura.domain.nameofFunction
|
||||
import es.verdnatura.domain.toast
|
||||
import es.verdnatura.domain.userCases.GetItemFromBarcodeUseCase
|
||||
import es.verdnatura.presentation.base.BaseViewModel
|
||||
import es.verdnatura.presentation.base.getMessageFromAllResponse
|
||||
import es.verdnatura.presentation.base.nameofFunction
|
||||
import es.verdnatura.presentation.common.Event
|
||||
import es.verdnatura.presentation.common.ResponseItemExistsItemShelvingSale
|
||||
import es.verdnatura.presentation.common.ResponseItemVO
|
||||
|
|
|
@ -22,6 +22,7 @@ import es.verdnatura.presentation.common.OnPackingClickListener
|
|||
import es.verdnatura.presentation.common.OnPasillerosItemClickListener
|
||||
import es.verdnatura.presentation.common.OnQuantityClickListener
|
||||
import es.verdnatura.presentation.common.OnSaleClickListener
|
||||
import es.verdnatura.presentation.common.OnTicketColorListener
|
||||
import es.verdnatura.presentation.common.ToolBarAdapterTooltip
|
||||
import es.verdnatura.presentation.common.hideKeyboard
|
||||
import es.verdnatura.presentation.common.itemScanValue
|
||||
|
@ -43,6 +44,7 @@ class CollectionShowTicketFragment(
|
|||
|
||||
private var lastScanned: Int = 0
|
||||
private var buttonPushedGetCollection = false
|
||||
private var hasFilterByLevel = false
|
||||
|
||||
companion object {
|
||||
fun newInstance(collection: CollectionVO, type: String) =
|
||||
|
@ -300,6 +302,18 @@ class CollectionShowTicketFragment(
|
|||
override fun onPackingClick(sale: SaleVO) {
|
||||
}
|
||||
|
||||
}, onTicketColorClickListener = object : OnTicketColorListener {
|
||||
override fun onTicketColorListener(sale: SaleVO) {
|
||||
hasFilterByLevel = !hasFilterByLevel
|
||||
|
||||
if (hasFilterByLevel) {
|
||||
if (buttonPushedGetCollection) {
|
||||
saleAdapter!!.updateSales(salesList.filter { it.level == sale.level } as MutableList)
|
||||
}
|
||||
} else {
|
||||
createCollectionList()
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
lm = LinearLayoutManager(requireContext(), LinearLayoutManager.VERTICAL, false)
|
||||
|
|
|
@ -5,9 +5,9 @@ import es.verdnatura.R
|
|||
import es.verdnatura.presentation.common.convertToDateString
|
||||
import es.verdnatura.presentation.view.feature.sacador.model.CollectionTicket
|
||||
import es.verdnatura.presentation.view.feature.sacador.model.CollectionVO
|
||||
import es.verdnatura.presentation.view.feature.sacador.model.PlacementSupplyVO
|
||||
import java.text.SimpleDateFormat
|
||||
import java.util.Calendar
|
||||
import java.util.Locale
|
||||
|
||||
fun CollectionVO.map(context: Context): CollectionVO {
|
||||
try {
|
||||
|
@ -20,7 +20,6 @@ fun CollectionVO.map(context: Context): CollectionVO {
|
|||
it.ticketFk = ticket.ticketFk
|
||||
it.level = ticket.level
|
||||
it.rgb = ticket.rgb
|
||||
it.salePersonFk = ticket.salesPersonFk
|
||||
it.agencyName = ticket.agencyName
|
||||
it.isNew = it.isAdded == "1"
|
||||
it.code = it.cel3
|
||||
|
@ -65,38 +64,31 @@ fun CollectionVO.map(context: Context): CollectionVO {
|
|||
|
||||
fun CollectionTicket.map(context: Context): CollectionTicket {
|
||||
try {
|
||||
this.tickets.forEach { ticket ->
|
||||
ticket.sales.forEach {
|
||||
val allSalesAreNullOrEmpty = tickets.all { it.sales.isNullOrEmpty() }
|
||||
if (!allSalesAreNullOrEmpty) {
|
||||
this.tickets?.forEach { ticket ->
|
||||
ticket.sales?.forEach {
|
||||
it.level = ticket.level ?: ""
|
||||
it.rgb = ticket.rgb ?: ""
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
this.isError = true
|
||||
if (this.tickets.isNullOrEmpty()) {
|
||||
if (this.tickets.isEmpty()) {
|
||||
this.errorMessage = context.getString(R.string.collectionNoTicketsError)
|
||||
} else {
|
||||
this.errorMessage =
|
||||
context.getString(R.string.collectionErrorBuilding) + context.getString(R.string.reviewSector)
|
||||
}
|
||||
|
||||
}
|
||||
return this
|
||||
}
|
||||
|
||||
private fun getCalendarFromDate(date: String, context: Context): Calendar {
|
||||
val sdf = SimpleDateFormat(context.getString(R.string.dateFormat))
|
||||
val sdf = SimpleDateFormat(context.getString(R.string.dateFormat), Locale.getDefault())
|
||||
val cal = Calendar.getInstance()
|
||||
cal.time = sdf.parse(date)!!
|
||||
return cal
|
||||
}
|
||||
|
||||
// para cuando se pase a Salix el modelo
|
||||
//Tarea 5134
|
||||
fun PlacementSupplyVO.proposal(context: Context): PlacementSupplyVO {
|
||||
try {
|
||||
} catch (ex: Exception) {
|
||||
}
|
||||
return this
|
||||
}
|
|
@ -1,356 +0,0 @@
|
|||
package es.verdnatura.presentation.view.feature.controlvehiculo.fragment
|
||||
|
||||
import android.content.Context
|
||||
import android.graphics.drawable.Drawable
|
||||
import android.util.TypedValue
|
||||
import android.view.View.GONE
|
||||
import android.view.inputmethod.EditorInfo
|
||||
import android.widget.ImageView
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import es.verdnatura.R
|
||||
import es.verdnatura.databinding.FragmentVehiclecontrolBinding
|
||||
import es.verdnatura.domain.toast
|
||||
import es.verdnatura.presentation.base.BaseFragment
|
||||
import es.verdnatura.presentation.common.OnCollectionSelectedListener
|
||||
import es.verdnatura.presentation.common.OnOptionsSelectedListener
|
||||
import es.verdnatura.presentation.common.TAG
|
||||
import es.verdnatura.presentation.common.ToolBarAdapterTooltip
|
||||
import es.verdnatura.presentation.common.hideKeyboard
|
||||
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.pasillero.model.PasillerosItemVO
|
||||
import es.verdnatura.presentation.view.feature.sacador.fragment.SacadorFragment
|
||||
|
||||
@Suppress("UNUSED_ANONYMOUS_PARAMETER")
|
||||
class ControlVehiculoFragment(
|
||||
private var tagName: String = ""
|
||||
) : BaseFragment<FragmentVehiclecontrolBinding, ControlVehiculoViewModel>(
|
||||
ControlVehiculoViewModel::class
|
||||
) {
|
||||
|
||||
private var goBack: Boolean = false
|
||||
private var onCollectionSelectedListener: OnCollectionSelectedListener? = null
|
||||
override fun getLayoutId(): Int = R.layout.fragment_vehiclecontrol
|
||||
private lateinit var customDialog: CustomDialog
|
||||
private var isWorkedTimed = "UNREGISTERED"
|
||||
private lateinit var customDialogInput: CustomDialogInput
|
||||
private lateinit var customDialogThreeButtons: CustomDialogThreeButtons
|
||||
|
||||
companion object {
|
||||
fun newInstance(tagName: String) = ControlVehiculoFragment(tagName)
|
||||
}
|
||||
|
||||
override fun onAttach(context: Context) {
|
||||
super.onAttach(context)
|
||||
if (context is OnCollectionSelectedListener) onCollectionSelectedListener = context
|
||||
}
|
||||
|
||||
override fun init() {
|
||||
|
||||
customDialog = CustomDialog(requireContext())
|
||||
customDialogInput = CustomDialogInput(requireContext())
|
||||
customDialogThreeButtons = CustomDialogThreeButtons(requireContext())
|
||||
goBack = false
|
||||
if (tagName == HistoricoVehiculoFragment.TAG) {
|
||||
setToolBar("HISTORY")
|
||||
showScanner(getString(R.string.scanShelvingHistorical), "HISTORY")
|
||||
} else {
|
||||
|
||||
checkControlTimeVehicle()
|
||||
setToolBar("ALL")
|
||||
}
|
||||
|
||||
|
||||
setEvents()
|
||||
super.init()
|
||||
}
|
||||
|
||||
override fun onPause() {
|
||||
goBack = true
|
||||
super.onPause()
|
||||
}
|
||||
|
||||
private fun setToolBar(direction: String?) {
|
||||
|
||||
binding.mainToolbar.toolbarTitle.text = getString(R.string.vehiclecontrol)
|
||||
binding.mainToolbar.toolbarTitle.setTextSize(TypedValue.COMPLEX_UNIT_SP, 13F)
|
||||
|
||||
val listIcons: ArrayList<ImageView> = ArrayList()
|
||||
val iconHistory = ImageView(context)
|
||||
iconHistory.setImageResource(R.drawable.ic_history_black_24dp)
|
||||
val iconVehicleIn = ImageView(context)
|
||||
iconVehicleIn.setImageResource(R.drawable.car)
|
||||
val iconVehicleOut = ImageView(context)
|
||||
iconVehicleOut.setImageResource(R.drawable.car_off)
|
||||
|
||||
iconHistory.tooltipText = getTooltip(R.drawable.ic_history_black_24dp)
|
||||
iconVehicleIn.tooltipText = getTooltip(R.drawable.car)
|
||||
iconVehicleOut.tooltipText = getTooltip(R.drawable.car_off)
|
||||
|
||||
when (direction) {
|
||||
"OUT" -> {
|
||||
listIcons.remove(iconVehicleIn)
|
||||
listIcons.add(iconVehicleOut)
|
||||
listIcons.add(iconHistory)
|
||||
}
|
||||
|
||||
"IN" -> {
|
||||
listIcons.remove(iconVehicleOut)
|
||||
listIcons.add(iconVehicleIn)
|
||||
listIcons.add(iconHistory)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
binding.mainToolbar.toolbarIcons.adapter =
|
||||
ToolBarAdapterTooltip(listIcons, object : OnOptionsSelectedListener {
|
||||
override fun onOptionsItemSelected(item: Drawable) {
|
||||
|
||||
when (item) {
|
||||
iconHistory.drawable -> showScanner(
|
||||
getString(R.string.scanShelvingHistorical), "HISTORY"
|
||||
)
|
||||
|
||||
iconVehicleIn.drawable -> showScanner(getString(R.string.scanPlate), "IN")
|
||||
iconVehicleOut.drawable -> showScanner(
|
||||
getString(R.string.scanPlateTakeoff), "OUT"
|
||||
)
|
||||
}
|
||||
}
|
||||
})
|
||||
binding.mainToolbar.toolbarIcons.layoutManager =
|
||||
LinearLayoutManager(requireContext(), LinearLayoutManager.HORIZONTAL, false)
|
||||
}
|
||||
|
||||
private fun showScanner(description: String, action: String) {
|
||||
|
||||
customDialogInput.setTitle(getString(R.string.vehiclecontrol)).setDescription(description)
|
||||
.setOkButton(getString(R.string.accept)) {
|
||||
if (customDialogInput.getValue().isNotEmpty()) {
|
||||
insertControlTimeVehicle(customDialogInput.getValue(), action)
|
||||
}
|
||||
}
|
||||
|
||||
.setKoButton(getString(R.string.cancel)) {
|
||||
customDialogInput.dismiss()
|
||||
if (tagName == HistoricoVehiculoFragment.TAG) {
|
||||
ma.onMyBackPressed()
|
||||
}
|
||||
|
||||
}.setValue("").show()
|
||||
|
||||
customDialogInput.setFocusText()
|
||||
|
||||
customDialogInput.getEditText().setOnEditorActionListener { v, actionId, event ->
|
||||
if (actionId == EditorInfo.IME_ACTION_SEARCH || actionId == EditorInfo.IME_ACTION_DONE || actionId == 0) {
|
||||
|
||||
if (customDialogInput.getValue().isNotEmpty()) {
|
||||
insertControlTimeVehicle(customDialogInput.getValue(), action)
|
||||
}
|
||||
return@setOnEditorActionListener true
|
||||
}
|
||||
false
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private fun checkControlTimeVehicle() {
|
||||
|
||||
if (!goBack) {
|
||||
try {
|
||||
viewModel.workerMachineryIsRegistered(mobileApplication.userId!!)
|
||||
} catch (ex: Exception) {
|
||||
ma.messageWithSound(
|
||||
message = getString(R.string.errorUserId),
|
||||
isError = true,
|
||||
isToasted = true,
|
||||
isPlayed = true
|
||||
)
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private fun insertControlTimeVehicle(plateNumber: String, direction: String) {
|
||||
|
||||
when (direction) {
|
||||
"HISTORY" -> {
|
||||
ma.onPasillerosItemClickListener(
|
||||
PasillerosItemVO(title = R.string.titleHistoricalHide), plateNumber
|
||||
)
|
||||
}
|
||||
|
||||
"IN" -> {
|
||||
viewModel.machineWorkerUpdate(plateNumber)
|
||||
}
|
||||
|
||||
"OUT" -> {
|
||||
viewModel.machineWorkerUpdate(plateNumber)
|
||||
}
|
||||
|
||||
"" -> {
|
||||
ma.openFragmentPickers(true)
|
||||
}
|
||||
}
|
||||
|
||||
customDialogInput.setValue("")
|
||||
scanRequest()
|
||||
customDialogInput.dismiss()
|
||||
hideKeyboards()
|
||||
}
|
||||
|
||||
private fun scanRequest() {
|
||||
binding.scanInput.requestFocus()
|
||||
hideKeyboards()
|
||||
}
|
||||
|
||||
private fun hideKeyboards() {
|
||||
try {
|
||||
requireActivity().hideKeyboard()
|
||||
} catch (e: Exception) {
|
||||
println(e.message)
|
||||
}
|
||||
}
|
||||
|
||||
private fun setEvents() {
|
||||
|
||||
binding.mainToolbar.backButton.setOnClickListener {
|
||||
ma.openFragmentPickers(true)
|
||||
|
||||
}
|
||||
|
||||
binding.scanInput.requestFocus()
|
||||
binding.scanInput.setOnEditorActionListener { v, actionId, event ->
|
||||
if (actionId == EditorInfo.IME_ACTION_SEARCH || actionId == EditorInfo.IME_ACTION_DONE || actionId == 0) {
|
||||
if (!binding.scanInput.text.isNullOrEmpty()) {
|
||||
|
||||
if (tagName == HistoricoVehiculoFragment.TAG) {
|
||||
showOptionsHistorical(binding.scanInput.text.toString())
|
||||
} else {
|
||||
showOptionsVehicleControl(binding.scanInput.text.toString())
|
||||
}
|
||||
}
|
||||
binding.scanInput.setText("")
|
||||
ma.hideKeyboard(binding.scanInput)
|
||||
return@setOnEditorActionListener true
|
||||
}
|
||||
false
|
||||
}
|
||||
}
|
||||
|
||||
private fun showOptionsVehicleControl(plate: String) {
|
||||
|
||||
customDialogThreeButtons.setCustomDialogValue(GONE)
|
||||
|
||||
customDialogThreeButtons.setDescription(getString(R.string.doVehiclePlate) + plate + "?")
|
||||
.setValue(plate)
|
||||
if (isWorkedTimed == "UNREGISTERED") {
|
||||
customDialogThreeButtons.setOkButtonTwo("COGER") {
|
||||
if (customDialogThreeButtons.getValue().trim().isEmpty()) {
|
||||
getString(R.string.returnScan).toast(requireContext())
|
||||
} else {
|
||||
customDialogThreeButtons.dismiss()
|
||||
insertControlTimeVehicle(customDialogThreeButtons.getValue(), "IN")
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
||||
customDialogThreeButtons.setOkButtonThree("DEJAR") {
|
||||
if (customDialogThreeButtons.getValue().trim().isEmpty()) {
|
||||
getString(R.string.returnScan).toast(requireContext())
|
||||
} else {
|
||||
customDialogThreeButtons.dismiss()
|
||||
insertControlTimeVehicle(customDialogThreeButtons.getValue(), "OUT")
|
||||
}
|
||||
}
|
||||
}.setOkButtonFour(getString(R.string.historical)) {
|
||||
if (customDialogThreeButtons.getValue().trim().isEmpty()) {
|
||||
getString(R.string.returnScan).toast(requireContext())
|
||||
} else {
|
||||
customDialogThreeButtons.dismiss()
|
||||
insertControlTimeVehicle(customDialogThreeButtons.getValue(), "HISTORY")
|
||||
|
||||
}
|
||||
|
||||
}.setKoButton(getString(R.string.cancel)) {
|
||||
scanRequest()
|
||||
customDialogThreeButtons.dismiss()
|
||||
}.show()
|
||||
}
|
||||
|
||||
private fun showOptionsHistorical(plate: String) {
|
||||
|
||||
customDialogThreeButtons.setCustomDialogValue(GONE)
|
||||
|
||||
customDialogThreeButtons.setDescription(getString(R.string.doVehiclePlate) + plate + "?")
|
||||
|
||||
.setValue(plate)
|
||||
|
||||
.setOkButtonFour(getString(R.string.historical)) {
|
||||
if (customDialogThreeButtons.getValue().trim().isEmpty()) {
|
||||
getString(R.string.returnScan).toast(requireContext())
|
||||
} else {
|
||||
customDialogThreeButtons.dismiss()
|
||||
insertControlTimeVehicle(customDialogThreeButtons.getValue(), "HISTORY")
|
||||
|
||||
}
|
||||
|
||||
}.setKoButton(getString(R.string.cancel)) {
|
||||
scanRequest()
|
||||
customDialogThreeButtons.dismiss()
|
||||
}.show()
|
||||
}
|
||||
|
||||
override fun observeViewModel() {
|
||||
|
||||
with(viewModel) {
|
||||
responseUpdate.observe(viewLifecycleOwner) {
|
||||
ma.openFragmentPickers(false)
|
||||
}
|
||||
|
||||
responseControl.observe(viewLifecycleOwner) {
|
||||
|
||||
if (it == "1") {
|
||||
isWorkedTimed = "REGISTERED"
|
||||
setToolBar("OUT")
|
||||
|
||||
if (tagName != SacadorFragment.TAG) {
|
||||
ma.openFragmentPickers(false)
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
if (it == "0") {
|
||||
setToolBar("IN")
|
||||
|
||||
customDialogInput.setTitle(getString(R.string.vehiclecontrol))
|
||||
.setDescription(getString(R.string.scanPlate))
|
||||
.setOkButton(getString(R.string.takeVehicle)) {
|
||||
if (customDialogInput.getValue().isNotEmpty()) {
|
||||
insertControlTimeVehicle(customDialogInput.getValue(), "IN")
|
||||
}
|
||||
customDialogInput.setValue("")
|
||||
scanRequest()
|
||||
customDialogInput.dismiss()
|
||||
hideKeyboards()
|
||||
}
|
||||
|
||||
.setKoButton(getString(R.string.noVehicle)) {
|
||||
customDialogInput.dismiss()
|
||||
ma.openFragmentPickers(true)
|
||||
|
||||
}.setValue("").show()
|
||||
|
||||
customDialogInput.setFocusText()
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -52,7 +52,6 @@ class ControlVehiculoUsuarioFragment(
|
|||
|
||||
if (userFk == vUserFK) {
|
||||
val androidId: String = mobileApplication.dataStoreApp.readDataStoreKey(ANDROID_ID)
|
||||
// viewModel.machineGetWorkerPlate(mobileApplication.userId!!)
|
||||
viewModel.deviceProductionGetnameDevice(
|
||||
androidId
|
||||
)
|
||||
|
@ -64,7 +63,6 @@ class ControlVehiculoUsuarioFragment(
|
|||
binding.userInformation.visibility = INVISIBLE
|
||||
binding.nameVehiclecontrol.visibility = INVISIBLE
|
||||
binding.userImage.setOnClickListener { binding.mainToolbar.backButton.performClick() }
|
||||
// viewModel.machineGetWorkerPlate(mobileApplication.userId!!)
|
||||
binding.nameVehiclecontrol.visibility = VISIBLE
|
||||
viewModel.getNameWorker(userFk)
|
||||
}
|
||||
|
|
|
@ -16,44 +16,12 @@ import retrofit2.Response
|
|||
|
||||
class ControlVehiculoViewModel(val context: Context) : BaseViewModel(context) {
|
||||
|
||||
private val _responseUpdate by lazy { MutableLiveData<Any>() }
|
||||
val responseUpdate: LiveData<Any>
|
||||
get() = _responseUpdate
|
||||
|
||||
private val _responseControl by lazy { MutableLiveData<String>() }
|
||||
val responseControl: LiveData<String>
|
||||
get() = _responseControl
|
||||
|
||||
private val _responseMachine by lazy { MutableLiveData<ResponseItemMachineControl>() }
|
||||
val responseMachine: LiveData<ResponseItemMachineControl>
|
||||
get() = _responseMachine
|
||||
|
||||
private val _responseGetName by lazy { MutableLiveData<NameWorker>() }
|
||||
val responseGetName: LiveData<NameWorker> = _responseGetName
|
||||
fun machineWorkerUpdate(
|
||||
plate: String
|
||||
) {
|
||||
salix.machineWorkerUpdateInTime(hashMapOf("plate" to plate))
|
||||
.enqueue(object : SalixCallback<Any>(context) {
|
||||
|
||||
override fun onSuccess(response: Response<Any>) {
|
||||
|
||||
_responseUpdate.value = response.body()
|
||||
|
||||
}
|
||||
|
||||
})
|
||||
}
|
||||
|
||||
fun workerMachineryIsRegistered(userId: Int) {
|
||||
salix.workerMachineryIsRegistered(arrayListOf(userId))
|
||||
.enqueue(object : SalixCallback<String>(context) {
|
||||
override fun onSuccess(response: Response<String>) {
|
||||
_responseControl.value =
|
||||
response.body()!!
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
fun deviceProductionGetnameDevice(androidId: String) {
|
||||
|
||||
|
|
|
@ -4,7 +4,8 @@ import android.content.Context
|
|||
import android.content.Intent
|
||||
import android.graphics.drawable.Drawable
|
||||
import android.os.Bundle
|
||||
import android.view.KeyEvent
|
||||
import android.text.Editable
|
||||
import android.text.TextWatcher
|
||||
import android.view.View
|
||||
import android.view.inputmethod.EditorInfo
|
||||
import android.widget.ImageView
|
||||
|
@ -16,6 +17,8 @@ import androidx.recyclerview.widget.LinearLayoutManager
|
|||
import es.verdnatura.R
|
||||
import es.verdnatura.databinding.FragmentExpeditionLoadunloadDeliveryBinding
|
||||
import es.verdnatura.db.DeliveryDatabase
|
||||
import es.verdnatura.domain.ConstAndValues.HUMAN_CHARACTERS_SECOND
|
||||
import es.verdnatura.domain.ConstAndValues.SCANNER_THRESHOLD_SPEED
|
||||
import es.verdnatura.domain.toDateString
|
||||
import es.verdnatura.domain.toast
|
||||
import es.verdnatura.presentation.base.BaseFragment
|
||||
|
@ -44,9 +47,10 @@ class LoadUnloadFragment(
|
|||
private var title: String = "",
|
||||
private var state: String = "",
|
||||
private var entryPoint: String,
|
||||
private var clientTicketList: ArrayList<ClientTicketSalix>?
|
||||
private var clientTicketList: ArrayList<ClientTicketSalix>?,
|
||||
private var startInputTime: Long = 0L,
|
||||
|
||||
) : BaseFragment<FragmentExpeditionLoadunloadDeliveryBinding, DeliveryViewModel>(
|
||||
) : BaseFragment<FragmentExpeditionLoadunloadDeliveryBinding, DeliveryViewModel>(
|
||||
DeliveryViewModel::class
|
||||
), OnBackPressedListener {
|
||||
|
||||
|
@ -85,6 +89,24 @@ class LoadUnloadFragment(
|
|||
}
|
||||
}
|
||||
})
|
||||
|
||||
binding.scanInput.addTextChangedListener(object : TextWatcher {
|
||||
override fun afterTextChanged(s: Editable?) {
|
||||
|
||||
}
|
||||
|
||||
override fun beforeTextChanged(s: CharSequence?, start: Int, count: Int, after: Int) {
|
||||
|
||||
}
|
||||
|
||||
override fun onTextChanged(s: CharSequence?, start: Int, before: Int, count: Int) {
|
||||
if (before == 0 && count > 0) {
|
||||
startInputTime = System.currentTimeMillis()
|
||||
}
|
||||
|
||||
}
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
override fun getLayoutId(): Int = R.layout.fragment_expedition_loadunload_delivery
|
||||
|
@ -179,30 +201,16 @@ class LoadUnloadFragment(
|
|||
|
||||
private fun setExpeditionsState(list: MutableList<ExpeditionInfoLoadUnload>, state: String) {
|
||||
scanning(false)
|
||||
/* val mlist = mutableListOf<ExpeditionSalix>()
|
||||
for (l in list) {
|
||||
mlist.add(
|
||||
ExpeditionSalix(
|
||||
expeditionFk = l.id,
|
||||
stateCode = if (l.code != state && l.code != "FOUND" && l.code != "DELIVERED") {
|
||||
if (state == "ON DELIVERY") "NOT SCANNED" else "LOST"
|
||||
} else {
|
||||
l.code
|
||||
},
|
||||
isScanned = l.isScanned
|
||||
)
|
||||
)
|
||||
}*/
|
||||
val mlistPosition = mutableListOf<ExpeditionSalixPosition>()
|
||||
for (l in list) {
|
||||
mlistPosition.add(
|
||||
ExpeditionSalixPosition(
|
||||
expeditionFk = l.id,
|
||||
stateCode = if (l.code == "FOUND") (l.code) else {
|
||||
if (state == "ON DELIVERY" && l.code != "ON DELIVERY" && l.code != "DELIVERED" && l.code != "LOST") {
|
||||
if (state == "ON DELIVERY" && l.code != "ON DELIVERY" && l.code != "DELIVERED" && l.code != "LOST" && l.code != "PENDING" && l.code != "STORED") {
|
||||
"NOT SCANNED"
|
||||
} else {
|
||||
if (state == "DELIVERED" && l.code != "DELIVERED") "LOST" else l.code
|
||||
if (state == "DELIVERED" && l.code != "DELIVERED" && l.code != "STORED") "PENDING" else l.code
|
||||
}
|
||||
},
|
||||
isScanned = l.isScanned,
|
||||
|
@ -273,12 +281,16 @@ class LoadUnloadFragment(
|
|||
ma.onMyBackPressed()
|
||||
}
|
||||
|
||||
binding.scanInput.setOnEditorActionListener { v, actionId, event ->
|
||||
binding.scanInput.setOnEditorActionListener { _, actionId, event ->
|
||||
if (actionId == EditorInfo.IME_ACTION_SEARCH || actionId == EditorInfo.IME_ACTION_DONE || actionId == 0 || actionId == EditorInfo.IME_ACTION_NEXT) {
|
||||
|
||||
if (!binding.scanInput.text.isNullOrEmpty()) {
|
||||
|
||||
val totalTime = (System.currentTimeMillis() - startInputTime)
|
||||
val charsPerSecond = (binding.scanInput.text!!.length * 1000.0) / totalTime
|
||||
val isScanned =
|
||||
event != null && event.action == KeyEvent.ACTION_DOWN && event.keyCode == KeyEvent.KEYCODE_ENTER
|
||||
charsPerSecond > HUMAN_CHARACTERS_SECOND && totalTime < SCANNER_THRESHOLD_SPEED
|
||||
|
||||
//Tarea 8152
|
||||
// showconfirmExpedition(binding.scanInput.text.toString().toInt(), isScanned)
|
||||
try {
|
||||
|
@ -478,7 +490,7 @@ class LoadUnloadFragment(
|
|||
code = if (item.code == "DELIVERED" || item.code == "ON DELIVERY") {
|
||||
item.code
|
||||
} else {
|
||||
"LOST"
|
||||
"PENDING"
|
||||
},
|
||||
nickname = item.nickname,
|
||||
postalCode = item.postalCode
|
||||
|
@ -595,7 +607,7 @@ class LoadUnloadFragment(
|
|||
override fun onBackPressedHandled(): Boolean {
|
||||
|
||||
if (scanned) {
|
||||
var customDialog = CustomDialog(requireContext())
|
||||
val customDialog = CustomDialog(requireContext())
|
||||
customDialog.setTitle(getString(R.string.packagesNotScanned))
|
||||
.setDescription(getString(R.string.savePackages))
|
||||
.setOkButton(getString(R.string.yes)) {
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
package es.verdnatura.presentation.view.feature.delivery.fragments
|
||||
|
||||
import android.graphics.drawable.Drawable
|
||||
import android.view.KeyEvent
|
||||
import android.os.Bundle
|
||||
import android.text.Editable
|
||||
import android.text.TextWatcher
|
||||
import android.view.View
|
||||
import android.view.inputmethod.EditorInfo
|
||||
import android.widget.ImageView
|
||||
|
@ -11,6 +13,8 @@ import androidx.recyclerview.widget.RecyclerView
|
|||
import com.google.gson.Gson
|
||||
import es.verdnatura.R
|
||||
import es.verdnatura.databinding.FragmentExpeditionSummaryBinding
|
||||
import es.verdnatura.domain.ConstAndValues.HUMAN_CHARACTERS_SECOND
|
||||
import es.verdnatura.domain.ConstAndValues.SCANNER_THRESHOLD_SPEED
|
||||
import es.verdnatura.domain.toast
|
||||
import es.verdnatura.presentation.base.BaseFragment
|
||||
import es.verdnatura.presentation.common.AdapterCallback
|
||||
|
@ -44,6 +48,7 @@ class SummaryFragment(
|
|||
private var routeSelected = 0
|
||||
private var isScanning = false
|
||||
private var positionSelected = -1
|
||||
private var startInputTime: Long = 0L
|
||||
|
||||
override fun getPosition(): Int {
|
||||
return positionSelected
|
||||
|
@ -67,6 +72,26 @@ class SummaryFragment(
|
|||
|
||||
}
|
||||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
binding.scanInput.addTextChangedListener(object : TextWatcher {
|
||||
override fun afterTextChanged(s: Editable?) {
|
||||
|
||||
}
|
||||
|
||||
override fun beforeTextChanged(s: CharSequence?, start: Int, count: Int, after: Int) {
|
||||
|
||||
}
|
||||
|
||||
override fun onTextChanged(s: CharSequence?, start: Int, before: Int, count: Int) {
|
||||
if (before == 0 && count > 0) {
|
||||
startInputTime = System.currentTimeMillis()
|
||||
}
|
||||
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
if (binding.mainToolbar.toolbarTitle.text != getString(R.string.titleDeliverySummary)) {
|
||||
binding.scanInput.isEnabled = true
|
||||
|
@ -151,10 +176,10 @@ class SummaryFragment(
|
|||
val listExpedition = list.filter { it.addressFk == address }.map { l ->
|
||||
ExpeditionSalixPosition(
|
||||
expeditionFk = l.id, stateCode = if (l.code == "FOUND") (l.code) else {
|
||||
if (state == "ON DELIVERY" && l.code != "ON DELIVERY" && l.code != "DELIVERED" && l.code != "LOST") {
|
||||
if (state == "ON DELIVERY" && l.code != "ON DELIVERY" && l.code != "DELIVERED" && l.code != "LOST" && l.code != "PENDING" && l.code != "STORED") {
|
||||
"NOT SCANNED"
|
||||
} else {
|
||||
if (state == "DELIVERED" && l.code != "DELIVERED") "LOST" else l.code
|
||||
if (state == "DELIVERED" && l.code != "DELIVERED" && l.code != "STORED") "PENDING" else l.code
|
||||
}
|
||||
}, isScanned = l.isScanned, scanOrder = l.scanOrder
|
||||
|
||||
|
@ -200,8 +225,12 @@ class SummaryFragment(
|
|||
if (actionId == EditorInfo.IME_ACTION_SEARCH || actionId == EditorInfo.IME_ACTION_DONE || actionId == 0) {
|
||||
if (!binding.scanInput.text.isNullOrEmpty()) {
|
||||
isScanning = true
|
||||
/* val isScanned =
|
||||
event != null && event.action == KeyEvent.ACTION_DOWN && event.keyCode == KeyEvent.KEYCODE_ENTER*/
|
||||
val totalTime = (System.currentTimeMillis() - startInputTime)
|
||||
val charsPerSecond = (binding.scanInput.text!!.length * 1000.0) / totalTime
|
||||
val isScanned =
|
||||
event != null && event.action == KeyEvent.ACTION_DOWN && event.keyCode == KeyEvent.KEYCODE_ENTER
|
||||
charsPerSecond > HUMAN_CHARACTERS_SECOND && totalTime < SCANNER_THRESHOLD_SPEED
|
||||
try {
|
||||
markExpedition(
|
||||
binding.scanInput.text.toString().toInt(),
|
||||
|
@ -233,14 +262,6 @@ class SummaryFragment(
|
|||
found = true
|
||||
exped.code = state
|
||||
exped.isScanned = isScanned
|
||||
|
||||
println(
|
||||
"scanOrder markExpedition${
|
||||
myList.filter { it.addressFk == addressFkSelected }
|
||||
.filter { it.code == state }.size
|
||||
}"
|
||||
)
|
||||
|
||||
exped.scanOrder = myList.filter { it.addressFk == addressFkSelected }
|
||||
.filter { it.code == state }.size
|
||||
break
|
||||
|
|
|
@ -429,22 +429,17 @@ class TicketsFragment : BaseFragment<FragmentTicketsBinding, DeliveryViewModel>(
|
|||
override fun onItemButtonCMRRowClickListener(
|
||||
item: Ticket
|
||||
) {
|
||||
ma.onPasillerosItemClickListener(
|
||||
PasillerosItemVO(
|
||||
title = R.string.titleWebViewer,
|
||||
), entryPoint = Gson().toJson(
|
||||
mutableMapOf(
|
||||
"entryPoint" to route.id,
|
||||
"web" to "${
|
||||
mobileApplication.dataStoreApp.getServerSalix()
|
||||
}/api/Cmrs/${item.cmrFk}/print?access_token=${
|
||||
|
||||
val url =
|
||||
"${mobileApplication.dataStoreApp.getServerLilium()}/api/Cmrs/${item.cmrFk}/print?access_token=${
|
||||
mobileApplication.dataStoreApp.readDataStoreKey<String>(
|
||||
TOKEN
|
||||
)
|
||||
}"
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
val intent = Intent(Intent.ACTION_QUICK_VIEW, Uri.parse(url))
|
||||
intent.setDataAndType(Uri.parse(url), "application/pdf")
|
||||
startActivity(intent)
|
||||
}
|
||||
})
|
||||
|
||||
|
|
|
@ -24,7 +24,10 @@ data class ClientTicketSalix(
|
|||
var postalCode: String,
|
||||
var city: String,
|
||||
var warehouseName: String?,
|
||||
var salePersonPhone: String?,
|
||||
@SerializedName(
|
||||
value = "salePersonPhone",
|
||||
alternate = ["departmentPhone"]
|
||||
) var salePersonPhone: String?,
|
||||
@SerializedName(value = "ticketObservation", alternate = ["observationDelivery"])
|
||||
var observationDelivery: String?,
|
||||
var observationDropOff: String?,
|
||||
|
|
|
@ -0,0 +1,137 @@
|
|||
package es.verdnatura.presentation.view.feature.diadeventa.fragment
|
||||
|
||||
import android.content.Context
|
||||
import android.os.Bundle
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.view.inputmethod.EditorInfo
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.ui.platform.ComposeView
|
||||
import androidx.fragment.app.Fragment
|
||||
import androidx.lifecycle.compose.collectAsStateWithLifecycle
|
||||
import es.verdnatura.R
|
||||
import es.verdnatura.presentation.common.OnPasillerosItemClickListener
|
||||
import es.verdnatura.presentation.composable.IconToolBar
|
||||
import es.verdnatura.presentation.view.component.CustomDialog
|
||||
import es.verdnatura.presentation.view.component.CustomDialogList
|
||||
import es.verdnatura.presentation.view.feature.diadeventa.adapter.DayOfSaleAdapter
|
||||
import es.verdnatura.presentation.view.feature.main.activity.MainActivity
|
||||
import es.verdnatura.presentation.view.feature.pasillero.model.PasillerosItemVO
|
||||
import org.koin.androidx.viewmodel.ext.android.viewModel
|
||||
|
||||
class DayOfSaleFragmentCompose(
|
||||
var title: String = ""
|
||||
) : Fragment() {
|
||||
private val viewModel: DayOfSaleViewModelCompose by viewModel()
|
||||
|
||||
private lateinit var customDialogList: CustomDialogList
|
||||
private lateinit var customDialog: CustomDialog
|
||||
private var adapter: DayOfSaleAdapter? = null
|
||||
private var itemScan = ""
|
||||
private var pasillerosItemClickListener: OnPasillerosItemClickListener? = null
|
||||
|
||||
companion object {
|
||||
fun newInstance(title: String) = DayOfSaleFragmentCompose(title)
|
||||
}
|
||||
|
||||
override fun onAttach(context: Context) {
|
||||
if (context is OnPasillerosItemClickListener) pasillerosItemClickListener = context
|
||||
super.onAttach(context)
|
||||
}
|
||||
|
||||
override fun onCreateView(
|
||||
inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?
|
||||
): View {
|
||||
return ComposeView(requireContext()).apply {
|
||||
setContent {
|
||||
SetView()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun SetView() {
|
||||
val uiState by viewModel.uiState.collectAsStateWithLifecycle()
|
||||
|
||||
val columnActions = listOf<(List<String>) -> Unit>(
|
||||
// { item -> println("Producto seleccionado: ${item[0]}") }, // Acción para la primera columna
|
||||
// { item -> println("Stock: ${item[1]}") }, // Acción para la segunda columna
|
||||
// { item -> println("Visible: ${item[2]}") } // Acción para la tercera columna
|
||||
)
|
||||
|
||||
GenericListScreen(
|
||||
uiState.items.map { item ->
|
||||
listOf(
|
||||
item.itemFk?.toString() ?: "",
|
||||
item.longName ?: "",
|
||||
item.dated,
|
||||
item.visible?.toString() ?: "",
|
||||
item.stock?.toString() ?: ""
|
||||
)
|
||||
},
|
||||
columnActions = columnActions,
|
||||
headers = listOf(
|
||||
getString(R.string.itemfk),
|
||||
getString(R.string.name),
|
||||
getString(R.string.date),
|
||||
getString(R.string.visible),
|
||||
getString(R.string.stock)
|
||||
),
|
||||
onTextChange = { input ->
|
||||
viewModel.itemShelvingGetSaleDate(input)
|
||||
},
|
||||
titleToolBar =
|
||||
if (uiState.shelvingCode.isNullOrEmpty()) title else title + " " + uiState.shelvingCode,
|
||||
onBackClick = { (context as MainActivity).onMyBackPressed() },
|
||||
onLongClick = { },
|
||||
onClick = { item -> openSearchItemFragment(item[0]) },
|
||||
listIconToolBar = listOf(
|
||||
IconToolBar(
|
||||
idRes = R.drawable.ic_local_parking_black_24dp,
|
||||
toolTip = getString(R.string.allowParking),
|
||||
onClickIcon = { showParking() },
|
||||
)
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
private fun showParking() {
|
||||
|
||||
customDialogList = CustomDialogList(requireContext())
|
||||
customDialogList.setTitle(getString(R.string.showParking))
|
||||
.setOkButton(getString(R.string.close)) {
|
||||
|
||||
customDialogList.dismiss()
|
||||
}.setValue("").show()
|
||||
|
||||
customDialogList.getEditText().requestFocus()
|
||||
customDialogList.getEditText().setOnEditorActionListener { _, actionId, _ ->
|
||||
if (actionId == EditorInfo.IME_ACTION_SEARCH || actionId == EditorInfo.IME_ACTION_DONE || actionId == 0 || actionId == 5) {
|
||||
if (customDialogList.getValue().isNotEmpty()) {
|
||||
viewModel.setParking(
|
||||
parking = customDialogList.getValue(),
|
||||
scanItem = itemScan
|
||||
)
|
||||
|
||||
customDialogList.dismiss()
|
||||
}
|
||||
customDialogList.setValue("")
|
||||
return@setOnEditorActionListener true
|
||||
}
|
||||
false
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private fun openSearchItemFragment(item: String) {
|
||||
pasillerosItemClickListener!!.onPasillerosItemClickListener(
|
||||
PasillerosItemVO(
|
||||
title =
|
||||
R.string.titleItemConsult
|
||||
), item
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,53 @@
|
|||
package es.verdnatura.presentation.view.feature.diadeventa.fragment
|
||||
|
||||
import es.verdnatura.domain.SalixCallback
|
||||
import es.verdnatura.domain.formatWithQuotes
|
||||
import es.verdnatura.presentation.base.BaseViewModelCompose
|
||||
import es.verdnatura.presentation.view.feature.diadeventa.model.ItemShelvingSaleDate
|
||||
import kotlinx.coroutines.flow.MutableStateFlow
|
||||
import kotlinx.coroutines.flow.asStateFlow
|
||||
import kotlinx.coroutines.flow.update
|
||||
import retrofit2.Response
|
||||
|
||||
data class UiState(
|
||||
val shelvingCode: String? = null,
|
||||
val items: List<ItemShelvingSaleDate> = emptyList()
|
||||
)
|
||||
|
||||
class DayOfSaleViewModelCompose(var application: android.app.Application) :
|
||||
BaseViewModelCompose(application) {
|
||||
|
||||
private val _uiState = MutableStateFlow(UiState())
|
||||
val uiState = _uiState.asStateFlow()
|
||||
|
||||
fun itemShelvingGetSaleDate(vShelvingFK: String) {
|
||||
_uiState.update { it.copy(shelvingCode = vShelvingFK) }
|
||||
salix.itemShelvingGetSaleDate(params = listOf(vShelvingFK).formatWithQuotes())
|
||||
.enqueue(object :
|
||||
SalixCallback<List<ItemShelvingSaleDate>>(application.applicationContext) {
|
||||
|
||||
override fun onSuccess(response: Response<List<ItemShelvingSaleDate>>) {
|
||||
|
||||
response.body()?.let { list ->
|
||||
_uiState.update { it.copy(items = list) }
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
fun setParking(scanItem: String, parking: String) {
|
||||
salix.setParking(arrayListOf(scanItem, parking).formatWithQuotes())
|
||||
.enqueue(object : SalixCallback<Any>(application.applicationContext) {})
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,215 @@
|
|||
package es.verdnatura.presentation.view.feature.diadeventa.fragment
|
||||
|
||||
import androidx.compose.foundation.ExperimentalFoundationApi
|
||||
import androidx.compose.foundation.background
|
||||
import androidx.compose.foundation.clickable
|
||||
import androidx.compose.foundation.combinedClickable
|
||||
import androidx.compose.foundation.layout.Arrangement
|
||||
import androidx.compose.foundation.layout.Box
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.Row
|
||||
import androidx.compose.foundation.layout.Spacer
|
||||
import androidx.compose.foundation.layout.fillMaxSize
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.foundation.layout.height
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.lazy.LazyColumn
|
||||
import androidx.compose.foundation.lazy.items
|
||||
import androidx.compose.material3.HorizontalDivider
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.LaunchedEffect
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.runtime.setValue
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.focus.FocusRequester
|
||||
import androidx.compose.ui.focus.focusRequester
|
||||
import androidx.compose.ui.focus.onFocusEvent
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.platform.LocalContext
|
||||
import androidx.compose.ui.platform.LocalSoftwareKeyboardController
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.text.style.TextAlign
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.compose.ui.unit.sp
|
||||
import androidx.core.content.ContextCompat
|
||||
import es.verdnatura.R
|
||||
import es.verdnatura.presentation.composable.CustomToolbar
|
||||
import es.verdnatura.presentation.composable.IconToolBar
|
||||
import es.verdnatura.presentation.composable.LottieLoadingAnimation
|
||||
import es.verdnatura.presentation.composable.ScanLineTextSearch
|
||||
import java.text.SimpleDateFormat
|
||||
import java.util.Date
|
||||
import java.util.Locale
|
||||
|
||||
@Composable
|
||||
fun GenericListScreen(
|
||||
items: List<List<String>>, // Lista de listas de strings para los datos
|
||||
headers: List<String>,// Lista de encabezados
|
||||
columnActions: List<(List<String>) -> Unit>, // Lista de acciones
|
||||
onTextChange: (String) -> Unit,
|
||||
titleToolBar: String,
|
||||
onBackClick: () -> Unit = {},
|
||||
onLongClick: (List<String>) -> Unit,
|
||||
onClick: (List<String>) -> Unit,
|
||||
listIconToolBar: List<IconToolBar> = listOf()
|
||||
) {
|
||||
var searchText by remember { mutableStateOf("") }
|
||||
val focusRequester = remember { FocusRequester() }
|
||||
val keyboardController = LocalSoftwareKeyboardController.current
|
||||
var showLoading by remember { mutableStateOf(false) }
|
||||
|
||||
val onImeAction: () -> Unit = {
|
||||
onTextChange(searchText)
|
||||
searchText = ""
|
||||
keyboardController?.hide()
|
||||
}
|
||||
|
||||
Box(
|
||||
modifier = Modifier
|
||||
.fillMaxSize()
|
||||
.background(Color.Black)
|
||||
) {
|
||||
Column(
|
||||
modifier = Modifier
|
||||
.fillMaxSize()
|
||||
.background(Color.Black)
|
||||
) {
|
||||
if (showLoading) {
|
||||
LottieLoadingAnimation(true)
|
||||
}
|
||||
CustomToolbar(
|
||||
title = titleToolBar,
|
||||
subtitle = "",
|
||||
showBackButton = true,
|
||||
showSwitch = false,
|
||||
iconList = listIconToolBar,
|
||||
onBackClick = onBackClick,
|
||||
onSwitchChange = { }
|
||||
)
|
||||
Spacer(modifier = Modifier.height(8.dp))
|
||||
|
||||
ScanLineTextSearch(
|
||||
value = searchText,
|
||||
onValueChange = {
|
||||
searchText = it
|
||||
showLoading = true
|
||||
},
|
||||
onImeAction,
|
||||
modifier = Modifier
|
||||
.focusRequester(focusRequester)
|
||||
.onFocusEvent {
|
||||
if (it.isFocused) {
|
||||
keyboardController?.hide()
|
||||
}
|
||||
}
|
||||
)
|
||||
LaunchedEffect(Unit) {
|
||||
focusRequester.requestFocus()
|
||||
keyboardController?.hide()
|
||||
}
|
||||
|
||||
// Encabezados
|
||||
Row(
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.padding(vertical = 8.dp),
|
||||
horizontalArrangement = Arrangement.SpaceEvenly
|
||||
) {
|
||||
headers.forEach { text ->
|
||||
Text(
|
||||
text = text,
|
||||
color = Color.White,
|
||||
fontSize = 14.sp,
|
||||
modifier = Modifier.weight(1f)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
HorizontalDivider(thickness = 1.dp, color = Color.White)
|
||||
|
||||
LazyColumn(modifier = Modifier.fillMaxSize()) {
|
||||
items(items) { item ->
|
||||
GenericRow(
|
||||
values = item,
|
||||
onLongClick = { onLongClick(item) },
|
||||
onClick = { onClick(item) },
|
||||
columnActions = columnActions
|
||||
)
|
||||
HorizontalDivider(thickness = 1.dp, color = Color.White)
|
||||
}
|
||||
}
|
||||
showLoading = false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@OptIn(ExperimentalFoundationApi::class)
|
||||
@Composable
|
||||
fun GenericRow(
|
||||
values: List<String>,
|
||||
onLongClick: () -> Unit,
|
||||
onClick: () -> Unit,
|
||||
columnActions: List<(List<String>) -> Unit>
|
||||
) {
|
||||
Row(
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.padding(vertical = 8.dp)
|
||||
.combinedClickable(onClick = onClick, onLongClick = onLongClick),
|
||||
horizontalArrangement = Arrangement.SpaceEvenly
|
||||
) {
|
||||
values.forEachIndexed { index, value ->
|
||||
val sdf = SimpleDateFormat(stringResource(R.string.dateFormat), Locale.getDefault())
|
||||
val currentDate = sdf.format(Date())
|
||||
|
||||
val context = LocalContext.current // Accediendo al contexto
|
||||
|
||||
val customOrange = ContextCompat.getColor(context, R.color.verdnatura_pumpkin_orange)
|
||||
val customWhite = ContextCompat.getColor(context, R.color.verdnatura_white)
|
||||
val color = if (value == currentDate) Color(customOrange) else Color(customWhite)
|
||||
|
||||
Text(
|
||||
text = value,
|
||||
color = color,
|
||||
textAlign = TextAlign.Center,
|
||||
modifier = Modifier
|
||||
.weight(1f)
|
||||
.then(if (index < columnActions.size) Modifier.clickable {
|
||||
columnActions[index](values)
|
||||
} else Modifier)
|
||||
.align(Alignment.CenterVertically)
|
||||
.padding(4.dp)
|
||||
)
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
fun TextDayOfSale(
|
||||
values: List<String>,
|
||||
value: String,
|
||||
index: Int,
|
||||
columnActions: List<(List<String>) -> Unit>
|
||||
) {
|
||||
val sdf = SimpleDateFormat(stringResource(R.string.dateFormat), Locale.getDefault())
|
||||
val currentDate = sdf.format(Date())
|
||||
|
||||
val context = LocalContext.current
|
||||
val customOrange = ContextCompat.getColor(context, R.color.verdnatura_pumpkin_orange)
|
||||
val customWhite = ContextCompat.getColor(context, R.color.verdnatura_white)
|
||||
val color = if (value == currentDate) Color(customOrange) else Color(customWhite)
|
||||
|
||||
Text(
|
||||
text = value,
|
||||
color = color,
|
||||
modifier = Modifier
|
||||
.then(if (index < columnActions.size) Modifier.clickable {
|
||||
columnActions[index](values)
|
||||
} else Modifier)
|
||||
)
|
||||
}
|
|
@ -7,13 +7,16 @@ import androidx.recyclerview.widget.RecyclerView
|
|||
import es.verdnatura.R
|
||||
import es.verdnatura.databinding.ItemHistoricoRowBinding
|
||||
import es.verdnatura.presentation.common.OnClientHistoricItemClickListener
|
||||
import es.verdnatura.presentation.common.OnOutQuantityHistoricItemClickListener
|
||||
import es.verdnatura.presentation.view.feature.historicoarticulo.model.ItemHistoricoVO
|
||||
import java.text.SimpleDateFormat
|
||||
import java.util.Date
|
||||
import java.util.Locale
|
||||
|
||||
class HistoricoAdapter(
|
||||
private val items: List<ItemHistoricoVO>,
|
||||
private val onClientHistoricItemClickListener: OnClientHistoricItemClickListener
|
||||
private val onClientHistoricItemClickListener: OnClientHistoricItemClickListener,
|
||||
private val onOutQuantityHistoricItemClickListener: OnOutQuantityHistoricItemClickListener
|
||||
) : RecyclerView.Adapter<HistoricoAdapter.ItemHolder>() {
|
||||
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ItemHolder {
|
||||
|
@ -36,12 +39,12 @@ class HistoricoAdapter(
|
|||
binding.apply {
|
||||
this.item = item
|
||||
|
||||
val sdf = SimpleDateFormat(res.getString(R.string.dateFormat))
|
||||
val sdf = SimpleDateFormat(res.getString(R.string.dateFormat), Locale.getDefault())
|
||||
val currentDate = sdf.format(Date())
|
||||
|
||||
historicoDate.setBackgroundColor(
|
||||
ContextCompat.getColor(
|
||||
historicoDate.context, if (currentDate == item.shipped) {
|
||||
historicoDate.context, if (item.shipped.contains(currentDate)) {
|
||||
R.color.verdnatura_pumpkin_orange
|
||||
} else {
|
||||
R.color.verdnatura_black_5
|
||||
|
@ -76,6 +79,14 @@ class HistoricoAdapter(
|
|||
clientName.setOnClickListener {
|
||||
onClientHistoricItemClickListener.onClientHistoricItemClickListener(item)
|
||||
}
|
||||
outQuantity.setOnClickListener {
|
||||
//tarea 8455
|
||||
if (item.out != null && item.isTicket == 1) {
|
||||
onOutQuantityHistoricItemClickListener.onOutQuantityHistoricItemClickListener(
|
||||
item
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -86,7 +97,6 @@ class HistoricoAdapter(
|
|||
binding: ItemHistoricoRowBinding,
|
||||
) {
|
||||
|
||||
|
||||
when (stateName?.lowercase()) {
|
||||
"preparado", "en preparación", "autoimpreso", "impreso" -> {
|
||||
binding.clientName.setBackgroundColor(
|
||||
|
|
|
@ -13,9 +13,11 @@ import es.verdnatura.R.color.verdnatura_white
|
|||
import es.verdnatura.databinding.FragmentHistoricoBinding
|
||||
import es.verdnatura.domain.ConstAndValues.WAREHOUSEFK
|
||||
import es.verdnatura.domain.notNull
|
||||
import es.verdnatura.domain.toast
|
||||
import es.verdnatura.presentation.base.BaseFragment
|
||||
import es.verdnatura.presentation.common.OnClientHistoricItemClickListener
|
||||
import es.verdnatura.presentation.common.OnOptionsSelectedListener
|
||||
import es.verdnatura.presentation.common.OnOutQuantityHistoricItemClickListener
|
||||
import es.verdnatura.presentation.common.OnPasillerosItemClickListener
|
||||
import es.verdnatura.presentation.common.ToolBarAdapterTooltip
|
||||
import es.verdnatura.presentation.view.component.CustomDialog
|
||||
|
@ -23,6 +25,7 @@ import es.verdnatura.presentation.view.feature.historicoarticulo.adapter.Histori
|
|||
import es.verdnatura.presentation.view.feature.historicoarticulo.model.ItemHistoricoListVO
|
||||
import es.verdnatura.presentation.view.feature.historicoarticulo.model.ItemHistoricoVO
|
||||
import es.verdnatura.presentation.view.feature.pasillero.model.PasillerosItemVO
|
||||
import java.net.URLEncoder
|
||||
import java.text.SimpleDateFormat
|
||||
import java.util.Date
|
||||
import java.util.Locale
|
||||
|
@ -191,8 +194,12 @@ class HistoricoArticuloFragment(
|
|||
listHistoric.add(it)
|
||||
}
|
||||
}
|
||||
listHistoric.sortWith { item1, item2 ->
|
||||
val compareShipped = item1.shipped.compareTo(item2.shipped)
|
||||
/* listHistoric.sortWith { item1, item2 ->
|
||||
|
||||
val date1 = item1.shipped.split(" ")[0]
|
||||
val date2 = item2.shipped.split(" ")[0]
|
||||
|
||||
val compareShipped = date1.compareTo(date2)
|
||||
//comentar con ivanm
|
||||
if (compareShipped == 0) {
|
||||
if (item1.order == null && item2.order == null) {
|
||||
|
@ -207,7 +214,7 @@ class HistoricoArticuloFragment(
|
|||
} else {
|
||||
compareShipped
|
||||
}
|
||||
}
|
||||
}*/
|
||||
adapter = HistoricoAdapter(listHistoric, object : OnClientHistoricItemClickListener {
|
||||
|
||||
override fun onClientHistoricItemClickListener(item: ItemHistoricoVO) {
|
||||
|
@ -242,6 +249,71 @@ class HistoricoArticuloFragment(
|
|||
|
||||
}
|
||||
}
|
||||
}, object : OnOutQuantityHistoricItemClickListener {
|
||||
override fun onOutQuantityHistoricItemClickListener(item: ItemHistoricoVO) {
|
||||
|
||||
val baseUrl =
|
||||
"${mobileApplication.dataStoreApp.getServerLilium()}/#/ticket/${item.originId}/log"
|
||||
val logsJson = """
|
||||
{
|
||||
"filter": {
|
||||
"limit": 20,
|
||||
"fields": [
|
||||
"id",
|
||||
"originFk",
|
||||
"userFk",
|
||||
"action",
|
||||
"changedModel",
|
||||
"oldInstance",
|
||||
"newInstance",
|
||||
"creationDate",
|
||||
"changedModelId",
|
||||
"changedModelValue",
|
||||
"description",
|
||||
"summaryId"
|
||||
],
|
||||
"where": {
|
||||
"and": [
|
||||
{
|
||||
"originFk": "${item.originId}"
|
||||
},
|
||||
{
|
||||
"or": [
|
||||
{
|
||||
"oldJson": {
|
||||
"like": "%${itemFk}%"
|
||||
}
|
||||
},
|
||||
{
|
||||
"newJson": {
|
||||
"like": "%${itemFk}%"
|
||||
}
|
||||
},
|
||||
{
|
||||
"description": {
|
||||
"like": "%${itemFk}%"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
"skip": 0
|
||||
}
|
||||
}
|
||||
""".trimIndent()
|
||||
val encodedJson = URLEncoder.encode(logsJson, "UTF-8")
|
||||
val entryPoint = Gson().toJson(
|
||||
mutableMapOf(
|
||||
"entryPoint" to item.entityId, "web" to "$baseUrl?logs=$encodedJson"
|
||||
)
|
||||
)
|
||||
ma.onPasillerosItemClickListener(
|
||||
PasillerosItemVO(
|
||||
title = R.string.titleWebViewer,
|
||||
), entryPoint = entryPoint
|
||||
)
|
||||
}
|
||||
})
|
||||
binding.historicoRecyclerview.adapter = adapter
|
||||
binding.historicoRecyclerview.layoutManager =
|
||||
|
@ -253,13 +325,22 @@ class HistoricoArticuloFragment(
|
|||
|
||||
private fun navigateToToday(it: ItemHistoricoListVO) {
|
||||
var positionToday = 0
|
||||
val sdf = SimpleDateFormat(getString(R.string.dateFormat), Locale.getDefault())
|
||||
val currentDate = sdf.format(Date())
|
||||
|
||||
val inputFormat = SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.getDefault())
|
||||
val outputFormat = SimpleDateFormat(getString(R.string.dateFormat), Locale.getDefault())
|
||||
val currentDate = outputFormat.format(Date())
|
||||
|
||||
for (item in it.list) {
|
||||
if (currentDate == item.shipped) {
|
||||
try {
|
||||
val shippedDate = inputFormat.parse(item.shipped)
|
||||
val formattedShippedDate = shippedDate?.let { date -> outputFormat.format(date) }
|
||||
if (currentDate == formattedShippedDate) {
|
||||
break
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
getString(R.string.errorOrderList).toast(requireContext())
|
||||
}
|
||||
|
||||
positionToday += 1
|
||||
}
|
||||
|
||||
|
|
|
@ -1,73 +0,0 @@
|
|||
package es.verdnatura.presentation.view.feature.historicoshelving.adapter
|
||||
|
||||
import android.view.LayoutInflater
|
||||
import android.view.ViewGroup
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import es.verdnatura.R
|
||||
import es.verdnatura.databinding.ItemShelvinglogRowBinding
|
||||
import es.verdnatura.presentation.common.OnPasillerosItemClickListener
|
||||
import es.verdnatura.presentation.view.feature.historicoshelving.model.ItemShelvingLog
|
||||
import es.verdnatura.presentation.view.feature.pasillero.model.PasillerosItemVO
|
||||
|
||||
class ItemShelvingLogAdapter(
|
||||
private var items: List<ItemShelvingLog>,
|
||||
private val onPasillerosItemClickListener: OnPasillerosItemClickListener
|
||||
) : RecyclerView.Adapter<ItemShelvingLogAdapter.ItemHolder>() {
|
||||
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ItemHolder {
|
||||
return ItemHolder(
|
||||
ItemShelvinglogRowBinding.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 {
|
||||
|
||||
if (!items[position].shelvingFk.isNullOrEmpty()) {
|
||||
|
||||
onPasillerosItemClickListener.onPasillerosItemClickListener(
|
||||
PasillerosItemVO(
|
||||
title =
|
||||
R.string.titleUbicator
|
||||
), items[position].shelvingFk!!
|
||||
)
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
fun addList(list:List<ItemShelvingLog>){
|
||||
items = list
|
||||
notifyDataSetChanged()
|
||||
|
||||
}
|
||||
inner class ItemHolder(
|
||||
val binding: ItemShelvinglogRowBinding
|
||||
) : RecyclerView.ViewHolder(binding.root) {
|
||||
private val res = binding.root.context.resources
|
||||
fun bind(item: ItemShelvingLog) {
|
||||
binding.apply {
|
||||
|
||||
binding.txtNickname.setOnClickListener {
|
||||
if (item.worker?.id != null) openWorker(binding, item.worker?.id!!)
|
||||
}
|
||||
binding.txtVisible.setOnClickListener {
|
||||
if (item.worker?.id != null) openWorker(binding, item.worker?.id!!)
|
||||
}
|
||||
|
||||
|
||||
this.item = item
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun openWorker(binding: ItemShelvinglogRowBinding, id: Int) {
|
||||
onPasillerosItemClickListener.onPasillerosItemClickListener(
|
||||
PasillerosItemVO(title = R.string.titleUserControlVehicle),
|
||||
id.toString()
|
||||
)
|
||||
}
|
||||
}
|
|
@ -1,153 +0,0 @@
|
|||
package es.verdnatura.presentation.view.feature.historicoshelving.fragment
|
||||
|
||||
import android.content.Context
|
||||
import android.os.Handler
|
||||
import android.os.Looper
|
||||
import android.view.View
|
||||
import android.view.inputmethod.EditorInfo
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import es.verdnatura.R
|
||||
import es.verdnatura.databinding.FragmentItemshelvinglogBinding
|
||||
import es.verdnatura.domain.ConstAndValues.LIMITRECORDSSHELVINGLOG
|
||||
import es.verdnatura.domain.toLong
|
||||
import es.verdnatura.presentation.base.BaseFragment
|
||||
import es.verdnatura.presentation.common.OnPasillerosItemClickListener
|
||||
import es.verdnatura.presentation.view.component.CustomDialog
|
||||
import es.verdnatura.presentation.view.feature.historicoshelving.adapter.ItemShelvingLogAdapter
|
||||
|
||||
@Suppress("UNUSED_ANONYMOUS_PARAMETER")
|
||||
class ItemShelvingLogFragment(
|
||||
var entryPoint: String = ""
|
||||
) : BaseFragment<FragmentItemshelvinglogBinding, ItemShelvingLogViewModel>(ItemShelvingLogViewModel::class) {
|
||||
|
||||
private var adapter: ItemShelvingLogAdapter? = null
|
||||
private var itemScan = ""
|
||||
private var pasillerosItemClickListener: OnPasillerosItemClickListener? = null
|
||||
private var records: Int = LIMITRECORDSSHELVINGLOG
|
||||
private var shelving: String = ""
|
||||
private var positionScroll = 0
|
||||
private var positionToReturn = 0
|
||||
|
||||
companion object {
|
||||
fun newInstance(entryPoint: String) = ItemShelvingLogFragment(entryPoint)
|
||||
}
|
||||
|
||||
private lateinit var customDialog: CustomDialog
|
||||
|
||||
override fun getLayoutId(): Int = R.layout.fragment_itemshelvinglog
|
||||
|
||||
override fun init() {
|
||||
|
||||
customDialog = CustomDialog(requireContext())
|
||||
setEvents()
|
||||
setToolBar(getString(R.string.itemShelvingLog))
|
||||
setAdapter()
|
||||
super.init()
|
||||
|
||||
}
|
||||
|
||||
private fun setAdapter() {
|
||||
binding.itemshelvinglogRecyclerview.layoutManager =
|
||||
LinearLayoutManager(
|
||||
requireContext(),
|
||||
LinearLayoutManager.VERTICAL,
|
||||
false
|
||||
)
|
||||
adapter = ItemShelvingLogAdapter(
|
||||
listOf(),
|
||||
onPasillerosItemClickListener = pasillerosItemClickListener!!
|
||||
)
|
||||
binding.itemshelvinglogRecyclerview.adapter = adapter
|
||||
}
|
||||
|
||||
override fun onAttach(context: Context) {
|
||||
if (context is OnPasillerosItemClickListener) pasillerosItemClickListener = context
|
||||
super.onAttach(context)
|
||||
}
|
||||
|
||||
private fun setToolBar(title: String) {
|
||||
binding.mainToolbar.toolbarTitle.text = title
|
||||
}
|
||||
|
||||
private fun setEvents() {
|
||||
val scrollView = binding.scrollView
|
||||
scrollView.setOnScrollChangeListener { _, _, scrollY, _, _->
|
||||
positionScroll = scrollY
|
||||
}
|
||||
|
||||
|
||||
binding.scanInput.requestFocus()
|
||||
binding.loadMoreButton.setOnClickListener {
|
||||
positionToReturn = positionScroll
|
||||
records += LIMITRECORDSSHELVINGLOG
|
||||
try {
|
||||
viewModel.getIdFromCodeSalix(shelving.toLong().toString(), records)
|
||||
} catch (ex: Exception) {
|
||||
|
||||
viewModel.itemShelvingLogGet(
|
||||
shelving,
|
||||
records
|
||||
)
|
||||
}
|
||||
}
|
||||
binding.scanInput.setOnEditorActionListener { v, actionId, event ->
|
||||
if (actionId == EditorInfo.IME_ACTION_SEARCH || actionId == EditorInfo.IME_ACTION_DONE || actionId == 0 || actionId == 5) {
|
||||
if (binding.scanInput.text.toString().isNotEmpty()) {
|
||||
//Tarea 7168
|
||||
shelving = binding.scanInput.text.toString()
|
||||
records = LIMITRECORDSSHELVINGLOG
|
||||
try {
|
||||
viewModel.getIdFromCodeSalix(binding.scanInput.toLong().toString(), records)
|
||||
} catch (ex: Exception) {
|
||||
viewModel.itemShelvingLogGet(
|
||||
shelving,
|
||||
records
|
||||
)
|
||||
}
|
||||
}
|
||||
binding.scanInput.setText("")
|
||||
ma.hideKeyboard(binding.scanInput)
|
||||
return@setOnEditorActionListener true
|
||||
}
|
||||
false
|
||||
}
|
||||
binding.mainToolbar.backButton.setOnClickListener {
|
||||
ma.onMyBackPressed()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
override fun observeViewModel() {
|
||||
with(viewModel) {
|
||||
|
||||
itemShelvingLogList.observe(viewLifecycleOwner) {
|
||||
|
||||
if (it.list.isEmpty()) {
|
||||
customDialog.setTitle(getString(R.string.noResults))
|
||||
.setDescription(getString(R.string.noDataLabelScanned))
|
||||
.setOkButton(getString(R.string.close)) {
|
||||
customDialog.dismiss()
|
||||
}.show()
|
||||
} else {
|
||||
|
||||
//TAREA 7168
|
||||
if (it.list.size == records) {
|
||||
binding.loadMoreButton.visibility = View.VISIBLE
|
||||
} else {
|
||||
binding.loadMoreButton.visibility = View.GONE
|
||||
}
|
||||
adapter!!.addList(it.list)
|
||||
setToolBar(getString(R.string.itemShelvingLog) + ":" + itemScan)
|
||||
|
||||
val handler = Handler(Looper.getMainLooper())
|
||||
handler.postDelayed({
|
||||
binding.scrollView.smoothScrollTo(0, positionToReturn)
|
||||
}, 1000)
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -1,64 +0,0 @@
|
|||
package es.verdnatura.presentation.view.feature.historicoshelving.fragment
|
||||
|
||||
import android.content.Context
|
||||
import androidx.lifecycle.LiveData
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
import es.verdnatura.domain.ConstAndValues.LIMITRECORDSSHELVINGLOG
|
||||
import es.verdnatura.domain.SalixCallback
|
||||
import es.verdnatura.domain.userCases.GetItemFromBarcodeUseCase
|
||||
import es.verdnatura.presentation.base.BaseViewModel
|
||||
import es.verdnatura.presentation.view.feature.historicoshelving.model.ItemShelvingLog
|
||||
import es.verdnatura.presentation.view.feature.historicoshelving.model.ItemShelvingLogList
|
||||
import retrofit2.Response
|
||||
|
||||
class ItemShelvingLogViewModel(val context: Context) : BaseViewModel(context) {
|
||||
|
||||
private val getItemFromBarcodeUseCase = GetItemFromBarcodeUseCase(salix)
|
||||
|
||||
private val _itemShelvingLogList by lazy { MutableLiveData<ItemShelvingLogList>() }
|
||||
val itemShelvingLogList: LiveData<ItemShelvingLogList> = _itemShelvingLogList
|
||||
|
||||
private val _responseCode by lazy { MutableLiveData<Int?>() }
|
||||
val responseCode: LiveData<Int?> = _responseCode
|
||||
|
||||
fun itemShelvingLogGet(shelvingOrItem: String, records: Int = LIMITRECORDSSHELVINGLOG) {
|
||||
//tarea 7168
|
||||
salix.itemShelvingLogGet(
|
||||
filter = """{ "where": { "or": [ {"shelvingFk": "$shelvingOrItem"}, {"itemFk": "$shelvingOrItem"} ] },
|
||||
"limit": $records,
|
||||
"order": "created DESC",
|
||||
"include": [ { "relation": "worker", "scope": { "fields": ["code"]} },
|
||||
{ "relation": "item", "scope": { "fields": ["longName"] } } ] }
|
||||
""".trim()
|
||||
)
|
||||
.enqueue(object :
|
||||
SalixCallback<List<ItemShelvingLog>>(context) {
|
||||
override fun onSuccess(response: Response<List<ItemShelvingLog>>) {
|
||||
_itemShelvingLogList.value = response.body()?.let {
|
||||
ItemShelvingLogList(it)
|
||||
}
|
||||
}
|
||||
|
||||
})
|
||||
}
|
||||
|
||||
fun getIdFromCodeSalix(code: String, records: Int) {
|
||||
getItemFromBarcodeUseCase.execute (code)
|
||||
.enqueue(object : SalixCallback<Int?>(context) {
|
||||
|
||||
override fun onSuccess(response: Response<Int?>) {
|
||||
itemShelvingLogGet(response.body()!!.toString(), records)
|
||||
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
@ -1,36 +0,0 @@
|
|||
package es.verdnatura.presentation.view.feature.historicoshelving.model
|
||||
|
||||
import es.verdnatura.domain.isoToString
|
||||
|
||||
|
||||
data class ItemShelvingLog(
|
||||
var itemFk: Int? = null,
|
||||
var longName: String? = null,
|
||||
var shelvingFk: String? = null,
|
||||
var visible: Int? = null,
|
||||
var accion: String? = null,
|
||||
var code: String? = null,
|
||||
var worker: Worker? = null,
|
||||
var item:ItemSalix? = null
|
||||
) {
|
||||
var created: String = ""
|
||||
get() {
|
||||
return field.isoToString(returnOnlyDate = false)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
data class ItemSalix(var longName: String?)
|
||||
|
||||
data class ItemShelvingSaleDateList(
|
||||
var list: List<ItemShelvingLog> = listOf()
|
||||
)
|
||||
|
||||
data class ItemShelvingLogList(
|
||||
var list: List<ItemShelvingLog> = listOf()
|
||||
)
|
||||
|
||||
data class Worker(
|
||||
var id:Int? ,
|
||||
var code: String,
|
||||
)
|
|
@ -1,48 +0,0 @@
|
|||
package es.verdnatura.presentation.view.feature.historicovehiculo.adapter
|
||||
import android.view.LayoutInflater
|
||||
import android.view.ViewGroup
|
||||
import androidx.core.content.ContextCompat
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import es.verdnatura.R
|
||||
import es.verdnatura.databinding.ItemHistoricovehiculoRowBinding
|
||||
import es.verdnatura.presentation.view.feature.historicovehiculo.model.ItemHistoricoVehiculo
|
||||
import java.text.SimpleDateFormat
|
||||
import java.util.*
|
||||
|
||||
|
||||
|
||||
class HistoricoVehiculoAdapter (
|
||||
private val items: List<ItemHistoricoVehiculo>
|
||||
): RecyclerView.Adapter<HistoricoVehiculoAdapter.ItemHolder> () {
|
||||
|
||||
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ItemHolder {
|
||||
return ItemHolder(
|
||||
ItemHistoricovehiculoRowBinding.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: ItemHistoricovehiculoRowBinding
|
||||
) : RecyclerView.ViewHolder(binding.root){
|
||||
private val res = binding.root.context.resources
|
||||
fun bind(item: ItemHistoricoVehiculo) {
|
||||
binding.apply {
|
||||
this.item = item
|
||||
val sdf = SimpleDateFormat(binding.root.context.getString(R.string.dateFormat))
|
||||
val currentDate = sdf.format(Date())
|
||||
if (currentDate == item.inTimed){
|
||||
historicoDate.setBackgroundColor(ContextCompat.getColor(historicoDate.context,R.color.verdnatura_pumpkin_orange))
|
||||
}else{
|
||||
historicoDate.setBackgroundColor(ContextCompat.getColor(historicoDate.context,R.color.verdnatura_black_5))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,93 +0,0 @@
|
|||
package es.verdnatura.presentation.view.feature.historicovehiculo.fragment
|
||||
|
||||
import android.view.View
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import es.verdnatura.R
|
||||
import es.verdnatura.databinding.FragmentHistoricovehiculoBinding
|
||||
import es.verdnatura.domain.notNull
|
||||
import es.verdnatura.presentation.base.BaseFragment
|
||||
import es.verdnatura.presentation.view.feature.historicovehiculo.adapter.HistoricoVehiculoAdapter
|
||||
import es.verdnatura.presentation.view.feature.historicovehiculo.model.ItemHistoricoVehiculoList
|
||||
import java.text.SimpleDateFormat
|
||||
import java.util.Date
|
||||
import java.util.Locale
|
||||
|
||||
class HistoricoVehiculoFragment(
|
||||
private var numberPlate: String = ""
|
||||
) : BaseFragment<FragmentHistoricovehiculoBinding, HistoricoVehiculoViewModel>(
|
||||
HistoricoVehiculoViewModel::class
|
||||
) {
|
||||
|
||||
private var adapter: HistoricoVehiculoAdapter? = null
|
||||
|
||||
companion object {
|
||||
fun newInstance(entryPoint: String) = HistoricoVehiculoFragment(entryPoint)
|
||||
}
|
||||
|
||||
override fun getLayoutId(): Int = R.layout.fragment_historicovehiculo
|
||||
|
||||
|
||||
override fun init() {
|
||||
|
||||
ma.hideBottomNavigation(View.GONE)
|
||||
viewModel.machineWorkeGetHistorical(numberPlate,mobileApplication.userId!!)
|
||||
binding.mainToolbar.toolbarTitle.text = getString(R.string.vehiclediary)
|
||||
setEvents()
|
||||
super.init()
|
||||
}
|
||||
|
||||
private fun setEvents() {
|
||||
binding.mainToolbar.backButton.setOnClickListener {
|
||||
ma.onMyBackPressed()
|
||||
}
|
||||
}
|
||||
|
||||
override fun observeViewModel() {
|
||||
with(viewModel) {
|
||||
loadHistoricoVehiculoList.observe(viewLifecycleOwner) { event ->
|
||||
event.getContentIfNotHandled().notNull {
|
||||
|
||||
if (it.list.isEmpty()) {
|
||||
ma.messageWithSound(
|
||||
getString(R.string.lookWithpermission),
|
||||
isError = true,
|
||||
isPlayed = true,
|
||||
getString(
|
||||
R.string.info
|
||||
)
|
||||
)
|
||||
} else {
|
||||
adapter = HistoricoVehiculoAdapter(it.list)
|
||||
binding.historicovehiculoRecyclerview.adapter = adapter
|
||||
binding.historicovehiculoRecyclerview.layoutManager =
|
||||
LinearLayoutManager(
|
||||
requireContext(),
|
||||
LinearLayoutManager.VERTICAL,
|
||||
false
|
||||
)
|
||||
navigateToToday(it)
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private fun navigateToToday(it: ItemHistoricoVehiculoList) {
|
||||
var positionToday = 0
|
||||
val sdf = SimpleDateFormat(getString(R.string.dateFormat), Locale.getDefault())
|
||||
val currentDate = sdf.format(Date())
|
||||
|
||||
for (item in it.list) {
|
||||
if (currentDate == item.inTimed) {
|
||||
break
|
||||
}
|
||||
positionToday += 1
|
||||
}
|
||||
|
||||
binding.historicovehiculoRecyclerview.scrollToPosition(positionToday)
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -1,31 +0,0 @@
|
|||
package es.verdnatura.presentation.view.feature.historicovehiculo.fragment
|
||||
|
||||
import android.content.Context
|
||||
import androidx.lifecycle.LiveData
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
import androidx.lifecycle.map
|
||||
import es.verdnatura.domain.SalixCallback
|
||||
import es.verdnatura.domain.formatWithQuotes
|
||||
import es.verdnatura.presentation.base.BaseViewModel
|
||||
import es.verdnatura.presentation.common.Event
|
||||
import es.verdnatura.presentation.view.feature.historicovehiculo.model.ItemHistoricoVehiculo
|
||||
import es.verdnatura.presentation.view.feature.historicovehiculo.model.ItemHistoricoVehiculoList
|
||||
import retrofit2.Response
|
||||
|
||||
class HistoricoVehiculoViewModel(var context: Context) : BaseViewModel(context) {
|
||||
|
||||
private val _historicovehiculoList by lazy { MutableLiveData<ItemHistoricoVehiculoList>() }
|
||||
val loadHistoricoVehiculoList: LiveData<Event<ItemHistoricoVehiculoList>> = _historicovehiculoList.map { Event(it) }
|
||||
|
||||
fun machineWorkeGetHistorical(plateNumber: String, workerId:Int) {
|
||||
salix.machineWorkerGetHistorical(arrayListOf(plateNumber,workerId).formatWithQuotes())
|
||||
.enqueue(object :
|
||||
SalixCallback<List<ItemHistoricoVehiculo>>(context) {
|
||||
override fun onSuccess(response: Response<List<ItemHistoricoVehiculo>>) {
|
||||
_historicovehiculoList.value =
|
||||
response.body()?.let { ItemHistoricoVehiculoList(it) }
|
||||
}
|
||||
|
||||
})
|
||||
}
|
||||
}
|
|
@ -1,22 +0,0 @@
|
|||
package es.verdnatura.presentation.view.feature.historicovehiculo.model
|
||||
|
||||
import es.verdnatura.domain.isoToString
|
||||
|
||||
class ItemHistoricoVehiculo(
|
||||
var workerName: String? = null,
|
||||
|
||||
) {
|
||||
var inTimed: String = ""
|
||||
get() {
|
||||
return field.isoToString()
|
||||
}
|
||||
var outTimed: String = ""
|
||||
get() {
|
||||
return field.isoToString()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class ItemHistoricoVehiculoList(
|
||||
var list: List<ItemHistoricoVehiculo> = listOf()
|
||||
)
|
|
@ -0,0 +1,81 @@
|
|||
package es.verdnatura.presentation.view.feature.indoor
|
||||
|
||||
import android.Manifest
|
||||
import android.content.pm.PackageManager
|
||||
import android.location.Location
|
||||
import android.location.LocationListener
|
||||
import android.location.LocationManager
|
||||
import android.os.Bundle
|
||||
import android.widget.TextView
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.core.app.ActivityCompat
|
||||
import androidx.core.content.ContextCompat
|
||||
import es.verdnatura.R
|
||||
|
||||
class MainActivityIndoor : AppCompatActivity(), LocationListener {
|
||||
|
||||
private lateinit var locationManager: LocationManager
|
||||
private lateinit var textView: TextView
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
setContentView(R.layout.indoor_activity_main)
|
||||
|
||||
textView = findViewById(R.id.textViewLocation)
|
||||
|
||||
locationManager = getSystemService(LOCATION_SERVICE) as LocationManager
|
||||
|
||||
// Verificar permisos
|
||||
if (ContextCompat.checkSelfPermission(this, Manifest.permission.ACCESS_COARSE_LOCATION)
|
||||
!= PackageManager.PERMISSION_GRANTED
|
||||
) {
|
||||
|
||||
ActivityCompat.requestPermissions(
|
||||
this,
|
||||
arrayOf(Manifest.permission.ACCESS_COARSE_LOCATION), 1
|
||||
)
|
||||
} else {
|
||||
startLocationUpdates()
|
||||
}
|
||||
}
|
||||
|
||||
private fun startLocationUpdates() {
|
||||
if (ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_COARSE_LOCATION)
|
||||
== PackageManager.PERMISSION_GRANTED
|
||||
) {
|
||||
|
||||
locationManager.requestLocationUpdates(
|
||||
LocationManager.NETWORK_PROVIDER,
|
||||
5000, // Tiempo mínimo de actualización (5 segundos)
|
||||
10f, // Distancia mínima de actualización (10 metros)
|
||||
this
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onLocationChanged(location: Location) {
|
||||
val latitude = location.latitude
|
||||
val longitude = location.longitude
|
||||
textView.text = "Lat: $latitude\nLon: $longitude"
|
||||
println(" $latitude:$longitude")
|
||||
}
|
||||
|
||||
override fun onRequestPermissionsResult(
|
||||
requestCode: Int,
|
||||
permissions: Array<out String>,
|
||||
grantResults: IntArray
|
||||
) {
|
||||
super.onRequestPermissionsResult(requestCode, permissions, grantResults)
|
||||
if (requestCode == 1 && grantResults.isNotEmpty()
|
||||
&& grantResults[0] == PackageManager.PERMISSION_GRANTED
|
||||
) {
|
||||
startLocationUpdates()
|
||||
}
|
||||
}
|
||||
|
||||
override fun onStatusChanged(provider: String?, status: Int, extras: Bundle?) {}
|
||||
|
||||
override fun onProviderEnabled(provider: String) {}
|
||||
|
||||
override fun onProviderDisabled(provider: String) {}
|
||||
}
|
|
@ -44,7 +44,7 @@ class InventaryFragment :
|
|||
private lateinit var itemClicked: ItemInventaryVO
|
||||
private var buyerId: Number = -1
|
||||
private var filterItemType: String? = null
|
||||
private var myListBuyers = listOf<Buyer>()
|
||||
private var myListBuyers = mutableListOf<Buyer>()
|
||||
|
||||
companion object {
|
||||
fun newInstance() = InventaryFragment()
|
||||
|
@ -82,6 +82,7 @@ class InventaryFragment :
|
|||
}
|
||||
.distinct()
|
||||
.sortedBy { it.name }
|
||||
|
||||
setSearchable(distinctPackingTypes as MutableList<NameWithId>)
|
||||
binding.searchableRecyclerView.visibility = View.VISIBLE
|
||||
binding.searchableRecyclerView.setSearchHint(getString(R.string.BuyerSearch))
|
||||
|
@ -235,7 +236,7 @@ class InventaryFragment :
|
|||
with(viewModel) {
|
||||
|
||||
buyersByItemPackingList.observe(viewLifecycleOwner) { list ->
|
||||
myListBuyers = list.list
|
||||
myListBuyers = list.list.toMutableList()
|
||||
val distinctPackingTypes =
|
||||
list?.list?.map {
|
||||
NameWithId(
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
package es.verdnatura.presentation.view.feature.inventario.model
|
||||
|
||||
import com.google.gson.annotations.SerializedName
|
||||
|
||||
class ItemInventaryVO(
|
||||
var itemFk: Int? = null,
|
||||
var longName: String? = null,
|
||||
|
@ -9,7 +11,7 @@ class ItemInventaryVO(
|
|||
var upstairs: Int? = null,
|
||||
var nicho: Int? = null,
|
||||
var itemColour: String = "",
|
||||
var pendingAmount :Long? = null
|
||||
var pendingAmount: Long? = null
|
||||
)
|
||||
|
||||
class InventaryListVO(
|
||||
|
@ -27,13 +29,14 @@ class ItemShelvingVisibleZero(
|
|||
|
||||
class ItemShelvingChecked(
|
||||
var isChecked: Boolean?,
|
||||
var userFk : Int
|
||||
var userFk: Int
|
||||
)
|
||||
|
||||
data class ItemInventoryParking(
|
||||
var id: Long = 0,
|
||||
var pickingOrder: Int = 0,
|
||||
var parking: String = "",
|
||||
@SerializedName(value = "shelvingFk", alternate = ["code"])
|
||||
var shelvingFk: String = "",
|
||||
var itemFk: Int = 0,
|
||||
var longName: String = "",
|
||||
|
@ -42,8 +45,8 @@ data class ItemInventoryParking(
|
|||
var buyer: String = "",
|
||||
var isChecked: Int? = null,
|
||||
var priority: Int = 0,
|
||||
var url:String? = null,
|
||||
var image:String? = null
|
||||
var url: String? = null,
|
||||
var image: String? = null
|
||||
)
|
||||
|
||||
class InventoryParkingList(
|
||||
|
|
|
@ -43,7 +43,7 @@ import kotlinx.coroutines.runBlocking
|
|||
import java.util.Date
|
||||
import kotlin.system.exitProcess
|
||||
|
||||
class LoginFragment() :
|
||||
class LoginFragment :
|
||||
BaseFragment<FragmentLoginBinding, LoginViewModel>(LoginViewModel::class) {
|
||||
|
||||
private lateinit var customDialogInput: CustomDialogInput
|
||||
|
@ -157,6 +157,7 @@ class LoginFragment() :
|
|||
}
|
||||
|
||||
)
|
||||
|
||||
}
|
||||
|
||||
private fun setSwitch() {
|
||||
|
@ -170,36 +171,6 @@ class LoginFragment() :
|
|||
}
|
||||
}
|
||||
|
||||
/* private fun getDevicePDA(): Int? {
|
||||
return try {
|
||||
Settings.Global.getString(
|
||||
mobileApplication.contentResolver, Settings.Global.DEVICE_NAME
|
||||
).toInt()
|
||||
} catch (ex: Exception) {
|
||||
null
|
||||
}
|
||||
|
||||
}*/
|
||||
|
||||
/* private fun createFolderSerial() {
|
||||
|
||||
val directory = File(
|
||||
requireContext().getExternalFilesDir(Environment.DIRECTORY_DOCUMENTS), "/dataSerial"
|
||||
)
|
||||
|
||||
if (!directory.exists()) {
|
||||
directory.mkdirs()
|
||||
}
|
||||
try {
|
||||
val filename = "serial.txt"
|
||||
val file = File(directory, filename)
|
||||
mobileApplication.serialNumber = file.readText()
|
||||
} catch (ex: Exception) {
|
||||
d("VERDNATURA:", getString(R.string.errorFile))
|
||||
}
|
||||
|
||||
}*/
|
||||
|
||||
private fun setAdapter(listWorkForms: List<WorkForms>) {
|
||||
|
||||
workFormAdapter = WorkFormAdapter(listWorkForms, object : OnWorkFormsItemRowClickListener {
|
||||
|
@ -355,6 +326,8 @@ class LoginFragment() :
|
|||
if (binding.edittextServer.text.toString() == "Producción") {
|
||||
mobileApplication.clearApplicationData()
|
||||
}
|
||||
//Tarea 8212 serialMuber is obtaines from back when PDA is registered, updated scaleFusion
|
||||
if (it.serialNumber.isEmpty()) {
|
||||
customDialog.setTitle(getString(R.string.Actualizar))
|
||||
.setDescription(getString(R.string.updatemng)).setOkButton(
|
||||
getString(
|
||||
|
@ -380,6 +353,9 @@ class LoginFragment() :
|
|||
}
|
||||
customDialog.show()
|
||||
|
||||
} else {
|
||||
goToMain()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -13,9 +13,9 @@ import es.verdnatura.domain.ConstAndValues.TOKENCREATED
|
|||
import es.verdnatura.domain.ConstAndValues.TTL
|
||||
import es.verdnatura.domain.SalixCallback
|
||||
import es.verdnatura.domain.formatWithQuotes
|
||||
import es.verdnatura.domain.getMessageFromAllResponse
|
||||
import es.verdnatura.domain.nameofFunction
|
||||
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.historicoshelvinglog.model.DeviceLogSalix
|
||||
import es.verdnatura.presentation.view.feature.login.model.AccessConfigSalix
|
||||
|
|
|
@ -3,7 +3,6 @@ package es.verdnatura.presentation.view.feature.main.activity
|
|||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.media.MediaPlayer
|
||||
import android.os.Build
|
||||
import android.util.AttributeSet
|
||||
import android.util.Log.e
|
||||
import android.view.Menu
|
||||
|
@ -11,7 +10,6 @@ import android.view.View
|
|||
import android.widget.Toast
|
||||
import androidx.activity.OnBackPressedCallback
|
||||
import androidx.activity.OnBackPressedDispatcherOwner
|
||||
import androidx.annotation.RequiresApi
|
||||
import androidx.core.content.ContextCompat
|
||||
import androidx.fragment.app.Fragment
|
||||
import androidx.fragment.app.FragmentManager
|
||||
|
@ -50,7 +48,7 @@ import es.verdnatura.presentation.common.OnStopMapClickListener
|
|||
import es.verdnatura.presentation.common.OnTruckClickListener
|
||||
import es.verdnatura.presentation.common.TAG
|
||||
import es.verdnatura.presentation.common.addFragment
|
||||
import es.verdnatura.presentation.view.commom.WebFragment
|
||||
import es.verdnatura.presentation.view.commom.webview.WebFragment
|
||||
import es.verdnatura.presentation.view.component.CustomDialogMainActivity
|
||||
import es.verdnatura.presentation.view.feature.ajustes.fragment.AjustesFragment
|
||||
import es.verdnatura.presentation.view.feature.articulo.fragment.ItemCardFragment
|
||||
|
@ -58,7 +56,7 @@ import es.verdnatura.presentation.view.feature.articulo.fragment.ItemProposalFra
|
|||
import es.verdnatura.presentation.view.feature.boxPicking.BoxPickingFragment
|
||||
import es.verdnatura.presentation.view.feature.buffer.fragment.BufferFragment
|
||||
import es.verdnatura.presentation.view.feature.buffer.fragment.BufferLoadFragment
|
||||
import es.verdnatura.presentation.view.feature.buscaritem.fragment.BuscarItemFragment
|
||||
import es.verdnatura.presentation.view.feature.buscaritem.fragment.BuscarItemFragmentCompose
|
||||
import es.verdnatura.presentation.view.feature.category.ChangeCategoryFragment
|
||||
import es.verdnatura.presentation.view.feature.claim.fragment.reubication.fragment.ReubicationCollectionFragment
|
||||
import es.verdnatura.presentation.view.feature.claim.fragment.reubication.fragment.ReubicationFragment
|
||||
|
@ -68,10 +66,10 @@ import es.verdnatura.presentation.view.feature.collection.fragment.CollectionFra
|
|||
import es.verdnatura.presentation.view.feature.collection.fragment.CollectionFragmentChecker
|
||||
import es.verdnatura.presentation.view.feature.collection.fragment.CollectionFragmentCheckerPreviousNew
|
||||
import es.verdnatura.presentation.view.feature.collection.fragment.CollectionFragmentPicker
|
||||
import es.verdnatura.presentation.view.feature.collection.fragment.CollectionFragmentPickerPreviousNew
|
||||
import es.verdnatura.presentation.view.feature.collection.fragment.CollectionFragmentPickerPreviousNewInterface
|
||||
import es.verdnatura.presentation.view.feature.collection.fragment.CollectionFragmentPickerPreviousNewInterfaceSacador
|
||||
import es.verdnatura.presentation.view.feature.collection.fragment.CollectionFragmentPreChecker
|
||||
import es.verdnatura.presentation.view.feature.collection.fragment.CollectionShowTicketFragment
|
||||
import es.verdnatura.presentation.view.feature.controlvehiculo.fragment.ControlVehiculoFragment
|
||||
import es.verdnatura.presentation.view.feature.controlvehiculo.fragment.ControlVehiculoUsuarioFragment
|
||||
import es.verdnatura.presentation.view.feature.delivery.fragments.InfoFragment
|
||||
import es.verdnatura.presentation.view.feature.delivery.fragments.LoadUnloadFragment
|
||||
|
@ -81,12 +79,10 @@ import es.verdnatura.presentation.view.feature.delivery.fragments.SalaryCompleme
|
|||
import es.verdnatura.presentation.view.feature.delivery.fragments.SummaryFragment
|
||||
import es.verdnatura.presentation.view.feature.delivery.fragments.TicketsFragment
|
||||
import es.verdnatura.presentation.view.feature.delivery.model.ClientTicketSalix
|
||||
import es.verdnatura.presentation.view.feature.diadeventa.fragment.DayOfSaleFragment
|
||||
import es.verdnatura.presentation.view.feature.diadeventa.fragment.DayOfSaleFragmentCompose
|
||||
import es.verdnatura.presentation.view.feature.historicoarticulo.fragment.HistoricoArticuloFragment
|
||||
import es.verdnatura.presentation.view.feature.historicoshelving.fragment.ItemShelvingLogFragment
|
||||
import es.verdnatura.presentation.view.feature.historicoshelvinglog.fragment.ShelvingLogFragment
|
||||
import es.verdnatura.presentation.view.feature.historicoshelvinglog.model.LogType
|
||||
import es.verdnatura.presentation.view.feature.historicovehiculo.fragment.HistoricoVehiculoFragment
|
||||
import es.verdnatura.presentation.view.feature.inventario.fragment.InventaryFragment
|
||||
import es.verdnatura.presentation.view.feature.inventario.fragment.InventaryParkingFragment
|
||||
import es.verdnatura.presentation.view.feature.login.fragment.LoginViewModel
|
||||
|
@ -103,7 +99,7 @@ import es.verdnatura.presentation.view.feature.paletizador.fragment.ExpeditionPa
|
|||
import es.verdnatura.presentation.view.feature.paletizador.fragment.ExpeditionPalletFragment
|
||||
import es.verdnatura.presentation.view.feature.paletizador.fragment.ExpeditionPreparedStateFragment
|
||||
import es.verdnatura.presentation.view.feature.paletizador.fragment.ExpeditionScanFragment
|
||||
import es.verdnatura.presentation.view.feature.paletizador.fragment.ExpeditionScanSorterFragment
|
||||
import es.verdnatura.presentation.view.feature.paletizador.fragment.ExpeditionScanSorterFragmentCompose
|
||||
import es.verdnatura.presentation.view.feature.paletizador.fragment.ExpeditionStateFragment
|
||||
import es.verdnatura.presentation.view.feature.paletizador.fragment.ExpeditionTruckListFragment
|
||||
import es.verdnatura.presentation.view.feature.paletizador.fragment.PalletScanFragment
|
||||
|
@ -135,9 +131,9 @@ import es.verdnatura.presentation.view.feature.sacador.model.CollectionTicket
|
|||
import es.verdnatura.presentation.view.feature.sacador.model.CollectionVO
|
||||
import es.verdnatura.presentation.view.feature.ticket.fragment.TicketAdvanceFragment
|
||||
import es.verdnatura.presentation.view.feature.ubicador.fragment.AutomaticAddItemFragment
|
||||
import es.verdnatura.presentation.view.feature.ubicador.fragment.UbicadorFragment6869
|
||||
import es.verdnatura.presentation.view.feature.ubicador.fragment.UbicadorFragment
|
||||
import es.verdnatura.presentation.view.feature.workermistake.fragment.PackingMistakeFragment
|
||||
import es.verdnatura.presentation.view.feature.workermistake.fragment.WorkermistakeFragment
|
||||
import es.verdnatura.presentation.view.feature.workermistake.fragment.WorkermistakeFragmentCompose
|
||||
import kotlinx.coroutines.DelicateCoroutinesApi
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.GlobalScope
|
||||
|
@ -176,7 +172,6 @@ class MainActivity : BaseActivity<ActivityMainBinding>(), OnPasillerosItemClickL
|
|||
|
||||
}
|
||||
|
||||
@RequiresApi(Build.VERSION_CODES.O)
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
try {
|
||||
|
@ -205,9 +200,8 @@ class MainActivity : BaseActivity<ActivityMainBinding>(), OnPasillerosItemClickL
|
|||
return super.onCreateView(name, context, attrs)
|
||||
}
|
||||
|
||||
@RequiresApi(Build.VERSION_CODES.O)
|
||||
@OptIn(DelicateCoroutinesApi::class)
|
||||
override fun init() {
|
||||
|
||||
mperror = MediaPlayer.create((this), R.raw.error)
|
||||
mpok = MediaPlayer.create((this), R.raw.ok)
|
||||
mpErrorRepeat = MediaPlayer.create((this), R.raw.errorrepeat)
|
||||
|
@ -247,11 +241,10 @@ class MainActivity : BaseActivity<ActivityMainBinding>(), OnPasillerosItemClickL
|
|||
networkUtils = NetworkUtilsApp(this, application as MobileApplication)
|
||||
}
|
||||
|
||||
@RequiresApi(Build.VERSION_CODES.O)
|
||||
private fun startRepeatingTask(myInterval: Long) {
|
||||
|
||||
scheduledExecutor = Executors.newSingleThreadScheduledExecutor()
|
||||
scheduledFuture = scheduledExecutor?.scheduleAtFixedRate(
|
||||
scheduledFuture = scheduledExecutor?.scheduleWithFixedDelay(
|
||||
{
|
||||
runOnUiThread {
|
||||
checkTokenRenew()
|
||||
|
@ -260,13 +253,11 @@ class MainActivity : BaseActivity<ActivityMainBinding>(), OnPasillerosItemClickL
|
|||
)
|
||||
}
|
||||
|
||||
@RequiresApi(Build.VERSION_CODES.O)
|
||||
override fun onDestroy() {
|
||||
super.onDestroy()
|
||||
scheduledExecutor?.shutdown()
|
||||
}
|
||||
|
||||
@RequiresApi(Build.VERSION_CODES.O)
|
||||
private fun setFragments() {
|
||||
try {
|
||||
val uriImage = intent.data
|
||||
|
@ -414,7 +405,7 @@ class MainActivity : BaseActivity<ActivityMainBinding>(), OnPasillerosItemClickL
|
|||
|
||||
getString(R.string.titleCorridors) -> {
|
||||
fm.popBackStack(null, FragmentManager.POP_BACK_STACK_INCLUSIVE)
|
||||
delete_Fragments()
|
||||
deleteFragments()
|
||||
addFragment(
|
||||
PasilleroFragment.newInstance(getString(R.string.main), true),
|
||||
R.id.main_frame_layout,
|
||||
|
@ -426,7 +417,7 @@ class MainActivity : BaseActivity<ActivityMainBinding>(), OnPasillerosItemClickL
|
|||
|
||||
getString(R.string.verticket) -> {
|
||||
fm.popBackStack(null, FragmentManager.POP_BACK_STACK_INCLUSIVE)
|
||||
delete_Fragments()
|
||||
deleteFragments()
|
||||
addFragment(
|
||||
ShowTicketFragment.newInstance(getString(R.string.main)),
|
||||
R.id.main_frame_layout,
|
||||
|
@ -438,7 +429,7 @@ class MainActivity : BaseActivity<ActivityMainBinding>(), OnPasillerosItemClickL
|
|||
|
||||
getString(R.string.Parking) -> {
|
||||
fm.popBackStack(null, FragmentManager.POP_BACK_STACK_INCLUSIVE)
|
||||
delete_Fragments()
|
||||
deleteFragments()
|
||||
addFragment(
|
||||
ParkingFragment.newInstance(getString(R.string.main)),
|
||||
R.id.main_frame_layout,
|
||||
|
@ -450,7 +441,7 @@ class MainActivity : BaseActivity<ActivityMainBinding>(), OnPasillerosItemClickL
|
|||
|
||||
getString(R.string.Ajustes) -> {
|
||||
fm.popBackStack(null, FragmentManager.POP_BACK_STACK_INCLUSIVE)
|
||||
delete_Fragments()
|
||||
deleteFragments()
|
||||
addFragment(
|
||||
AjustesFragment.newInstance(),
|
||||
R.id.main_frame_layout,
|
||||
|
@ -469,7 +460,7 @@ class MainActivity : BaseActivity<ActivityMainBinding>(), OnPasillerosItemClickL
|
|||
|
||||
getString(R.string.titleCorridors) -> {
|
||||
fm.popBackStack(null, FragmentManager.POP_BACK_STACK_INCLUSIVE)
|
||||
delete_Fragments()
|
||||
deleteFragments()
|
||||
addFragment(
|
||||
PasilleroFragment.newInstance(getString(R.string.main), true),
|
||||
R.id.main_frame_layout,
|
||||
|
@ -485,7 +476,7 @@ class MainActivity : BaseActivity<ActivityMainBinding>(), OnPasillerosItemClickL
|
|||
}
|
||||
}
|
||||
|
||||
fun delete_Fragments() {
|
||||
private fun deleteFragments() {
|
||||
fm.fragments.forEach {
|
||||
val fragment: Fragment? = supportFragmentManager.findFragmentByTag(it.tag.toString())
|
||||
if (fragment != null) supportFragmentManager.beginTransaction().remove(fragment)
|
||||
|
@ -493,12 +484,10 @@ class MainActivity : BaseActivity<ActivityMainBinding>(), OnPasillerosItemClickL
|
|||
}
|
||||
}
|
||||
|
||||
@RequiresApi(Build.VERSION_CODES.O)
|
||||
override fun onPasillerosItemClickListener(
|
||||
item: PasillerosItemVO, entryPoint: String, param: Any?
|
||||
) {
|
||||
val itemTitle = getString(item.title!!)
|
||||
when (itemTitle) {
|
||||
when (val itemTitle = getString(item.title!!)) {
|
||||
|
||||
//BUFFERS
|
||||
getString(R.string.titlePalletizar) -> {
|
||||
|
@ -586,7 +575,8 @@ class MainActivity : BaseActivity<ActivityMainBinding>(), OnPasillerosItemClickL
|
|||
}
|
||||
|
||||
getString(R.string.titleScanExpedition) -> {
|
||||
addFragmentOnTop(ExpeditionScanSorterFragment.newInstance(itemTitle))
|
||||
//addFragmentOnTop(ExpeditionScanSorterFragment.newInstance(itemTitle))
|
||||
addFragmentOnTop(ExpeditionScanSorterFragmentCompose.newInstance(itemTitle))
|
||||
}
|
||||
|
||||
getString(R.string.titleBufferManegement) -> {
|
||||
|
@ -615,21 +605,15 @@ class MainActivity : BaseActivity<ActivityMainBinding>(), OnPasillerosItemClickL
|
|||
|
||||
}
|
||||
|
||||
/* getString(R.string.titlePrePicker) -> {
|
||||
addFragmentOnTop(PreSacadorFragment.newInstance())
|
||||
}*/
|
||||
getString(R.string.titleDayOfSale) -> {
|
||||
addFragmentOnTop(DayOfSaleFragment(itemTitle))
|
||||
//addFragmentOnTop(DayOfSaleFragment(itemTitle))
|
||||
addFragmentOnTop(DayOfSaleFragmentCompose(itemTitle))
|
||||
}
|
||||
|
||||
getString(R.string.titleShowTicket) -> {
|
||||
addFragmentOnTop(ShowTicketFragment.newInstance(getString(R.string.titleCorridors)))
|
||||
}
|
||||
|
||||
getString(R.string.titleHistoricalVehicle) -> {
|
||||
addFragmentOnTop(ControlVehiculoFragment.newInstance(HistoricoVehiculoFragment.TAG))
|
||||
}
|
||||
|
||||
getString(R.string.titleItemConsult) -> {
|
||||
addFragmentOnTop(ItemCardFragment.newInstance(entryPoint))
|
||||
}
|
||||
|
@ -638,19 +622,15 @@ class MainActivity : BaseActivity<ActivityMainBinding>(), OnPasillerosItemClickL
|
|||
addFragmentOnTop(ItemProposalFragment.newInstance(entryPoint.toInt()))
|
||||
}
|
||||
|
||||
//segio: esta opción no se muestra, solo es accesible para añadir fragmentos de otras partes.
|
||||
getString(R.string.titleHistoricalHide) -> {
|
||||
addFragmentOnTop(HistoricoVehiculoFragment.newInstance(entryPoint))
|
||||
}
|
||||
|
||||
getString(R.string.Parking) -> {
|
||||
addFragmentOnTop(ParkingFragment.newInstance(""))
|
||||
}
|
||||
|
||||
getString(R.string.titleItemSearch) -> {
|
||||
|
||||
//JETPACKCOMPOSE
|
||||
addFragmentOnTop(
|
||||
BuscarItemFragment.newInstance(
|
||||
BuscarItemFragmentCompose.newInstance(
|
||||
if (entryPoint == "") {
|
||||
null
|
||||
} else {
|
||||
|
@ -658,6 +638,16 @@ class MainActivity : BaseActivity<ActivityMainBinding>(), OnPasillerosItemClickL
|
|||
}
|
||||
)
|
||||
)
|
||||
|
||||
/* addFragmentOnTop(
|
||||
BuscarItemFragment.newInstance(
|
||||
if (entryPoint == "") {
|
||||
null
|
||||
} else {
|
||||
entryPoint.toInt()
|
||||
}
|
||||
)
|
||||
)*/
|
||||
}
|
||||
|
||||
getString(R.string.titleHistorical) -> {
|
||||
|
@ -673,13 +663,9 @@ class MainActivity : BaseActivity<ActivityMainBinding>(), OnPasillerosItemClickL
|
|||
}
|
||||
|
||||
getString(R.string.titleUbicator) -> {
|
||||
//addFragmentOnTop(UbicadorFragmentNew.newInstance(entryPoint))
|
||||
addFragmentOnTop(UbicadorFragment6869.newInstance(entryPoint))
|
||||
|
||||
addFragmentOnTop(UbicadorFragment.newInstance(entryPoint))
|
||||
}
|
||||
//Tarea 6869
|
||||
/* getString(R.string.ubicatorNew) -> {
|
||||
addFragmentOnTop(UbicadorFragment6869.newInstance(entryPoint))
|
||||
}*/
|
||||
|
||||
//Tarea 7855
|
||||
getString(R.string.scanPreparedExpedition) -> {
|
||||
|
@ -717,6 +703,8 @@ class MainActivity : BaseActivity<ActivityMainBinding>(), OnPasillerosItemClickL
|
|||
|
||||
getString(R.string.titleWebViewer) -> {
|
||||
// el entryPoint de WebFragment se le pasa un JSON del tipo {"entryPoint":"itemScanned","web":"www.google.com}
|
||||
//JETPACKCOMPOSE
|
||||
//addFragmentOnTop(WebFragmentCompose.newInstance(entryPoint))
|
||||
addFragmentOnTop(WebFragment.newInstance(entryPoint))
|
||||
}
|
||||
//Menu qr
|
||||
|
@ -757,9 +745,6 @@ class MainActivity : BaseActivity<ActivityMainBinding>(), OnPasillerosItemClickL
|
|||
addFragmentOnTop(CollectionFragmentCheckerPreviousNew.newInstance())
|
||||
}
|
||||
|
||||
getString(R.string.titleShelvingHistorical) -> {
|
||||
addFragmentOnTop(ItemShelvingLogFragment.newInstance(itemTitle))
|
||||
}
|
||||
//Tarea 7920
|
||||
getString(R.string.titleShelvingHistNew) -> {
|
||||
addFragmentOnTop(ShelvingLogFragment.newInstance(itemTitle, LogType.ITEMSHELVING))
|
||||
|
@ -774,7 +759,8 @@ class MainActivity : BaseActivity<ActivityMainBinding>(), OnPasillerosItemClickL
|
|||
}
|
||||
|
||||
getString(R.string.titleWorkerMistake) -> {
|
||||
addFragmentOnTop(WorkermistakeFragment.newInstance(itemTitle))
|
||||
//addFragmentOnTop(WorkermistakeFragment.newInstance(itemTitle))
|
||||
addFragmentOnTop(WorkermistakeFragmentCompose.newInstance(itemTitle))
|
||||
}
|
||||
|
||||
getString(R.string.deleteExpedition) -> {
|
||||
|
@ -785,7 +771,11 @@ class MainActivity : BaseActivity<ActivityMainBinding>(), OnPasillerosItemClickL
|
|||
addFragmentOnTop(PackingMistakeFragment.newInstance(itemTitle))
|
||||
}
|
||||
|
||||
getString(R.string.titlePrePickerTest) -> {
|
||||
/* getString(R.string.titlePrePickerTest) -> {
|
||||
addFragmentOnTop(SacadorFragmentNew.newInstance("PREITEMPICKERTEST"))
|
||||
}*/
|
||||
|
||||
getString(R.string.preSacadorInterfaz) -> {
|
||||
addFragmentOnTop(SacadorFragmentNew.newInstance("PREITEMPICKERTEST"))
|
||||
}
|
||||
|
||||
|
@ -830,8 +820,7 @@ class MainActivity : BaseActivity<ActivityMainBinding>(), OnPasillerosItemClickL
|
|||
}
|
||||
|
||||
getString(R.string.selfConsumption) -> {
|
||||
// addFragmentOnTop(UbicadorFragmentNew.newInstance(entryPoint, true))
|
||||
addFragmentOnTop(UbicadorFragment6869.newInstance(entryPoint, true))
|
||||
addFragmentOnTop(UbicadorFragment.newInstance(entryPoint, true))
|
||||
}
|
||||
|
||||
getString(R.string.titlePackingHolland) -> {
|
||||
|
@ -957,13 +946,15 @@ class MainActivity : BaseActivity<ActivityMainBinding>(), OnPasillerosItemClickL
|
|||
}
|
||||
|
||||
"PREITEMPICKERTEST" -> {
|
||||
|
||||
addFragmentOnTop(
|
||||
CollectionFragmentPickerPreviousNew.newInstance(
|
||||
CollectionFragmentPickerPreviousNewInterface.newInstance(
|
||||
CollectionTicket(collectionFk = entryPoint.toInt()),
|
||||
"PREITEMPICKERTEST",
|
||||
false
|
||||
)
|
||||
)
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1071,15 +1062,11 @@ class MainActivity : BaseActivity<ActivityMainBinding>(), OnPasillerosItemClickL
|
|||
//Misma pantalla para los dos scador y prescador
|
||||
SACADOR -> {
|
||||
addFragmentOnTop(
|
||||
CollectionFragmentPickerPreviousNew.newInstance(
|
||||
CollectionFragmentPickerPreviousNewInterfaceSacador.newInstance(
|
||||
collection, type, hasPicking
|
||||
)
|
||||
)
|
||||
/* addFragmentOnTop(
|
||||
CollectionFragmentPickerNew.newInstance(
|
||||
collection, type, hasPicking
|
||||
)
|
||||
)*/
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1124,19 +1111,6 @@ class MainActivity : BaseActivity<ActivityMainBinding>(), OnPasillerosItemClickL
|
|||
|
||||
}
|
||||
|
||||
//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,
|
||||
true
|
||||
)
|
||||
}
|
||||
|
||||
fun openSummaryFragment(route: Int, state: String) {
|
||||
addFragmentOnTop(
|
||||
SummaryFragment.newInstance(
|
||||
|
@ -1146,10 +1120,10 @@ class MainActivity : BaseActivity<ActivityMainBinding>(), OnPasillerosItemClickL
|
|||
}
|
||||
|
||||
fun openFragmentPickers(delete: Boolean) {
|
||||
//delete_Fragments()
|
||||
//deleteFragments()
|
||||
fm.popBackStack(null, FragmentManager.POP_BACK_STACK_INCLUSIVE)
|
||||
if (delete) {
|
||||
delete_Fragments()
|
||||
deleteFragments()
|
||||
}
|
||||
addFragment(
|
||||
SacadorFragment.newInstance("PREPARED"),
|
||||
|
@ -1228,14 +1202,13 @@ class MainActivity : BaseActivity<ActivityMainBinding>(), OnPasillerosItemClickL
|
|||
userFk = (application as MobileApplication).userId!!
|
||||
)
|
||||
} catch (ex: Exception) {
|
||||
ex.message!!.toast(this)
|
||||
ex.message?.toast(this)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@RequiresApi(Build.VERSION_CODES.O)
|
||||
fun checkTokenRenew() {
|
||||
private fun checkTokenRenew() {
|
||||
val renewPeriod = mobileApplication.dataStoreApp.readDataStoreKey<Long>(RENEWPERIOD)
|
||||
val min = minOf(mobileApplication.dataStoreApp.readDataStoreKey(TTL), renewPeriod) * 1000
|
||||
if (Date().time < (min + mobileApplication.dataStoreApp.readDataStoreKey<Long>(TOKENCREATED))) {
|
||||
|
|
|
@ -18,6 +18,7 @@ import com.esafirm.imagepicker.features.registerImagePicker
|
|||
import com.esafirm.imagepicker.model.Image
|
||||
import es.verdnatura.R
|
||||
import es.verdnatura.databinding.FragmentPackagingObsBinding
|
||||
import es.verdnatura.domain.ConstAndValues.COMPANYFK
|
||||
import es.verdnatura.domain.ConstAndValues.ENTRYID
|
||||
import es.verdnatura.domain.ConstAndValues.ENTRYNUMBERIMAGES
|
||||
import es.verdnatura.domain.ConstAndValues.ENTRYOBSERVATIONORIGINAL
|
||||
|
@ -60,6 +61,7 @@ class ObservFragment(
|
|||
private var pasillerosItemClickListener: OnPasillerosItemClickListener? = null
|
||||
private var layoutManager: LinearLayoutManager? = null
|
||||
private lateinit var customDialogList: CustomDialogList
|
||||
private var dmsType: Int? = null
|
||||
|
||||
companion object {
|
||||
fun newInstance(entryPoint: String) = ObservFragment(entryPoint)
|
||||
|
@ -79,6 +81,7 @@ class ObservFragment(
|
|||
setEvents()
|
||||
setObservations()
|
||||
loadImages()
|
||||
viewModel.getTypeDMS()
|
||||
super.init()
|
||||
}
|
||||
|
||||
|
@ -244,8 +247,8 @@ class ObservFragment(
|
|||
warehouseId = mobileApplication.dataStoreApp.readDataStoreKey<Int>(
|
||||
WAREHOUSEFK
|
||||
),
|
||||
companyId = 442,
|
||||
dmsTypeId = 27,
|
||||
companyId = mobileApplication.dataStoreApp.readDataStoreKey<Int>(COMPANYFK),
|
||||
dmsTypeId = dmsType!!,
|
||||
reference = mobileApplication.dataStoreApp.readDataStoreKey<Int>(
|
||||
ENTRYID
|
||||
).toString(),
|
||||
|
@ -266,6 +269,18 @@ class ObservFragment(
|
|||
openSummary()
|
||||
}
|
||||
}
|
||||
dmsTypeId.observe(viewLifecycleOwner) {
|
||||
if (it.id == 0) {
|
||||
ma.messageWithSound(
|
||||
message = getString(R.string.errorDMS),
|
||||
isError = true,
|
||||
isPlayed = true
|
||||
)
|
||||
} else {
|
||||
dmsType = it.id
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -278,13 +293,14 @@ class ObservFragment(
|
|||
val drawable = getDrawableFromImageUri(requireContext(), (item as Image).uri)
|
||||
val bitmap = drawable!!.toBitmap()
|
||||
|
||||
|
||||
viewModel.entryUploadPhotoSalix(
|
||||
idEntry = mobileApplication.dataStoreApp.readDataStoreKey<Int>(ENTRYID),
|
||||
warehouseId = mobileApplication.dataStoreApp.readDataStoreKey<Int>(
|
||||
WAREHOUSEFK
|
||||
),
|
||||
companyId = 442,
|
||||
dmsTypeId = 27,
|
||||
companyId = mobileApplication.dataStoreApp.readDataStoreKey<Int>(COMPANYFK),
|
||||
dmsTypeId = dmsType!!,
|
||||
reference = mobileApplication.dataStoreApp.readDataStoreKey<Int>(
|
||||
ENTRYID
|
||||
).toString(),
|
||||
|
@ -294,7 +310,6 @@ class ObservFragment(
|
|||
hasFile = false,
|
||||
urlImage = saveBitmapAsTempFile(requireContext(), bitmap)
|
||||
)
|
||||
|
||||
}
|
||||
|
||||
}, object : OnImageTrashClickListener {
|
||||
|
|
|
@ -49,8 +49,15 @@ class PackagingCountFragment(
|
|||
override fun init() {
|
||||
|
||||
viewModel.getItemsPackaging(
|
||||
mobileApplication.dataStoreApp.readDataStoreKey(SUPPLIERID),
|
||||
mobileApplication.dataStoreApp.readDataStoreKey(ENTRYID)
|
||||
mobileApplication.dataStoreApp.readDataStoreKey<Int>(SUPPLIERID),
|
||||
mobileApplication.dataStoreApp.readDataStoreKey<Int>(ENTRYID)
|
||||
)
|
||||
println(
|
||||
"EntryId ${mobileApplication.dataStoreApp.readDataStoreKey<Int>(ENTRYID)} \n SupplierId ${
|
||||
mobileApplication.dataStoreApp.readDataStoreKey<Int>(
|
||||
SUPPLIERID
|
||||
)
|
||||
}"
|
||||
)
|
||||
customDialogInput = CustomDialogInput(requireContext())
|
||||
customDialog = CustomDialog(requireContext())
|
||||
|
@ -106,8 +113,8 @@ class PackagingCountFragment(
|
|||
event.getContentIfNotHandled().notNull {
|
||||
|
||||
viewModel.getItemsPackaging(
|
||||
mobileApplication.dataStoreApp.readDataStoreKey(SUPPLIERID),
|
||||
mobileApplication.dataStoreApp.readDataStoreKey(ENTRYID)
|
||||
mobileApplication.dataStoreApp.readDataStoreKey<Int>(SUPPLIERID),
|
||||
mobileApplication.dataStoreApp.readDataStoreKey<Int>(ENTRYID)
|
||||
)
|
||||
|
||||
}
|
||||
|
|
|
@ -48,8 +48,8 @@ class PackagingSummaryFragment(
|
|||
|
||||
|
||||
viewModel.getItemsPackaging(
|
||||
mobileApplication.dataStoreApp.readDataStoreKey(SUPPLIERID),
|
||||
mobileApplication.dataStoreApp.readDataStoreKey(ENTRYID)
|
||||
mobileApplication.dataStoreApp.readDataStoreKey<Int>(SUPPLIERID),
|
||||
mobileApplication.dataStoreApp.readDataStoreKey<Int>(ENTRYID)
|
||||
)
|
||||
|
||||
ma.hideBottomNavigation(View.GONE)
|
||||
|
|
|
@ -6,6 +6,7 @@ import android.view.View
|
|||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import es.verdnatura.R
|
||||
import es.verdnatura.databinding.FragmentPackagingBinding
|
||||
import es.verdnatura.domain.ConstAndValues.COMPANYFK
|
||||
import es.verdnatura.domain.ConstAndValues.ENTRYID
|
||||
import es.verdnatura.domain.ConstAndValues.ENTRYOBSERVATIONORIGINAL
|
||||
import es.verdnatura.domain.ConstAndValues.SUPPLIERID
|
||||
|
@ -108,11 +109,19 @@ class SupplierFragment(
|
|||
context = requireContext()
|
||||
) { elementSelected ->
|
||||
binding.filterEntry.text = elementSelected.name
|
||||
|
||||
runBlocking {
|
||||
mobileApplication.dataStoreApp.editDataStoreKey(
|
||||
ENTRYID,
|
||||
elementSelected.id
|
||||
elementSelected.id.toInt()
|
||||
)
|
||||
mobileApplication.dataStoreApp.editDataStoreKey(
|
||||
COMPANYFK,
|
||||
entries.find { it.id == elementSelected.id }!!.companyFk.toInt()
|
||||
)
|
||||
var element = entries.find { it.id == elementSelected.id }!!.companyFk
|
||||
println("companyFk $element")
|
||||
|
||||
mobileApplication.dataStoreApp.editDataStoreKey(
|
||||
ENTRYOBSERVATIONORIGINAL,
|
||||
entries.find { it.id == elementSelected.id }?.observation ?: ""
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue