diff --git a/.idea/compiler.xml b/.idea/compiler.xml new file mode 100644 index 00000000..61a9130c --- /dev/null +++ b/.idea/compiler.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.idea/gradle.xml b/.idea/gradle.xml index 5cd135a0..9bba60da 100644 --- a/.idea/gradle.xml +++ b/.idea/gradle.xml @@ -14,6 +14,7 @@ diff --git a/.idea/misc.xml b/.idea/misc.xml index 7bfef59d..d5d35ec4 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -1,6 +1,6 @@ - + diff --git a/app/build.gradle b/app/build.gradle index e1da7a55..adfe2de9 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -14,8 +14,8 @@ android { applicationId "es.verdnatura" minSdkVersion 21 targetSdkVersion 29 - versionCode 45 - versionName "5.3.5" + versionCode 49 + versionName "5.3.9" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" } diff --git a/app/src/main/java/es/verdnatura/di/viewModelModule.kt b/app/src/main/java/es/verdnatura/di/viewModelModule.kt index f08e39f9..ccce720d 100644 --- a/app/src/main/java/es/verdnatura/di/viewModelModule.kt +++ b/app/src/main/java/es/verdnatura/di/viewModelModule.kt @@ -3,6 +3,8 @@ package es.verdnatura.di import es.verdnatura.presentation.view.feature.ajustes.fragment.AjustesViewModel import es.verdnatura.presentation.view.feature.articulo.fragment.ItemCardViewModel import es.verdnatura.presentation.view.feature.buscaritem.fragment.BuscarItemViewModel +import es.verdnatura.presentation.view.feature.calidad.fragment.BuyersViewModel +import es.verdnatura.presentation.view.feature.calidad.fragment.QaualityViewModel import es.verdnatura.presentation.view.feature.collection.fragment.CollectionViewModel import es.verdnatura.presentation.view.feature.controlador.fragment.ControladorViewModel import es.verdnatura.presentation.view.feature.faltas.fragment.FaltasViewModel @@ -120,4 +122,12 @@ val viewModelModule = module{ viewModel { ReposicionViewModel() } + + viewModel { + BuyersViewModel() + } + + viewModel { + QaualityViewModel() + } } \ No newline at end of file diff --git a/app/src/main/java/es/verdnatura/domain/ApiUtils.kt b/app/src/main/java/es/verdnatura/domain/ApiUtils.kt index 66caddec..d3a3b4ac 100644 --- a/app/src/main/java/es/verdnatura/domain/ApiUtils.kt +++ b/app/src/main/java/es/verdnatura/domain/ApiUtils.kt @@ -8,7 +8,7 @@ import java.util.concurrent.TimeUnit class ApiUtils { companion object { - // const val BASE_URL:String = "http://192.168.1.54:8009/" + //const val BASE_URL:String = "http://192.168.1.54:8009/" const val BASE_URL:String = "https://app.verdnatura.es/" fun getApiService():VerdnaturaService{ val retrofit = Retrofit.Builder() diff --git a/app/src/main/java/es/verdnatura/domain/GetQualityUserCase.kt b/app/src/main/java/es/verdnatura/domain/GetQualityUserCase.kt new file mode 100644 index 00000000..bbf260fb --- /dev/null +++ b/app/src/main/java/es/verdnatura/domain/GetQualityUserCase.kt @@ -0,0 +1,25 @@ +package es.verdnatura.domain + +import es.verdnatura.presentation.view.feature.calidad.model.BuyerVO +import es.verdnatura.presentation.view.feature.calidad.model.ItemBuyerVO +import retrofit2.Call + +class GetQualityUserCase() : RestClient() { + + fun itemShelvingBuyerGet(usuario:String,password:String) : Call> { + return restClient!!.itemShelvingBuyerGet("json","1",usuario,password,"application/json") + } + + fun itemShelvingBuyerTask(usuario:String,password:String, userFk: String) : Call> { + val params:ArrayList = ArrayList(); + params.add(userFk) + return restClient!!.itemShelvingBuyerTask("json","1",usuario,password,"application/json",params) + } + + fun itemShelvingStarsUpdate(usuario:String,password:String, vId: String,vStars: String) : Call { + val params:ArrayList = ArrayList(); + params.add(vId) + params.add(vStars) + return restClient!!.itemShelvingStarsUpdate("json","1",usuario,password,"application/json",params) + } +} \ No newline at end of file diff --git a/app/src/main/java/es/verdnatura/domain/VerdnaturaService.kt b/app/src/main/java/es/verdnatura/domain/VerdnaturaService.kt index 8dc6dea9..5b7426df 100644 --- a/app/src/main/java/es/verdnatura/domain/VerdnaturaService.kt +++ b/app/src/main/java/es/verdnatura/domain/VerdnaturaService.kt @@ -5,6 +5,8 @@ package es.verdnatura.domain import es.verdnatura.presentation.view.feature.ajustes.model.SectorItemVO import es.verdnatura.presentation.view.feature.articulo.model.ItemCardVO import es.verdnatura.presentation.view.feature.buscaritem.model.ItemLocationVO +import es.verdnatura.presentation.view.feature.calidad.model.BuyerVO +import es.verdnatura.presentation.view.feature.calidad.model.ItemBuyerVO import es.verdnatura.presentation.view.feature.collection.ItemVO import es.verdnatura.presentation.view.feature.faltas.model.ItemFaltasVO import es.verdnatura.presentation.view.feature.historico.model.ItemHistoricoVO @@ -14,7 +16,6 @@ import es.verdnatura.presentation.view.feature.presacador.model.PreSacadorItemVO import es.verdnatura.presentation.view.feature.sacador.model.CollectionVO import es.verdnatura.presentation.view.feature.sacador.model.MistakeTypeVO import es.verdnatura.presentation.view.feature.sacador.model.PlacementSupplyVO -import es.verdnatura.presentation.view.feature.sacador.model.PlacementVO import es.verdnatura.presentation.view.feature.shelvingparking.model.ItemShelvingParkingVO import es.verdnatura.presentation.view.feature.ubicador.model.ItemUbicadorVO import retrofit2.Call @@ -567,4 +568,31 @@ interface VerdnaturaService { @Body params: List): Call + + //CALIDAD + @POST("almacennew/itemShelvingBuyerGet") + fun itemShelvingBuyerGet(@Header("aplicacion") aplicacion: String, + @Header("version") version: String, + @Header("user") user: String, + @Header("pass") pass: String, + @Header("Content-Type") content_type: String): + Call> + + @POST("almacennew/itemShelvingBuyerTask") + fun itemShelvingBuyerTask(@Header("aplicacion") aplicacion: String, + @Header("version") version: String, + @Header("user") user: String, + @Header("pass") pass: String, + @Header("Content-Type") content_type: String, + @Body params: List): + Call> + + @POST("almacennew/itemShelvingStarsUpdate") + fun itemShelvingStarsUpdate(@Header("aplicacion") aplicacion: String, + @Header("version") version: String, + @Header("user") user: String, + @Header("pass") pass: String, + @Header("Content-Type") content_type: String, + @Body params: List): + Call } \ No newline at end of file diff --git a/app/src/main/java/es/verdnatura/presentation/base/BaseFragment.kt b/app/src/main/java/es/verdnatura/presentation/base/BaseFragment.kt index bfedec61..e15c81a5 100644 --- a/app/src/main/java/es/verdnatura/presentation/base/BaseFragment.kt +++ b/app/src/main/java/es/verdnatura/presentation/base/BaseFragment.kt @@ -1,7 +1,6 @@ package es.verdnatura.presentation.base import android.Manifest -import android.Manifest.permission import android.content.Context import android.content.Intent import android.content.pm.PackageManager @@ -18,7 +17,6 @@ import android.view.LayoutInflater import android.view.View import android.view.ViewGroup import androidx.annotation.LayoutRes -import androidx.core.content.PermissionChecker.checkCallingOrSelfPermission import androidx.databinding.DataBindingUtil import androidx.databinding.ViewDataBinding import androidx.fragment.app.Fragment @@ -47,6 +45,7 @@ abstract class BaseFragment(viewModelCla protected val VOZ = "voz" protected val viewModel: V by viewModel(viewModelClass) protected lateinit var binding: T + private var isOnReadyForSpeech = false private var textToSpeech: TextToSpeech? = null @@ -117,6 +116,7 @@ abstract class BaseFragment(viewModelCla ) mSpeechRecognizerIntent!!.putExtra(RecognizerIntent.EXTRA_PREFER_OFFLINE, true) mSpeechRecognizer?.setRecognitionListener(this) + isOnReadyForSpeech = false; startListening() }catch (e:Exception){ cancelSpeech() @@ -191,7 +191,9 @@ abstract class BaseFragment(viewModelCla override fun onReadyForSpeech(params: Bundle?) { + isOnReadyForSpeech = true; Log.i("Speech", "onReadyForSpeech") + "onReadyForSpeech".toast(requireContext()) } override fun onBeginningOfSpeech() { @@ -209,10 +211,16 @@ abstract class BaseFragment(viewModelCla } override fun onError(error: Int) { - Log.i("Speech", "onError "+error) - if (mSpeechRecognizer != null) mSpeechRecognizer!!.destroy() - mSpeechRecognizer = null - initialize() + if (!isOnReadyForSpeech && error == SpeechRecognizer.ERROR_NO_MATCH) { + startListening() + }else{ + Log.i("Speech", "onError "+error) + ("onError "+error).toast(requireContext()) + if (mSpeechRecognizer != null) mSpeechRecognizer!!.destroy() + mSpeechRecognizer = null + initialize() + } + } override fun onResults(results: Bundle) {} @@ -285,7 +293,10 @@ abstract class BaseFragment(viewModelCla } } val numChar = a.length - return count * 100 / numChar + if (numChar != 0) + return count * 100 / numChar + else + return 100 } private fun requestRecordAudioPermission() { diff --git a/app/src/main/java/es/verdnatura/presentation/common/UICallbacks.kt b/app/src/main/java/es/verdnatura/presentation/common/UICallbacks.kt index 5cece799..6d59c112 100644 --- a/app/src/main/java/es/verdnatura/presentation/common/UICallbacks.kt +++ b/app/src/main/java/es/verdnatura/presentation/common/UICallbacks.kt @@ -94,4 +94,12 @@ interface OnSaleClickListener { interface OnMistakeClickListener { fun onMistakeClickListener(sale:SaleVO) +} + +interface OnBuyerSelectedListener { + fun onBuyerSelected(userFk:String) +} + +interface OnStarSelectedListener { + fun onStarSelected(vId:String, vStars:String) } \ No newline at end of file diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/calidad/adapter/ItemBuyersAdapter.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/calidad/adapter/ItemBuyersAdapter.kt new file mode 100644 index 00000000..5da2a6fc --- /dev/null +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/calidad/adapter/ItemBuyersAdapter.kt @@ -0,0 +1,124 @@ +package es.verdnatura.presentation.view.feature.calidad.adapter + +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup +import androidx.recyclerview.widget.RecyclerView +import es.verdnatura.databinding.ItemBuyerRowBinding +import es.verdnatura.presentation.common.OnPasillerosItemClickListener +import es.verdnatura.presentation.common.OnStarSelectedListener +import es.verdnatura.presentation.common.convertToDateString +import es.verdnatura.presentation.common.loadUrl +import es.verdnatura.presentation.view.feature.calidad.model.ItemBuyerVO +import es.verdnatura.presentation.view.feature.pasillero.model.PasillerosItemVO +import java.text.SimpleDateFormat +import java.util.* + +class ItemBuyersAdapter ( + private val items: List, + private val onPasillerosItemClickListener: OnPasillerosItemClickListener, + private val onStarSelectedListener: OnStarSelectedListener +): RecyclerView.Adapter () { + + + override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): BuyersItemHolder { + return BuyersItemHolder( + ItemBuyerRowBinding.inflate(LayoutInflater.from(parent.context),parent,false) + ) + } + + override fun getItemCount() =items.size + + override fun onBindViewHolder(holder: BuyersItemHolder, position: Int) { + holder.bind(items[position]) + + } + + + inner class BuyersItemHolder( + val binding: ItemBuyerRowBinding + ) : RecyclerView.ViewHolder(binding.root){ + fun bind(item: ItemBuyerVO) { + binding.apply { + this.itemBuyer = item + if (item != null && item.image != "") + imgItem.loadUrl("https://verdnatura.es/vn-image-data/catalog/200x200/"+item.image); + else + imgItem.loadUrl("https://verdnatura.es/vn-image-data/catalog/200x200/"+item.itemFk); + + imgItem.setOnClickListener { + onPasillerosItemClickListener.onPasillerosItemClickListener(PasillerosItemVO(title = "Consultar artículo"),item.itemFk) + } + + if (item.showStars) layoutStars.visibility = View.VISIBLE + else layoutStars.visibility = View.GONE + + + s1.setOnClickListener { + onStarSelectedListener.onStarSelected(item.id,"1") + } + + s2.setOnClickListener { + onStarSelectedListener.onStarSelected(item.id,"2") + } + + s3.setOnClickListener { + onStarSelectedListener.onStarSelected(item.id,"3") + } + + s4.setOnClickListener { + onStarSelectedListener.onStarSelected(item.id,"4") + } + + s5.setOnClickListener { + onStarSelectedListener.onStarSelected(item.id,"5") + } + + if (item.stars != null && item.stars != ""){ + try { + val punt = item.stars.toInt() + if (punt == 1){ + s1.setImageResource(item.iconResourceOk) + s2.setImageResource(item.iconResourceKo) + s3.setImageResource(item.iconResourceKo) + s4.setImageResource(item.iconResourceKo) + s5.setImageResource(item.iconResourceKo) + }else if (punt == 2){ + s1.setImageResource(item.iconResourceOk) + s2.setImageResource(item.iconResourceOk) + s3.setImageResource(item.iconResourceKo) + s4.setImageResource(item.iconResourceKo) + s5.setImageResource(item.iconResourceKo) + }else if (punt == 3){ + s1.setImageResource(item.iconResourceOk) + s2.setImageResource(item.iconResourceOk) + s3.setImageResource(item.iconResourceOk) + s4.setImageResource(item.iconResourceKo) + s5.setImageResource(item.iconResourceKo) + }else if (punt == 4){ + s1.setImageResource(item.iconResourceOk) + s2.setImageResource(item.iconResourceOk) + s3.setImageResource(item.iconResourceOk) + s4.setImageResource(item.iconResourceOk) + s5.setImageResource(item.iconResourceKo) + }else if (punt == 5){ + s1.setImageResource(item.iconResourceOk) + s2.setImageResource(item.iconResourceOk) + s3.setImageResource(item.iconResourceOk) + s4.setImageResource(item.iconResourceOk) + s5.setImageResource(item.iconResourceOk) + }else{ + s1.setImageResource(item.iconResourceOk) + s2.setImageResource(item.iconResourceOk) + s3.setImageResource(item.iconResourceOk) + s4.setImageResource(item.iconResourceOk) + s5.setImageResource(item.iconResourceOk) + } + }catch (e:Exception){} + } + } + } + + + } +} \ No newline at end of file diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/calidad/fragment/BuyersFragment.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/calidad/fragment/BuyersFragment.kt new file mode 100644 index 00000000..14943cd3 --- /dev/null +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/calidad/fragment/BuyersFragment.kt @@ -0,0 +1,127 @@ +package es.verdnatura.presentation.view.feature.calidad.fragment + +import android.content.Context +import android.content.SharedPreferences +import android.graphics.drawable.Drawable +import android.os.Bundle +import android.view.View +import androidx.lifecycle.Observer +import androidx.recyclerview.widget.LinearLayoutManager +import es.verdnatura.R +import es.verdnatura.databinding.BuyersFragmentBinding +import es.verdnatura.domain.toast +import es.verdnatura.presentation.base.BaseFragment +import es.verdnatura.presentation.common.OnAjustesItemClickListener +import es.verdnatura.presentation.common.OnBuyerSelectedListener +import es.verdnatura.presentation.common.OnOptionsSelectedListener +import es.verdnatura.presentation.common.OnPasillerosItemClickListener +import es.verdnatura.presentation.view.component.CustomDialog +import es.verdnatura.presentation.view.feature.ajustes.adapter.AjustesAdapter +import es.verdnatura.presentation.view.feature.ajustes.model.AjustesItemVO +import es.verdnatura.presentation.view.feature.calidad.model.BuyerVO +import es.verdnatura.presentation.view.feature.inventario.adapter.ToolBarAdapter +import kotlinx.android.synthetic.main.activity_main.* +import kotlinx.android.synthetic.main.buyers_fragment.* +import kotlinx.android.synthetic.main.buyers_fragment.splash_progress +import kotlinx.android.synthetic.main.fragment_ajustes.* +import kotlinx.android.synthetic.main.toolbar.* + +class BuyersFragment : BaseFragment(BuyersViewModel::class) { + + + private var user = "" + private var password = "" + private var sectorFk = "" + private var warehouseFk = "" + private lateinit var customDialog: CustomDialog + private var onBuyerSelectedListener : OnBuyerSelectedListener? = null + private var buyersAdapter: AjustesAdapter? = null + + companion object { + fun newInstance() = BuyersFragment() + } + + override fun getLayoutId(): Int = R.layout.buyers_fragment + + override fun onAttach(context: Context) { + if (context is OnBuyerSelectedListener) onBuyerSelectedListener = context + super.onAttach(context) + } + + override fun onCreate(savedInstanceState: Bundle?) { + val prefs: SharedPreferences = activity!!.getSharedPreferences(PREFS_USER,0) + user = prefs.getString(USER,"").toString() + password = prefs.getString(PASSWORD,"").toString() + sectorFk = prefs.getInt(SECTORFK,1).toString() + warehouseFk = prefs.getInt(WAREHOUSEFK,1).toString() + viewModel.itemShelvingBuyerGet(user = user,password = password) + super.onCreate(savedInstanceState) + } + + override fun init() { + customDialog = CustomDialog(requireContext()) + activity!!.main_bottom_navigation.visibility = View.GONE + splash_progress.visibility = View.VISIBLE + toolbar_title.text = "itemShelving_BuyerGet" + setToolBar() + setEvents() + super.init() + } + + private fun setToolBar(){ + val listIcons:ArrayList = ArrayList() + val iconReload : Drawable = resources.getDrawable(R.drawable.ic_autorenew_black_24dp,resources.newTheme()) + listIcons.add(iconReload) + toolbar_icons.adapter = ToolBarAdapter(listIcons,object: OnOptionsSelectedListener { + override fun onOptionsItemSelected(item: Drawable) { + if (item == iconReload){ + splash_progress.visibility = View.VISIBLE + viewModel.itemShelvingBuyerGet(user = user,password = password) + + } + } + }) + toolbar_icons.layoutManager = LinearLayoutManager(requireContext(), LinearLayoutManager.HORIZONTAL, false) + } + + private fun setEvents(){ + backButton.setOnClickListener { + activity!!.onBackPressed() + } + } + + override fun observeViewModel() { + with(viewModel) { + buyersList.observe(viewLifecycleOwner, Observer { + splash_progress.visibility = View.GONE + createBuyerList(it.list) + }) + } + } + + private fun createBuyerList(list:List){ + var buyers = ArrayList() + list.forEach { buyer -> + if (!buyer.isError){ + try { + buyers.add( + AjustesItemVO( + id = buyer.userFk.toInt(), + title = buyer.nickname, + sectorFk = 0, + warehouse = 0 + ) + ) + }catch (e:Exception){} + } + } + buyersAdapter = AjustesAdapter(buyers,object: OnAjustesItemClickListener { + override fun onAjustesItemClickListener(item: AjustesItemVO) { + onBuyerSelectedListener?.onBuyerSelected(item.id.toString()) + } + }) + buyers_items.adapter = buyersAdapter + buyers_items.layoutManager = LinearLayoutManager(requireContext(), LinearLayoutManager.VERTICAL, false) + } + +} \ No newline at end of file diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/calidad/fragment/BuyersViewModel.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/calidad/fragment/BuyersViewModel.kt new file mode 100644 index 00000000..d1ae0db4 --- /dev/null +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/calidad/fragment/BuyersViewModel.kt @@ -0,0 +1,48 @@ +package es.verdnatura.presentation.view.feature.calidad.fragment + +import androidx.lifecycle.LiveData +import androidx.lifecycle.MutableLiveData +import es.verdnatura.domain.GetQualityUserCase +import es.verdnatura.presentation.base.BaseViewModel +import es.verdnatura.presentation.view.feature.calidad.model.BuyerListVO +import es.verdnatura.presentation.view.feature.calidad.model.BuyerVO +import es.verdnatura.presentation.view.feature.inventario.model.InventaryListVO +import es.verdnatura.presentation.view.feature.inventario.model.ItemInventaryVO +import retrofit2.Call +import retrofit2.Callback +import retrofit2.Response + +class BuyersViewModel : BaseViewModel() { + + private val getQualityUserCase: GetQualityUserCase = GetQualityUserCase() + + private val _buyersList by lazy { MutableLiveData() } + val buyersList: LiveData + get() = _buyersList + + fun itemShelvingBuyerGet(user:String,password:String){ + getQualityUserCase.itemShelvingBuyerGet(user,password).enqueue(object : + Callback> { + override fun onFailure(call: Call>, t: Throwable) { + val listError:ArrayList = ArrayList() + listError.add(BuyerVO(isError = true,errorMessage = t.message!!)) + _buyersList.value = BuyerListVO(listError) + } + + override fun onResponse( + call: Call>, + response: Response> + ) { + if (response.body() != null){ + _buyersList.value = response.body()?.let { BuyerListVO(it) } + }else{ + val listError:ArrayList = ArrayList() + listError.add(BuyerVO(isError = true,errorMessage = "Error en la llamada de itemShelving_buyerGet")) + _buyersList.value = BuyerListVO(listError) + } + } + + }) + } + +} \ No newline at end of file diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/calidad/fragment/QaualityFragment.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/calidad/fragment/QaualityFragment.kt new file mode 100644 index 00000000..6fcc818e --- /dev/null +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/calidad/fragment/QaualityFragment.kt @@ -0,0 +1,211 @@ +package es.verdnatura.presentation.view.feature.calidad.fragment + +import android.content.Context +import android.content.SharedPreferences +import android.graphics.drawable.Drawable +import android.os.Bundle +import android.view.View +import android.view.inputmethod.EditorInfo +import androidx.lifecycle.Observer +import androidx.recyclerview.widget.LinearLayoutManager +import es.verdnatura.R +import es.verdnatura.databinding.QaualityFragmentBinding +import es.verdnatura.presentation.base.BaseFragment +import es.verdnatura.presentation.common.* +import es.verdnatura.presentation.view.component.CustomDialog +import es.verdnatura.presentation.view.feature.calidad.adapter.ItemBuyersAdapter +import es.verdnatura.presentation.view.feature.calidad.model.ItemBuyerVO +import es.verdnatura.presentation.view.feature.inventario.adapter.ToolBarAdapter +import kotlinx.android.synthetic.main.activity_main.* +import kotlinx.android.synthetic.main.fragment_collection.* +import kotlinx.android.synthetic.main.qauality_fragment.* +import kotlinx.android.synthetic.main.qauality_fragment.scan_input +import kotlinx.android.synthetic.main.qauality_fragment.splash_progress +import kotlinx.android.synthetic.main.toolbar.* +import java.text.SimpleDateFormat +import java.util.* +import kotlin.collections.ArrayList + +class QaualityFragment( + var userFk : String = "0" +) : BaseFragment(QaualityViewModel::class) { + + private var user = "" + private var password = "" + private var sectorFk = "" + private var warehouseFk = "" + private lateinit var customDialog: CustomDialog + private var buyersAdapter: ItemBuyersAdapter? = null + private var pasillerosItemClickListener: OnPasillerosItemClickListener? = null + private var onStarSelectedListener : OnStarSelectedListener? = null + private var listItems:List = listOf() + private var lm : LinearLayoutManager? = null + private var storedPosition: Int = 0 + private var goBack:Boolean = false + + + companion object { + fun newInstance(userFk:String) = QaualityFragment(userFk) + } + + override fun onAttach(context: Context) { + if (context is OnPasillerosItemClickListener) pasillerosItemClickListener = context + super.onAttach(context) + } + + override fun getLayoutId(): Int = R.layout.qauality_fragment + + override fun onCreate(savedInstanceState: Bundle?) { + val prefs: SharedPreferences = activity!!.getSharedPreferences(PREFS_USER,0) + user = prefs.getString(USER,"").toString() + password = prefs.getString(PASSWORD,"").toString() + sectorFk = prefs.getInt(SECTORFK,1).toString() + warehouseFk = prefs.getInt(WAREHOUSEFK,1).toString() + viewModel.itemShelvingBuyerTask(user = user,password = password,userFk = userFk) + super.onCreate(savedInstanceState) + } + + override fun init() { + customDialog = CustomDialog(requireContext()) + activity!!.main_bottom_navigation.visibility = View.GONE + splash_progress.visibility = View.VISIBLE + toolbar_title.text = "itemShelving_BuyerTask" + setToolBar() + setEvents() + super.init() + } + + override fun onPause() { + super.onPause() + goBack = true + storedPosition = lm?.findFirstVisibleItemPosition() ?: 0 + } + + private fun setToolBar(){ + val listIcons:ArrayList = ArrayList() + val iconReload : Drawable = resources.getDrawable(R.drawable.ic_autorenew_black_24dp,resources.newTheme()) + listIcons.add(iconReload) + toolbar_icons.adapter = ToolBarAdapter(listIcons,object: OnOptionsSelectedListener { + override fun onOptionsItemSelected(item: Drawable) { + if (item == iconReload){ + splash_progress.visibility = View.VISIBLE + viewModel.itemShelvingBuyerTask(user = user,password = password,userFk = userFk) + } + } + }) + toolbar_icons.layoutManager = LinearLayoutManager(requireContext(), LinearLayoutManager.HORIZONTAL, false) + } + + private fun setEvents(){ + backButton.setOnClickListener { + activity!!.onBackPressed() + } + + //ESCANER ========= + hideKeyboards() + scan_input.requestFocus() + scan_input.setOnEditorActionListener { v, actionId, event -> + if (actionId == EditorInfo.IME_ACTION_SEARCH || actionId == EditorInfo.IME_ACTION_DONE || actionId == 0 || actionId == 5) { + if (!scan_input.text.toString().isNullOrEmpty()){ + findSale(scan_input.text.toString()) + } + scan_input.setText("") + hideKeyboards() + return@setOnEditorActionListener true + } + true + } + } + + private fun hideKeyboards(){ + try{ + requireActivity().hideKeyboard() + }catch (e:Exception){} + } + + override fun observeViewModel() { + with(viewModel) { + buyersList.observe(viewLifecycleOwner, Observer { + splash_progress.visibility = View.GONE + createBuyerList(it.list) + }) + + response.observe(viewLifecycleOwner, Observer { + viewModel.itemShelvingBuyerTask(user = user,password = password,userFk = userFk) + }) + } + } + + private fun createBuyerList(list:List){ + list.forEach { item -> + if (!goBack){ + if (item.created != null && item.created != ""){ + item.created = getCalendarFromDate(item.created).convertToDateString() + } + } + + if (item.visible.contains("Visible:",ignoreCase = true)){ + item.visible = item.visible + }else{ + item.visible = "Visible: "+item.visible + } + + item.iconResourceOk = R.drawable.ic_start_ok + item.iconResourceKo = R.drawable.ic_star_ko + } + goBack = false + listItems = list + buyersAdapter = ItemBuyersAdapter(listItems,pasillerosItemClickListener!!,object: OnStarSelectedListener{ + override fun onStarSelected(vId: String, vStars: String) { + splash_progress.visibility = View.VISIBLE + viewModel.itemShelvingStarsUpdate(user,password,vId,vStars) + } + + }) + shelving_buyers_items.adapter = buyersAdapter + lm = LinearLayoutManager(requireContext(), LinearLayoutManager.VERTICAL, false) + shelving_buyers_items.layoutManager = lm + + if (storedPosition < listItems.size) + goToPosition(storedPosition) + } + + private fun getCalendarFromDate(date:String): Calendar { + val sdf = SimpleDateFormat("yyyy-MM-dd") + val cal = Calendar.getInstance() + cal.setTime(sdf.parse(date)) + return cal + } + + private fun findSale(matricula:String){ + var isSearch = false + var index = 0 + var position = 0 + listItems.forEach { item -> + if (item.shelvingFk.toUpperCase() == matricula.toUpperCase()){ + item.showStars = true + if (!isSearch){ + position = index + isSearch = true + } + }else{ + item.showStars = false + } + index += 1 + } + + storedPosition = position + goToPosition(position) + + buyersAdapter?.notifyDataSetChanged() + } + + private fun goToPosition(position:Int){ + if (shelving_buyers_items != null){ + shelving_buyers_items.addViewObserver { + lm!!.scrollToPositionWithOffset(position,0) + } + } + } + +} \ No newline at end of file diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/calidad/fragment/QaualityViewModel.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/calidad/fragment/QaualityViewModel.kt new file mode 100644 index 00000000..a86a866c --- /dev/null +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/calidad/fragment/QaualityViewModel.kt @@ -0,0 +1,70 @@ +package es.verdnatura.presentation.view.feature.calidad.fragment + +import androidx.lifecycle.LiveData +import androidx.lifecycle.MutableLiveData +import es.verdnatura.domain.GetQualityUserCase +import es.verdnatura.presentation.base.BaseViewModel +import es.verdnatura.presentation.common.ResponseItemVO +import es.verdnatura.presentation.view.feature.calidad.model.BuyerListVO +import es.verdnatura.presentation.view.feature.calidad.model.BuyerVO +import es.verdnatura.presentation.view.feature.calidad.model.ItemBuyerListVO +import es.verdnatura.presentation.view.feature.calidad.model.ItemBuyerVO +import retrofit2.Call +import retrofit2.Callback +import retrofit2.Response + +class QaualityViewModel : BaseViewModel() { + + private val getQualityUserCase: GetQualityUserCase = GetQualityUserCase() + + private val _buyersList by lazy { MutableLiveData() } + val buyersList: LiveData + get() = _buyersList + + + private val _response by lazy { MutableLiveData() } + val response: LiveData + get() = _response + + + fun itemShelvingBuyerTask(user:String,password:String,userFk:String){ + getQualityUserCase.itemShelvingBuyerTask(user,password,userFk).enqueue(object : + Callback> { + override fun onFailure(call: Call>, t: Throwable) { + val listError:ArrayList = ArrayList() + listError.add(ItemBuyerVO(isError = true,errorMessage = t.message!!)) + _buyersList.value = ItemBuyerListVO(listError) + } + + override fun onResponse( + call: Call>, + response: Response> + ) { + if (response.body() != null){ + _buyersList.value = response.body()?.let { ItemBuyerListVO(it) } + }else{ + val listError:ArrayList = ArrayList() + listError.add(ItemBuyerVO(isError = true,errorMessage = "Error en la llamada de itemShelvingBuyerTask")) + _buyersList.value = ItemBuyerListVO(listError) + } + } + + }) + } + + fun itemShelvingStarsUpdate(usuario:String,password:String, vId: String,vStars: String) { + getQualityUserCase.itemShelvingStarsUpdate(usuario,password,vId,vStars).enqueue(object : Callback{ + override fun onFailure(call: Call, t: Throwable) { + _response.value = ResponseItemVO(isError = true,errorMessage = ""+t.message!!) + } + + override fun onResponse(call: Call, response: Response) { + if (response.body() == null){ + _response.value = ResponseItemVO(isError = true,errorMessage = "Error en la llamada itemShelvingStarsUpdate") + }else{ + _response.value = ResponseItemVO(isError = false,response = response.body()!!) + } + } + }) + } +} \ No newline at end of file diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/calidad/model/BuyerVO.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/calidad/model/BuyerVO.kt new file mode 100644 index 00000000..efbc2495 --- /dev/null +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/calidad/model/BuyerVO.kt @@ -0,0 +1,36 @@ +package es.verdnatura.presentation.view.feature.calidad.model + +import es.verdnatura.presentation.view.feature.inventario.model.ItemInventaryVO + +class BuyerVO ( + var userFk:String = "", + var nickname:String= "", + var isError:Boolean = false, + var errorMessage:String = "" +) + + +class BuyerListVO ( + var list: List = listOf() +) + +class ItemBuyerVO ( + var id:String = "", + var itemFk:String = "", + var longName:String = "", + var image:String = "", + var parking:String = "", + var shelvingFk:String = "", + var visible:String = "", + var created:String = "", + var stars:String = "", + var isError:Boolean = false, + var errorMessage:String = "", + var showStars:Boolean = false, + var iconResourceOk: Int = 0, + var iconResourceKo: Int = 0 +) + +class ItemBuyerListVO( + var list: List = listOf() +) diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/collection/fragment/CollectionViewModel.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/collection/fragment/CollectionViewModel.kt index 27022ca0..0a3bda73 100644 --- a/app/src/main/java/es/verdnatura/presentation/view/feature/collection/fragment/CollectionViewModel.kt +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/collection/fragment/CollectionViewModel.kt @@ -10,7 +10,6 @@ import es.verdnatura.presentation.base.BaseViewModel import es.verdnatura.presentation.common.ResponseItemVO import es.verdnatura.presentation.view.feature.collection.ItemVO import es.verdnatura.presentation.view.feature.collection.mapper.map -import es.verdnatura.presentation.view.feature.login.model.SalixMessageVO import es.verdnatura.presentation.view.feature.sacador.model.* import retrofit2.Call import retrofit2.Callback diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/controlador/fragment/ControladorViewModel.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/controlador/fragment/ControladorViewModel.kt index 5d828b7e..53ee7a7b 100644 --- a/app/src/main/java/es/verdnatura/presentation/view/feature/controlador/fragment/ControladorViewModel.kt +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/controlador/fragment/ControladorViewModel.kt @@ -4,11 +4,8 @@ import androidx.lifecycle.LiveData import androidx.lifecycle.MutableLiveData import es.verdnatura.domain.GetSacadorControladorUserCase import es.verdnatura.presentation.base.BaseViewModel -import es.verdnatura.presentation.common.ResponseItemVO 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 retrofit2.Call import retrofit2.Callback import retrofit2.Response diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/login/activity/LoginActivity.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/login/activity/LoginActivity.kt index 34a10af8..244977c4 100644 --- a/app/src/main/java/es/verdnatura/presentation/view/feature/login/activity/LoginActivity.kt +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/login/activity/LoginActivity.kt @@ -1,7 +1,5 @@ package es.verdnatura.presentation.view.feature.login.activity -import android.view.ViewGroup -import android.widget.Button import es.verdnatura.R import es.verdnatura.databinding.ActivityLoginBinding import es.verdnatura.presentation.base.BaseActivity diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/main/activity/MainActivity.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/main/activity/MainActivity.kt index b3709337..94349375 100644 --- a/app/src/main/java/es/verdnatura/presentation/view/feature/main/activity/MainActivity.kt +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/main/activity/MainActivity.kt @@ -14,6 +14,8 @@ import es.verdnatura.presentation.view.component.CustomDialog import es.verdnatura.presentation.view.feature.ajustes.fragment.AjustesFragment import es.verdnatura.presentation.view.feature.articulo.fragment.ItemCardFragment import es.verdnatura.presentation.view.feature.buscaritem.fragment.BuscarItemFragment +import es.verdnatura.presentation.view.feature.calidad.fragment.BuyersFragment +import es.verdnatura.presentation.view.feature.calidad.fragment.QaualityFragment import es.verdnatura.presentation.view.feature.collection.fragment.CollectionFragment import es.verdnatura.presentation.view.feature.controlador.fragment.ControladorFragment import es.verdnatura.presentation.view.feature.faltas.fragment.FaltasFragment @@ -43,7 +45,7 @@ import kotlinx.coroutines.launch class MainActivity : BaseActivity() , OnPasillerosItemClickListener, - OnTruckClickListener, OnPalletClickListener,OnComprobarPalletViewClickListener,OnCollectionSelectedListener { + OnTruckClickListener, OnPalletClickListener,OnComprobarPalletViewClickListener,OnCollectionSelectedListener,OnBuyerSelectedListener { private var lastBottomMenuItemSelected: ItemMenuVO? = null private lateinit var customDialog: CustomDialog @@ -199,6 +201,9 @@ class MainActivity : BaseActivity() , OnPasillerosItemClick "Automatic" -> { addFragmentOnTop(AutomaticAddItemFragment.newInstance(entryPoint)) } + "Calidad" -> { + addFragmentOnTop(BuyersFragment.newInstance()) + } } Log.i("Item: ",item.title) } @@ -251,4 +256,8 @@ class MainActivity : BaseActivity() , OnPasillerosItemClick addFragmentOnTop(CollectionFragment.newInstance(collection,type)) } + override fun onBuyerSelected(userFk: String) { + addFragmentOnTop(QaualityFragment.newInstance(userFk)) + } + } diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/pasillero/fragment/PasilleroViewModel.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/pasillero/fragment/PasilleroViewModel.kt index f09ca5f8..ae94169a 100644 --- a/app/src/main/java/es/verdnatura/presentation/view/feature/pasillero/fragment/PasilleroViewModel.kt +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/pasillero/fragment/PasilleroViewModel.kt @@ -1,7 +1,6 @@ package es.verdnatura.presentation.view.feature.pasillero.fragment -import android.app.Application import es.verdnatura.R import es.verdnatura.presentation.base.BaseViewModel import es.verdnatura.presentation.view.feature.pasillero.model.PasillerosItemVO @@ -68,6 +67,12 @@ class PasilleroViewModel : BaseViewModel() { "Shelving Parking",R.string.ShelvingParking) ) + _pasillerositem.add( + PasillerosItemVO(8, + R.drawable.ic_baseline_star_24, + "Calidad",R.string.Calidad) + ) + } diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/presacador/fragment/PreSacadorFragment.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/presacador/fragment/PreSacadorFragment.kt index bfd495fb..58257b39 100644 --- a/app/src/main/java/es/verdnatura/presentation/view/feature/presacador/fragment/PreSacadorFragment.kt +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/presacador/fragment/PreSacadorFragment.kt @@ -166,7 +166,9 @@ class PreSacadorFragment : BaseFragment( diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/ubicador/fragment/AutomaticAddItemFragment.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/ubicador/fragment/AutomaticAddItemFragment.kt index db489dcf..3926d8c9 100644 --- a/app/src/main/java/es/verdnatura/presentation/view/feature/ubicador/fragment/AutomaticAddItemFragment.kt +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/ubicador/fragment/AutomaticAddItemFragment.kt @@ -1,7 +1,6 @@ package es.verdnatura.presentation.view.feature.ubicador.fragment import android.content.SharedPreferences -import android.graphics.drawable.Drawable import android.view.View import android.view.inputmethod.EditorInfo import androidx.lifecycle.Observer @@ -10,11 +9,9 @@ import es.verdnatura.R import es.verdnatura.databinding.FragmentAutomaticAddItemBinding import es.verdnatura.presentation.base.BaseFragment import es.verdnatura.presentation.common.OnAutomaticItemClickListener -import es.verdnatura.presentation.common.OnOptionsSelectedListener import es.verdnatura.presentation.view.component.CustomDialog import es.verdnatura.presentation.view.component.CustomDialogInput import es.verdnatura.presentation.view.component.CustomDialogUbicador -import es.verdnatura.presentation.view.feature.inventario.adapter.ToolBarAdapter import es.verdnatura.presentation.view.feature.main.activity.MainActivity import es.verdnatura.presentation.view.feature.ubicador.adapter.AutomaticAdapter import es.verdnatura.presentation.view.feature.ubicador.model.ItemEscanerVO diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/ubicador/fragment/UbicadorFragment.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/ubicador/fragment/UbicadorFragment.kt index 691405b2..caacc7b3 100644 --- a/app/src/main/java/es/verdnatura/presentation/view/feature/ubicador/fragment/UbicadorFragment.kt +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/ubicador/fragment/UbicadorFragment.kt @@ -29,9 +29,7 @@ import es.verdnatura.presentation.view.feature.pasillero.model.PasillerosItemVO import es.verdnatura.presentation.view.feature.ubicador.adapter.UbicadorAdapter import es.verdnatura.presentation.view.feature.ubicador.model.ItemUbicadorVO import kotlinx.android.synthetic.main.activity_main.* -import kotlinx.android.synthetic.main.fragment_collection.* import kotlinx.android.synthetic.main.fragment_ubicador.* -import kotlinx.android.synthetic.main.fragment_ubicador.splash_progress import kotlinx.android.synthetic.main.toolbar.* class UbicadorFragment( diff --git a/app/src/main/res/drawable/ic_baseline_star_24.xml b/app/src/main/res/drawable/ic_baseline_star_24.xml new file mode 100644 index 00000000..2cca397f --- /dev/null +++ b/app/src/main/res/drawable/ic_baseline_star_24.xml @@ -0,0 +1,5 @@ + + + diff --git a/app/src/main/res/drawable/ic_star_ko.xml b/app/src/main/res/drawable/ic_star_ko.xml new file mode 100644 index 00000000..445f93e8 --- /dev/null +++ b/app/src/main/res/drawable/ic_star_ko.xml @@ -0,0 +1,5 @@ + + + diff --git a/app/src/main/res/drawable/ic_start_ok.xml b/app/src/main/res/drawable/ic_start_ok.xml new file mode 100644 index 00000000..92fccae1 --- /dev/null +++ b/app/src/main/res/drawable/ic_start_ok.xml @@ -0,0 +1,5 @@ + + + diff --git a/app/src/main/res/layout/buyers_fragment.xml b/app/src/main/res/layout/buyers_fragment.xml new file mode 100644 index 00000000..c509f8f9 --- /dev/null +++ b/app/src/main/res/layout/buyers_fragment.xml @@ -0,0 +1,60 @@ + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/item_buyer_row.xml b/app/src/main/res/layout/item_buyer_row.xml new file mode 100644 index 00000000..f17a298b --- /dev/null +++ b/app/src/main/res/layout/item_buyer_row.xml @@ -0,0 +1,178 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/qauality_fragment.xml b/app/src/main/res/layout/qauality_fragment.xml new file mode 100644 index 00000000..afa2844f --- /dev/null +++ b/app/src/main/res/layout/qauality_fragment.xml @@ -0,0 +1,77 @@ + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/values-es/strings.xml b/app/src/main/res/values-es/strings.xml index b5646b4d..6b7be265 100644 --- a/app/src/main/res/values-es/strings.xml +++ b/app/src/main/res/values-es/strings.xml @@ -91,4 +91,5 @@ CANTIDAD DAR DE ALTA DAR DE BAJA + Calidad \ No newline at end of file diff --git a/app/src/main/res/values/dimens.xml b/app/src/main/res/values/dimens.xml index eed2361c..20d61403 100644 --- a/app/src/main/res/values/dimens.xml +++ b/app/src/main/res/values/dimens.xml @@ -72,6 +72,7 @@ 40dp 10dp 40dp + 80dp 33dp diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 07c19cb3..fc39db34 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -90,4 +90,5 @@ QUANTITY ADD REMOVE + Quality