diff --git a/.gradle/5.4.1/executionHistory/executionHistory.bin b/.gradle/5.4.1/executionHistory/executionHistory.bin
index 947d37c..ff1f904 100644
Binary files a/.gradle/5.4.1/executionHistory/executionHistory.bin and b/.gradle/5.4.1/executionHistory/executionHistory.bin differ
diff --git a/.gradle/5.4.1/executionHistory/executionHistory.lock b/.gradle/5.4.1/executionHistory/executionHistory.lock
index fe29b82..f0b078d 100644
Binary files a/.gradle/5.4.1/executionHistory/executionHistory.lock and b/.gradle/5.4.1/executionHistory/executionHistory.lock differ
diff --git a/.gradle/5.4.1/fileHashes/fileHashes.bin b/.gradle/5.4.1/fileHashes/fileHashes.bin
index d4bdf0e..1e3adea 100644
Binary files a/.gradle/5.4.1/fileHashes/fileHashes.bin and b/.gradle/5.4.1/fileHashes/fileHashes.bin differ
diff --git a/.gradle/5.4.1/fileHashes/fileHashes.lock b/.gradle/5.4.1/fileHashes/fileHashes.lock
index a824e8f..34a9767 100644
Binary files a/.gradle/5.4.1/fileHashes/fileHashes.lock and b/.gradle/5.4.1/fileHashes/fileHashes.lock differ
diff --git a/.gradle/5.4.1/fileHashes/resourceHashesCache.bin b/.gradle/5.4.1/fileHashes/resourceHashesCache.bin
index 4e01d5a..3b70e01 100644
Binary files a/.gradle/5.4.1/fileHashes/resourceHashesCache.bin and b/.gradle/5.4.1/fileHashes/resourceHashesCache.bin differ
diff --git a/.gradle/5.4.1/javaCompile/classAnalysis.bin b/.gradle/5.4.1/javaCompile/classAnalysis.bin
index d556d73..df57d90 100644
Binary files a/.gradle/5.4.1/javaCompile/classAnalysis.bin and b/.gradle/5.4.1/javaCompile/classAnalysis.bin differ
diff --git a/.gradle/5.4.1/javaCompile/javaCompile.lock b/.gradle/5.4.1/javaCompile/javaCompile.lock
index cdaaefb..6b58659 100644
Binary files a/.gradle/5.4.1/javaCompile/javaCompile.lock and b/.gradle/5.4.1/javaCompile/javaCompile.lock differ
diff --git a/.gradle/5.4.1/javaCompile/taskHistory.bin b/.gradle/5.4.1/javaCompile/taskHistory.bin
index c4d4f28..df0525c 100644
Binary files a/.gradle/5.4.1/javaCompile/taskHistory.bin and b/.gradle/5.4.1/javaCompile/taskHistory.bin differ
diff --git a/.gradle/buildOutputCleanup/buildOutputCleanup.lock b/.gradle/buildOutputCleanup/buildOutputCleanup.lock
index d887b92..ffa7826 100644
Binary files a/.gradle/buildOutputCleanup/buildOutputCleanup.lock and b/.gradle/buildOutputCleanup/buildOutputCleanup.lock differ
diff --git a/.gradle/buildOutputCleanup/outputFiles.bin b/.gradle/buildOutputCleanup/outputFiles.bin
index 2ded953..cbdca2a 100644
Binary files a/.gradle/buildOutputCleanup/outputFiles.bin and b/.gradle/buildOutputCleanup/outputFiles.bin differ
diff --git a/.idea/gradle.xml b/.idea/gradle.xml
index 4404972..4877ac9 100644
--- a/.idea/gradle.xml
+++ b/.idea/gradle.xml
@@ -14,7 +14,6 @@
-
diff --git a/.idea/libraries/Gradle__junit_junit_4_12.xml b/.idea/libraries/Gradle__junit_junit_4_12.xml
index 6c078d6..f7d27c4 100644
--- a/.idea/libraries/Gradle__junit_junit_4_12.xml
+++ b/.idea/libraries/Gradle__junit_junit_4_12.xml
@@ -1,5 +1,8 @@
+
+
+
diff --git a/.idea/misc.xml b/.idea/misc.xml
index 0c64e0b..3587279 100644
--- a/.idea/misc.xml
+++ b/.idea/misc.xml
@@ -3,23 +3,49 @@
diff --git a/.idea/modules.xml b/.idea/modules.xml
index 08c494d..e522fed 100644
--- a/.idea/modules.xml
+++ b/.idea/modules.xml
@@ -4,6 +4,9 @@
+
+
+
\ No newline at end of file
diff --git a/.idea/modules/app/vn-delivery.app.iml b/.idea/modules/app/vn-delivery.app.iml
index 888faf0..06f9d7d 100644
--- a/.idea/modules/app/vn-delivery.app.iml
+++ b/.idea/modules/app/vn-delivery.app.iml
@@ -54,118 +54,11 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index 0dec646..938846f 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -9,7 +9,7 @@
-
+
@@ -40,7 +40,9 @@
-
+
+
+
@@ -51,98 +53,35 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
-
-
-
-
-
+
+
-
-
-
+
+
+
+
@@ -150,15 +89,9 @@
-
-
-
-
-
-
@@ -166,7 +99,7 @@
-
+
@@ -182,17 +115,6 @@
-
-
-
-
-
-
-
-
-
-
-
@@ -203,9 +125,10 @@
@@ -226,6 +149,13 @@
+
+
+
+
+
+
+
@@ -249,37 +179,55 @@
+
+
+
+
+
-
+
+
-
-
+
+
+
+
+
+
+
+
+
-
+
+
-
+
+
+
+
+
@@ -305,8 +253,7 @@
-
-
+
@@ -384,8 +331,26 @@
1546927317651
+
+ 1646409844507
+
+
+
+ 1646409844507
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/build.gradle b/app/build.gradle
index 878aac0..5bccbcb 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -7,14 +7,15 @@ android {
applicationId "verdnatura.es.repartoverdnatura"
minSdkVersion 19
//targetSdkVersion 28
+ versionCode 24
+ versionName "9.4"
+ //versionName "9.3.2" // versionCode 23 (madrid)
+ //versionName "9.3.2" versionCode 21
+ //versionName "9.3.1" versionCode 20
+ //versionCode 19 //version 9.3
+ //versionName "9.3"
+
- versionCode 12 // test de carga i descarga de furgo
- //versionCode 11 // test de Cargar Furgo
- //versionCode 10 es la versión 9.2
- //versionCode 8
- versionName "9.2"//versión soluciona fallo si quitamos gps y que no envíe la location 0,0
- //versionName "9.1"//es la versión que se utiliza para comprar en bbdd
- //versionName "1.8"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
multiDexEnabled true
}
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index bba5853..0700e87 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -68,7 +68,18 @@
android:name=".UnLoadVanActivity"
android:configChanges="orientation"
android:screenOrientation="portrait" />
-
+
+
+
diff --git a/app/src/main/java/verdnatura/es/repartoverdnatura/ADAPTERS/CheckAdapter.java b/app/src/main/java/verdnatura/es/repartoverdnatura/ADAPTERS/CheckAdapter.java
index be1f4d3..06fc365 100644
--- a/app/src/main/java/verdnatura/es/repartoverdnatura/ADAPTERS/CheckAdapter.java
+++ b/app/src/main/java/verdnatura/es/repartoverdnatura/ADAPTERS/CheckAdapter.java
@@ -1,6 +1,7 @@
package verdnatura.es.repartoverdnatura.ADAPTERS;
import android.content.Context;
+import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
@@ -13,41 +14,61 @@ import verdnatura.es.repartoverdnatura.MODELS.Check;
import verdnatura.es.repartoverdnatura.R;
public class CheckAdapter extends ArrayAdapter {
+
public CheckAdapter(Context context, List signs) {
super(context,0,signs);
+
}
@Override
public View getView(final int position, View convertView, ViewGroup parent) {
Check c = getItem(position);
- if (convertView == null){
- convertView = LayoutInflater.from(getContext()).inflate(R.layout.row_check,parent,false);
+ if (convertView == null) {
+ convertView = LayoutInflater.from(getContext()).inflate(R.layout.row_check, parent, false);
}
- TextView txtId = convertView.findViewById(R.id.txtId);
- TextView txtAddress = convertView.findViewById(R.id.txtAddress);
- // TextView txtWarehouse = convertView.findViewById(R.id.txtWarehouse);
- // TextView txtBulto = convertView.findViewById(R.id.txtBulto);
- TextView txtName = convertView.findViewById(R.id.txtClientName);
- TextView txtCheck = convertView.findViewById(R.id.txtCheck);
- LinearLayout fondo = convertView.findViewById(R.id.fondo);
- TextView txtConsignatario = convertView.findViewById(R.id.consignatarioId);
- TextView txtItemPacking = convertView.findViewById(R.id.txtItemPacking );
- txtId.setText(c.getId());
+ TextView txtId = convertView.findViewById(R.id.txtId);
+ TextView txtAddress = convertView.findViewById(R.id.txtAddress);
+ // TextView txtWarehouse = convertView.findViewById(R.id.txtWarehouse);
+ // TextView txtBulto = convertView.findViewById(R.id.txtBulto);
+ TextView txtName = convertView.findViewById(R.id.txtClientName);
+ TextView txtCheck = convertView.findViewById(R.id.txtCheck);
+ LinearLayout fondo = convertView.findViewById(R.id.fondo);
+ TextView txtConsignatario = convertView.findViewById(R.id.consignatarioId);
+ TextView txtItemPacking = convertView.findViewById(R.id.txtItemPacking);
- txtAddress.setText(c.getStreet()+" "+c.getCity()+" "+c.getPostalCode());
- //txtAddress.setText(c.getAddressFk()+" - "+c.getStreet()+" "+c.getCity()+" "+c.getPostalCode());
- //txtWarehouse.setText(c.getWarehouse());
- //txtBulto.setText(c.getBultos());
- txtName.setText(c.getNickName());
- txtConsignatario.setText(c.getAddressFk());
- txtItemPacking.setText(c.getItemPackingTypeFk());
+ txtId.setText(c.getId());
- if (c.getChecked().equals("1")){
+ txtAddress.setText(c.getStreet() + " " + c.getCity() + " " + c.getPostalCode());
+ //txtAddress.setText(c.getAddressFk()+" - "+c.getStreet()+" "+c.getCity()+" "+c.getPostalCode());
+
+ //txtWarehouse.setText(c.getWarehouse());
+ //txtBulto.setText(c.getBultos());
+
+ txtName.setText(c.getNickName());
+ txtConsignatario.setText(c.getAddressFk());
+ txtItemPacking.setText(c.getItemPackingTypeConcat());
+
+
+ /* if (c.getNickName().isEmpty()) {
+ txtName.setVisibility(convertView.GONE);
+ }
+ if (c.getStreet().isEmpty() || c.getCity().isEmpty() || c.getPostalCode().isEmpty()) {
+ txtAddress.setVisibility(convertView.GONE);
+ }
+ if (c.getAddressFk().isEmpty()) {
+ txtConsignatario.setVisibility(convertView.GONE);
+ }
+ if (c.getItemPackingTypeConcat().isEmpty()) {
+ txtItemPacking.setVisibility(convertView.GONE);
+ }*/
+
+
+ /*if (c.getChecked().equals("1")){
fondo.setBackgroundColor(getContext().getResources().getColor(R.color.verdnatura_pumpkin_orange));
txtCheck.setText("OK");
}else{
@@ -61,8 +82,23 @@ public class CheckAdapter extends ArrayAdapter {
fondo.setBackgroundColor(getContext().getResources().getColor(R.color.verdnatura_dark_mint));
//txtCheck.setText(txtCheck.getText()+"Entregada");
}
- }
+ }*/
+ // Log.d("VERDNATURA::","El code de " + c.getId() + ":"+c.getCode());
+ switch (c.getCode()){
+ case "ON DELIVERY":
+ fondo.setBackgroundColor(getContext().getResources().getColor(R.color.verdnatura_pumpkin_orange));
+ txtCheck.setText("OK");
+ break;
+ case "DELIVERED":
+ fondo.setBackgroundColor(getContext().getResources().getColor(R.color.verdnatura_dark_mint));
+ break;
+
+ default:
+ fondo.setBackgroundColor(getContext().getResources().getColor(R.color.colorMainHeader));
+ txtCheck.setText("NO");
+ break;
+ }
return convertView;
}
}
diff --git a/app/src/main/java/verdnatura/es/repartoverdnatura/ADAPTERS/RutaAdapter.java b/app/src/main/java/verdnatura/es/repartoverdnatura/ADAPTERS/RutaAdapter.java
index a068812..f607692 100644
--- a/app/src/main/java/verdnatura/es/repartoverdnatura/ADAPTERS/RutaAdapter.java
+++ b/app/src/main/java/verdnatura/es/repartoverdnatura/ADAPTERS/RutaAdapter.java
@@ -50,26 +50,22 @@ public class RutaAdapter extends ArrayAdapter {
TextView txtM3 = convertView.findViewById(R.id.txtM3);
TextView txtHour = convertView.findViewById(R.id.textView15);
TextView txtDriver = convertView.findViewById(R.id.txtDriver);
- LinearLayout btnShow = convertView.findViewById(R.id.linearLayout);
- TextView btnCargador = convertView.findViewById(R.id.btnCargadores);
+ LinearLayout btnShow = convertView.findViewById(R.id.linearLayoutShowTickets);
+ //TextView btnCargador = convertView.findViewById(R.id.btnCargadores);
TextView txtOnline = convertView.findViewById(R.id.txtOnline);
ImageView imgNoWeb = convertView.findViewById(R.id.imageView10);
ImageView loadVan = convertView.findViewById(R.id.imageLoadVan);
TextView loadVanTxt = convertView.findViewById(R.id.loadVanTxt);
-
+ LinearLayout loadVanLayout = convertView.findViewById(R.id.linearLayoutShowLoad);
if (!listaRutasCargadas.isEmpty()){
- // Log.d("VERDNATURA::","La ruta no está vacía");
if (listaRutasCargadas.contains(ruta.getId())){
loadVan.setVisibility(View.GONE);
}
}
- /* if (LocalStorage.loadRutaCargada(loadVan.getContext(),ruta.getId())){
- loadVan.setVisibility(View.GONE);
- }*/
txtIdRuta.setText(ruta.getId());
txtZona.setText(ruta.getAgency());
@@ -87,7 +83,7 @@ public class RutaAdapter extends ArrayAdapter {
}
});
- loadVanTxt.setOnClickListener(new View.OnClickListener() {
+ loadVanTxt.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if (getContext() instanceof MainActivity) {
@@ -105,14 +101,23 @@ public class RutaAdapter extends ArrayAdapter {
}
});
- btnCargador.setOnClickListener(new View.OnClickListener() {
+ loadVanLayout.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ if (getContext() instanceof MainActivity) {
+ ((MainActivity) getContext()).onLoadSelected(position);
+ }
+ }
+ });
+
+ /* btnCargador.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if (getContext() instanceof MainActivity) {
((MainActivity) getContext()).goToLoaders(position);
}
}
- });
+ });*/
if (LocalStorage.isOfflineAviable(getContext(),ruta.getId())){
txtOnline.setText(getContext().getResources().getString(R.string.disponible_offline));
diff --git a/app/src/main/java/verdnatura/es/repartoverdnatura/ConfigureActivity.java b/app/src/main/java/verdnatura/es/repartoverdnatura/ConfigureActivity.java
index e229781..d7b4a00 100644
--- a/app/src/main/java/verdnatura/es/repartoverdnatura/ConfigureActivity.java
+++ b/app/src/main/java/verdnatura/es/repartoverdnatura/ConfigureActivity.java
@@ -121,13 +121,12 @@ public class ConfigureActivity extends AppCompatActivity {
args[2] = txtKmFinish.getText().toString().trim();
args[3] = txtHourStart.getText().toString().trim();
args[4] = txtHourFinish.getText().toString().trim();
- restClient.saveConfig(Utils.getMapWhitUser(this),args).enqueue(new Callback() {
+ restClient.saveConfig(Utils.getMapWhitUser(this),args).enqueue(new Callback() {
@Override
- public void onResponse(Call call, Response response) {
+ public void onResponse(Call call, Response response) {
Utils.progressBar.getDialog().dismiss();
if(response.isSuccessful()){
- if (response.body().equals("Finish")){
- Log.i("INFO","guardado");
+ // Log.i("INFO","guardado");
Intent returnIntent = new Intent();
route.setKmStart(txtKmStart.getText().toString().trim());
route.setKmEnd(txtKmFinish.getText().toString().trim());
@@ -136,9 +135,6 @@ public class ConfigureActivity extends AppCompatActivity {
returnIntent.putExtra("route",route);
setResult(Activity.RESULT_OK,returnIntent);
finish();
- }else{
- Utils.showErrorDialog(that,that.getResources().getString(R.string.error_conexion));
- }
}else{
Log.i("ERROR","error al guardar");
@@ -147,7 +143,7 @@ public class ConfigureActivity extends AppCompatActivity {
}
@Override
- public void onFailure(Call call, Throwable t) {
+ public void onFailure(Call call, Throwable t) {
Utils.progressBar.getDialog().dismiss();
Utils.showErrorDialog(that,that.getResources().getString(R.string.error_conexion));
}
diff --git a/app/src/main/java/verdnatura/es/repartoverdnatura/INTERFACES/RestClient.java b/app/src/main/java/verdnatura/es/repartoverdnatura/INTERFACES/RestClient.java
index e18a944..1637922 100644
--- a/app/src/main/java/verdnatura/es/repartoverdnatura/INTERFACES/RestClient.java
+++ b/app/src/main/java/verdnatura/es/repartoverdnatura/INTERFACES/RestClient.java
@@ -2,6 +2,7 @@ package verdnatura.es.repartoverdnatura.INTERFACES;
import java.util.List;
import java.util.Map;
+
import retrofit2.Call;
import retrofit2.http.Body;
import retrofit2.http.HeaderMap;
@@ -9,73 +10,103 @@ import retrofit2.http.POST;
import verdnatura.es.repartoverdnatura.MODELS.Check;
import verdnatura.es.repartoverdnatura.MODELS.Cliente;
import verdnatura.es.repartoverdnatura.MODELS.DeliveryInfo;
+import verdnatura.es.repartoverdnatura.MODELS.ExpeditionInfoLog;
+import verdnatura.es.repartoverdnatura.MODELS.ExpeditionInfoSummary;
import verdnatura.es.repartoverdnatura.MODELS.Ruta;
+import verdnatura.es.repartoverdnatura.MODELS.SectorItem;
import verdnatura.es.repartoverdnatura.MODELS.Version;
import verdnatura.es.repartoverdnatura.MODELS.Worker;
public interface RestClient {
- @POST("/security/login")
- Call login(@HeaderMap Map headers, @Body String[] userData);
+ /* @POST("/security/login")
+ Call login(@HeaderMap Map headers, @Body String[] userData);*/
//cambiada version porque se requería un objeto desde el servidor y solo devolvía un false
- @POST("/security/getVersion")
- Call getVersion(@HeaderMap Map headers, @Body String[] userData);
- // @POST("/delivery/get_version")
- // Call getVersion(@HeaderMap Map headers, @Body String[] userData);
+ @POST("/security/getVersion")
+ Call getVersion(@HeaderMap Map headers, @Body String[] userData);
+
+ @POST("/almacennew/worker_getId")
+ Call worker_getId(@HeaderMap Map headers);
+
+ @POST("/almacennew/deviceLog_add")
+ Call deviceLog_add(@HeaderMap Map headers, @Body String[] data);
@POST("/delivery/get_routes")
- Call> getRoutes(@HeaderMap Map headers);
+ Call> getRoutes(@HeaderMap Map headers);
@POST("/delivery/get_expeditions")
- Call> getExpeditions(@HeaderMap Map headers);
+ Call> getExpeditions(@HeaderMap Map headers);
@POST("/delivery/get_tickets")
- Call> getClients(@HeaderMap Map headers, @Body String[] route);
+ Call> getClients(@HeaderMap Map headers, @Body String[] route);
@POST("/delivery/save_sign")
- Call saveSign(@HeaderMap Map headers,@Body Object[] args);
+ Call saveSign(@HeaderMap Map headers, @Body Object[] args);
@POST("/delivery/update_routes")
- Call saveConfig(@HeaderMap Map headers,@Body Object[] args);
+ Call saveConfig(@HeaderMap Map headers, @Body Object[] args);
@POST("/delivery/getWorkers")
- Call> getWorkers(@HeaderMap Map headers);
+ Call> getWorkers(@HeaderMap Map headers);
@POST("/delivery/getExpeditionFromRoute")
- Call> getExpeditionFromRoute(@HeaderMap Map headers,@Body Object[] args);
+ Call> getExpeditionFromRoute(@HeaderMap Map headers, @Body Object[] args);
@POST("/delivery/updateExpeditionChecked")
- Call updateExpeditionChecked(@HeaderMap Map headers,@Body Object[] args);
+ Call updateExpeditionChecked(@HeaderMap Map headers, @Body Object[] args);
@POST("/delivery/setRouteOk")
- Call setRouteOk(@HeaderMap Map headers,@Body Object[] args);
+ Call setRouteOk(@HeaderMap Map headers, @Body Object[] args);
- @POST("/delivery/expeditionState_add")
- Call expeditionState_add(@HeaderMap Map headers,@Body Object[] args);
+ /* @POST("/delivery/expeditionState_add")
+ Call expeditionState_add(@HeaderMap Map headers,@Body Object[] args);*/
- @POST("/delivery/expeditionState_addByAdress")
+ /* @POST("/delivery/expeditionState_addByAdress")
Call expeditionState_addByAdress(@HeaderMap Map headers,@Body Object[] args);
@POST("/delivery/expeditionState_addByExpedition")
- Call expeditionState_addByExpedition(@HeaderMap Map headers,@Body Object[] args);
+ Call expeditionState_addByExpedition(@HeaderMap Map headers,@Body Object[] args);*/
- @POST("/delivery/expeditionState_addByRoute")
- Call expeditionState_addByRoute(@HeaderMap Map headers,@Body Object[] args);
+ @POST("/delivery/expedition_getLog")
+ Call> expedition_getLog(@HeaderMap Map headers, @Body Object[] args);
+
+ @POST("/delivery/get_routesFromExpedition")
+ Call> get_routesFromExpedition(@HeaderMap Map headers, @Body Object[] args);
+
+
+ @POST("/delivery/route_getExpeditionSummary")
+ Call> route_getExpeditionSummary(@HeaderMap Map headers, @Body Object[] args);
+
+ @POST("/delivery/expeditionState_add")
+ Call expeditionState_addByExpeditionMulti(@HeaderMap Map headers, @Body Object[] args);
+
+ /*@POST("/delivery/expeditionState_addByRoute")
+ Call expeditionState_addByRoute(@HeaderMap Map headers,@Body Object[] args);*/
@POST("/delivery/saveLoadersWorkers")
- Call saveLoadersWorkers(@HeaderMap Map headers,@Body Object[] args);
+ Call saveLoadersWorkers(@HeaderMap Map headers, @Body Object[] args);
@POST("/delivery/addNote")
- Call addNote(@HeaderMap Map headers,@Body Object[] args);
+ Call addNote(@HeaderMap Map headers, @Body Object[] args);
@POST("/delivery/getInfo")
- Call> getInfo(@HeaderMap Map headers, @Body Object[] args);
+ Call> getInfo(@HeaderMap Map headers, @Body Object[] args);
@POST("/delivery/getInfoCompany")
- Call> getInfoCompany(@HeaderMap Map headers, @Body Object[] args);
+ Call> getInfoCompany(@HeaderMap Map headers, @Body Object[] args);
@POST("/delivery/getInfoFreelance")
- Call> getInfoFreelance(@HeaderMap Map headers, @Body Object[] args);
+ Call> getInfoFreelance(@HeaderMap Map headers, @Body Object[] args);
+
+ @POST("/almacennew/worker_getSector")
+ Call worker_getSector(@HeaderMap Map headers);
+
+ @POST("/almacennew/sector_get")
+ Call> sector_get(@HeaderMap Map headers);
+
+ @POST("/almacennew/worker_updateSector")
+ Call worker_updateSector(@HeaderMap Map headers, @Body Object[] args);
+
}
diff --git a/app/src/main/java/verdnatura/es/repartoverdnatura/InfoActivity.java b/app/src/main/java/verdnatura/es/repartoverdnatura/InfoActivity.java
index 57ddfcc..dd94767 100644
--- a/app/src/main/java/verdnatura/es/repartoverdnatura/InfoActivity.java
+++ b/app/src/main/java/verdnatura/es/repartoverdnatura/InfoActivity.java
@@ -1,13 +1,19 @@
package verdnatura.es.repartoverdnatura;
+import android.app.Dialog;
import android.content.Context;
+import android.content.DialogInterface;
import android.content.Intent;
import android.content.pm.PackageManager;
+import android.support.v7.app.AlertDialog;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
+import android.view.View;
+import android.widget.ImageView;
import android.widget.TextView;
+import java.util.ArrayList;
import java.util.List;
import retrofit2.Call;
@@ -17,16 +23,23 @@ import verdnatura.es.repartoverdnatura.ADAPTERS.WorkerAdapter;
import verdnatura.es.repartoverdnatura.INTERFACES.RestClient;
import verdnatura.es.repartoverdnatura.MODELS.DeliveryInfo;
import verdnatura.es.repartoverdnatura.MODELS.Ruta;
+import verdnatura.es.repartoverdnatura.MODELS.SectorItem;
import verdnatura.es.repartoverdnatura.MODELS.Worker;
import verdnatura.es.repartoverdnatura.UTILS.ApiUtils;
+import verdnatura.es.repartoverdnatura.UTILS.LocalStorage;
import verdnatura.es.repartoverdnatura.UTILS.Utils;
public class InfoActivity extends AppCompatActivity {
- private TextView txtRazonSocial,txtNif, txtDireccionFiscal,txtMunicipio, txtCodigoPostal,txtNameCorp,txtNIFCorp,txtAdressCorp,txtVersion;
+ private TextView txtRazonSocial,txtNif, txtDireccionFiscal,txtMunicipio, txtCodigoPostal,txtNameCorp,txtNIFCorp,txtAdressCorp,txtVersion,txtSectorInfo;
+ private ImageView imgSectorEdit;
private RestClient restClient;
public Ruta route;
private Context Mycontext;
+ private ArrayList sectors = new ArrayList<>();
+ final List listSectors = new ArrayList();
+
+
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
@@ -44,6 +57,25 @@ public class InfoActivity extends AppCompatActivity {
txtVersion=(TextView) findViewById(R.id.textView43);
+ imgSectorEdit =(ImageView) findViewById(R.id.sectorEdit);
+ imgSectorEdit.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View view) {
+
+ showSectors(view.getContext());
+ }
+ });
+
+
+ txtSectorInfo =(TextView) findViewById(R.id.sectorInfo);
+ txtSectorInfo.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View view) {
+
+ showSectors(view.getContext());
+ }
+ });
+
restClient = ApiUtils.getAPIService();
Intent intent = this.getIntent();
@@ -51,18 +83,29 @@ public class InfoActivity extends AppCompatActivity {
company_getInfo(Utils.getIdUserLogin(this));
freelance_getInfo(Utils.getIdUserLogin(this));
+ worker_getSector();
version_infoapp();
+ get_Sectors();
+ }
+
+ private void showSectors(final Context context) {
+
+ AlertDialog.Builder builder = new AlertDialog.Builder(this);
+ builder.setTitle("Selecciona sector");
+
+
+ builder.setItems(listSectors.toArray(new String[0]), new DialogInterface.OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialog, int which) {
+
+ worker_updateSector(sectors.get(which));
-/*
- if (bundle != null){
- route = (Ruta) bundle.getSerializable("route");
- if (route != null){
- getInfo();
}
- }else{
+ });
- }*/
+ AlertDialog dialog = builder.create();
+ dialog.show();
}
private void version_infoapp() {
@@ -70,50 +113,77 @@ public class InfoActivity extends AppCompatActivity {
PackageManager packageManager = getApplicationContext().getPackageManager();
try {
- txtVersion.setText(getString(R.string.version)+""+packageManager.getPackageInfo(context.getPackageName(), 0).versionName);
+ txtVersion.setText(getString(R.string.version)+packageManager.getPackageInfo(context.getPackageName(), 0).versionName);
} catch (PackageManager.NameNotFoundException e) {
e.printStackTrace();
}
}
- /*
- private void getInfo(){
- txtCodigoPostal.setText("");
- txtDireccionFiscal.setText("");
- txtMunicipio.setText("");
- txtNif.setText("");
- txtRazonSocial.setText("");
+ private void worker_updateSector(final SectorItem sector){
Utils.progressBar.show(this,getResources().getString(R.string.please_wait));
Object[] args = new Object[1];
- args[0] = route.getId();
+ args[0] =sector.getId();
- restClient.getInfo(Utils.getMapWhitUser(this),args).enqueue(new Callback>() {
+ restClient.worker_updateSector(Utils.getMapWhitUser(this),args).enqueue(new Callback() {
@Override
- public void onResponse(Call> call, Response> response) {
+ public void onResponse(Call call, Response response) {
Utils.progressBar.getDialog().dismiss();
- if (response.isSuccessful()) {
- for (DeliveryInfo deliveryInfo : response.body()){
- txtCodigoPostal.setText(deliveryInfo.getPostCode());
- txtDireccionFiscal.setText(deliveryInfo.getStreet());
- txtMunicipio.setText(deliveryInfo.getCity());
- txtNif.setText(deliveryInfo.getNif());
- txtRazonSocial.setText(deliveryInfo.getName());
- }
+ if (response.isSuccessful()) {
+ LocalStorage.saveSector(getApplicationContext(), sector);
+ txtSectorInfo.setText(LocalStorage.getSectorDescrip(getApplicationContext()));
+
+ }else{
+ txtSectorInfo.setText(LocalStorage.getSectorDescrip(getApplicationContext()));
+ Utils.showErrorDialog(getBaseContext(), "Error al guarda. Pruebe de nuevo a seleccionar sector");
}
}
@Override
- public void onFailure(Call> call, Throwable t) {
+ public void onFailure(Call call, Throwable t) {
Utils.progressBar.getDialog().dismiss();
+ Utils.showErrorDialog(getBaseContext(), "Error al guarda. Pruebe de nuevo a seleccionar sector");
+ txtSectorInfo.setText(LocalStorage.getSectorDescrip(getApplicationContext()));
}
});
- }*/
+ }
+ private void worker_getSector(){
+
+ // Utils.progressBar.show(this,getResources().getString(R.string.please_wait));
+ Object[] args = new Object[1];
+ //args[0] =id;
+
+
+ restClient.worker_getSector(Utils.getMapWhitUser(this)).enqueue(new Callback() {
+ @Override
+ public void onResponse(Call call, Response response) {
+ Utils.progressBar.getDialog().dismiss();
+
+ if (response.isSuccessful()) {
+
+ txtSectorInfo.setText(response.body().getDescription());
+
+ }else{
+ Utils.showErrorDialog(getBaseContext(), "Error al guarda. Pruebe de nuevo a seleccionar sector");
+ txtSectorInfo.setText(LocalStorage.getSectorDescrip(getApplicationContext()));
+ }
+ }
+
+ @Override
+ public void onFailure(Call call, Throwable t) {
+ Utils.progressBar.getDialog().dismiss();
+
+ txtSectorInfo.setText(LocalStorage.getSectorDescrip(getApplicationContext()));
+ }
+ });
+
+
+ }
private void company_getInfo(String id){
@@ -148,7 +218,7 @@ public class InfoActivity extends AppCompatActivity {
}
private void freelance_getInfo(String id){
-
+ // Utils.progressBar.show(this,getResources().getString(R.string.please_wait));
Object[] args = new Object[1];
args[0] =id;
restClient.getInfoFreelance(Utils.getMapWhitUser(this),args).enqueue(new Callback>() {
@@ -177,4 +247,34 @@ public class InfoActivity extends AppCompatActivity {
}
+ private void get_Sectors(){
+ // Utils.progressBar.show(this,getResources().getString(R.string.please_wait));
+ Object[] args = new Object[1];
+ //args[0] =id;
+ restClient.sector_get(Utils.getMapWhitUser(this)).enqueue(new Callback>() {
+ @Override
+ public void onResponse(Call> call, Response> response) {
+ Utils.progressBar.getDialog().dismiss();
+ if (response.isSuccessful()) {
+
+ for (SectorItem sectorInfo : response.body()){
+ // Log.d("VERDNATURA::","El sector es "+sectorInfo.getDescription()+"-"+sectorInfo.getWarehouseFk()+"-"+sectorInfo.getId());
+ sectors.add(sectorInfo);
+ listSectors.add(sectorInfo.getDescription());
+
+
+ }
+ imgSectorEdit.setVisibility(View.VISIBLE);
+ }
+ }
+
+ @Override
+ public void onFailure(Call> call, Throwable t) {
+ Utils.progressBar.getDialog().dismiss();
+ }
+ });
+
+
+ }
+
}
diff --git a/app/src/main/java/verdnatura/es/repartoverdnatura/LoadVanActivity.kt b/app/src/main/java/verdnatura/es/repartoverdnatura/LoadVanActivity.kt
new file mode 100644
index 0000000..d462687
--- /dev/null
+++ b/app/src/main/java/verdnatura/es/repartoverdnatura/LoadVanActivity.kt
@@ -0,0 +1,588 @@
+package verdnatura.es.repartoverdnatura
+
+import android.app.Activity
+import android.content.Context
+import android.media.MediaPlayer
+import android.os.Bundle
+import android.support.v7.app.AppCompatActivity
+import android.util.Log
+import android.view.View
+import android.view.View.GONE
+import android.view.View.OnFocusChangeListener
+import android.view.inputmethod.InputMethodManager
+import android.widget.*
+import retrofit2.Call
+import retrofit2.Callback
+import retrofit2.Response
+import verdnatura.es.repartoverdnatura.ADAPTERS.CheckAdapter
+import verdnatura.es.repartoverdnatura.INTERFACES.RestClient
+import verdnatura.es.repartoverdnatura.MODELS.Check
+import verdnatura.es.repartoverdnatura.MODELS.Ruta
+import verdnatura.es.repartoverdnatura.MainActivity.listaRutasCargadas
+import verdnatura.es.repartoverdnatura.UTILS.ApiUtils
+import verdnatura.es.repartoverdnatura.UTILS.LocalStorage
+import verdnatura.es.repartoverdnatura.UTILS.Utils
+
+class LoadVanActivity : AppCompatActivity() {
+ var mperror: MediaPlayer? = null
+ var mpok: MediaPlayer? = null
+ var mpErrorRepeat: MediaPlayer? = null
+
+ var listCheck = ArrayList()
+ var adapter: CheckAdapter? = null
+ var listView: ListView? = null
+ private var restClient: RestClient? = null
+ var txtRuta: EditText? = null
+ var txtEscaner: EditText? = null
+ var txtLineas: TextView? = null
+ var txtIdRuta: TextView? = null
+ var txtMessage: TextView? = null
+ var checked = 0
+ var totalChecks = 0
+ var routeLoaded = false
+ var totalSend = 0
+ var totalSendSuccessful = 0
+ private var routeOfLoad = ""
+ private lateinit var switchLoad: Switch
+ private var loadForAdressing = false
+ private var adressOfLoad = ""
+
+ override fun onCreate(savedInstanceState: Bundle?) {
+ super.onCreate(savedInstanceState)
+ setContentView(R.layout.activity_loadvan)
+ mperror = MediaPlayer.create((this), R.raw.error)
+ mpok = MediaPlayer.create((this), R.raw.ok)
+ mpErrorRepeat = MediaPlayer.create((this), R.raw.errorrepeat)
+
+ restClient = ApiUtils.getAPIService()
+ listView = findViewById(R.id.listRoute)
+ txtRuta = findViewById(R.id.txtRuta)
+
+ txtEscaner = findViewById(R.id.txtEscaner)
+ txtLineas = findViewById(R.id.txtLineas)
+ txtIdRuta = findViewById(R.id.textView41)
+ txtMessage = findViewById(R.id.textView3)
+
+ switchLoad = findViewById(R.id.switchLoad) as Switch
+
+ setEvents()
+ fillRoutes()
+
+ }
+
+ override fun onBackPressed() {
+ // setRouteLoaded()
+ reviewLoad()
+ }
+
+
+ private fun reviewLoad() {
+
+
+ if (checked >= totalChecks) {
+ // sergio: se cierra porque es automática cuando se escanea y no es necesario hacer nada más
+ Toast.makeText(this, "Expediciones de la ruta cargadas", Toast.LENGTH_SHORT).show()
+ finish()
+ } else {
+ if (checked == 0) {
+ finish()
+ } else {
+
+ val alertDialog = android.app.AlertDialog.Builder(this).create()
+ alertDialog.setTitle("Información")
+ alertDialog.setMessage("El total de expediciones escaneadas es diferente al total de la ruta. ¿ Quieres guardar las expediciones escaneadas o buscar la/s expedición/es ?")
+ alertDialog.setButton(
+ android.app.AlertDialog.BUTTON_NEUTRAL, "GUARDAR "
+ ) { dialog, which ->
+
+ setRouteLoaded()
+
+
+ for (check in listCheck.filter { it.routeFk == routeOfLoad }) {
+ if (check.code != "ON DELIVERY" && check.code != "FOUND") {
+ check.code = "LOST"
+ }
+ }
+ totalSend = 0
+ if (listCheck.filter { it.routeFk == routeOfLoad }
+ .filter { it.code == "ON DELIVERY" }.isNotEmpty()) {
+ totalSend = totalSend + 1
+
+ expeditionState_addByExpeditionMulti(listCheck.filter { it.routeFk == routeOfLoad }
+ .filter { it.code == "ON DELIVERY" }, "ON DELIVERY")
+ }
+
+ //Sergio:Diferenciamos dos cargas, la general y la por consignatario
+ if (loadForAdressing){
+ if (listCheck.filter { it.addressFk == adressOfLoad }.filter { it.routeFk == routeOfLoad }
+ .filter { it.code == "LOST" }.isNotEmpty()) {
+ totalSend = totalSend + 1
+ expeditionState_addByExpeditionMulti(listCheck. filter{ it.addressFk == adressOfLoad }.filter { it.routeFk == routeOfLoad }
+ .filter { it.code == "LOST" }, "LOST")
+ }
+
+ routeLoaded
+
+ }else{
+ if (listCheck.filter { it.routeFk == routeOfLoad }
+ .filter { it.code == "LOST" }.isNotEmpty()) {
+ totalSend = totalSend + 1
+ expeditionState_addByExpeditionMulti(listCheck.filter { it.routeFk == routeOfLoad }
+ .filter { it.code == "LOST" }, "LOST")
+ }
+
+ routeLoaded
+ }
+ }
+
+ alertDialog.setButton(
+ android.app.AlertDialog.BUTTON_POSITIVE, "BUSCAR"
+
+ ) { dialog, which ->
+
+
+
+ if (!loadForAdressing) {
+ adapter = CheckAdapter(
+ this,
+ listCheck.sortedBy { it.checked }.filter { it.routeFk == routeOfLoad })
+ this.listView!!.adapter = adapter
+ adapter!!.notifyDataSetChanged()
+ }else{
+ adapter = CheckAdapter(
+ this,
+ listCheck.sortedBy { it.checked }.filter { it.addressFk == adressOfLoad }.filter { it.routeFk == routeOfLoad })
+ this.listView!!.adapter = adapter
+ adapter!!.notifyDataSetChanged()
+
+ } }
+ alertDialog.show()
+ }
+ }
+
+ }
+
+ private fun expeditionStateUnmarking_addByExpedition(expedition: String, state: String) {
+
+ val stateData: Array = arrayOfNulls(2)
+
+ stateData[0] = expedition
+ stateData[1] = state
+
+ restClient!!.expeditionState_addByExpeditionMulti(Utils.getMapWhitUser(this), stateData)
+ .enqueue(object : Callback {
+ override fun onResponse(call: Call, response: Response) {
+ Utils.progressBar.dialog.dismiss()
+ if (response.isSuccessful) {
+ Toast.makeText(baseContext, "Expedición descargada", Toast.LENGTH_SHORT)
+ .show()
+ mpok?.start()
+ adapter!!.notifyDataSetChanged()
+ }
+ }
+
+ override fun onFailure(call: Call, t: Throwable) {
+ Utils.progressBar.dialog.dismiss()
+ Utils.showErrorDialog(
+ this@LoadVanActivity,
+ resources.getString(R.string.error_conexion) + ".Vuelva a intentarlo de nuevo"
+ )
+ }
+ })
+ }
+
+ private fun expeditionState_addByExpeditionMulti(expeditions: List, state: String) {
+ // private fun expeditionState_addByExpeditionMulti(expeditions: List, state:String){
+ val stateData: Array = arrayOfNulls(2)
+ Utils.progressBar.show(this, getResources().getString(R.string.please_wait))
+ stateData[0] = expeditions
+ stateData[1] = state
+
+ //var listCheck = stateData[0] as ArrayList
+
+ restClient!!.expeditionState_addByExpeditionMulti(Utils.getMapWhitUser(this), stateData)
+ .enqueue(object : Callback {
+ override fun onResponse(call: Call, response: Response) {
+ Utils.progressBar.dialog.dismiss()
+ if (response.isSuccessful) {
+ totalSendSuccessful += 1
+ if (totalSend == totalSendSuccessful) {
+ finish()
+ }
+
+ }
+ }
+
+ override fun onFailure(call: Call, t: Throwable) {
+ Utils.progressBar.dialog.dismiss()
+ Utils.showErrorDialog(
+ this@LoadVanActivity,
+ resources.getString(R.string.error_conexion) + ".Vuelva a intentarlo"
+ )
+ }
+ })
+ }
+
+
+
+ private fun fillRoutes() {
+
+ val intent = this.intent
+ val bundle = intent.extras
+
+ try {
+
+ //carga total
+ val route = bundle.getSerializable("route") as Ruta
+ routeOfLoad = route.id.toString()
+ txtRuta!!.setText(route.id.toString())
+ checks
+
+ } catch (e: Exception) {
+ //carga por consignatario
+ routeOfLoad = bundle.getString("routeId")
+ adressOfLoad = bundle.getString("adress")
+
+ txtRuta!!.setText(routeOfLoad)
+ loadForAdressing = true
+ checks
+ }
+
+
+ }
+
+
+ private fun setRouteLoaded() {
+ val intent = this.intent
+ val bundle = intent.extras
+ var route: Ruta? = null
+ try {
+ route = bundle.getSerializable("route") as Ruta
+
+ } catch (e: Exception) {
+ }
+
+ if (!loadForAdressing) {
+ listaRutasCargadas.add(route!!.id.toString())
+ LocalStorage.saveRutasCargadas(getApplicationContext(), listaRutasCargadas)
+ LocalStorage.saveRutaCargada(getApplicationContext(), route!!.id.toString())
+ }
+
+ }
+
+ private fun setEvents() {
+
+ var btnUpload = findViewById(R.id.imageVanLoaded)
+ btnUpload.setOnClickListener {
+ reviewLoad()
+ }
+ switchLoad.setOnClickListener({ showMessageInfo() })
+
+
+ val that = this
+
+ txtRuta!!.setOnEditorActionListener { textView, i, keyEvent ->
+
+ if (!routeLoaded) {
+ checks
+ } else {
+ findExpedition(txtRuta!!.text.toString())
+ }
+ // txtEscaner!!.requestFocus()
+
+ false
+ }
+ txtRuta!!.onFocusChangeListener = OnFocusChangeListener { view, b ->
+
+
+ if (b) {
+ txtRuta!!.setText("")
+ txtIdRuta!!.setText(R.string.esccaneaEtiqueta)
+ }
+
+ }
+ txtEscaner!!.setOnEditorActionListener { textView, i, keyEvent ->
+ checkList()
+ false
+ }
+ listView!!.setOnFocusChangeListener { view, b ->
+ txtRuta!!.requestFocus()
+ false
+ }
+ }
+
+
+ //sergio: nuevo para cargar furgos
+ private fun findExpedition(textScanned: String) {
+
+ var position: Int
+
+ if (loadForAdressing){
+ position = listCheck.filter{it.addressFk==adressOfLoad}.indexOfFirst { it.id == textScanned }
+
+ //se transforma el número de la position para la lista completa
+ if (position>=0){
+ Log.d("VERDNATURA::","Encontrado")
+ position= listCheck.indexOfFirst { it.id == textScanned }
+ }
+
+
+ }else{
+ position = listCheck.indexOfFirst { it.id == textScanned }
+ }
+
+ if (position >= 0 && listCheck[position].routeFk == routeOfLoad) {
+ if (switchLoad.isChecked) {
+
+ markExpeditionLoaded(position)
+ } else {
+ unMarkExpeditionLoaded(position)
+ }
+ } else {
+ mperror?.start()
+ }
+
+ txtRuta!!.requestFocus()
+
+ }
+
+ private fun markExpeditionLoaded(i: Int) {
+ if (listCheck[i].checked == "1") {
+ mpErrorRepeat?.start()
+ Toast.makeText(this, "Expedición ya cargada", Toast.LENGTH_SHORT).show()
+
+ } else {
+ mpok?.start()
+ listCheck[i].checked = "1"
+ listCheck[i].code = "ON DELIVERY"
+ checked += 1
+ }
+ adapter!!.notifyDataSetChanged()
+ txtLineas!!.text = checked.toString() + "/" + totalChecks + " cargadas"
+ if (checked >= totalChecks) {
+
+ if (loadForAdressing){
+ Toast.makeText(this, "Consignatario cargado", Toast.LENGTH_SHORT).show()
+ }else{
+ Toast.makeText(this, "Ruta cargada", Toast.LENGTH_SHORT).show()
+ }
+
+ totalSend = 1
+ expeditionState_addByExpeditionMulti(listCheck.filter { it.routeFk == routeOfLoad }
+ .filter { it.code == "ON DELIVERY" }, "ON DELIVERY")
+ setRouteLoaded()
+ }
+ txtRuta!!.requestFocus()
+ hideKeyboard()
+
+ }
+
+ private fun unMarkExpeditionLoaded(i: Int) {
+ if (listCheck[i].checked == "1") {
+ listCheck[i].checked = "0"
+ listCheck[i].code = "FOUND"
+ checked -= 1
+
+ Utils.progressBar.show(this, getResources().getString(R.string.please_wait));
+ expeditionStateUnmarking_addByExpedition(listCheck[i].id, "FOUND")
+ } else {
+ Toast.makeText(this, "Expedición no cargada", Toast.LENGTH_SHORT).show()
+ }
+
+ adapter!!.notifyDataSetChanged()
+ txtLineas!!.text = checked.toString() + "/" + totalChecks + " cargadas"
+
+ txtRuta!!.requestFocus()
+ hideKeyboard()
+
+ }
+
+ private fun checkList() {
+ val idCheck = txtEscaner!!.text.toString()
+ txtEscaner!!.setText("")
+ var pos = 0
+ var isFind = false
+ for (c in listCheck) {
+ if (c.checked == "1") {
+ checked += 1
+ }
+ if (c.id == idCheck && c.checked == "0") {
+ listCheck[pos].checked = "1"
+ adapter!!.notifyDataSetChanged()
+ checked += 1
+ isFind = true
+ listView!!.setSelection(pos)
+ Toast.makeText(this, "OK", Toast.LENGTH_SHORT).show()
+
+ break
+ } else if (c.id == idCheck && c.checked == "1") {
+ checked -= 1
+ listCheck[pos].checked = "0"
+ adapter!!.notifyDataSetChanged()
+ isFind = true
+ listView!!.setSelection(pos)
+ Toast.makeText(this, "OK", Toast.LENGTH_SHORT).show()
+
+ break
+ }
+ pos += 1
+ }
+ txtLineas!!.text = checked.toString() + "/" + listCheck.size + " cargadas"
+ if (!isFind) {
+ Toast.makeText(this, "No Encontrada", Toast.LENGTH_LONG).show()
+ }
+ if (checked >= listCheck.size) {
+ if (loadForAdressing){
+ Toast.makeText(this, "Consignatario cargado", Toast.LENGTH_SHORT).show()
+ }else{
+ Toast.makeText(this, "Ruta cargada", Toast.LENGTH_SHORT).show()
+ }
+
+ totalSend = 1
+ expeditionState_addByExpeditionMulti(listCheck.filter { it.routeFk == routeOfLoad }
+ .filter { it.code == "ON DELIVERY" }, "ON DELIVERY")
+ //setRouteOK()
+ }
+ }
+
+
+
+ private val checks: Unit
+ private get() {
+ // listCheck = ArrayList()
+
+ var listDownload = ArrayList()
+ listDownload = ArrayList()
+
+ val that = this
+ val idR = txtRuta!!.text.toString()
+
+ val routeData: Array = arrayOfNulls(1)
+ routeData[0] = idR
+ Utils.progressBar.show(this, resources.getString(R.string.please_wait))
+
+ restClient!!.getExpeditionFromRoute(Utils.getMapWhitUser(this), routeData)
+ .enqueue(object : Callback> {
+ override fun onResponse(
+ call: Call>,
+ response: Response>
+ ) {
+ Utils.progressBar.dialog.dismiss()
+ if (response.isSuccessful) {
+ for (c in response.body()!!) {
+ //txtRuta!!.setText("")
+ //txtIdRuta!!.text = "Route ID"
+
+ if (!c.code.isNullOrBlank()) {
+
+ if (c.code.equals("ON DELIVERY")) {
+ c.checked = "1"
+ }
+ if (c.code.equals("DELIVERED")) {
+ c.delivered = "1"
+ }
+
+ }
+ listDownload.add(c)
+ }
+
+
+ LocalStorage.addExpeditionSave(that, listDownload)
+ getLocalDataExpedition(routeOfLoad)
+
+ } else {
+ Utils.progressBar.dialog.dismiss()
+ Utils.showErrorDialog(
+ that,
+ that.resources.getString(R.string.error_conexion)
+ )
+ }
+ }
+
+ override fun onFailure(call: Call>, t: Throwable) {
+ Utils.progressBar.dialog.dismiss()
+ Utils.showErrorDialog(
+ that,
+ that.resources.getString(R.string.error_conexion)
+ )
+ getLocalDataExpedition(routeOfLoad)
+ }
+ })
+ txtIdRuta!!.visibility = GONE
+ txtRuta!!.requestFocus()
+ }
+
+ fun Activity.hideKeyboard() {
+ hideKeyboard(currentFocus ?: View(this))
+ }
+
+ fun Context.hideKeyboard(view: View) {
+ val inputMethodManager =
+ getSystemService(Activity.INPUT_METHOD_SERVICE) as InputMethodManager
+ inputMethodManager.hideSoftInputFromWindow(view.windowToken, 0)
+ }
+
+
+ fun getLocalDataExpedition(route: String) {
+ val list: List = LocalStorage.getExpeditions(this)
+
+ if (loadForAdressing) {
+ listCheck = LocalStorage.getExpeditions(this)
+ if (list.size > 0) {
+
+ totalChecks =
+ list.filter { it.addressFk == adressOfLoad }.filter { it.routeFk == route }.size
+ checked =
+ list.filter { it.addressFk == adressOfLoad }.filter { it.routeFk == route }
+ .filter { it.checked == "1" || it.code == "ON DELIVERY" }.size
+
+ txtLineas!!.text = checked.toString() + "/" + totalChecks + " cargadas"
+
+ adapter = CheckAdapter(
+ this,
+ listCheck.filter { it.addressFk == adressOfLoad }
+ .filter { it.routeFk == route })
+ this.listView!!.adapter = adapter
+ txtIdRuta!!.visibility = GONE
+ routeLoaded = true
+ txtRuta!!.requestFocus()
+ hideKeyboard()
+
+ }
+ } else {
+ listCheck = LocalStorage.getExpeditions(this)
+ if (list.size > 0) {
+
+
+ totalChecks = list.filter { it.routeFk == route }.size
+ checked = list.filter { it.routeFk == route }
+ .filter { it.checked == "1" || it.code == "ON DELIVERY" }.size
+
+ //txtLineas!!.text = checked.toString() + "/" + listCheck.size + " cargadas"
+ txtLineas!!.text = checked.toString() + "/" + totalChecks + " cargadas"
+ adapter = CheckAdapter(this, listCheck.filter { it.routeFk == route })
+ this.listView!!.adapter = adapter
+ txtIdRuta!!.visibility = GONE
+ routeLoaded = true
+ txtRuta!!.requestFocus()
+ hideKeyboard()
+
+ }
+ }
+ }
+
+ fun showMessageInfo() {
+
+ if (!switchLoad.isChecked) {
+ Utils.showErrorDialog(
+ this@LoadVanActivity,
+ "Esta opción te permite descargar expediciones de la furgoneta."
+ )
+ txtMessage!!.setText("Descargando")
+ } else {
+ txtMessage!!.setText("Cargando furgo")
+ }
+ }
+
+
+}
\ No newline at end of file
diff --git a/app/src/main/java/verdnatura/es/repartoverdnatura/LoadersActivity.java b/app/src/main/java/verdnatura/es/repartoverdnatura/LoadersActivity.java
index 0074297..30e9b8e 100644
--- a/app/src/main/java/verdnatura/es/repartoverdnatura/LoadersActivity.java
+++ b/app/src/main/java/verdnatura/es/repartoverdnatura/LoadersActivity.java
@@ -1,34 +1,24 @@
package verdnatura.es.repartoverdnatura;
-import android.app.Activity;
import android.content.Intent;
-import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
+import android.support.v7.app.AppCompatActivity;
import android.text.Editable;
import android.text.TextWatcher;
import android.util.Log;
-import android.view.KeyEvent;
import android.view.View;
-import android.view.ViewGroup;
import android.widget.EditText;
import android.widget.ListView;
import android.widget.TextView;
-import java.text.ParseException;
import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Comparator;
import java.util.List;
-import java.util.stream.Stream;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
-import verdnatura.es.repartoverdnatura.ADAPTERS.RutaAdapter;
import verdnatura.es.repartoverdnatura.ADAPTERS.WorkerAdapter;
import verdnatura.es.repartoverdnatura.INTERFACES.RestClient;
-import verdnatura.es.repartoverdnatura.MODELS.Ruta;
import verdnatura.es.repartoverdnatura.MODELS.Worker;
import verdnatura.es.repartoverdnatura.MODELS.WorkerSave;
import verdnatura.es.repartoverdnatura.UTILS.ApiUtils;
diff --git a/app/src/main/java/verdnatura/es/repartoverdnatura/LoginActivity.java b/app/src/main/java/verdnatura/es/repartoverdnatura/LoginActivity.java
index 07c961c..e7ebc77 100644
--- a/app/src/main/java/verdnatura/es/repartoverdnatura/LoginActivity.java
+++ b/app/src/main/java/verdnatura/es/repartoverdnatura/LoginActivity.java
@@ -1,35 +1,31 @@
package verdnatura.es.repartoverdnatura;
-import android.app.AlertDialog;
-import android.content.Context;
import android.content.Intent;
-import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
+import android.support.v7.app.AppCompatActivity;
import android.text.InputType;
import android.text.method.HideReturnsTransformationMethod;
-import android.text.method.PasswordTransformationMethod;
import android.util.Log;
import android.view.View;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.EditText;
-import java.util.HashMap;
-import java.util.Map;
-
-import okhttp3.ResponseBody;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
import verdnatura.es.repartoverdnatura.INTERFACES.RestClient;
+import verdnatura.es.repartoverdnatura.INTERFACES.RestClientSalix;
+import verdnatura.es.repartoverdnatura.MODELS.LoginSalix;
import verdnatura.es.repartoverdnatura.UTILS.ApiUtils;
-import verdnatura.es.repartoverdnatura.UTILS.CustomProgressBar;
+import verdnatura.es.repartoverdnatura.UTILS.ApiUtilsSalix;
import verdnatura.es.repartoverdnatura.UTILS.Utils;
public class LoginActivity extends AppCompatActivity {
private RestClient restClient;
- private EditText txtUser,txtPassword;
+ private RestClientSalix restClientSalix;
+ private EditText txtUser, txtPassword;
private CheckBox checkVerPass;
@@ -37,78 +33,160 @@ public class LoginActivity extends AppCompatActivity {
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_login);
+
restClient = ApiUtils.getAPIService();
+ restClientSalix = ApiUtilsSalix.getAPIService();
+
setViews();
setEvents();
-
checkUser();
}
- private void checkUser(){
- if (!Utils.getIdUser(this).equals("nouser")){
- startActivity(new Intent(this,MainActivity.class));
+ private void checkUser() {
+ if (!Utils.getIdUser(this).equals("nouser")) {
+ deviceLog_add();
+ //startActivity(new Intent(this, MainActivity.class));
}
}
- private void setViews(){
+ private void setViews() {
txtUser = findViewById(R.id.txtUsuario);
txtPassword = findViewById(R.id.txtPassword);
checkVerPass = findViewById(R.id.checkVerPass);
}
- private void setEvents(){
+ private void setEvents() {
checkVerPass.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean isChecked) {
- if(!isChecked){
+ if (!isChecked) {
txtPassword.setInputType(InputType.TYPE_TEXT_VARIATION_PASSWORD);
- }else{
+ } else {
txtPassword.setInputType(InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD);
}
}
});
}
- public void logIn(View v){
- Utils.progressBar.show(this,"Check user");
+ public void logInSalix(View v) {
+ Utils.progressBar.show(this, "Check user");
final String user = txtUser.getText().toString();
final String password = txtPassword.getText().toString();
- String[] userData = new String[2];
+ LoginSalix ls = new LoginSalix(user, password, "", false, "");
final LoginActivity that = this;
- restClient.login(Utils.getMap(user,password),userData).enqueue(new Callback() {
+ restClientSalix.loginSalix(Utils.getMapSalix(user, password), ls).enqueue(new Callback() {
@Override
- public void onResponse(Call call, Response response) {
+ public void onResponse(Call call, Response response) {
Utils.progressBar.getDialog().dismiss();
- if(response.isSuccessful()){
- Log.i("API","Respuesta: "+response.body());
- Utils.saveIdUserLogin(that,response.body());
- Utils.saveIdUser(that,response.body().toString());
- Utils.saveUserPass(that,user,password);
- startActivity(new Intent(that,MainActivity.class));
+ if (response.isSuccessful()) {
+
+ Utils.saveUserPass(that, user, password);
+ Utils.saveTokenUser(that, response.body().getToken());
+ worker_getId();
txtUser.setText("");
txtPassword.setText("");
- }else{
- Utils.showErrorDialog(that,that.getResources().getString(R.string.usuario_incorrecto));
- Log.e("API", "Response is not successful "+response.message());
+ } else {
+ Utils.showErrorDialog(that, that.getResources().getString(R.string.usuario_incorrecto));
+ Log.e("API", "Response is not successful " + response.message());
}
}
@Override
- public void onFailure(Call call, Throwable t) {
+ public void onFailure(Call call, Throwable t) {
Utils.progressBar.getDialog().dismiss();
- Utils.showErrorDialog(that,that.getResources().getString(R.string.error_conexion));
+ Utils.showErrorDialog(that, that.getResources().getString(R.string.error_conexion));
}
});
}
- public void showPassword(View v){
+
+ public void worker_getId() {
+
+ Utils.progressBar.show(this, "Check user");
+ final String user = txtUser.getText().toString();
+ final String password = txtPassword.getText().toString();
+
+ final LoginActivity that = this;
+
+ restClient.worker_getId(Utils.getMap(user, password)).enqueue(new Callback() {
+ @Override
+ public void onResponse(Call call, Response response) {
+ Utils.progressBar.getDialog().dismiss();
+ if (response.isSuccessful()) {
+
+ Utils.saveIdUserLogin(that,response.body());
+ Utils.saveIdUser(that, response.body());
+ deviceLog_add();
+ txtUser.setText("");
+ txtPassword.setText("");
+
+
+ } else {
+ Utils.showErrorDialog(that, that.getResources().getString(R.string.workerId_incorrect));
+ Log.e("API", "Response is not successful " + response.message());
+ }
+ }
+
+ @Override
+ public void onFailure(Call call, Throwable t) {
+ Utils.progressBar.getDialog().dismiss();
+ Utils.showErrorDialog(that, that.getResources().getString(R.string.error_conexion));
+ }
+ });
+
+
+ }
+
+
+ public void deviceLog_add() {
+
+ Utils.progressBar.show(this, "Añadiendo log");
+ final String user = Utils.getUser(this);
+ final String password = Utils.getPass(this);
+
+ String data[] = new String[3];
+ data[0] = Utils.getAppName();
+ data[1] = Utils.getAppVersion(this);
+ data[2] = Utils.getAndroid_id(this);
+
+ final LoginActivity that = this;
+
+ restClient.deviceLog_add(Utils.getMap(user, password), data).enqueue(new Callback() {
+ @Override
+ public void onResponse(Call call, Response response) {
+ Utils.progressBar.getDialog().dismiss();
+ if (response.isSuccessful()) {
+
+ startActivity(new Intent(that, MainActivity.class));
+ txtUser.setText("");
+ txtPassword.setText("");
+
+
+ } else {
+ Utils.showErrorDialog(that, that.getResources().getString(R.string.log_incorrect));
+ //Utils.showErrorDialog(that,response.message().toString());
+ startActivity(new Intent(that, MainActivity.class));
+ }
+ }
+
+ @Override
+ public void onFailure(Call call, Throwable t) {
+ Utils.progressBar.getDialog().dismiss();
+ Utils.showErrorDialog(that, that.getResources().getString(R.string.error_conexion));
+ }
+ });
+
+
+ }
+
+ public void showPassword(View v) {
txtPassword.setTransformationMethod(HideReturnsTransformationMethod.getInstance());
}
}
diff --git a/app/src/main/java/verdnatura/es/repartoverdnatura/MODELS/Check.java b/app/src/main/java/verdnatura/es/repartoverdnatura/MODELS/Check.java
index b14300d..3416a05 100644
--- a/app/src/main/java/verdnatura/es/repartoverdnatura/MODELS/Check.java
+++ b/app/src/main/java/verdnatura/es/repartoverdnatura/MODELS/Check.java
@@ -43,13 +43,21 @@ public class Check {
@SerializedName("nickname")
private String nickname;
- @SerializedName("itemPackingTypeFk")
- private String itemPackingTypeFk;
+ @SerializedName("itemPackingTypeConcat")
+ private String itemPackingTypeConcat;
+
+ @SerializedName("code")
+ private String code;
+
+ private String isSent;
- public Check(String id, String ticketFk, String checked, String nickname,String address,String street,String city, String postalCode,
- String alertLevel,String routeFK,String delivered,String itemPackingTypeFk) {
+
+
+
+ public Check(String id, String ticketFk, String checked, String nickname, String address, String street, String city, String postalCode,
+ String alertLevel, String routeFK, String delivered, String itemPackingTypeConcat, String isSent, String code) {
this.id = id;
this.ticketFk = ticketFk;
this.checked = checked;
@@ -61,18 +69,41 @@ public class Check {
this.alertLevel = alertLevel;
this.routeFk =routeFK;
this.delivered = delivered;
- this.itemPackingTypeFk =itemPackingTypeFk;
+ this.itemPackingTypeConcat = itemPackingTypeConcat;
+ this.isSent = isSent;
+ this.code = code;
//c.getStreet()+" "+c.getCity()+" "+c.getPostalCode()
}
- public String getItemPackingTypeFk(){
- return itemPackingTypeFk;
+
+
+ public String getItemPackingTypeConcat(){
+ return itemPackingTypeConcat;
}
- public void setItemPackingTypeFk(String itemPackingTypeFk){
- this.itemPackingTypeFk=itemPackingTypeFk;
+ public void setItemPackingTypeConcat(String itemPackingTypeConcat){
+ this.itemPackingTypeConcat=itemPackingTypeConcat;
+ }
+ public String getCode() {
+ return code;
+ }
+
+ public Check(String id){
+ this.id=id;
+ }
+
+ public void setCode(String code) {
+ this.code = code;
+ }
+
+ public void setSent(String sent) {
+ isSent = sent;
+ }
+
+ public String getSent(){
+ return isSent;
}
public String getBultos() {
diff --git a/app/src/main/java/verdnatura/es/repartoverdnatura/MODELS/SignDataUpload.java b/app/src/main/java/verdnatura/es/repartoverdnatura/MODELS/SignDataUpload.java
index d2046e6..aa852bd 100644
--- a/app/src/main/java/verdnatura/es/repartoverdnatura/MODELS/SignDataUpload.java
+++ b/app/src/main/java/verdnatura/es/repartoverdnatura/MODELS/SignDataUpload.java
@@ -2,7 +2,10 @@ package verdnatura.es.repartoverdnatura.MODELS;
import android.location.Location;
+import java.text.SimpleDateFormat;
+import java.util.Date;
import java.util.List;
+import java.util.Locale;
public class SignDataUpload {
private String Sign;
@@ -10,18 +13,39 @@ public class SignDataUpload {
private verdnatura.es.repartoverdnatura.MODELS.Location Location;
private String clientName = "";
private String idClient = "";
+ private String signedTime;
+ private String addressFk;
- public SignDataUpload(String sign, List tickets, verdnatura.es.repartoverdnatura.MODELS.Location location) {
+ public SignDataUpload(String sign, List tickets, verdnatura.es.repartoverdnatura.MODELS.Location location, String address) {
Sign = sign;
Tickets = tickets;
Location = location;
+ signedTime = new SimpleDateFormat("yyyy-LL-dd HH:mm", Locale.getDefault()).format(new Date());
+ addressFk =address;
}
- public SignDataUpload(String sign, List tickets) {
+ public SignDataUpload(String sign, List tickets,String address) {
Sign = sign;
Tickets = tickets;
Location = null;
+ signedTime = new SimpleDateFormat("yyyy-LL-dd HH:mm", Locale.getDefault()).format(new Date());
+ addressFk = address;
}
+
+ public String getSignedTime(){
+ return signedTime;}
+
+ public void setSignedTime(String signedTime) {
+ this.signedTime = signedTime;
+ }
+ public String getAddressFk(){
+ return addressFk;
+ }
+ public void setAddressFk(String address){
+ addressFk=address;
+ }
+
+
public String getSign() {
return Sign;
}
diff --git a/app/src/main/java/verdnatura/es/repartoverdnatura/MainActivity.java b/app/src/main/java/verdnatura/es/repartoverdnatura/MainActivity.java
index 97e9d0f..1ab460e 100644
--- a/app/src/main/java/verdnatura/es/repartoverdnatura/MainActivity.java
+++ b/app/src/main/java/verdnatura/es/repartoverdnatura/MainActivity.java
@@ -1,7 +1,8 @@
package verdnatura.es.repartoverdnatura;
+import static verdnatura.es.repartoverdnatura.UTILS.LocalStorage.clearPendingExpedition;
+
import android.Manifest;
-import android.app.Activity;
import android.app.AlertDialog;
import android.content.BroadcastReceiver;
import android.content.Context;
@@ -11,10 +12,9 @@ import android.content.IntentFilter;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.net.Uri;
-import android.os.Parcelable;
+import android.os.Bundle;
import android.support.v4.app.ActivityCompat;
import android.support.v7.app.AppCompatActivity;
-import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.ViewGroup;
@@ -24,14 +24,12 @@ import android.widget.TextView;
import com.google.gson.Gson;
-import java.io.Serializable;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
-import java.util.Locale;
import java.util.Set;
import retrofit2.Call;
@@ -43,7 +41,6 @@ import verdnatura.es.repartoverdnatura.INTERFACES.RestClient;
import verdnatura.es.repartoverdnatura.MODELS.Check;
import verdnatura.es.repartoverdnatura.MODELS.Ruta;
import verdnatura.es.repartoverdnatura.MODELS.SignDataUpload;
-import verdnatura.es.repartoverdnatura.MODELS.Ticket;
import verdnatura.es.repartoverdnatura.MODELS.Version;
import verdnatura.es.repartoverdnatura.UTILS.ApiUtils;
import verdnatura.es.repartoverdnatura.UTILS.LocalStorage;
@@ -54,6 +51,9 @@ public class MainActivity extends AppCompatActivity {
private ListView listViewRutas, listViewPendingTickets;
private ArrayList listaRutas = new ArrayList<>();
private ArrayList listaPendientes = new ArrayList<>();
+
+
+
private RutaAdapter rutaAdapter;
private PendingTickets pendingAdapter;
private int heightCellRoute;
@@ -74,18 +74,14 @@ public class MainActivity extends AppCompatActivity {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
- /* listaRutasCargadas.addAll(LocalStorage.loadRutasCargadas(this));
-
- for (String i:listaRutasCargadas){
- Log.d("VERDNATURA::","La ruta recuperada es onCreate es "+i);
- }*/
- //Log.d("VERDNATURA::","La ruta OnCreate es "+LocalStorage.loadRutaCargada(this,"IdRoute128623"));
restClient = ApiUtils.getAPIService();
setViews();
getRoutes(null);
getPending();
+ getPengingExpeditions();
+
registerReceiver(broadcastReceiver, new IntentFilter("UPDATEPENDING"));
if (ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
@@ -106,13 +102,10 @@ public class MainActivity extends AppCompatActivity {
@Override
protected void onRestart() {
- /* listaRutasCargadas= (ArrayList) LocalStorage.loadRutasCargadas(this);
- for (String ruta : listaRutasCargadas){
- Log.d("VERDNATURA::","La rutas cargadas son :"+ruta);
- }
-*/
+
getRoutes(null);
getPending();
+ getPengingExpeditions();
super.onRestart();
}
@@ -159,6 +152,7 @@ public class MainActivity extends AppCompatActivity {
}
+
that.rutaAdapter = new RutaAdapter(that,listaRutas);
that.listViewRutas.setAdapter(that.rutaAdapter);
ViewGroup.LayoutParams params = listViewRutas.getLayoutParams();
@@ -192,6 +186,14 @@ public class MainActivity extends AppCompatActivity {
}
+ public void goToExpeditionInfo(View v){
+
+
+ Intent i = new Intent(this,ExpeditionInfoActivity.class);
+ startActivity(i);
+
+ }
+
public void getLocalData(){
List list = LocalStorage.getRutas(this);
if (list.size() > 0){
@@ -234,7 +236,6 @@ public class MainActivity extends AppCompatActivity {
try {
Log.d("VERDNATURA::","Las rutas son "+ruta.getId());
- Log.d("VERDNATURA::","Las rutas son "+ruta.getDate());
} catch (Exception e) {
e.printStackTrace();
@@ -253,7 +254,63 @@ public class MainActivity extends AppCompatActivity {
}
+ private void getPengingExpeditions(){
+
+ ArrayListlistExpeditionPending = new ArrayList<>();
+ Set listPendientes = LocalStorage.getPendingExpeditions(this);
+
+ Gson gson = new Gson();
+ if (listPendientes.size() > 0 ){
+ for(String s : listPendientes){
+ listExpeditionPending.add(gson.fromJson(s,Check.class));
+ }
+ // Log.d("VERDNATURA::","Pendientes:"+ listExpeditionPending.size());
+ if (listExpeditionPending.size()>0) {
+ sendPengingExpeditionsList(listExpeditionPending,"DELIVERED");
+
+ }
+
+ }else{
+ // Log.d("VERDNATURA::","No hay Pendientes"+ listExpeditionPending.size());
+ }
+
+
+ }
+
+ public void sendPengingExpeditionsList(final List listPending, String state){
+
+
+ final MainActivity that = this;
+ Object[] stateData = new Object[2];
+ stateData[0]= listPending;
+ stateData[1]=state;
+
+ restClient.expeditionState_addByExpeditionMulti(Utils.getMapWhitUser(this),stateData).enqueue(new Callback() {
+ @Override
+ public void onResponse(Call call, Response response) {
+ Utils.progressBar.getDialog().dismiss();
+ if(response.isSuccessful()){
+
+ // Log.d("VERDNATURA::","enviados pendientes");
+ clearPendingExpedition(that);
+
+ }else{
+ Utils.progressBar.getDialog().dismiss();
+
+ }
+ }
+
+ @Override
+ public void onFailure(Call call, Throwable t) {
+ Utils.progressBar.getDialog().dismiss();
+ }
+ });
+ }
+
+
private void getPending(){
+
+ // Log.d("VERDNATURA::","Se ha cambiado la red");
listaPendientes = new ArrayList<>();
Set listPendientes = LocalStorage.getPendingSigns(this);
Gson gson = new Gson();
@@ -280,11 +337,14 @@ public class MainActivity extends AppCompatActivity {
}
public void onLoadSelected(int pos){
- Intent i = new Intent(this,LoadVanActivity.class);
+ // Intent i = new Intent(this,LoadVanActivity.class);
+ Intent i=new Intent(this,ExpeditionSummaryActivity.class);
i.putExtra("route",listaRutas.get(pos));
startActivity(i);
}
+
+
public void logOut(View v){
final MainActivity that = this;
@@ -329,12 +389,14 @@ public class MainActivity extends AppCompatActivity {
public void goToInfo(View v){
startActivity(new Intent(this,InfoActivity.class));
}
-
- public void goToLoaders(int pos){
+ public void goToFound(View v){
+ startActivity(new Intent(this,ExpeditionScanActivity.class));
+ }
+ /* public void goToLoaders(int pos){
Intent i = new Intent(this,LoadersActivity.class);
i.putExtra("idRoute",listaRutas.get(pos).getId());
startActivity(i);
- }
+ }*/
public void savePending(int pos){
SignDataUpload data = listaPendientes.get(pos);
@@ -422,8 +484,6 @@ public class MainActivity extends AppCompatActivity {
}
public void checkVersion(){
- // //Log.i("VERDNATURA","entramos en checkVersion");
-
String[] userData = new String[1];
userData[0] = "delivery";
@@ -494,6 +554,7 @@ public class MainActivity extends AppCompatActivity {
@Override
public void onBackPressed() {
+ finish();
}
}
diff --git a/app/src/main/java/verdnatura/es/repartoverdnatura/NetworkStateReveiver.java b/app/src/main/java/verdnatura/es/repartoverdnatura/NetworkStateReveiver.java
index 0552eac..d106247 100644
--- a/app/src/main/java/verdnatura/es/repartoverdnatura/NetworkStateReveiver.java
+++ b/app/src/main/java/verdnatura/es/repartoverdnatura/NetworkStateReveiver.java
@@ -28,11 +28,11 @@ public class NetworkStateReveiver extends BroadcastReceiver {
public void onReceive(Context context, Intent intent) {
this.context = context;
- Log.d("app", "Network connectivity change");
+ Log.d("VERDNATURA::", "Network connectivity change");
if (intent.getExtras() != null) {
NetworkInfo ni = (NetworkInfo) intent.getExtras().get(ConnectivityManager.EXTRA_NETWORK_INFO);
if (ni != null && ni.getState() == NetworkInfo.State.CONNECTED) {
- Log.i("app", "Network " + ni.getTypeName() + " connected");
+ Log.i("VERDNATURA::", "Network " + ni.getTypeName() + " connected");
//TENEMOS INTERNET
Set listPendientes = LocalStorage.getPendingSigns(context);
if (listPendientes.size() != 0){
diff --git a/app/src/main/java/verdnatura/es/repartoverdnatura/NoteActivity.java b/app/src/main/java/verdnatura/es/repartoverdnatura/NoteActivity.java
index 379a4fc..f823bbc 100644
--- a/app/src/main/java/verdnatura/es/repartoverdnatura/NoteActivity.java
+++ b/app/src/main/java/verdnatura/es/repartoverdnatura/NoteActivity.java
@@ -121,9 +121,10 @@ public class NoteActivity extends AppCompatActivity {
public void onResponse(Call call, Response response) {
Utils.progressBar.getDialog().dismiss();
if (response.isSuccessful()){
- if(response.body().equals("Finish")){
+ //sergio:modificat per llevar el "finish"
+ /* if(response.body().equals("Finish")){
finish();
- }else{
+ }else{*/
clientTicket.setNote(response.body());
Intent returnIntent = new Intent();
returnIntent.putExtra("clientTicket",clientTicket);
@@ -131,7 +132,7 @@ public class NoteActivity extends AppCompatActivity {
setResult(Activity.RESULT_OK,returnIntent);
finish();
- }
+ // }
}else{
Utils.showErrorDialog(that,that.getResources().getString(R.string.error_conexion));
}
diff --git a/app/src/main/java/verdnatura/es/repartoverdnatura/SignActivity.java b/app/src/main/java/verdnatura/es/repartoverdnatura/SignActivity.java
index 8d92428..09676a4 100644
--- a/app/src/main/java/verdnatura/es/repartoverdnatura/SignActivity.java
+++ b/app/src/main/java/verdnatura/es/repartoverdnatura/SignActivity.java
@@ -23,8 +23,11 @@ import android.widget.TextView;
import com.simplify.ink.InkView;
import java.io.ByteArrayOutputStream;
+import java.text.SimpleDateFormat;
import java.util.ArrayList;
+import java.util.Date;
import java.util.List;
+import java.util.Locale;
import java.util.Map;
import retrofit2.Call;
@@ -55,7 +58,7 @@ public class SignActivity extends AppCompatActivity implements LocationListener{
setContentView(R.layout.activity_sign);
restClient = ApiUtils.getAPIService();
locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
- Criteria criteria = new Criteria();
+ Criteria criteria = new Criteria();
String provider = locationManager.getBestProvider(criteria, true);
if (ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
ActivityCompat.requestPermissions(this,
@@ -64,14 +67,20 @@ public class SignActivity extends AppCompatActivity implements LocationListener{
}else{
location = locationManager.getLastKnownLocation(provider);
}
-
+ try {
locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER,0, 0,this);
locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER,0, 0,this);
+ }
+ catch(Exception e) {
+
+ }
+
Intent intent = this.getIntent();
Bundle bundle = intent.getExtras();
clientTickets = (ClientTickets) bundle.getSerializable("clientTicket");
+ // Log.d("VERDNATURA::","El consignatario es "+clientTickets.getAddress());
idRuta = bundle.getString("idRuta");
setViews();
setScreen();
@@ -144,7 +153,7 @@ public class SignActivity extends AppCompatActivity implements LocationListener{
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
- SignDataUpload data = new SignDataUpload(that.BitMapToString(drawing),tickets,new verdnatura.es.repartoverdnatura.MODELS.Location(clientTickets.getLongitude(),clientTickets.getLatitude()));
+ SignDataUpload data = new SignDataUpload(that.BitMapToString(drawing),tickets,new verdnatura.es.repartoverdnatura.MODELS.Location(clientTickets.getLongitude(),clientTickets.getLatitude()),clientTickets.getAddress());
confirmSave(data);
}
@@ -153,7 +162,7 @@ public class SignActivity extends AppCompatActivity implements LocationListener{
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
- SignDataUpload data = new SignDataUpload(that.BitMapToString(drawing),tickets,new verdnatura.es.repartoverdnatura.MODELS.Location(String.valueOf(location.getLongitude()),String.valueOf(location.getLatitude())));
+ SignDataUpload data = new SignDataUpload(that.BitMapToString(drawing),tickets,new verdnatura.es.repartoverdnatura.MODELS.Location(String.valueOf(location.getLongitude()),String.valueOf(location.getLatitude())),clientTickets.getAddress());
confirmSave(data);
}
@@ -163,21 +172,21 @@ public class SignActivity extends AppCompatActivity implements LocationListener{
}else{
//sergio: No subido para comprobar si location == null.
if (location==null) {
- SignDataUpload data = new SignDataUpload(that.BitMapToString(drawing), tickets);
+ SignDataUpload data = new SignDataUpload(that.BitMapToString(drawing), tickets,clientTickets.getAddress());
// SignDataUpload data = new SignDataUpload(that.BitMapToString(drawing), tickets, new verdnatura.es.repartoverdnatura.MODELS.Location("0.0", "0.0"));
confirmSave(data);
}else{
- SignDataUpload data = new SignDataUpload(that.BitMapToString(drawing),tickets,new verdnatura.es.repartoverdnatura.MODELS.Location(String.valueOf(location.getLongitude()),String.valueOf(location.getLatitude())));
+ SignDataUpload data = new SignDataUpload(that.BitMapToString(drawing),tickets,new verdnatura.es.repartoverdnatura.MODELS.Location(String.valueOf(location.getLongitude()),String.valueOf(location.getLatitude())),clientTickets.getAddress());
confirmSave(data);}
}
}else{
if (location != null){
- SignDataUpload data = new SignDataUpload(that.BitMapToString(drawing),tickets,new verdnatura.es.repartoverdnatura.MODELS.Location(String.valueOf(location.getLongitude()),String.valueOf(location.getLatitude())));
+ SignDataUpload data = new SignDataUpload(that.BitMapToString(drawing),tickets,new verdnatura.es.repartoverdnatura.MODELS.Location(String.valueOf(location.getLongitude()),String.valueOf(location.getLatitude())),clientTickets.getAddress());
confirmSave(data);
}else{
//SignDataUpload data = new SignDataUpload(that.BitMapToString(drawing),tickets,new verdnatura.es.repartoverdnatura.MODELS.Location("0.0","0.0"));
- SignDataUpload data = new SignDataUpload(that.BitMapToString(drawing), tickets);
+ SignDataUpload data = new SignDataUpload(that.BitMapToString(drawing), tickets,clientTickets.getAddress());
confirmSave(data);
}
@@ -193,10 +202,20 @@ public class SignActivity extends AppCompatActivity implements LocationListener{
}
public void confirmSave(final SignDataUpload data){
+ Log.d("VERDNATURA::","La firma es "+data.getSignedTime());
+ Log.d("VERDNATURA::","EL consig es "+data.getAddressFk());
+
Utils.progressBar.show(this,getResources().getString(R.string.please_wait));
+
+
final SignActivity that = this;
Object[] args = new Object[1];
args[0] = data;
+
+
+
+
+
restClient.saveSign(Utils.getMapWhitUser(this),args).enqueue(new Callback() {
@Override
public void onResponse(Call call, Response response) {
@@ -204,7 +223,7 @@ public class SignActivity extends AppCompatActivity implements LocationListener{
if(response.isSuccessful()){
if (response.body().equals("OK")){
- Log.i("INFO","guardado");
+ //Log.i("INFO","guardado");
Intent returnIntent = new Intent();
returnIntent.putExtra("idCliente",clientTickets.getClient());
setResult(Activity.RESULT_OK,returnIntent);
diff --git a/app/src/main/java/verdnatura/es/repartoverdnatura/Tickets.java b/app/src/main/java/verdnatura/es/repartoverdnatura/Tickets.java
index 826f871..02c3bf3 100644
--- a/app/src/main/java/verdnatura/es/repartoverdnatura/Tickets.java
+++ b/app/src/main/java/verdnatura/es/repartoverdnatura/Tickets.java
@@ -74,6 +74,13 @@ public class Tickets extends AppCompatActivity {
}
+ @Override
+ protected void onRestart() {
+ super.onRestart();
+ setViews();
+ checkPendingSigns();
+ }
+
public void checkPendingSigns(){
Set pendingSigns = LocalStorage.getPendingSigns(this);
if (pendingSigns.size() == 0){
diff --git a/app/src/main/java/verdnatura/es/repartoverdnatura/UTILS/ApiUtils.java b/app/src/main/java/verdnatura/es/repartoverdnatura/UTILS/ApiUtils.java
index ea36e40..377d445 100644
--- a/app/src/main/java/verdnatura/es/repartoverdnatura/UTILS/ApiUtils.java
+++ b/app/src/main/java/verdnatura/es/repartoverdnatura/UTILS/ApiUtils.java
@@ -5,12 +5,11 @@ import verdnatura.es.repartoverdnatura.INTERFACES.RestClient;
public class ApiUtils {
private ApiUtils() {}
- //public static final String BASE_URL = "http://192.168.1.141:9000/";
- // public static final String BASE_URL = "http://10.1.2.179:9000/";
-
- public static final String BASE_URL = "https://app.verdnatura.es/";
-
+ public static final String BASE_URL = "http://10.1.4.42:9000/";
+ //public static final String BASE_URL = "http://192.168.1.132:9000/";
+ //public static final String BASE_URL = "https://test-app.verdnatura.es/";
+ //public static final String BASE_URL = "https://app.verdnatura.es/";
public static RestClient getAPIService() {
return RetrofitClient.getClient(BASE_URL).create(RestClient.class);
diff --git a/app/src/main/java/verdnatura/es/repartoverdnatura/UTILS/LocalStorage.java b/app/src/main/java/verdnatura/es/repartoverdnatura/UTILS/LocalStorage.java
index c37beae..9ab67c7 100644
--- a/app/src/main/java/verdnatura/es/repartoverdnatura/UTILS/LocalStorage.java
+++ b/app/src/main/java/verdnatura/es/repartoverdnatura/UTILS/LocalStorage.java
@@ -23,6 +23,7 @@ import java.util.concurrent.TimeUnit;
import verdnatura.es.repartoverdnatura.MODELS.Check;
import verdnatura.es.repartoverdnatura.MODELS.ClientTickets;
import verdnatura.es.repartoverdnatura.MODELS.Ruta;
+import verdnatura.es.repartoverdnatura.MODELS.SectorItem;
import verdnatura.es.repartoverdnatura.MODELS.SignDataUpload;
public class LocalStorage {
@@ -55,12 +56,31 @@ public class LocalStorage {
editor.commit();
}
+
+
+
public static void addExpeditionSave(Context context, List checks){
sp = context.getSharedPreferences("expedition",Activity.MODE_PRIVATE);
SharedPreferences.Editor editor = sp.edit();
-
ArrayList listCheckSaved=getExpeditions(context);
+
+//sergio: modificar para borrar las expediciones con un criterio concreto si no se quedan sin borrar hasta que entren en la otra ruta.
+
+ ArrayList listDeleting = new ArrayList<>();
+
+ for (Check c: checks ){
+
+ for (Check l:listCheckSaved){
+ if (l.getId().equals(c.getId())){
+
+ listDeleting.add(l);
+
+ }
+ }
+ }
+
+ listCheckSaved.removeAll(listDeleting);
listCheckSaved.addAll(checks);
Gson gson = new Gson();
@@ -158,7 +178,9 @@ public class LocalStorage {
((list.get(i) == null) || (list.get(i).get("alertLevel") == null) ? "" : list.get(i).get("alertLevel")).toString(),
((list.get(i) == null) || (list.get(i).get("routeFk") == null) ? "" : list.get(i).get("routeFk")).toString(),
((list.get(i) == null) || (list.get(i).get("delivered") == null) ? "" : list.get(i).get("delivered")).toString(),
- ((list.get(i) == null) || (list.get(i).get("itemPackingTypeFk") == null) ? "" : list.get(i).get("itemPackingTypeFk").toString()
+ ((list.get(i) == null) || (list.get(i).get("itemPackingTypeConcat") == null) ? "" : list.get(i).get("itemPackingTypeConcat")).toString(),
+ ((list.get(i) == null) || (list.get(i).get("isSent") == null) ? "" : list.get(i).get("isSent")).toString(),
+ ((list.get(i) == null) || (list.get(i).get("code") == null) ? "" : list.get(i).get("code").toString()
)));
}
@@ -355,6 +377,8 @@ public class LocalStorage {
}
+
+
public static void saveSign(Context context,SignDataUpload data, String clientName,String idRuta){
sp = context.getSharedPreferences("delivery",Activity.MODE_PRIVATE);
SharedPreferences.Editor editor = sp.edit();
@@ -401,6 +425,34 @@ public class LocalStorage {
sp = context.getSharedPreferences("delivery",Activity.MODE_PRIVATE);
return sp.getStringSet("listSigns",new HashSet());
}
+
+
+ public static Set getPendingExpeditions(Context context){
+ sp = context.getSharedPreferences("deliveryexpedition",Activity.MODE_PRIVATE);
+ return sp.getStringSet("expeditionsPendings",new HashSet());
+ }
+
+ public static void clearPendingExpedition(Context context){
+ sp = context.getSharedPreferences("deliveryexpedition",Activity.MODE_PRIVATE);
+ SharedPreferences.Editor editor = sp.edit();
+ editor.remove("expeditionsPendings");
+ editor.commit();
+
+ }
+
+ public static void savePendingExpedition(Context context, List checks){
+ sp = context.getSharedPreferences("deliveryexpedition",Activity.MODE_PRIVATE);
+ SharedPreferences.Editor editor = sp.edit();
+ Set listString = new HashSet<>();
+ Gson gson = new Gson();
+ for(Check s : checks){
+ listString.add(gson.toJson(s));
+ }
+
+ editor.putStringSet("expeditionsPendings",listString);
+ editor.commit();
+ }
+
public static void udpatePendingSigns(Context context,ArrayList list,String idRuta){
for(SignDataUpload s : list){
saveSign(context,s,s.getClientName(),idRuta);
@@ -465,14 +517,29 @@ public class LocalStorage {
String daydownloaded =sp.getString("datedownload", "1900-01-01");
- if (getDateDiff(new SimpleDateFormat("yyyy-MM-dd"),today,daydownloaded)> 1) {
+ if (getDateDiff(new SimpleDateFormat("yyyy-MM-dd"),today,daydownloaded)> 0) {
clearExpeditions(context);
}
- // Log.d("VERDNATURA::","DateOfdownload"+sp.getString("datedownload","1900-01-01") + "-today:"+today+"-difrence"+getDateDiff(new SimpleDateFormat("yyyy-MM-dd"),today,daydownloaded));
saveDateOfDownload(context);
}
+ public static void saveSector(Context context, SectorItem sector) {
+ sp = context.getSharedPreferences("sector",Activity.MODE_PRIVATE);
+ SharedPreferences.Editor editor = sp.edit();
+
+ editor.putInt("sectorId",sector.getId());
+ editor.putString("sectorDescrip",sector.getDescription());
+ editor.putInt("sectorWarehouse",sector.getWarehouseFk());
+ editor.commit();
+
+ }
+
+ public static String getSectorDescrip(Context context) {
+
+ sp = context.getSharedPreferences("sector",Activity.MODE_PRIVATE);
+ return sp.getString("sectorDescrip","Sin sector");
+ }
}
diff --git a/app/src/main/java/verdnatura/es/repartoverdnatura/UTILS/RetrofitClient.java b/app/src/main/java/verdnatura/es/repartoverdnatura/UTILS/RetrofitClient.java
index d7a6c41..3179f85 100644
--- a/app/src/main/java/verdnatura/es/repartoverdnatura/UTILS/RetrofitClient.java
+++ b/app/src/main/java/verdnatura/es/repartoverdnatura/UTILS/RetrofitClient.java
@@ -17,3 +17,4 @@ public class RetrofitClient {
return retrofit;
}
}
+
diff --git a/app/src/main/java/verdnatura/es/repartoverdnatura/UTILS/Utils.java b/app/src/main/java/verdnatura/es/repartoverdnatura/UTILS/Utils.java
index bacd160..93c225f 100644
--- a/app/src/main/java/verdnatura/es/repartoverdnatura/UTILS/Utils.java
+++ b/app/src/main/java/verdnatura/es/repartoverdnatura/UTILS/Utils.java
@@ -5,16 +5,23 @@ import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.SharedPreferences;
+import android.content.pm.ApplicationInfo;
+import android.content.pm.PackageManager;
+import android.provider.Settings;
+import android.support.v4.BuildConfig;
import android.util.Log;
import java.util.HashMap;
import java.util.Map;
+import verdnatura.es.repartoverdnatura.R;
+
public class Utils {
static SharedPreferences sp;
static Map map = new HashMap<>();
+ static Map mapSalix = new HashMap<>();
public static CustomProgressBar progressBar = new CustomProgressBar();
public static CustomProgressBar progressBar_info = new CustomProgressBar();
@@ -23,7 +30,31 @@ public class Utils {
return (int) (dips * context.getResources().getDisplayMetrics().density + 0.5f);
}
- public static Map getMap(String user,String password){
+ public static String getAppName() {
+ /* ApplicationInfo applicationInfo = context.getApplicationInfo();
+ int stringId = applicationInfo.labelRes;
+ return stringId == 0 ? applicationInfo.nonLocalizedLabel.toString() : context.getString(stringId);*/
+ return "delivery";
+ }
+
+ public static String getAppVersion(Context context) {
+ PackageManager packageManager = context.getPackageManager();
+ String version="";
+ try {
+
+ version=packageManager.getPackageInfo(context.getPackageName(), 0).versionName;
+ } catch (PackageManager.NameNotFoundException e) {
+ e.printStackTrace();
+ }
+ return version;
+ }
+
+ public static String getAndroid_id(Context context) {
+ return Settings.Secure.getString(context.getContentResolver(), Settings.Secure.ANDROID_ID);
+
+ }
+
+ public static Map getMap(String user, String password) {
map.put("version", "1");
map.put("aplicacion", "json");
map.put("user", user);
@@ -32,20 +63,30 @@ public class Utils {
return map;
}
- public static Map getMapWhitUser(Context context){
- sp = context.getSharedPreferences("delivery",Activity.MODE_PRIVATE);
- String user = sp.getString("user","");
- String password = sp.getString("pass","");
+ public static Map getMapSalix(String user, String password) {
+ map.put("version", "1");
+ map.put("aplicacion", "json");
+ map.put("user", user);
+ map.put("pass", password);
+ map.put("Content-Type", "application/json");
+ return mapSalix;
+ }
+
+
+ public static Map getMapWhitUser(Context context) {
+ sp = context.getSharedPreferences("delivery", Activity.MODE_PRIVATE);
+ String user = sp.getString("user", "");
+ String password = sp.getString("pass", "");
+
map.put("version", "1");
map.put("aplicacion", "json");
map.put("user", user);
map.put("pass", password);
map.put("Content-Type", "application/x-www-form-urlencoded");
- ////Log.i("VERDNATURA","Mapeado"+map);
return map;
}
- public static void showErrorDialog(Context context,String mensaje){
+ public static void showErrorDialog(Context context, String mensaje) {
AlertDialog.Builder builder1 = new AlertDialog.Builder(context);
builder1.setMessage(mensaje);
builder1.setCancelable(true);
@@ -62,7 +103,8 @@ public class Utils {
AlertDialog alert11 = builder1.create();
alert11.show();
}
- public static void showErrorDialogAndFinish(final Context context, String mensaje){
+
+ public static void showErrorDialogAndFinish(final Context context, String mensaje) {
AlertDialog.Builder builder1 = new AlertDialog.Builder(context);
builder1.setMessage(mensaje);
builder1.setCancelable(true);
@@ -81,41 +123,59 @@ public class Utils {
alert11.show();
}
- public static void saveIdUser(Context context,String idUser){
- sp = context.getSharedPreferences("delivery",Activity.MODE_PRIVATE);
+ public static void saveIdUser(Context context, String idUser) {
+ sp = context.getSharedPreferences("delivery", Activity.MODE_PRIVATE);
SharedPreferences.Editor editor = sp.edit();
- editor.putString("idUser",idUser);
+ editor.putString("idUser", idUser);
+ editor.commit();
+ }
+
+ public static void saveTokenUser(Context context, String idUser) {
+ sp = context.getSharedPreferences("delivery", Activity.MODE_PRIVATE);
+ SharedPreferences.Editor editor = sp.edit();
+ editor.putString("idToken", idUser);
+ editor.commit();
+ }
+
+ public static void saveIdUserLogin(Context context, String idUser) {
+ sp = context.getSharedPreferences("deliveryLogin", Activity.MODE_PRIVATE);
+ SharedPreferences.Editor editor = sp.edit();
+ editor.putString("idUserLogin", idUser);
editor.commit();
}
- public static void saveIdUserLogin(Context context,String idUser){
- sp = context.getSharedPreferences("deliveryLogin",Activity.MODE_PRIVATE);
- SharedPreferences.Editor editor = sp.edit();
- editor.putString("idUserLogin",idUser);
- editor.commit();
- }
- public static String getIdUserLogin(Context context){
- sp = context.getSharedPreferences("deliveryLogin",Activity.MODE_PRIVATE);
- return sp.getString("idUserLogin","nouser");
+
+ public static String getIdUserLogin(Context context) {
+ sp = context.getSharedPreferences("deliveryLogin", Activity.MODE_PRIVATE);
+ return sp.getString("idUserLogin", "nouser");
}
- public static void saveUserPass(Context context,String user,String pass){
- sp = context.getSharedPreferences("delivery",Activity.MODE_PRIVATE);
+ public static void saveUserPass(Context context, String user, String pass) {
+ sp = context.getSharedPreferences("delivery", Activity.MODE_PRIVATE);
SharedPreferences.Editor editor = sp.edit();
- editor.putString("user",user);
- editor.putString("pass",pass);
+ editor.putString("user", user);
+ editor.putString("pass", pass);
editor.commit();
}
- public static String getIdUser(Context context){
- sp = context.getSharedPreferences("delivery",Activity.MODE_PRIVATE);
- return sp.getString("idUser","nouser");
+
+ public static String getUser(Context context) {
+ sp = context.getSharedPreferences("delivery", Activity.MODE_PRIVATE);
+ return sp.getString("user", "nouser");
+ }
+ public static String getPass(Context context) {
+ sp = context.getSharedPreferences("delivery", Activity.MODE_PRIVATE);
+ return sp.getString("pass", "");
+ }
+ public static String getIdUser(Context context) {
+ sp = context.getSharedPreferences("delivery", Activity.MODE_PRIVATE);
+ return sp.getString("idUser", "nouser");
}
- public static void logOut(Context context){
- sp = context.getSharedPreferences("delivery",Activity.MODE_PRIVATE);
+ public static void logOut(Context context) {
+ sp = context.getSharedPreferences("delivery", Activity.MODE_PRIVATE);
SharedPreferences.Editor editor = sp.edit();
editor.clear();
editor.commit();
diff --git a/app/src/main/java/verdnatura/es/repartoverdnatura/UnLoadVanActivity.kt b/app/src/main/java/verdnatura/es/repartoverdnatura/UnLoadVanActivity.kt
new file mode 100644
index 0000000..212cc40
--- /dev/null
+++ b/app/src/main/java/verdnatura/es/repartoverdnatura/UnLoadVanActivity.kt
@@ -0,0 +1,364 @@
+package verdnatura.es.repartoverdnatura
+
+import android.app.Activity
+import android.content.Context
+import android.content.Intent
+import android.media.MediaPlayer
+import android.os.Bundle
+import android.support.v7.app.AppCompatActivity
+import android.util.Log
+import android.view.View
+import android.view.View.GONE
+import android.view.View.OnFocusChangeListener
+import android.view.inputmethod.InputMethodManager
+import android.widget.*
+import com.google.gson.Gson
+import retrofit2.Call
+import retrofit2.Callback
+import retrofit2.Response
+import verdnatura.es.repartoverdnatura.ADAPTERS.CheckAdapter
+import verdnatura.es.repartoverdnatura.INTERFACES.RestClient
+import verdnatura.es.repartoverdnatura.MODELS.Check
+import verdnatura.es.repartoverdnatura.UTILS.ApiUtils
+import verdnatura.es.repartoverdnatura.UTILS.LocalStorage
+import verdnatura.es.repartoverdnatura.UTILS.Utils
+
+class UnLoadVanActivity : AppCompatActivity() {
+ var mperror: MediaPlayer? = null
+ var mpok: MediaPlayer? = null
+ var mpErrorRepeat: MediaPlayer? = null
+
+ var listCheck = ArrayList()
+
+ var adapter: CheckAdapter? = null
+ var listView: ListView? = null
+ private var restClient: RestClient? = null
+ var txtRuta: EditText? = null
+ var txtEscaner: EditText? = null
+ var txtLineas: TextView? = null
+ var txtIdRuta: TextView? = null
+ var txtTitle: TextView? = null
+
+ var delivered = 0
+ var routeLoaded=false
+ private var routeOfLoad = ""
+ private var adressToExpeditions=""
+ private lateinit var switchLoad:Switch
+
+ override fun onCreate(savedInstanceState: Bundle?) {
+ super.onCreate(savedInstanceState)
+ setContentView(R.layout.activity_loadvan)
+ mperror = MediaPlayer.create((this), R.raw.error)
+ mpok = MediaPlayer.create((this), R.raw.ok)
+ mpErrorRepeat = MediaPlayer.create((this), R.raw.errorrepeat)
+
+ restClient = ApiUtils.getAPIService()
+ listView = findViewById(R.id.listRoute)
+ txtRuta = findViewById(R.id.txtRuta)
+ txtEscaner = findViewById(R.id.txtEscaner)
+ txtLineas = findViewById(R.id.txtLineas)
+ txtIdRuta = findViewById(R.id.textView41)
+ txtTitle = findViewById(R.id.textView3)
+
+ setEvents()
+ fillRoutes()
+
+ }
+
+ override fun onBackPressed() {
+ // setRouteLoaded()
+ reviewLoad()
+ }
+
+ private fun reviewLoad(){
+
+ //sergio:último cambio después de que Felipe diera el ok
+ if (delivered >= (listCheck.filter{it.addressFk==adressToExpeditions}.filter{it.routeFk==routeOfLoad}).size){
+ Toast.makeText(this,"Expediciones de la ruta y cliente escaneada",Toast.LENGTH_SHORT).show()
+ goSign()
+ } else{
+ val alertDialog = android.app.AlertDialog.Builder(this).create()
+ alertDialog.setTitle("Información")
+ alertDialog.setMessage("El total de expediciones escaneadas es diferente al total a entregar. ¿ Quieres guardar las expediciones escaneadas o buscar la/s expedición/es ?")
+
+ alertDialog.setButton(
+ android.app.AlertDialog.BUTTON_NEUTRAL,"GUARDAR"
+ ) { dialog, which ->
+
+ if (listCheck.filter{it.addressFk==adressToExpeditions}.filter{it.code=="DELIVERED"}.isEmpty()){
+ goSign()
+ }else{
+ Utils.progressBar.show(this,getResources().getString(R.string.please_wait))
+ expeditionState_addByExpeditionMulti(listCheck.filter{it.addressFk==adressToExpeditions}.filter{it.code=="DELIVERED"},"DELIVERED")
+ routeLoaded}
+
+ }
+ alertDialog.setButton(
+ android.app.AlertDialog.BUTTON_POSITIVE,"BUSCAR"
+
+ ) { dialog, which ->
+
+ adapter = CheckAdapter(
+ this,
+ listCheck.sortedBy { it.delivered }.filter { it.addressFk == adressToExpeditions })
+ this.listView!!.adapter = adapter
+ adapter!!.notifyDataSetChanged()
+
+
+ }
+ alertDialog.show()
+ }
+
+ }
+
+
+ private fun expeditionState_addByExpeditionMulti(expeditions: List, state:String){
+ val stateData: Array = arrayOfNulls(2)
+ stateData[0]=expeditions
+ stateData[1]=state
+
+ restClient!!.expeditionState_addByExpeditionMulti(Utils.getMapWhitUser(this), stateData)
+ .enqueue(object : Callback {
+ override fun onResponse(call: Call, response: Response) {
+ Utils.progressBar.dialog.dismiss()
+ if (response.isSuccessful ) {
+ goSign()
+ }else{
+ showMessageError()
+ }
+ }
+
+ override fun onFailure(call: Call, t: Throwable) {
+ showMessageError()
+ }
+ })
+ }
+
+
+ private fun showMessageError(){
+ Utils.progressBar.dialog.dismiss()
+ Toast.makeText(this@UnLoadVanActivity, "Error al enviar. Se queda guardado para enviar más tarde", Toast.LENGTH_SHORT).show()
+ saveExpeditionPendings()
+ goSign()
+ }
+
+ private fun goSign(){
+
+ val bundle = intent.extras
+ val i = Intent(this, SignActivity::class.java)
+ i.putExtra("clientTicket", bundle.getSerializable("clientTicket"))
+ i.putExtra("idRuta", bundle.getString("idRuta"))
+ startActivity(i)
+ finish()
+
+ }
+
+
+
+ private fun saveExpeditionPendings() {
+
+ LocalStorage.savePendingExpedition(this, listCheck.filter { it.addressFk==adressToExpeditions }.filter{it.code=="DELIVERED"})
+
+
+ var listaPendientes = ArrayList()
+ val listPendientes = LocalStorage.getPendingExpeditions(this)
+ val gson = Gson()
+ for (s in listPendientes) {
+ listaPendientes.add(gson.fromJson(s, Check::class.java))
+
+ }
+
+ }
+
+ private fun fillRoutes() {
+
+ val intent = this.intent
+ val bundle = intent.extras
+
+ try {
+ adressToExpeditions = bundle.getString("adress")
+ routeOfLoad= bundle.getString("routeId")
+ }catch(e:Exception){}
+
+ checks_new
+
+ }
+
+ private fun setEvents() {
+
+ switchLoad = findViewById(R.id.switchLoad) as Switch
+ switchLoad.visibility=GONE
+ txtTitle!!.setText("Escáner entregado")
+
+ var btnUpload = findViewById(R.id.imageVanLoaded)
+ btnUpload.setOnClickListener{
+ reviewLoad()
+ }
+ btnUpload.setImageResource(R.drawable.firmar)
+
+ txtRuta!!.setOnEditorActionListener { textView, i, keyEvent ->
+
+ if (!routeLoaded){
+ checks_new
+ }
+ else{
+ findExpedition(txtRuta!!.text.toString())
+ }
+
+ false
+ }
+ txtRuta!!.onFocusChangeListener = OnFocusChangeListener { view, b ->
+
+
+ if (b) {
+ txtRuta!!.setText("")
+ txtIdRuta!!.setText(R.string.esccaneaEtiqueta)
+ }
+
+ }
+ /* txtEscaner!!.setOnEditorActionListener { textView, i, keyEvent ->
+ // checkList()
+ false
+ }*/
+ listView!!.setOnFocusChangeListener { view, b ->
+ txtRuta!!.requestFocus()
+ false
+ }
+ }
+
+
+ //sergio: nuevo para cargar furgos
+ private fun findExpedition(textScanned: String) {
+
+
+ var position = listCheck.indexOfFirst{it.id==textScanned}
+
+ if (position>=0 && listCheck[position].addressFk==adressToExpeditions){
+
+ markExpeditionUnLoaded(position)
+ } else{
+ mperror?.start()
+ }
+
+ txtRuta!!.requestFocus()
+
+ }
+
+ private fun markExpeditionUnLoaded(i:Int){
+ if (listCheck[i].delivered == "1") {
+ mpErrorRepeat?.start()
+ Toast.makeText(this, "Expedición ya escaneada para entrega", Toast.LENGTH_SHORT).show()
+
+ } else {
+ mpok?.start()
+ listCheck[i].delivered = "1"
+ delivered = delivered + 1
+ listCheck[i].code = "DELIVERED"
+ //solo guarda las expediciones para tenerlas al día
+ setCheck(listCheck[i])
+
+ }
+
+ adapter!!.notifyDataSetChanged()
+ txtLineas!!.text = delivered.toString() + "/" + listCheck.filter { it.addressFk==adressToExpeditions }.filter{it.routeFk==routeOfLoad}.size + " entregadas"
+ if (delivered >= listCheck.filter { it.addressFk==adressToExpeditions }.filter{it.routeFk==routeOfLoad}.size) {
+ Toast.makeText(this, "Escaneo a entregar completo", Toast.LENGTH_SHORT).show()
+ expeditionState_addByExpeditionMulti(listCheck.filter{it.routeFk==routeOfLoad}.filter{it.addressFk==adressToExpeditions }.filter{it.code=="DELIVERED"},"DELIVERED")
+ }
+ txtRuta!!.requestFocus()
+ hideKeyboard()
+
+ }
+
+
+ private fun setCheck(c: Check) {
+ LocalStorage.saveExpeditions(this,listCheck)
+ }
+
+ private val checks_new: Unit
+
+ private get() {
+ // listCheck = ArrayList()
+
+ var listDownload = ArrayList()
+ listDownload = ArrayList()
+
+ val that = this
+ val routeData: Array = arrayOfNulls(1)
+ routeData[0] = routeOfLoad
+ Utils.progressBar.show(this, resources.getString(R.string.please_wait))
+
+ restClient!!.getExpeditionFromRoute(Utils.getMapWhitUser(this), routeData)
+ .enqueue(object : Callback> {
+ override fun onResponse(
+ call: Call>,
+ response: Response>
+ ) {
+ Utils.progressBar.dialog.dismiss()
+ if (response.isSuccessful) {
+ for (c in response.body()!!) {
+
+ if (!c.code.isNullOrBlank()){
+
+ if (c.code.equals("ON DELIVERY")){
+ c.checked="1"
+ }
+ if (c.code.equals("DELIVERED")){
+ c.delivered="1"
+ }
+ }
+ listDownload.add(c)
+
+ }
+
+ LocalStorage.addExpeditionSave(that,listDownload)
+ getLocalDataExpedition(adressToExpeditions)
+
+ }else{
+
+ }
+ }
+
+ override fun onFailure(call: Call>, t: Throwable) {
+ Utils.progressBar.dialog.dismiss()
+ Utils.showErrorDialog(
+ that,
+ that.resources.getString(R.string.error_conexion)
+ )
+ getLocalDataExpedition(adressToExpeditions)
+ }
+ })
+ txtIdRuta!!.visibility= GONE
+ txtRuta!!.requestFocus()
+ }
+
+ fun Activity.hideKeyboard() {
+ hideKeyboard(currentFocus ?: View(this))
+ }
+
+ fun Context.hideKeyboard(view: View) {
+ val inputMethodManager = getSystemService(Activity.INPUT_METHOD_SERVICE) as InputMethodManager
+ inputMethodManager.hideSoftInputFromWindow(view.windowToken, 0)
+ }
+ fun getLocalDataExpedition(adress:String) {
+ val list: List = LocalStorage.getExpeditions(this)
+ listCheck=LocalStorage.getExpeditions(this)
+ if (list.size > 0) {
+
+ delivered = list.filter { it.addressFk == adress }
+ .filter { it.delivered == "1"}.filter{it.routeFk==routeOfLoad}.size
+
+ txtLineas!!.text = delivered.toString() + "/" + (listCheck.filter { it.addressFk==adress }.filter{it.routeFk==routeOfLoad}).size + " escaneadas"
+ //adapter = CheckAdapter(this, this.listCheck)
+ adapter = CheckAdapter(this, listCheck.filter { it.addressFk==adress }.filter{it.routeFk==routeOfLoad})
+
+ this.listView!!.adapter = adapter
+ routeLoaded=true
+ txtIdRuta!!.visibility= GONE
+ txtRuta!!.requestFocus()
+ hideKeyboard()
+
+ }
+ }
+
+}
\ No newline at end of file
diff --git a/app/src/main/res/layout/activity_info.xml b/app/src/main/res/layout/activity_info.xml
index 98be5ac..f7bafb1 100644
--- a/app/src/main/res/layout/activity_info.xml
+++ b/app/src/main/res/layout/activity_info.xml
@@ -18,18 +18,41 @@
+
+
+
diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml
index 864fa12..93aab98 100644
--- a/app/src/main/res/layout/activity_main.xml
+++ b/app/src/main/res/layout/activity_main.xml
@@ -41,26 +41,40 @@
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="@drawable/exit"
android:padding="5dp"
- android:onClick="logOut"/>
+ android:onClick="logOut"
+ android:visibility="gone"/>
+
+
+ app:srcCompat="@drawable/ic_history"
+ android:onClick="goToExpeditionInfo"/>
+
-
+
+ android:padding="2dp">
+ android:textSize="13sp" />
+ android:textSize="13sp" />
+
@@ -175,6 +177,7 @@
android:layout_height="wrap_content"
android:text="Cargada: "
android:textColor="@color/colorMainBg"
+ android:visibility="gone"
android:textSize="18sp" />
diff --git a/app/src/main/res/layout/row_route.xml b/app/src/main/res/layout/row_route.xml
index a017b75..d792714 100644
--- a/app/src/main/res/layout/row_route.xml
+++ b/app/src/main/res/layout/row_route.xml
@@ -8,7 +8,7 @@
+ android:layout_height="145dp"
+ android:paddingTop="1dp"
+ android:paddingLeft="5dp"
+ android:paddingRight="5dp"
+
+ >
+ android:visibility="gone"
+ android:textStyle="bold"
+ tools:visibility="visible"/>
+
+
+
+
+
+ android:textAlignment="center"
+ android:textColor="@color/colorPrimary" />
+
\ No newline at end of file
diff --git a/app/src/main/res/layout/row_sub_ticket.xml b/app/src/main/res/layout/row_sub_ticket.xml
index 7702ac1..42176af 100644
--- a/app/src/main/res/layout/row_sub_ticket.xml
+++ b/app/src/main/res/layout/row_sub_ticket.xml
@@ -49,7 +49,11 @@
+ android:orientation="horizontal"
+ android:gravity="right"
+ android:textAlignment="gravity"
+
+ >
+ android:textColor="@color/colorGray"
+ android:textSize="20sp"
+
+ />
+ android:textSize="20sp"
+ android:textColor="@color/colorMainBg"
+ />
+
+ android:orientation="horizontal"
+ android:gravity="right"
+ android:textAlignment="gravity">
+ android:visibility="gone"
+ android:textColor="@color/colorGray"
+ android:textSize="18sp"
+ />
-
+ -->
diff --git a/app/src/main/res/layout/row_ticket.xml b/app/src/main/res/layout/row_ticket.xml
index 8f29ce6..e42df16 100644
--- a/app/src/main/res/layout/row_ticket.xml
+++ b/app/src/main/res/layout/row_ticket.xml
@@ -37,44 +37,52 @@
+ />
diff --git a/app/src/main/res/values-en/strings.xml b/app/src/main/res/values-en/strings.xml
index f9f70ec..493bb1f 100644
--- a/app/src/main/res/values-en/strings.xml
+++ b/app/src/main/res/values-en/strings.xml
@@ -59,4 +59,9 @@
This package belongs to a ticket that is not ready, consult a responsible
Version app:
Packing type:
+ Scan delivery
+ It\'s not possilble to get worker id
+ It\'s not possilble to log the session
+ Resumen carga ruta:
+ Address:
\ No newline at end of file
diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml
index fd4fbb9..554c736 100644
--- a/app/src/main/res/values/colors.xml
+++ b/app/src/main/res/values/colors.xml
@@ -11,6 +11,7 @@
#30D961
#7B7B7B
#f7931e
+ #f77956
#000000
#1d1d1d
#171717
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index 4f2d8c4..2b98b8d 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -17,7 +17,8 @@
Clientes por firmar
ver firmados
Cliente
- Consignatorio
+ Consignatario
+ Consign:
PC
Ticket
Bultos
@@ -26,6 +27,8 @@
trabajando
error de conexión
Usuario o contraseña incorrectos
+ No se ha podido obtener el id del trabajador
+ No se ha podido realizar el log
Clientes firmados
ver por firmar
Teléfono
@@ -60,8 +63,10 @@
DESCARGAR
Hora
Cargar furgo
+ Escáner reparto
Esccanea una etiqueta para obtener ruta
Este bulto pertenece a un ticket que no está preaprado, consulta con un responsable
Versión app:
Tipo embalaje:
+ Resumen carga ruta:
diff --git a/build/intermediates/lint-cache/maven.google/com/google/firebase/group-index.xml b/build/intermediates/lint-cache/maven.google/com/google/firebase/group-index.xml
index e4067b7..eb4df55 100644
--- a/build/intermediates/lint-cache/maven.google/com/google/firebase/group-index.xml
+++ b/build/intermediates/lint-cache/maven.google/com/google/firebase/group-index.xml
@@ -1,86 +1,91 @@
-
-
-
-
+
+
+
+
-
+
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
-
+
-
+
-
-
-
+
+
+
-
-
+
+
-
+
-
-
-
-
-
-
-
+
+
+
+
+
+
+
-
+
-
-
-
+
+
+
-
+
-
-
-
-
+
+
+
+
-
-
-
-
-
-
-
+
+
+
+
+
+
+
-
-
-
+
+
+
-
-
+
+
@@ -94,14 +99,14 @@
-
-
+
+
-
+
-
+
diff --git a/build/intermediates/lint-cache/maven.google/master-index.xml b/build/intermediates/lint-cache/maven.google/master-index.xml
index e9f659d..a72b8b0 100644
--- a/build/intermediates/lint-cache/maven.google/master-index.xml
+++ b/build/intermediates/lint-cache/maven.google/master-index.xml
@@ -36,6 +36,7 @@
+
@@ -118,15 +119,20 @@
+
+
+
+
+
@@ -161,6 +167,7 @@
+
@@ -177,6 +184,7 @@
+
@@ -191,6 +199,7 @@
+
@@ -203,6 +212,7 @@
+
diff --git a/build/intermediates/lint-cache/sdk-registry.xml/sdk-registry.xml b/build/intermediates/lint-cache/sdk-registry.xml/sdk-registry.xml
index b617f27..753ee14 100644
--- a/build/intermediates/lint-cache/sdk-registry.xml/sdk-registry.xml
+++ b/build/intermediates/lint-cache/sdk-registry.xml/sdk-registry.xml
@@ -110,6 +110,9 @@
+
+
+
diff --git a/vn-delivery.iml b/vn-delivery.iml
index cabb566..0a534c9 100644
--- a/vn-delivery.iml
+++ b/vn-delivery.iml
@@ -7,9 +7,7 @@
-
-
-
+