initial commit

parent 988f2930
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="CompilerConfiguration">
<bytecodeTargetLevel target="17" />
</component>
</project>
\ No newline at end of file
......@@ -4,17 +4,16 @@
<component name="GradleSettings">
<option name="linkedExternalProjectsSettings">
<GradleProjectSettings>
<option name="testRunner" value="PLATFORM" />
<option name="testRunner" value="GRADLE" />
<option name="distributionType" value="DEFAULT_WRAPPED" />
<option name="externalProjectPath" value="$PROJECT_DIR$" />
<option name="gradleJvm" value="JDK" />
<option name="gradleJvm" value="jbr-17" />
<option name="modules">
<set>
<option value="$PROJECT_DIR$" />
<option value="$PROJECT_DIR$/app" />
</set>
</option>
<option name="resolveModulePerSourceSet" value="false" />
</GradleProjectSettings>
</option>
</component>
......
......@@ -5,7 +5,7 @@
<configuration PROFILE_NAME="Debug" CONFIG_NAME="Debug" />
</configurations>
</component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" project-jdk-name="1.8" project-jdk-type="JavaSDK">
<component name="ProjectRootManager" version="2" languageLevel="JDK_17" default="true" project-jdk-name="jbr-17" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/build/classes" />
</component>
<component name="ProjectType">
......
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="RunConfigurationProducerService">
<option name="ignoredProducers">
<set>
<option value="org.jetbrains.plugins.gradle.execution.test.runner.AllInPackageGradleConfigurationProducer" />
<option value="org.jetbrains.plugins.gradle.execution.test.runner.TestClassGradleConfigurationProducer" />
<option value="org.jetbrains.plugins.gradle.execution.test.runner.TestMethodGradleConfigurationProducer" />
</set>
</option>
</component>
</project>
\ No newline at end of file
......@@ -3,12 +3,17 @@
xmlns:android="http://schemas.android.com/apk/res/android"
package="w.soulofpluto.posstock">
<uses-permission android:name="android.permission.BLUETOOTH"
android:maxSdkVersion="30"/>
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN"
android:maxSdkVersion="30"/>
<uses-permission android:name="android.permission.BLUETOOTH_ADVERTISE" />
<uses-permission android:name="android.permission.BLUETOOTH_CONNECT" />
<uses-permission android:name="android.permission.BLUETOOTH_SCAN" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.BLUETOOTH"/>
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN"/>
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION"/>
......
......@@ -15,10 +15,10 @@ import retrofit2.http.Path;
* Created by Ramesh on 05/09/20.
*/
public interface ApiService{
public interface ApiService {
/*String BASE_URL = "https://aeebe1.emporter.eu/pos_actions/";
String Token = "41f34d7009db337f6213be52f7151108";
String StoreId = "980";
String Token = "41f34d7009db337f6213be52f7151108";
String StoreId = "980";
@Headers({"Pos-Access-Token:" + Token,"Pos-User-Access-Store-Id:"+StoreId, "Accept: application/json","Content-Type:multipart/form-data"})
@Multipart
@POST("uploadBarcodeImages")
......@@ -27,11 +27,11 @@ import retrofit2.http.Path;
@Headers({"Content-type: application/json"})
@POST("/login/doLogin")
Call<String> Login(@Body RequestBody body);
Call<String> Login(@Body RequestBody body);
@POST("/Tfs/getInfoWithTfsNumber")
Call<Response> getInfoTfsNumber(@HeaderMap Map<String, String> headers, @Body RequestBody responseBody);
@GET("/login/getStoresMappedToUser/{id}")
Call<Response> getStoreId(@Path("id") String id);
}
}
......@@ -4,15 +4,17 @@ package w.soulofpluto.posstock;
Create by Ramesh Babu
*/
public class
Barcode {
String barcode, empId;
int qty;
public class Barcode {
private String barcode;
private String empId;
private int qty;
public Barcode(String Barcode, int Qty, String empId){
this.barcode = Barcode;
this.qty = Qty;
this.empId = empId;
}
public String getBarcode() {
return barcode;
}
......
......@@ -11,10 +11,13 @@ import android.view.View;
import android.view.inputmethod.InputMethodManager;
import android.widget.EditText;
import android.widget.Toast;
import com.squareup.okhttp.MediaType;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import java.security.MessageDigest;
import java.text.NumberFormat;
import java.util.ArrayList;
......@@ -26,672 +29,672 @@ import java.util.Locale;
Create by Ramesh Babu
*/
public class Constants{
//public static String BASE_URL = "https://49588a.emporter.eu/";
//public static String BASE_URL = "https://30ad04.emporter.eu/";
public static String BASE_URL = "http://192.168.34.14/";
public class Constants {
//public static String BASE_URL = "https://49588a.emporter.eu/";
//public static String BASE_URL = "https://30ad04.emporter.eu/";
//public static String BASE_URL = "http://192.168.34.14/";
//20009 13022020
//public static String BASE_URL = "http://182.18.167.139/";
//public static String BASE_URL = "http://posapi.plutokm.com/";
public static String MenuBar = BASE_URL + "/Users/generateUserMenuBarLinksForAndroidApp";
public static String Logout = BASE_URL + "/login/doLogout/";
public static String Login = BASE_URL + "/login/doLogin";
public static String StoreId = BASE_URL + "login/getStoresMappedToUser/";
public static String Dashboard = BASE_URL + "/stockaudit/listOfStockAuditsOfLoginStore";
public static String BarcodeUpload = BASE_URL + "/stockaudit/validateStockAuditBarcode";
public static String BarcodeDelete = BASE_URL + "/stockaudit/deleteBarcodeAndQuantityFromStockAudit";
public static String BarcodeComplete = BASE_URL + "/stockaudit/batchScanningCompleted";
public static String RackWiseQty = BASE_URL + "/stockaudit/stockAuditPlanBarcodesScannedInformation";
public static String BarcodeSearch = BASE_URL + "/stockaudit/stockAuditBarcodeRackInformation";
public static String GenerateSlip = BASE_URL + "/Sales/generateDeliverySlip";
public static String GetInfoWithTFS = BASE_URL + "Tfs/getInfoWithTfsNumber";
public static String GetTFSBoxNumbers = BASE_URL + "/Tfs/getTfsBoxesNumbers/";
public static String GetTFSBoxDetailsByBarcode = BASE_URL + "/Tfs/getTfsBoxDetailsBybarcode/";
public static String StockReceiving = BASE_URL + "Tfs/stockReceiving";
public static String ToState = BASE_URL + "Stores/getActiveStoreStates";
public static String ToFormat = BASE_URL + "Stores/getDistinctActiveStoreForamtsOfGivenState/";
public static String ToStoreFormat = BASE_URL + "Stores/getActiveStoresInGivenStoreAndFormat/";
public static String StockPointId = BASE_URL + "/stockpoint/getGivenStoreSaleStockPointId/";
public static String CheckBarcodeQty = BASE_URL + "Inventory/checkBarcodeQuantityInGivenStockPoint";
public static String StockTransfer = BASE_URL + "/Tfs/stockTransfer";
public static String Type = "Content-Type";
public static String App_json = "application/json";
public static String Access_Token = "Pos-Access-Token";
public static String Access_StoreId = "Pos-User-Access-Store-Id";
public static MediaType JSON = MediaType.parse("application/json; charset=utf-8");
public static String Sec = "<font color=#3700B3><b>SECTION : </b></font>";
public static String div = "<font color=#3700B3><b>DIVISION : </b></font>";
public static String Id = "<font color=#3700B3><b>RACK ID : </b></font>";
public static String Qty = "<font color=#3700B3><b>QTY : </b></font>";
public static String User = "<font color=#3700B3><b>UserId : </b></font>";
public static String From = "<font color=#3700B3><b>Start time : </b></font>";
public static String To = "<font color=#3700B3><b>End time : </b></font>";
public static String Count = "<font color=#3700B3><b>TOTAL SCANNED ITEMS : </b></font>";
public static String Barcode = "<font color=#3700B3><b>Barcode : </b></font>";
public static String Ver_Text = "<font color=#ee4d35><b>Version : </b></font>";
public static String Plan_Id = "<font color=#3700B3><b>PLAN ID : </b></font>";
public static String Name = "<font color=#3700B3><b>NAME : </b></font>";
public static String VERSION = "1.1";
public static int Value = 14 ;
public static final String dashed = "------------------------------------------------"+"\n";
//public static String BASE_URL = "http://192.168.34.16/";
//public static String BASE_URL = "http://182.18.167.139/";
public static String BASE_URL = "http://posapi.plutokm.com/";
public static String MenuBar = BASE_URL + "/Users/generateUserMenuBarLinksForAndroidApp";
public static String Logout = BASE_URL + "/login/doLogout/";
public static String Login = BASE_URL + "/login/doLogin";
public static String StoreId = BASE_URL + "login/getStoresMappedToUser/";
public static String Dashboard = BASE_URL + "/stockaudit/listOfStockAuditsOfLoginStore";
public static String BarcodeUpload = BASE_URL + "/stockaudit/validateStockAuditBarcode";
public static String BarcodeDelete = BASE_URL + "/stockaudit/deleteBarcodeAndQuantityFromStockAudit";
public static String BarcodeComplete = BASE_URL + "/stockaudit/batchScanningCompleted";
public static String RackWiseQty = BASE_URL + "/stockaudit/stockAuditPlanBarcodesScannedInformation";
public static String BarcodeSearch = BASE_URL + "/stockaudit/stockAuditBarcodeRackInformation";
public static String GenerateSlip = BASE_URL + "/Sales/generateDeliverySlip";
public static String GetInfoWithTFS = BASE_URL + "Tfs/getInfoWithTfsNumber";
public static String GetTFSBoxNumbers = BASE_URL + "/Tfs/getTfsBoxesNumbers/";
public static String GetTFSBoxDetailsByBarcode = BASE_URL + "/Tfs/getTfsBoxDetailsBybarcode/";
public static String StockReceiving = BASE_URL + "Tfs/stockReceiving";
public static String ToState = BASE_URL + "Stores/getActiveStoreStates";
public static String ToFormat = BASE_URL + "Stores/getDistinctActiveStoreForamtsOfGivenState/";
public static String ToStoreFormat = BASE_URL + "Stores/getActiveStoresInGivenStoreAndFormat/";
public static String StockPointId = BASE_URL + "/stockpoint/getGivenStoreSaleStockPointId/";
public static String CheckBarcodeQty = BASE_URL + "Inventory/checkBarcodeQuantityInGivenStockPoint";
public static String StockTransfer = BASE_URL + "/Tfs/stockTransfer";
public static String Type = "Content-Type";
public static String App_json = "application/json";
public static String Access_Token = "Pos-Access-Token";
public static String Access_StoreId = "Pos-User-Access-Store-Id";
public static MediaType JSON = MediaType.parse("application/json; charset=utf-8");
public static String Sec = "<font color=#3700B3><b>SECTION : </b></font>";
public static String div = "<font color=#3700B3><b>DIVISION : </b></font>";
public static String Id = "<font color=#3700B3><b>RACK ID : </b></font>";
public static String Qty = "<font color=#3700B3><b>QTY : </b></font>";
public static String User = "<font color=#3700B3><b>UserId : </b></font>";
public static String From = "<font color=#3700B3><b>Start time : </b></font>";
public static String To = "<font color=#3700B3><b>End time : </b></font>";
public static String Count = "<font color=#3700B3><b>TOTAL SCANNED ITEMS : </b></font>";
public static String Barcode = "<font color=#3700B3><b>Barcode : </b></font>";
public static String Ver_Text = "<font color=#ee4d35><b>Version : </b></font>";
public static String Plan_Id = "<font color=#3700B3><b>PLAN ID : </b></font>";
public static String Name = "<font color=#3700B3><b>NAME : </b></font>";
public static String VERSION = "1.1";
public static int Value = 14;
public static final String dashed = "------------------------------------------------" + "\n";
public static ProgressDialog progressDialog;
public static StringBuilder stringBuilder;
public static StringBuilder stringBuilder;
public static void getToast(Context context, String data){
public static void getToast(Context context, String data) {
Toast toast = Toast.makeText(context, data, Toast.LENGTH_SHORT);
toast.setGravity(Gravity.CENTER, 0, 0);
toast.show();
}
public static String getVal(int count){
return "<font color=#3700B3><b>TOTAL SCANNED ITEMS : </b></font>"+"<font color=#3700B3><b>"+count+"</b></font>";
public static String getVal(int count) {
return "<font color=#3700B3><b>TOTAL SCANNED ITEMS : </b></font>" + "<font color=#3700B3><b>" + count + "</b></font>";
}
public static String getTotalItems(String count){
return "<font color=#ee4d35><b>Items : </b></font>"+"<font color=#000000><b>"+count+"</b></font>";
public static String getTotalItems(String count) {
return "<font color=#ee4d35><b>Items : </b></font>" + "<font color=#000000><b>" + count + "</b></font>";
}
public static String getTotalMRP(String count){
return "<font color=#ee4d35><b>Total MRP &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;: </b></font>"+"<font color=#000000><b>"+count+"</b></font>";
public static String getTotalMRP(String count) {
return "<font color=#ee4d35><b>Total MRP &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;: </b></font>" + "<font color=#000000><b>" + count + "</b></font>";
}
public static String getTotalDisc(String count){
return "<font color=#ee4d35><b> Disc &nbsp;&nbsp;&nbsp; : </b></font>"+"<font color=#000000><b>"+count+"</b></font>";
public static String getTotalDisc(String count) {
return "<font color=#ee4d35><b> Disc &nbsp;&nbsp;&nbsp; : </b></font>" + "<font color=#000000><b>" + count + "</b></font>";
}
public static String getTotalNetPayable(String count){
return "<font color=#ee4d35><b>NetPayable : </b></font>"+"<font color=#000000><b>"+count+"</b></font>";
public static String getTotalNetPayable(String count) {
return "<font color=#ee4d35><b>NetPayable : </b></font>" + "<font color=#000000><b>" + count + "</b></font>";
}
public static String getBarcode(String count){
return "<font color=#797979><b>Barcode : </b></font>"+"<font color=#000000><b>"+count+"</b></font>";
public static String getBarcode(String count) {
return "<font color=#797979><b>Barcode : </b></font>" + "<font color=#000000><b>" + count + "</b></font>";
}
public static String getCode(String count){
return "<font color=#797979><b>Disc : </b></font>"+"<font color=#000000><b>"+count+"</b></font>";
public static String getCode(String count) {
return "<font color=#797979><b>Disc : </b></font>" + "<font color=#000000><b>" + count + "</b></font>";
}
public static String getMRP(String count){
return "<font color=#797979><b>MRP &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : </b></font>"+"<font color=#000000><b>"+count+"</b></font>";
public static String getMRP(String count) {
return "<font color=#797979><b>MRP &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : </b></font>" + "<font color=#000000><b>" + count + "</b></font>";
}
public static String getEmpId(String count){
return "<font color=#797979><b>SM &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : </b></font>"+"<font color=#000000><b>"+count+"</b></font>";
public static String getEmpId(String count) {
return "<font color=#797979><b>SM &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : </b></font>" + "<font color=#000000><b>" + count + "</b></font>";
}
public static String getNetPayable(String count){
return "<font color=#797979><b>NetPayable : </b></font>"+"<font color=#4caa4c><b>"+count+"</b></font>";
public static String getNetPayable(String count) {
return "<font color=#797979><b>NetPayable : </b></font>" + "<font color=#4caa4c><b>" + count + "</b></font>";
}
public static boolean isNetworkAvailable(Context context){
ConnectivityManager connectivityManager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo activeNetworkInfo = connectivityManager.getActiveNetworkInfo();
return activeNetworkInfo != null;
public static boolean isNetworkAvailable(Context context) {
ConnectivityManager connectivityManager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo activeNetworkInfo = connectivityManager.getActiveNetworkInfo();
return activeNetworkInfo != null;
}
public static String IndianRupeesFormat(String amount){
NumberFormat formatter = NumberFormat.getCurrencyInstance(new Locale("en", "in"));
String moneyString = formatter.format(Double.valueOf(amount));
return moneyString;
public static String IndianRupeesFormat(String amount) {
NumberFormat formatter = NumberFormat.getCurrencyInstance(new Locale("en", "in"));
String moneyString = formatter.format(Double.valueOf(amount));
return moneyString;
}
public static void ProgressDialogShow(Context context){
progressDialog = new ProgressDialog(context);
progressDialog.setMessage("Loading Please wait ...");
progressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
progressDialog.show();
public static void ProgressDialogShow(Context context) {
progressDialog = new ProgressDialog(context);
progressDialog.setMessage("Loading Please wait ...");
progressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
progressDialog.show();
}
public static void ProgressDialogDismiss(){
if(progressDialog != null){
public static void ProgressDialogDismiss() {
if (progressDialog != null) {
progressDialog.dismiss();
}
}
}
public static String PrintData(String Id){
return ",{" + '"' + "delivery_slip_id" + '"' + ":" + '"' + Id + '"' + "," + '"' + "manual_discount" + '"' + ":" + 0 + "}";
public static String PrintData(String Id) {
return ",{" + '"' + "delivery_slip_id" + '"' + ":" + '"' + Id + '"' + "," + '"' + "manual_discount" + '"' + ":" + 0 + "}";
}
public static String PrintData1(String Id){
return "{" + '"' + "delivery_slip_id" + '"' + ":" + '"' + Id + '"' + "," + '"' + "manual_discount" + '"' + ":" + 0 + "}";
public static String PrintData1(String Id) {
return "{" + '"' + "delivery_slip_id" + '"' + ":" + '"' + Id + '"' + "," + '"' + "manual_discount" + '"' + ":" + 0 + "}";
}
public static String getSHA256(String data){
StringBuffer sb = new StringBuffer();
try{
MessageDigest md = MessageDigest.getInstance("SHA-256");
md.update(data.getBytes());
byte byteData[] = md.digest();
for(int i = 0; i < byteData.length; i++){
sb.append(Integer.toString((byteData[i] & 0xff) + 0x100, 16).substring(1));
}
}catch (Exception e) {
e.printStackTrace();
}
return sb.toString();
}
public static String convertString(String data){
StringBuilder stringBuilder = new StringBuilder();
try{
JSONArray jsonArray = new JSONArray(data);
for(int i = 0; i < jsonArray.length(); i++){
stringBuilder.append(jsonArray.get(i) + ",");
}
}catch(JSONException e){
e.printStackTrace();
}
return stringBuilder.toString().substring(0, stringBuilder.toString().length() - 1);
public static String getSHA256(String data) {
StringBuffer sb = new StringBuffer();
try {
MessageDigest md = MessageDigest.getInstance("SHA-256");
md.update(data.getBytes());
byte byteData[] = md.digest();
for (int i = 0; i < byteData.length; i++) {
sb.append(Integer.toString((byteData[i] & 0xff) + 0x100, 16).substring(1));
}
} catch (Exception e) {
e.printStackTrace();
}
return sb.toString();
}
public static String convertString(String data) {
StringBuilder stringBuilder = new StringBuilder();
try {
JSONArray jsonArray = new JSONArray(data);
for (int i = 0; i < jsonArray.length(); i++) {
stringBuilder.append(jsonArray.get(i) + ",");
}
} catch (JSONException e) {
e.printStackTrace();
}
return stringBuilder.toString().substring(0, stringBuilder.toString().length() - 1);
}
public static Boolean Existing(ArrayList<Plans> plans, String barcode){
for(Plans plan : plans){
if(plan.getBarcode().contains(barcode)){
public static Boolean Existing(ArrayList<Plans> plans, String barcode) {
for (Plans plan : plans) {
if (plan.getBarcode().contains(barcode)) {
return true;
}
}
return false;
}
return false;
}
public static Boolean ExistingStockWord(ArrayList<StockBarcode> plans, String barcode){
for(StockBarcode plan : plans){
Log.e("barcode ===>>",plan.barcode);
Log.e("barode ====<>",barcode);
if(plan.getBarcode().contains(barcode)){
return true;
}
}
return false;
}
public static Date getDateWithOffset(int offset, Date date){
Calendar calendar = Calendar.getInstance();
calendar.setTime(date);
calendar.add(Calendar.DAY_OF_MONTH, offset);
return calendar.getTime();
}
protected static void hideSoftKeyboard(EditText input,Context context){
InputMethodManager imm = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(input.getWindowToken(), 0);
}
public static String SL(String len){
if(len.length() == 3){
return len;
}else if(len.length() == 2){
return len+" ";
}else if(len.length() == 1){
return len+" ";
}
return null;
}
public static String Qty(String len){
if(len.length() == 3){
return len+" ";
}else if(len.length() == 2){
return len+" ";
}else if(len.length() == 1){
return len+" ";
}
return null;
}
public static String Barcode(String mrp){
if(mrp.length() == 11){
return mrp;
}else if(mrp.length() == 10){
return mrp+" ";
}else if(mrp.length() == 9){
return mrp+" ";
}else if(mrp.length() == 8){
return mrp+" ";
}else if(mrp.length() == 7){
return mrp+" ";
}else if(mrp.length() == 6){
return mrp+" ";
}else if(mrp.length() == 5){
return mrp+" ";
}else if(mrp.length() == 4){
return mrp+" ";
}else if(mrp.length() == 3){
return mrp+" ";
}else if(mrp.length() == 2){
return mrp+" ";
}else if(mrp.length() == 1){
return mrp+" ";
}
public static Boolean ExistingStockWord(ArrayList<StockBarcode> plans, String barcode) {
for (StockBarcode plan : plans) {
Log.e("barcode ===>", plan.barcode);
Log.e("barcode ===>", barcode);
if (plan.getBarcode().contains(barcode)) {
return true;
}
}
return false;
}
public static Date getDateWithOffset(int offset, Date date) {
Calendar calendar = Calendar.getInstance();
calendar.setTime(date);
calendar.add(Calendar.DAY_OF_MONTH, offset);
return calendar.getTime();
}
protected static void hideSoftKeyboard(EditText input, Context context) {
InputMethodManager imm = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(input.getWindowToken(), 0);
}
public static String SL(String len) {
if (len.length() == 3) {
return len;
} else if (len.length() == 2) {
return len + " ";
} else if (len.length() == 1) {
return len + " ";
}
return null;
}
public static String Qty(String len) {
if (len.length() == 3) {
return len + " ";
} else if (len.length() == 2) {
return len + " ";
} else if (len.length() == 1) {
return len + " ";
}
return null;
}
public static String Barcode(String mrp) {
if (mrp.length() == 11) {
return mrp;
} else if (mrp.length() == 10) {
return mrp + " ";
} else if (mrp.length() == 9) {
return mrp + " ";
} else if (mrp.length() == 8) {
return mrp + " ";
} else if (mrp.length() == 7) {
return mrp + " ";
} else if (mrp.length() == 6) {
return mrp + " ";
} else if (mrp.length() == 5) {
return mrp + " ";
} else if (mrp.length() == 4) {
return mrp + " ";
} else if (mrp.length() == 3) {
return mrp + " ";
} else if (mrp.length() == 2) {
return mrp + " ";
} else if (mrp.length() == 1) {
return mrp + " ";
}
return null;
}
public static String Mrp(String mrp){
if(mrp.length() == 9){
public static String Mrp(String mrp) {
if (mrp.length() == 9) {
return mrp;
}else if(mrp.length() == 9){
return mrp+" ";
}else if(mrp.length() == 8){
return mrp+" ";
}else if(mrp.length() == 7){
return mrp+" ";
}else if(mrp.length() == 6){
return mrp+" ";
}else if(mrp.length() == 5){
return mrp+" ";
}else if(mrp.length() == 4){
return mrp+" ";
}else if(mrp.length() == 3){
return mrp+" ";
}else if(mrp.length() == 2){
return mrp+" ";
}else if(mrp.length() == 1){
return mrp+" ";
} else if (mrp.length() == 9) {
return mrp + " ";
} else if (mrp.length() == 8) {
return mrp + " ";
} else if (mrp.length() == 7) {
return mrp + " ";
} else if (mrp.length() == 6) {
return mrp + " ";
} else if (mrp.length() == 5) {
return mrp + " ";
} else if (mrp.length() == 4) {
return mrp + " ";
} else if (mrp.length() == 3) {
return mrp + " ";
} else if (mrp.length() == 2) {
return mrp + " ";
} else if (mrp.length() == 1) {
return mrp + " ";
}
return null;
}
public static String Dis(String dis){
if(dis.length() == 9){
public static String Dis(String dis) {
if (dis.length() == 9) {
return dis;
}else if(dis.length() == 8){
return dis+" ";
}else if(dis.length() == 7){
return dis+" ";
}else if(dis.length() == 6){
return dis+" ";
}else if(dis.length() == 5){
return dis+" ";
}else if(dis.length() == 4){
return dis+" ";
}else if(dis.length() == 3){
return dis+" ";
}else if(dis.length() == 2){
return dis+" ";
}else if(dis.length() == 1){
return dis+" ";
} else if (dis.length() == 8) {
return dis + " ";
} else if (dis.length() == 7) {
return dis + " ";
} else if (dis.length() == 6) {
return dis + " ";
} else if (dis.length() == 5) {
return dis + " ";
} else if (dis.length() == 4) {
return dis + " ";
} else if (dis.length() == 3) {
return dis + " ";
} else if (dis.length() == 2) {
return dis + " ";
} else if (dis.length() == 1) {
return dis + " ";
}
return null;
}
public static String Total(String mrp){
if(mrp.length() == 11){
public static String Total(String mrp) {
if (mrp.length() == 11) {
return mrp;
}else if(mrp.length() == 10){
return mrp+" ";
}else if(mrp.length() == 9){
return mrp+" ";
}else if(mrp.length() == 8){
return mrp+" ";
}else if(mrp.length() == 7){
return mrp+" ";
}else if(mrp.length() == 6){
return mrp+" ";
}else if(mrp.length() == 5){
return mrp+" ";
}else if(mrp.length() == 4){
return mrp+" ";
}else if(mrp.length() == 3){
return mrp+" ";
}else if(mrp.length() == 2){
return mrp+" ";
}else if(mrp.length() == 1){
return mrp+" ";
} else if (mrp.length() == 10) {
return mrp + " ";
} else if (mrp.length() == 9) {
return mrp + " ";
} else if (mrp.length() == 8) {
return mrp + " ";
} else if (mrp.length() == 7) {
return mrp + " ";
} else if (mrp.length() == 6) {
return mrp + " ";
} else if (mrp.length() == 5) {
return mrp + " ";
} else if (mrp.length() == 4) {
return mrp + " ";
} else if (mrp.length() == 3) {
return mrp + " ";
} else if (mrp.length() == 2) {
return mrp + " ";
} else if (mrp.length() == 1) {
return mrp + " ";
}
return null;
}
public static String Taxable(String tax){
if(tax.length() == 13){
public static String Taxable(String tax) {
if (tax.length() == 13) {
return tax;
}else if(tax.length() == 12){
return tax+" ";
}else if(tax.length() == 11){
return tax+" ";
}else if(tax.length() == 10){
return tax+" ";
}else if(tax.length() == 9){
return tax+" ";
}else if(tax.length() == 8){
return tax+" ";
}else if(tax.length() == 7){
return tax+" ";
}else if(tax.length() == 6){
return tax+" ";
}else if(tax.length() == 5){
return tax+" ";
}else if(tax.length() == 4){
return tax+" ";
}else if(tax.length() == 3){
return tax+" ";
}else if(tax.length() == 2){
return tax+" ";
}else if(tax.length() == 1){
return tax+" ";
} else if (tax.length() == 12) {
return tax + " ";
} else if (tax.length() == 11) {
return tax + " ";
} else if (tax.length() == 10) {
return tax + " ";
} else if (tax.length() == 9) {
return tax + " ";
} else if (tax.length() == 8) {
return tax + " ";
} else if (tax.length() == 7) {
return tax + " ";
} else if (tax.length() == 6) {
return tax + " ";
} else if (tax.length() == 5) {
return tax + " ";
} else if (tax.length() == 4) {
return tax + " ";
} else if (tax.length() == 3) {
return tax + " ";
} else if (tax.length() == 2) {
return tax + " ";
} else if (tax.length() == 1) {
return tax + " ";
}
return null;
}
public static String CGST(String dis){
if(dis.length() == 9){
public static String CGST(String dis) {
if (dis.length() == 9) {
return dis;
}else if(dis.length() == 8){
return dis+" ";
}else if(dis.length() == 7){
return dis+" ";
}else if(dis.length() == 6){
return dis+" ";
}else if(dis.length() == 5){
return dis+" ";
}else if(dis.length() == 4){
return dis+" ";
}else if(dis.length() == 3){
return dis+" ";
}else if(dis.length() == 2){
return dis+" ";
}else if(dis.length() == 1){
return dis+" ";
} else if (dis.length() == 8) {
return dis + " ";
} else if (dis.length() == 7) {
return dis + " ";
} else if (dis.length() == 6) {
return dis + " ";
} else if (dis.length() == 5) {
return dis + " ";
} else if (dis.length() == 4) {
return dis + " ";
} else if (dis.length() == 3) {
return dis + " ";
} else if (dis.length() == 2) {
return dis + " ";
} else if (dis.length() == 1) {
return dis + " ";
}
return null;
}
public static String SGST(String dis){
if(dis.length() == 7){
return dis+" ";
}else if(dis.length() == 6){
return dis+" ";
}else if(dis.length() == 5){
return dis+" ";
}else if(dis.length() == 4){
return dis+" ";
}else if(dis.length() == 3){
return dis+" ";
}else if(dis.length() == 2){
return dis+" ";
}else if(dis.length() == 1){
return dis+" ";
public static String SGST(String dis) {
if (dis.length() == 7) {
return dis + " ";
} else if (dis.length() == 6) {
return dis + " ";
} else if (dis.length() == 5) {
return dis + " ";
} else if (dis.length() == 4) {
return dis + " ";
} else if (dis.length() == 3) {
return dis + " ";
} else if (dis.length() == 2) {
return dis + " ";
} else if (dis.length() == 1) {
return dis + " ";
}
return null;
}
public static String IGST(String dis){
if(dis.length()== 8){
public static String IGST(String dis) {
if (dis.length() == 8) {
return dis;
}else if(dis.length() == 7){
return dis+" ";
}else if(dis.length() == 6){
return dis+" ";
}else if(dis.length() == 5){
return dis+" ";
}else if(dis.length() == 4){
return dis+" ";
}else if(dis.length() == 3){
return dis+" ";
}else if(dis.length() == 2){
return dis+" ";
}else if(dis.length() == 1){
return dis+" ";
} else if (dis.length() == 7) {
return dis + " ";
} else if (dis.length() == 6) {
return dis + " ";
} else if (dis.length() == 5) {
return dis + " ";
} else if (dis.length() == 4) {
return dis + " ";
} else if (dis.length() == 3) {
return dis + " ";
} else if (dis.length() == 2) {
return dis + " ";
} else if (dis.length() == 1) {
return dis + " ";
}
return null;
}
public static String GST(String dis){
if(dis.length() == 7){
public static String GST(String dis) {
if (dis.length() == 7) {
return dis;
}else if(dis.length() == 6){
return dis+" ";
}else if(dis.length() == 5){
return dis+" ";
}else if(dis.length() == 4){
return dis+" ";
}else if(dis.length() == 3){
return dis+" ";
}else if(dis.length() == 2){
return dis+" ";
}else if(dis.length() == 1){
return dis+" ";
} else if (dis.length() == 6) {
return dis + " ";
} else if (dis.length() == 5) {
return dis + " ";
} else if (dis.length() == 4) {
return dis + " ";
} else if (dis.length() == 3) {
return dis + " ";
} else if (dis.length() == 2) {
return dis + " ";
} else if (dis.length() == 1) {
return dis + " ";
}
return null;
}
public static String Gross(String dis){
if(dis.length() == 10){
return " "+dis;
}else if(dis.length() == 9){
return " "+dis;
}else if(dis.length() == 8){
return " "+dis;
}else if(dis.length() == 7){
return " "+dis;
}else if(dis.length() == 6){
return " "+dis;
}else if(dis.length() == 5){
return " "+dis;
}else if(dis.length() == 4){
return " "+dis;
}else if(dis.length() == 3){
return " "+dis;
}else if(dis.length() == 2){
return " "+dis;
}else if(dis.length() == 1){
return " "+dis;
public static String Gross(String dis) {
if (dis.length() == 10) {
return " " + dis;
} else if (dis.length() == 9) {
return " " + dis;
} else if (dis.length() == 8) {
return " " + dis;
} else if (dis.length() == 7) {
return " " + dis;
} else if (dis.length() == 6) {
return " " + dis;
} else if (dis.length() == 5) {
return " " + dis;
} else if (dis.length() == 4) {
return " " + dis;
} else if (dis.length() == 3) {
return " " + dis;
} else if (dis.length() == 2) {
return " " + dis;
} else if (dis.length() == 1) {
return " " + dis;
}
return null;
}
public static String RecievedCashText(String dis){
if(dis.length() == 13){
return dis+" ";
}else if(dis.length() == 14){
return dis+" ";
}else if(dis.length() == 15){
return dis+" ";
}else if(dis.length() == 16){
return dis+" ";
}else if(dis.length() == 17){
return dis+" ";
}else if(dis.length() == 18){
public static String RecievedCashText(String dis) {
if (dis.length() == 13) {
return dis + " ";
} else if (dis.length() == 14) {
return dis + " ";
} else if (dis.length() == 15) {
return dis + " ";
} else if (dis.length() == 16) {
return dis + " ";
} else if (dis.length() == 17) {
return dis + " ";
} else if (dis.length() == 18) {
return dis;
}
return null;
}
public static String Deliveryslipnumber(String dev){
if(dev.length() == 16){
return dev+" ";
}else if(dev.length() == 15){
return dev+" ";
}else if(dev.length() == 14){
return dev+" ";
}else if(dev.length() == 13){
return dev+" ";
}else if(dev.length() == 12){
return dev+" ";
}else if(dev.length() == 11){
return dev+" ";
public static String Deliveryslipnumber(String dev) {
if (dev.length() == 16) {
return dev + " ";
} else if (dev.length() == 15) {
return dev + " ";
} else if (dev.length() == 14) {
return dev + " ";
} else if (dev.length() == 13) {
return dev + " ";
} else if (dev.length() == 12) {
return dev + " ";
} else if (dev.length() == 11) {
return dev + " ";
}
return null;
}
public static String DeliveryslipQty(String dev){
if(dev.length() == 7){
return dev+" ";
}else if(dev.length() == 6){
return dev+" ";
}else if(dev.length() == 5){
return dev+" ";
}else if(dev.length() == 4){
return dev+" ";
}else if(dev.length() == 3){
return dev+" ";
}else if(dev.length() == 2){
return dev+" ";
}else if(dev.length() == 1){
return dev+" ";
public static String DeliveryslipQty(String dev) {
if (dev.length() == 7) {
return dev + " ";
} else if (dev.length() == 6) {
return dev + " ";
} else if (dev.length() == 5) {
return dev + " ";
} else if (dev.length() == 4) {
return dev + " ";
} else if (dev.length() == 3) {
return dev + " ";
} else if (dev.length() == 2) {
return dev + " ";
} else if (dev.length() == 1) {
return dev + " ";
}
return null;
}
public static String DeliveryslipAmt(String dev){
if(dev.length() == 11){
return dev+" ";
}else if(dev.length() == 10){
return dev+" ";
}else if(dev.length() == 9){
return dev+" ";
}else if(dev.length() == 8){
return dev+" ";
}else if(dev.length() == 7){
return dev+" ";
}else if(dev.length() == 6){
return dev+" ";
}else if(dev.length() == 5){
return dev+" ";
}else if(dev.length() == 4){
return dev+" ";
}else if(dev.length() == 3){
return dev+" ";
}else if(dev.length() == 2){
return dev+" ";
}else if(dev.length() == 1){
return dev+" ";
public static String DeliveryslipAmt(String dev) {
if (dev.length() == 11) {
return dev + " ";
} else if (dev.length() == 10) {
return dev + " ";
} else if (dev.length() == 9) {
return dev + " ";
} else if (dev.length() == 8) {
return dev + " ";
} else if (dev.length() == 7) {
return dev + " ";
} else if (dev.length() == 6) {
return dev + " ";
} else if (dev.length() == 5) {
return dev + " ";
} else if (dev.length() == 4) {
return dev + " ";
} else if (dev.length() == 3) {
return dev + " ";
} else if (dev.length() == 2) {
return dev + " ";
} else if (dev.length() == 1) {
return dev + " ";
}
return null;
}
public static String RecievedCash(String dis){
if(dis.length() == 10){
return " "+dis;
}else if(dis.length() == 9){
return " "+dis;
}else if(dis.length() == 8){
return " "+dis;
}else if(dis.length() == 7){
return " "+dis;
}else if(dis.length() == 6){
return " "+dis;
}else if(dis.length() == 5){
return " "+dis;
}else if(dis.length() == 4){
return " "+dis;
}else if(dis.length() == 3){
return " "+dis;
}else if(dis.length() == 2){
return " "+dis;
}else if(dis.length() == 1){
return " "+dis;
public static String RecievedCash(String dis) {
if (dis.length() == 10) {
return " " + dis;
} else if (dis.length() == 9) {
return " " + dis;
} else if (dis.length() == 8) {
return " " + dis;
} else if (dis.length() == 7) {
return " " + dis;
} else if (dis.length() == 6) {
return " " + dis;
} else if (dis.length() == 5) {
return " " + dis;
} else if (dis.length() == 4) {
return " " + dis;
} else if (dis.length() == 3) {
return " " + dis;
} else if (dis.length() == 2) {
return " " + dis;
} else if (dis.length() == 1) {
return " " + dis;
}
return null;
}
public static String TotalSavings(String dis){
if(dis.length() == 10){
return " "+dis;
}else if(dis.length() == 9){
return " "+dis;
}else if(dis.length() == 8){
return " "+dis;
}else if(dis.length() == 7){
return " "+dis;
}else if(dis.length() == 6){
return " "+dis;
}else if(dis.length() == 5){
return " "+dis;
}else if(dis.length() == 4){
return " "+dis;
}else if(dis.length() == 3){
return " "+dis;
}else if(dis.length() == 2){
return " "+dis;
}else if(dis.length() == 1){
return " "+dis;
public static String TotalSavings(String dis) {
if (dis.length() == 10) {
return " " + dis;
} else if (dis.length() == 9) {
return " " + dis;
} else if (dis.length() == 8) {
return " " + dis;
} else if (dis.length() == 7) {
return " " + dis;
} else if (dis.length() == 6) {
return " " + dis;
} else if (dis.length() == 5) {
return " " + dis;
} else if (dis.length() == 4) {
return " " + dis;
} else if (dis.length() == 3) {
return " " + dis;
} else if (dis.length() == 2) {
return " " + dis;
} else if (dis.length() == 1) {
return " " + dis;
}
return null;
}
public static String IndianRupeesformat(String amount){
public static String IndianRupeesformat(String amount) {
NumberFormat formatter = NumberFormat.getCurrencyInstance(new Locale("en", "in"));
String moneyString = formatter.format(Double.valueOf(amount));
String moneyString = formatter.format(Double.valueOf(amount));
return moneyString;
}
public static void hideKeyboard(Activity activity){
public static void hideKeyboard(Activity activity) {
InputMethodManager imm = (InputMethodManager) activity.getSystemService(Activity.INPUT_METHOD_SERVICE);
View view = activity.getCurrentFocus();
if(view == null){
view = new View(activity);
if (view == null) {
view = new View(activity);
}
imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
}
public static void hideSoftKeyBoardOnTabClicked(View v,Context context) {
if(v != null && context != null){
InputMethodManager imm = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(v.getApplicationWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS);
public static void hideSoftKeyBoardOnTabClicked(View v, Context context) {
if (v != null && context != null) {
InputMethodManager imm = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(v.getApplicationWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS);
}
}
public static String formData(String builder, String name, String phone){
public static String formData(String builder, String name, String phone) {
stringBuilder = new StringBuilder();
stringBuilder.append("{"+'"'+"approval_emp_id"+'"'+":"+'"'+"1"+'"'+",");
stringBuilder.append('"'+"from_mobile"+'"'+":"+'"'+"yes"+'"'+",");
stringBuilder.append('"'+"incharge_emp_id"+'"'+":"+'"'+"1"+'"'+",");
stringBuilder.append('"'+"bill_level_manual_discount"+'"'+":"+'"'+"0"+'"'+",");
stringBuilder.append('"'+"transaction_type"+'"'+":"+'"'+"presale_check"+'"'+",");
stringBuilder.append('"'+"clear_promotion"+'"'+":"+'"'+"N"+'"'+",");
stringBuilder.append('"'+"delivery_slips"+'"'+":"+"["+builder+"]"+",");
stringBuilder.append('"'+"actual_received_cash"+'"'+":"+'"'+"0"+'"'+",");
stringBuilder.append('"'+"return_cash_amount"+'"'+":"+'"'+"0"+'"'+",");
stringBuilder.append('"'+"mop"+'"'+":"+"{");
stringBuilder.append('"'+"cash"+'"'+":"+'"'+0+'"'+",");
stringBuilder.append('"'+"credit_card"+'"'+":"+"[]"+",");
stringBuilder.append('"'+"return_slips"+'"'+":"+"[]"+",");
stringBuilder.append('"'+"pkt_pending"+'"'+":"+'"'+0+'"'+",");
stringBuilder.append('"'+"pkt_advance_used"+'"'+":"+"[]"+",");
stringBuilder.append('"'+"gv_ids"+'"'+":"+"[]"+",");
stringBuilder.append('"'+"loyalty_points"+'"'+":"+"[]"+",");
stringBuilder.append('"'+"km_gvs"+'"'+":"+"[]"+",");
stringBuilder.append('"'+"online_gvs"+'"'+":"+"[]"+"}"+",");
stringBuilder.append('"'+"customer_info"+'"'+":"+"{");
stringBuilder.append('"'+"customer_phone"+'"'+":"+'"'+phone+'"'+",");
stringBuilder.append('"'+"customer_name"+'"'+":"+'"'+name+'"'+"},");
stringBuilder.append('"'+"otp"+'"'+":"+'"'+'"'+"}");
stringBuilder.append("{" + '"' + "approval_emp_id" + '"' + ":" + '"' + "1" + '"' + ",");
stringBuilder.append('"' + "from_mobile" + '"' + ":" + '"' + "yes" + '"' + ",");
stringBuilder.append('"' + "incharge_emp_id" + '"' + ":" + '"' + "1" + '"' + ",");
stringBuilder.append('"' + "bill_level_manual_discount" + '"' + ":" + '"' + "0" + '"' + ",");
stringBuilder.append('"' + "transaction_type" + '"' + ":" + '"' + "presale_check" + '"' + ",");
stringBuilder.append('"' + "clear_promotion" + '"' + ":" + '"' + "N" + '"' + ",");
stringBuilder.append('"' + "delivery_slips" + '"' + ":" + "[" + builder + "]" + ",");
stringBuilder.append('"' + "actual_received_cash" + '"' + ":" + '"' + "0" + '"' + ",");
stringBuilder.append('"' + "return_cash_amount" + '"' + ":" + '"' + "0" + '"' + ",");
stringBuilder.append('"' + "mop" + '"' + ":" + "{");
stringBuilder.append('"' + "cash" + '"' + ":" + '"' + 0 + '"' + ",");
stringBuilder.append('"' + "credit_card" + '"' + ":" + "[]" + ",");
stringBuilder.append('"' + "return_slips" + '"' + ":" + "[]" + ",");
stringBuilder.append('"' + "pkt_pending" + '"' + ":" + '"' + 0 + '"' + ",");
stringBuilder.append('"' + "pkt_advance_used" + '"' + ":" + "[]" + ",");
stringBuilder.append('"' + "gv_ids" + '"' + ":" + "[]" + ",");
stringBuilder.append('"' + "loyalty_points" + '"' + ":" + "[]" + ",");
stringBuilder.append('"' + "km_gvs" + '"' + ":" + "[]" + ",");
stringBuilder.append('"' + "online_gvs" + '"' + ":" + "[]" + "}" + ",");
stringBuilder.append('"' + "customer_info" + '"' + ":" + "{");
stringBuilder.append('"' + "customer_phone" + '"' + ":" + '"' + phone + '"' + ",");
stringBuilder.append('"' + "customer_name" + '"' + ":" + '"' + name + '"' + "},");
stringBuilder.append('"' + "otp" + '"' + ":" + '"' + '"' + "}");
return stringBuilder.toString();
}
public static String formData1(String builder, String name, String phone, JSONObject obj){
public static String formData1(String builder, String name, String phone, JSONObject obj) {
stringBuilder = new StringBuilder();
stringBuilder.append("{"+'"'+"approval_emp_id"+'"'+":"+'"'+"1"+'"'+",");
stringBuilder.append('"'+"from_mobile"+'"'+":"+'"'+"yes"+'"'+",");
stringBuilder.append('"'+"incharge_emp_id"+'"'+":"+'"'+"1"+'"'+",");
stringBuilder.append('"'+"bill_level_manual_discount"+'"'+":"+'"'+"0"+'"'+",");
stringBuilder.append('"'+"transaction_type"+'"'+":"+'"'+"sale"+'"'+",");
stringBuilder.append('"'+"clear_promotion"+'"'+":"+'"'+"N"+'"'+",");
stringBuilder.append('"'+"delivery_slips"+'"'+":"+"["+builder+"]"+",");
stringBuilder.append('"'+"actual_received_cash"+'"'+":"+'"'+"0"+'"'+",");
stringBuilder.append('"'+"return_cash_amount"+'"'+":"+'"'+"0"+'"'+",");
stringBuilder.append('"'+"mop"+'"'+":"+"{");
stringBuilder.append('"'+"cash"+'"'+":"+'"'+0+'"'+",");
stringBuilder.append('"'+"credit_card"+'"'+":"+"["+obj+"]"+",");
stringBuilder.append('"'+"return_slips"+'"'+":"+"[]"+",");
stringBuilder.append('"'+"pkt_pending"+'"'+":"+'"'+0+'"'+",");
stringBuilder.append('"'+"pkt_advance_used"+'"'+":"+"[]"+",");
stringBuilder.append('"'+"gv_ids"+'"'+":"+"[]"+",");
stringBuilder.append('"'+"loyalty_points"+'"'+":"+"[]"+",");
stringBuilder.append('"'+"km_gvs"+'"'+":"+"[]"+",");
stringBuilder.append('"'+"online_gvs"+'"'+":"+"[]"+"}"+",");
stringBuilder.append('"'+"customer_info"+'"'+":"+"{");
stringBuilder.append('"'+"customer_phone"+'"'+":"+'"'+phone+'"'+",");
stringBuilder.append('"'+"customer_name"+'"'+":"+'"'+name+'"'+"},");
stringBuilder.append('"'+"otp"+'"'+":"+'"'+'"'+"}");
stringBuilder.append("{" + '"' + "approval_emp_id" + '"' + ":" + '"' + "1" + '"' + ",");
stringBuilder.append('"' + "from_mobile" + '"' + ":" + '"' + "yes" + '"' + ",");
stringBuilder.append('"' + "incharge_emp_id" + '"' + ":" + '"' + "1" + '"' + ",");
stringBuilder.append('"' + "bill_level_manual_discount" + '"' + ":" + '"' + "0" + '"' + ",");
stringBuilder.append('"' + "transaction_type" + '"' + ":" + '"' + "sale" + '"' + ",");
stringBuilder.append('"' + "clear_promotion" + '"' + ":" + '"' + "N" + '"' + ",");
stringBuilder.append('"' + "delivery_slips" + '"' + ":" + "[" + builder + "]" + ",");
stringBuilder.append('"' + "actual_received_cash" + '"' + ":" + '"' + "0" + '"' + ",");
stringBuilder.append('"' + "return_cash_amount" + '"' + ":" + '"' + "0" + '"' + ",");
stringBuilder.append('"' + "mop" + '"' + ":" + "{");
stringBuilder.append('"' + "cash" + '"' + ":" + '"' + 0 + '"' + ",");
stringBuilder.append('"' + "credit_card" + '"' + ":" + "[" + obj + "]" + ",");
stringBuilder.append('"' + "return_slips" + '"' + ":" + "[]" + ",");
stringBuilder.append('"' + "pkt_pending" + '"' + ":" + '"' + 0 + '"' + ",");
stringBuilder.append('"' + "pkt_advance_used" + '"' + ":" + "[]" + ",");
stringBuilder.append('"' + "gv_ids" + '"' + ":" + "[]" + ",");
stringBuilder.append('"' + "loyalty_points" + '"' + ":" + "[]" + ",");
stringBuilder.append('"' + "km_gvs" + '"' + ":" + "[]" + ",");
stringBuilder.append('"' + "online_gvs" + '"' + ":" + "[]" + "}" + ",");
stringBuilder.append('"' + "customer_info" + '"' + ":" + "{");
stringBuilder.append('"' + "customer_phone" + '"' + ":" + '"' + phone + '"' + ",");
stringBuilder.append('"' + "customer_name" + '"' + ":" + '"' + name + '"' + "},");
stringBuilder.append('"' + "otp" + '"' + ":" + '"' + '"' + "}");
return stringBuilder.toString();
}
public static String JsonFormatData( String TFS, String Box, ArrayList<BoxInfo> arrayList, String Store_Id) throws JSONException {
public static String JsonFormatData(String TFS, String Box, ArrayList<BoxInfo> arrayList, String Store_Id) throws JSONException {
JSONArray jsonArray = new JSONArray();
for(int i = 0 ; i<arrayList.size();i++){
for (int i = 0; i < arrayList.size(); i++) {
BoxInfo boxInfo = arrayList.get(i);
JSONObject jsonObject = new JSONObject();
if(boxInfo.getStatus()) {
if (boxInfo.getStatus()) {
jsonObject.put("barcode", boxInfo.getBarcode());
jsonObject.put("box_id", Box);
jsonObject.put("pending_qty", boxInfo.getPending_qty());
......@@ -699,7 +702,7 @@ public class Constants{
jsonObject.put("received_qty", boxInfo.getReceive_qty());
jsonObject.put("transfered_qty", boxInfo.getTransfer_qty());
jsonObject.put("uom", "units");
}else{
} else {
jsonObject.put("barcode", boxInfo.getBarcode());
jsonObject.put("box_id", Box);
jsonObject.put("pending_qty", boxInfo.getPending_qty());
......@@ -711,9 +714,9 @@ public class Constants{
jsonArray.put(jsonObject);
}
JSONObject jsonObject1 = new JSONObject();
jsonObject1.put("tfs_id",TFS);
jsonObject1.put("receiving_store_id",Store_Id);
jsonObject1.put("received_items",jsonArray);
jsonObject1.put("tfs_id", TFS);
jsonObject1.put("receiving_store_id", Store_Id);
jsonObject1.put("received_items", jsonArray);
return jsonObject1.toString();
}
}
}
package w.soulofpluto.posstock;
import android.app.Dialog;
import android.content.Context;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
......@@ -29,7 +26,6 @@ import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.SimpleAdapter;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
......@@ -37,16 +33,13 @@ import androidx.appcompat.widget.Toolbar;
import androidx.recyclerview.widget.ItemTouchHelper;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import com.epson.epos2.Epos2Exception;
import com.epson.epos2.discovery.DeviceInfo;
import com.epson.epos2.discovery.Discovery;
import com.epson.epos2.discovery.DiscoveryListener;
import com.epson.epos2.discovery.FilterOption;
import com.epson.epos2.printer.Printer;
import com.epson.epos2.printer.PrinterStatusInfo;
import com.epson.epos2.printer.ReceiveListener;
import com.google.android.material.snackbar.Snackbar;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import com.squareup.okhttp.Callback;
......@@ -54,20 +47,15 @@ import com.squareup.okhttp.OkHttpClient;
import com.squareup.okhttp.Request;
import com.squareup.okhttp.RequestBody;
import com.squareup.okhttp.Response;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.concurrent.TimeUnit;
import static w.soulofpluto.posstock.Constants.DeliveryslipAmt;
import static w.soulofpluto.posstock.Constants.DeliveryslipQty;
import static w.soulofpluto.posstock.Constants.JSON;
import static w.soulofpluto.posstock.Constants.Logout;
......@@ -75,38 +63,41 @@ import static w.soulofpluto.posstock.Constants.Logout;
Create by Ramesh Babu
*/
//1141
//11411526
public class CreateDeliverySlip extends AppCompatActivity implements AdapterView.OnItemClickListener, ReceiveListener, TextView.OnEditorActionListener {
Toolbar createDeliverySlip_toolbar;
EditText barcode_enter, empId;
Toolbar createDeliverySlip_toolbar;
EditText barcode_enter , empId;
List<CreateResponse> arrayList;
LinearLayout header_items;
CheckBox checkBox;
PreferenceManager preferenceManager;
RecyclerView deliveryslip_list;
RecyclerView DeliverySlip_List;
TextView totalItems, totalMrp, totalDis, totalNetMrp;
ArrayList<Barcode> list;
Button valid, valid_print;
Boolean print = false;
Button valid, valid_print;
Boolean print = false;
public static Printer mPrinter = null;
DeliverySlipAdapter deliverySlipAdapter;
List<CreateResponse.Datum> versionList;
ListView bluetooth_list;
private ArrayList<HashMap<String, String>> mPrinterList = null;
private SimpleAdapter mPrinterListAdapter = null;
private FilterOption mFilterOption = null;
private TextView store_location;
private Boolean initial = false;
Menu globalMenuItem;
Dialog dialog;
private ArrayList<HashMap<String, String>> mPrinterList = null;
private SimpleAdapter mPrinterListAdapter = null;
private FilterOption mFilterOption = null;
private TextView store_location;
private Boolean initial = false;
Menu globalMenuItem;
Dialog dialog;
JSONObject responseObj;
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
setContentView(R.layout.activity_createdeliveryslip);
createDeliverySlip_toolbar = findViewById(R.id.createdeliveryslip_toolbar);
checkBox = findViewById(R.id.checked);
checkBox = findViewById(R.id.checked);
barcode_enter = findViewById(R.id.barcode_enter);
deliveryslip_list = findViewById(R.id.deliveryslip_list);
DeliverySlip_List = findViewById(R.id.deliveryslip_list);
totalItems = findViewById(R.id.totalItems);
totalMrp = findViewById(R.id.totalMrp);
totalDis = findViewById(R.id.totalDis);
......@@ -115,42 +106,39 @@ public class CreateDeliverySlip extends AppCompatActivity implements AdapterView
valid = findViewById(R.id.valid);
header_items = findViewById(R.id.header_items);
valid_print = findViewById(R.id.valid_print);
setSupportActionBar(createDeliverySlip_toolbar);
getSupportActionBar().setTitle(getResources().getString(R.string.create_title));
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
preferenceManager = new PreferenceManager(this);
arrayList = new ArrayList<>();
list = new ArrayList<>();
versionList = new ArrayList<>();
//empId.setText(preferenceManager.getUserId());
setSupportActionBar(createDeliverySlip_toolbar);
getSupportActionBar().setTitle(getResources().getString(R.string.create_title));
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
checkBox.setChecked(true);
empId.requestFocus();
barcode_enter.setOnEditorActionListener(this);
setItems();
Log.e("Access Token ====> ", preferenceManager.getCustToken());
valid_print.setOnClickListener(view -> {
if(preferenceManager.getBLUETOOTH().length()>0) {
if(list.size() > 0){
if (preferenceManager.getBLUETOOTH().length() > 0) {
if (list.size() > 0) {
if (Constants.isNetworkAvailable(CreateDeliverySlip.this)) {
Constants.ProgressDialogShow(CreateDeliverySlip.this);
GenerateDeliverySlip("save", barcode_enter.getText().toString().trim(), "Y", false);
GenerateDeliverySlip("save", barcode_enter.getText().toString().trim(), "Y", false);
} else {
Constants.getToast(CreateDeliverySlip.this, getResources().getString(R.string.connection));
}
} else {
Constants.getToast(CreateDeliverySlip.this, "Please Scan Barcode Items");
}
}else{
Constants.getToast(CreateDeliverySlip.this,"Please Connect Bluetooth Printer");
} else {
Constants.getToast(CreateDeliverySlip.this, "Please Connect Bluetooth Printer");
}
});
valid.setOnClickListener(view -> {
if (list.size() > 0) {
if (Constants.isNetworkAvailable(CreateDeliverySlip.this)) {
Constants.ProgressDialogShow(CreateDeliverySlip.this);
GenerateDeliverySlip("scan", barcode_enter.getText().toString().trim(), "Y",true);
GenerateDeliverySlip("scan", barcode_enter.getText().toString().trim(), "Y", true);
} else {
Constants.getToast(CreateDeliverySlip.this, getResources().getString(R.string.connection));
}
......@@ -158,8 +146,8 @@ public class CreateDeliverySlip extends AppCompatActivity implements AdapterView
Constants.getToast(CreateDeliverySlip.this, "Please Scan Barcode Items");
}
});
barcode_enter.addTextChangedListener(new Checked());
barcode_enter.addTextChangedListener(new Checked());
new ItemTouchHelper(new ItemTouchHelper.SimpleCallback(0, ItemTouchHelper.RIGHT) {
@Override
public boolean onMove(@NonNull RecyclerView recyclerView, @NonNull RecyclerView.ViewHolder viewHolder, @NonNull RecyclerView.ViewHolder target) {
......@@ -170,29 +158,29 @@ public class CreateDeliverySlip extends AppCompatActivity implements AdapterView
final CreateResponse.Datum deletedCourse = versionList.get(viewHolder.getAdapterPosition());
versionList.remove(viewHolder.getAdapterPosition());
deliverySlipAdapter.notifyItemRemoved(viewHolder.getAdapterPosition());
for(Barcode barcode : list){
if(barcode.getBarcode().equalsIgnoreCase(deletedCourse.getBarcode())){
list.remove(barcode);
break;
for (Barcode barcode : list) {
if (barcode.getBarcode().equalsIgnoreCase(deletedCourse.getBarcode())) {
list.remove(barcode);
break;
}
}
if(list.size()<1){
if (list.size() < 1) {
valid_print.setVisibility(View.GONE);
if(checkBox.isChecked()){
if (checkBox.isChecked()) {
barcode_enter.requestFocus();
}else{
} else {
empId.setText("");
empId.requestFocus();
}
}
if(Constants.isNetworkAvailable(CreateDeliverySlip.this)) {
if (Constants.isNetworkAvailable(CreateDeliverySlip.this)) {
Constants.ProgressDialogShow(CreateDeliverySlip.this);
GenerateDeliverySlip("scan", "", "N",false);
}else{
GenerateDeliverySlip("scan", "", "N", false);
} else {
Constants.getToast(CreateDeliverySlip.this, getResources().getString(R.string.connection));
}
}
}).attachToRecyclerView(deliveryslip_list);
}).attachToRecyclerView(DeliverySlip_List);
super.onCreate(savedInstanceState);
}
......@@ -202,7 +190,7 @@ public class CreateDeliverySlip extends AppCompatActivity implements AdapterView
return false;
}
if (!createReceiptData()) {
System.out.println("runPrintReceipt1");
Log.e("runPrintReceipt1", "");
finalizeObject();
return false;
}
......@@ -220,9 +208,9 @@ public class CreateDeliverySlip extends AppCompatActivity implements AdapterView
return false;
}
try {
//System.out.println("Checking Printer ======>"+com.epson.epos2.printer.Printer.PARAM_DEFAULT);
mPrinter.connect(preferenceManager.getBLUETOOTH(), 30000);
System.out.println("Shared Preferences Bluetooth ========>" + preferenceManager.getBLUETOOTH());
//Log.e("Checking Printer ======>"+com.epson.epos2.printer.Printer.PARAM_DEFAULT);
mPrinter.connect(preferenceManager.getBLUETOOTH(), 50000);
//Log.e("Shared Preferences Bluetooth ========>" + preferenceManager.getBLUETOOTH());
} catch (Exception e) {
ShowMsg.showException(e, "connect", CreateDeliverySlip.this);
return false;
......@@ -259,7 +247,6 @@ public class CreateDeliverySlip extends AppCompatActivity implements AdapterView
public void onFailure(Request request, IOException e) {
Constants.ProgressDialogDismiss();
}
@Override
public void onResponse(Response response) throws IOException {
try {
......@@ -276,7 +263,7 @@ public class CreateDeliverySlip extends AppCompatActivity implements AdapterView
preferenceManager.setStoreId("");
preferenceManager.setBLUETOOTH("");
Login.logout(CreateDeliverySlip.this);
} else if(jsonObject.has("msg")) {
} else if (jsonObject.has("msg")) {
Constants.getToast(CreateDeliverySlip.this, jsonObject.getString("msg"));
}
}
......@@ -288,7 +275,7 @@ public class CreateDeliverySlip extends AppCompatActivity implements AdapterView
} catch (NullPointerException np) {
np.printStackTrace();
}
}
}
});
}
......@@ -309,7 +296,7 @@ public class CreateDeliverySlip extends AppCompatActivity implements AdapterView
Discovery.stop();
break;
} catch (Epos2Exception e1) {
System.out.println("Output =====>" + e1.getMessage());
Log.e("Output =====>", e1.getMessage());
}
break;
......@@ -334,11 +321,12 @@ public class CreateDeliverySlip extends AppCompatActivity implements AdapterView
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.menu_create, menu);
globalMenuItem = menu;
Log.e("Connection ===>", preferenceManager.getBLUETOOTH());
if (preferenceManager.getBLUETOOTH().length() > 0) {
//System.out.println("connection ====>"+preferenceManager.getBLUETOOTH().length());
//Log.e("connection ====>"+preferenceManager.getBLUETOOTH().length());
globalMenuItem.findItem(R.id.dashboard_connection).setIcon(R.drawable.ic_bluetooth_indicator);
} else {
//System.out.println("connection1 ====>"+preferenceManager.getBLUETOOTH());
//Log.e("connection1 ====>"+preferenceManager.getBLUETOOTH());
globalMenuItem.findItem(R.id.dashboard_connection).setIcon(R.drawable.ic_bluetooth_signal_indicator);
}
return super.onCreateOptionsMenu(menu);
......@@ -399,13 +387,12 @@ public class CreateDeliverySlip extends AppCompatActivity implements AdapterView
mPrinter = null;
}
void getPrint() {
String method = "";
StringBuilder textData = new StringBuilder();
try {
if (responseObj.has("data")) {
System.out.println("Response Data =============>" + responseObj);
Log.e("Response Data ====>", responseObj.toString());
JSONObject dataobj = responseObj.getJSONObject("data");
method = "addTextSize";
mPrinter.addTextSize(2, 2);
......@@ -438,7 +425,7 @@ public class CreateDeliverySlip extends AppCompatActivity implements AdapterView
textData.delete(0, textData.length());
if (dataobj.has("ds_lines")) {
if(android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.KITKAT) {
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.KITKAT) {
method = "addTextAlign";
mPrinter.addTextAlign(Printer.ALIGN_LEFT);
textData.append("SL Barcode Qty MRP Disc Amount " + "\n");
......@@ -455,8 +442,8 @@ public class CreateDeliverySlip extends AppCompatActivity implements AdapterView
String key = keys.next();
if (da.get(key) instanceof JSONArray) {
// do something with jsonObject here
System.out.println("Connection =====>" + da);
System.out.println("Connection =====>" + key);
Log.e("Connection =====>", da.toString());
Log.e("Connection =====>", key);
JSONArray bill_data = new JSONArray(da.getString(key));
for (int i = 0; i < bill_data.length(); i++) {
JSONObject bill_object = bill_data.getJSONObject(i);
......@@ -555,7 +542,7 @@ public class CreateDeliverySlip extends AppCompatActivity implements AdapterView
} catch (Epos2Exception e) {
e.printStackTrace();
} catch (Exception e) {
System.out.println("Error Message ======>" + e.getMessage());
Log.e("Error Message ======>", e.getMessage());
ShowMsg.showException(e, method, CreateDeliverySlip.this);
}
}
......@@ -572,9 +559,9 @@ public class CreateDeliverySlip extends AppCompatActivity implements AdapterView
getPrint();
} else {
for(int k = 0; k < 2; k++) {
if(mPrinter == null) {
return false;
for (int k = 0; k < 2; k++) {
if (mPrinter == null) {
return false;
}
getPrint();
}
......@@ -583,7 +570,7 @@ public class CreateDeliverySlip extends AppCompatActivity implements AdapterView
valid_print.setVisibility(View.GONE);
arrayList.clear();
list.clear();
deliveryslip_list.setAdapter(null);
DeliverySlip_List.setAdapter(null);
setItems();
});
}
......@@ -606,7 +593,7 @@ public class CreateDeliverySlip extends AppCompatActivity implements AdapterView
private void updateButtonState(boolean state) {
valid.setEnabled(state);
System.out.println("Data State Enables===>" + state);
Log.e("Data State Enables===>", String.valueOf(state));
}
@Override
......@@ -615,7 +602,7 @@ public class CreateDeliverySlip extends AppCompatActivity implements AdapterView
Intent intent = new Intent();
HashMap<String, String> item = mPrinterList.get(position);
intent.putExtra(getString(R.string.title_target), item.get("Target"));
//System.out.println("Bluetooth Target =====>"+item.get("Target"));
//Log.e("Bluetooth Target =====>"+item.get("Target"));
dialog.dismiss();
preferenceManager.setBLUETOOTH(item.get("Target"));
invalidateOptionsMenu();
......@@ -720,13 +707,13 @@ public class CreateDeliverySlip extends AppCompatActivity implements AdapterView
@Override
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
if(v.getId() == R.id.barcode_enter) {
if (v.getId() == R.id.barcode_enter) {
if (TextUtils.isEmpty(barcode_enter.getText().toString())) {
Constants.getToast(CreateDeliverySlip.this, "Enter Barcode");
} else {
if((event != null && (event.getKeyCode() == KeyEvent.KEYCODE_ENTER)) || (actionId == EditorInfo.IME_ACTION_DONE) || (actionId == EditorInfo.IME_ACTION_NEXT) || (actionId == EditorInfo.IME_ACTION_GO)) {
Log.e("Event =============>","");
if(!TextUtils.isEmpty(empId.getText().toString())) {
if ((event != null && (event.getKeyCode() == KeyEvent.KEYCODE_ENTER)) || (actionId == EditorInfo.IME_ACTION_DONE) || (actionId == EditorInfo.IME_ACTION_NEXT) || (actionId == EditorInfo.IME_ACTION_GO)) {
Log.e("Event =============>", "");
if (!TextUtils.isEmpty(empId.getText().toString())) {
Constants.hideKeyboard(this);
if (Constants.isNetworkAvailable(this)) {
GenerateDeliverySlip("scan", barcode_enter.getText().toString().trim(), "N", false);
......@@ -734,9 +721,9 @@ public class CreateDeliverySlip extends AppCompatActivity implements AdapterView
} else {
Constants.getToast(CreateDeliverySlip.this, "Please check internet connection");
}
}else{
Constants.getToast(CreateDeliverySlip.this,"Enter SalesMen No");
empId.requestFocus();
} else {
Constants.getToast(CreateDeliverySlip.this, "Enter SalesMen No");
empId.requestFocus();
}
}
}
......@@ -750,8 +737,8 @@ public class CreateDeliverySlip extends AppCompatActivity implements AdapterView
}
@Override
public void onTextChanged(CharSequence val, int i, int i1, int i2) {
try{
if(!TextUtils.isEmpty(empId.getText().toString())) {
try {
if (!TextUtils.isEmpty(empId.getText().toString())) {
if (val.toString().length() > 0) {
if (val.toString().contains("\n")) {
if (Constants.isNetworkAvailable(CreateDeliverySlip.this)) {
......@@ -762,9 +749,9 @@ public class CreateDeliverySlip extends AppCompatActivity implements AdapterView
}
}
}
}else{
Constants.getToast(CreateDeliverySlip.this,"Enter SalesMen No");
empId.requestFocus();
} else {
Constants.getToast(CreateDeliverySlip.this, "Enter SalesMen No");
empId.requestFocus();
}
} catch (NullPointerException np) {
np.printStackTrace();
......@@ -775,21 +762,21 @@ public class CreateDeliverySlip extends AppCompatActivity implements AdapterView
}
}
public void GenerateDeliverySlip(final String scan, String trim, String app, final boolean var) {
public void GenerateDeliverySlip(final String scan, String trim, String app, final boolean var) {
JSONObject object = new JSONObject();
try {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
object.put(getResources().getString(R.string.action), scan);
object.put(getResources().getString(R.string.promotions), "N");
object.put(getResources().getString(R.string.apply_promotion),app);
object.put(getResources().getString(R.string.apply_promotion), app);
JSONArray jsonArray = new JSONArray();
JSONObject jsonObject = null;
if (list.size() > 0) {
for (Barcode b : list) {
jsonObject = new JSONObject();
jsonObject.put(getResources().getString(R.string.barcode_name), b.barcode);
jsonObject.put(getResources().getString(R.string.qty_name), b.qty);
jsonObject.put(getResources().getString(R.string.empid), b.empId);
jsonObject.put(getResources().getString(R.string.barcode_name), b.getBarcode());
jsonObject.put(getResources().getString(R.string.qty_name), b.getQty());
jsonObject.put(getResources().getString(R.string.empid), b.getEmpId());
jsonArray.put(jsonObject);
}
}
......@@ -806,8 +793,6 @@ public class CreateDeliverySlip extends AppCompatActivity implements AdapterView
//object.put(getResources().getString(R.string.android_version),Constants.VERSION);
Log.e("Search", object.toString());
RequestBody body = RequestBody.create(JSON, object.toString());
final OkHttpClient client = new OkHttpClient();
client.setConnectTimeout(250, TimeUnit.SECONDS);
client.setReadTimeout(250, TimeUnit.SECONDS);
......@@ -827,6 +812,7 @@ public class CreateDeliverySlip extends AppCompatActivity implements AdapterView
Constants.ProgressDialogDismiss();
});
}
@Override
public void onResponse(final com.squareup.okhttp.Response response) throws IOException {
try {
......@@ -862,19 +848,19 @@ public class CreateDeliverySlip extends AppCompatActivity implements AdapterView
new TypeToken<List<CreateResponse.Datum>>() {
}.getType());
Log.e("Response =====>", String.valueOf(responseObj.getJSONArray(getResources().getString(R.string.data))));
deliveryslip_list.setLayoutManager(new LinearLayoutManager(CreateDeliverySlip.this));
DeliverySlip_List.setLayoutManager(new LinearLayoutManager(CreateDeliverySlip.this));
deliverySlipAdapter = new DeliverySlipAdapter(CreateDeliverySlip.this, versionList);
deliveryslip_list.setAdapter(deliverySlipAdapter);
DeliverySlip_List.setAdapter(deliverySlipAdapter);
}
totalItems.setText(Html.fromHtml(Constants.getTotalItems(responseObj.getString(getResources().getString(R.string.totalqty)))));
totalMrp.setText(Html.fromHtml(Constants.getTotalMRP(Constants.IndianRupeesFormat(responseObj.getString(getResources().getString(R.string.totalMrp))))));
totalDis.setText(Html.fromHtml(Constants.getTotalDisc(Constants.IndianRupeesFormat(responseObj.getString(getResources().getString(R.string.totalDisc))))));
totalNetMrp.setText(Html.fromHtml(Constants.getTotalNetPayable(Constants.IndianRupeesFormat(responseObj.getString(getResources().getString(R.string.netpayable))))));
if(checkBox.isChecked()){
barcode_enter.requestFocus();
}else{
empId.setText("");
empId.requestFocus();
if (checkBox.isChecked()) {
barcode_enter.requestFocus();
} else {
empId.setText("");
empId.requestFocus();
}
Log.e("total Qty ========>", responseObj.getString(getResources().getString(R.string.totalqty)));
Log.e("total NetPayable ===>", responseObj.getString(getResources().getString(R.string.netpayable)));
......@@ -892,19 +878,19 @@ public class CreateDeliverySlip extends AppCompatActivity implements AdapterView
new TypeToken<List<CreateResponse.Datum>>() {
}.getType());
Log.e("Response =====>", String.valueOf(responseObj.getJSONArray(getResources().getString(R.string.data))));
deliveryslip_list.setLayoutManager(new LinearLayoutManager(CreateDeliverySlip.this));
DeliverySlip_List.setLayoutManager(new LinearLayoutManager(CreateDeliverySlip.this));
deliverySlipAdapter = new DeliverySlipAdapter(CreateDeliverySlip.this, versionList);
deliveryslip_list.setAdapter(deliverySlipAdapter);
DeliverySlip_List.setAdapter(deliverySlipAdapter);
}
totalItems.setText(Html.fromHtml(Constants.getTotalItems(responseObj.getString(getResources().getString(R.string.totalqty)))));
totalMrp.setText(Html.fromHtml(Constants.getTotalMRP(Constants.IndianRupeesFormat(responseObj.getString(getResources().getString(R.string.totalMrp))))));
totalDis.setText(Html.fromHtml(Constants.getTotalDisc(Constants.IndianRupeesFormat(responseObj.getString(getResources().getString(R.string.totalDisc))))));
totalNetMrp.setText(Html.fromHtml(Constants.getTotalNetPayable(Constants.IndianRupeesFormat(responseObj.getString(getResources().getString(R.string.netpayable))))));
if(checkBox.isChecked()){
barcode_enter.requestFocus();
}else{
empId.setText("");
empId.requestFocus();
if (checkBox.isChecked()) {
barcode_enter.requestFocus();
} else {
empId.setText("");
empId.requestFocus();
}
Log.e("total Qty ========>", responseObj.getString(getResources().getString(R.string.totalqty)));
Log.e("total NetPayable ===>", responseObj.getString(getResources().getString(R.string.netpayable)));
......@@ -929,8 +915,8 @@ public class CreateDeliverySlip extends AppCompatActivity implements AdapterView
}
});
}
}else {
runOnUiThread(() -> Constants.getToast(CreateDeliverySlip.this,Response));
} else {
runOnUiThread(() -> Constants.getToast(CreateDeliverySlip.this, Response));
}
} catch (JSONException e) {
e.printStackTrace();
......@@ -952,12 +938,12 @@ public class CreateDeliverySlip extends AppCompatActivity implements AdapterView
}
} catch (JSONException e) {
e.printStackTrace();
}catch (NullPointerException npe){
} catch (NullPointerException npe) {
npe.printStackTrace();
}
}
public void setItems(){
public void setItems() {
totalItems.setText(Html.fromHtml(Constants.getTotalItems("0")));
totalMrp.setText(Html.fromHtml(Constants.getTotalMRP("0")));
totalNetMrp.setText(Html.fromHtml(Constants.getTotalNetPayable("0")));
......@@ -973,33 +959,33 @@ public class CreateDeliverySlip extends AppCompatActivity implements AdapterView
bluetooth_list = dialog.findViewById(R.id.bluetooth_list);
ImageView refresh_bluetooth = dialog.findViewById(R.id.refresh_bluetooth);
mPrinterList = new ArrayList<>();
mPrinterListAdapter = new SimpleAdapter(this, mPrinterList, R.layout.list_at,new String[]{"PrinterName","Target"},new int[]{R.id.PrinterName, R.id.Target});
mPrinterListAdapter = new SimpleAdapter(this, mPrinterList, R.layout.list_at, new String[]{"PrinterName", "Target"}, new int[]{R.id.PrinterName, R.id.Target});
bluetooth_list.setAdapter(mPrinterListAdapter);
bluetooth_list.setOnItemClickListener(this);
mFilterOption = new FilterOption();
mFilterOption.setDeviceType(Discovery.TYPE_PRINTER);
mFilterOption.setEpsonFilter(Discovery.FILTER_NAME);
try{
if(initial){
try {
if (initial) {
Discovery.stop();
initial = false;
Discovery.start(this, mFilterOption, mDiscoveryListener);
}else{
try{
Discovery.start(this, mFilterOption, mDiscoveryListener);
Constants.ProgressDialogShow(this);
}catch(Exception e) {
} else {
try {
Discovery.start(this, mFilterOption, mDiscoveryListener);
Constants.ProgressDialogShow(this);
} catch (Exception e) {
}
}
}catch(Epos2Exception e) {
try{
Discovery.start(this, mFilterOption, mDiscoveryListener);
}catch(Epos2Exception e1){
e1.getMessage();
} catch (Epos2Exception e) {
try {
Discovery.start(this, mFilterOption, mDiscoveryListener);
} catch (Epos2Exception e1) {
e1.getMessage();
}
if(e.getErrorStatus() != Epos2Exception.ERR_PROCESSING){
ShowMsg.showException(e, "stop", CreateDeliverySlip.this);
return;
if (e.getErrorStatus() != Epos2Exception.ERR_PROCESSING) {
ShowMsg.showException(e, "stop", CreateDeliverySlip.this);
return;
}
} finally {
}
......@@ -1007,34 +993,34 @@ public class CreateDeliverySlip extends AppCompatActivity implements AdapterView
}
private void restartDiscovery() {
while(true){
try{
while (true) {
try {
Discovery.stop();
break;
}catch(Epos2Exception e){
if(e.getErrorStatus() != Epos2Exception.ERR_PROCESSING){
ShowMsg.showException(e, "stop", CreateDeliverySlip.this);
return;
}
} catch (Epos2Exception e) {
if (e.getErrorStatus() != Epos2Exception.ERR_PROCESSING) {
ShowMsg.showException(e, "stop", CreateDeliverySlip.this);
return;
}
}
}
mPrinterList.clear();
mPrinterListAdapter.notifyDataSetChanged();
try{
try {
Discovery.start(this, mFilterOption, mDiscoveryListener);
Constants.ProgressDialogShow(this);
}catch(Exception e){
ShowMsg.showException(e, "stop", CreateDeliverySlip.this);
} catch (Exception e) {
ShowMsg.showException(e, "stop", CreateDeliverySlip.this);
}
}
private DiscoveryListener mDiscoveryListener = deviceInfo -> runOnUiThread(new Runnable() {
@Override
public synchronized void run(){
public synchronized void run() {
initial = true;
HashMap<String, String> item = new HashMap<>();
item.put(getResources().getString(R.string.printerName), deviceInfo.getDeviceName());
item.put(getResources().getString(R.string.target) , deviceInfo.getTarget());
item.put(getResources().getString(R.string.target), deviceInfo.getTarget());
mPrinterList.add(item);
mPrinterListAdapter.notifyDataSetChanged();
Constants.ProgressDialogDismiss();
......
......@@ -35,7 +35,7 @@ public class CreateResponse {
private String transactionStartTime;
@SerializedName("transaction_start_microtime")
@Expose
private Long transactionStartMicrotime;
private Long transactionStartMicroTime;
public Integer getSuccess() {
return success;
......@@ -101,16 +101,14 @@ public class CreateResponse {
this.transactionStartTime = transactionStartTime;
}
public Long getTransactionStartMicrotime() {
return transactionStartMicrotime;
public Long getTransactionStartMicroTime() {
return transactionStartMicroTime;
}
public void setTransactionStartMicrotime(Long transactionStartMicrotime) {
this.transactionStartMicrotime = transactionStartMicrotime;
public void setTransactionStartMicroTime(Long transactionStartMicroTime) {
this.transactionStartMicroTime = transactionStartMicroTime;
}
public class Datum {
@SerializedName("barcode")
@Expose
......@@ -283,7 +281,5 @@ public class CreateResponse {
public void setColorCode(String colorCode) {
this.colorCode = colorCode;
}
}
}
\ No newline at end of file
......@@ -61,56 +61,57 @@ import static w.soulofpluto.posstock.Constants.JSON;
Create by Ramesh Babu
*/
public class CreateSaleBill extends AppCompatActivity implements View.OnClickListener,
ReceiveListener, AdapterView.OnItemClickListener,DataInterface, TextView.OnEditorActionListener {
private Button pluto_Print, send , generate_invoice;
private Toolbar main_toolbar;
private EditText cust_name, cust_number, ds_Number,last_four_digits;
public Menu globalMenuItem;
private TextView gross_amount,discount_amount,round_off,netamount;
public class CreateSaleBill extends AppCompatActivity implements View.OnClickListener, ReceiveListener, AdapterView.OnItemClickListener, DataInterface, TextView.OnEditorActionListener {
private Button pluto_Print, send , generate_invoice;
private Toolbar main_toolbar;
private EditText cust_name, cust_number, ds_Number, last_four_digits;
private Menu globalMenuItem;
private TextView gross_amount, discount_amount, round_off, netamount;
private PreferenceManager preferenceManager;
private LinearLayout layout,data;
private StringBuilder builder;
private StringBuilder build;
private String NetAmount;
private ArrayList<Model> datalist;
private JSONObject responseObj;
private RecyclerView ds_list;
ArrayList<String> arrayList;
Dialog dialog;
private static final int REQUEST_PERMISSION = 100;
public static Printer mPrinter = null;
private Context mContext = null;
ListView bluetooth_list;
private LinearLayout layout, data;
private StringBuilder builder;
private StringBuilder build;
private String NetAmount;
private ArrayList<Model> DataList;
private JSONObject responseObj;
private RecyclerView ds_list;
private ArrayList<String> arrayList;
private Dialog dialog;
private static final int REQUEST_PERMISSION = 100;
private static Printer mPrinter = null;
private Context mContext = null;
private ListView bluetooth_list;
private ArrayList<HashMap<String, String>> mPrinterList = null;
private SimpleAdapter mPrinterListAdapter = null;
private FilterOption mFilterOption = null;
private TextView store_location;
private Boolean initial = false;
private String BankName;
private int BankId;
Dialog bankDialog;
private DataPresenter dataPresenter;
private Boolean print = false;
private SimpleAdapter mPrinterListAdapter = null;
private FilterOption mFilterOption = null;
private TextView store_location;
private Boolean initial = false;
private String BankName;
private int BankId;
private Dialog bankDialog;
private DataPresenter dataPresenter;
private Boolean print = false;
@Override
protected void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_create_salebill);
cust_name = findViewById(R.id.cust_name);
cust_number = findViewById(R.id.cust_number);
cust_name = findViewById(R.id.cust_name);
cust_number = findViewById(R.id.cust_number);
store_location = findViewById(R.id.store_location);
ds_Number = findViewById(R.id.ds_Number);
gross_amount = findViewById(R.id.gross_amount);
discount_amount = findViewById(R.id.discount_amount);
round_off = findViewById(R.id.round_off);
netamount = findViewById(R.id.netamount);
pluto_Print = findViewById(R.id.pluto_Print);
send = findViewById(R.id.send);
layout = findViewById(R.id.layout);
data = findViewById(R.id.data);
main_toolbar = findViewById(R.id.main_toolbar);
ds_list = findViewById(R.id.ds_list);
generate_invoice = findViewById(R.id.generate_invoice);
ds_Number = findViewById(R.id.ds_Number);
gross_amount = findViewById(R.id.gross_amount);
discount_amount= findViewById(R.id.discount_amount);
round_off = findViewById(R.id.round_off);
netamount = findViewById(R.id.netamount);
pluto_Print = findViewById(R.id.pluto_Print);
send = findViewById(R.id.send);
layout = findViewById(R.id.layout);
data = findViewById(R.id.data);
main_toolbar = findViewById(R.id.main_toolbar);
ds_list = findViewById(R.id.ds_list);
generate_invoice = findViewById(R.id.generate_invoice);
preferenceManager = new PreferenceManager(this);
store_location.setText(preferenceManager.getStoreName());
pluto_Print.setOnClickListener(this);
......@@ -119,13 +120,13 @@ public class CreateSaleBill extends AppCompatActivity implements View.OnClickLis
setSupportActionBar(main_toolbar);
getSupportActionBar().setTitle(" Create Sale Bill ");
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
builder = new StringBuilder();
datalist = new ArrayList<>();
requestRuntimePermission();
mContext = this;
dataPresenter = new DataPresenter(this,(DataInterface)this);
ds_Number.setOnEditorActionListener(this);
builder = new StringBuilder();
DataList = new ArrayList<>();
mContext = this;
dataPresenter = new DataPresenter(this,(DataInterface)this);
ds_Number. setOnEditorActionListener(this);
cust_number.addTextChangedListener(new AutoChecked());
requestRuntimePermission();
}
class AutoChecked implements TextWatcher {
......@@ -155,23 +156,25 @@ public class CreateSaleBill extends AppCompatActivity implements View.OnClickLis
protected void onResume(){
super.onResume();
}
private void requestRuntimePermission() {
if(Build.VERSION.SDK_INT < Build.VERSION_CODES.M){
return;
return;
}
int permissionStorage = ContextCompat.checkSelfPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE);
int permissionStorage = ContextCompat.checkSelfPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE);
int permissionLocation = ContextCompat.checkSelfPermission(this, Manifest.permission.ACCESS_COARSE_LOCATION);
List<String> requestPermissions = new ArrayList<>();
if(permissionStorage == PackageManager.PERMISSION_DENIED) {
requestPermissions.add(Manifest.permission.WRITE_EXTERNAL_STORAGE);
if(permissionStorage == PackageManager.PERMISSION_DENIED) {
requestPermissions.add(Manifest.permission.WRITE_EXTERNAL_STORAGE);
}
if(permissionLocation == PackageManager.PERMISSION_DENIED) {
requestPermissions.add(Manifest.permission.ACCESS_COARSE_LOCATION);
requestPermissions.add(Manifest.permission.ACCESS_COARSE_LOCATION);
}
if(!requestPermissions.isEmpty()) {
ActivityCompat.requestPermissions(this, requestPermissions.toArray(new String[requestPermissions.size()]), REQUEST_PERMISSION);
ActivityCompat.requestPermissions(this, requestPermissions.toArray(new String[requestPermissions.size()]), REQUEST_PERMISSION);
}
}
@Override
public void onRequestPermissionsResult(int requestCode, @NonNull String permissions[], @NonNull int[] grantResults) {
if(requestCode != REQUEST_PERMISSION || grantResults.length == 0){
......@@ -179,27 +182,26 @@ public class CreateSaleBill extends AppCompatActivity implements View.OnClickLis
}
List<String> requestPermissions = new ArrayList<>();
for(int i = 0; i < permissions.length; i++){
if(permissions[i].equals(Manifest.permission.WRITE_EXTERNAL_STORAGE)
&& grantResults[i] == PackageManager.PERMISSION_DENIED){
requestPermissions.add(permissions[i]);
if(permissions[i].equals(Manifest.permission.WRITE_EXTERNAL_STORAGE) && grantResults[i] == PackageManager.PERMISSION_DENIED){
requestPermissions.add(permissions[i]);
}
if(permissions[i].equals(Manifest.permission.ACCESS_COARSE_LOCATION)
&& grantResults[i] == PackageManager.PERMISSION_DENIED){
requestPermissions.add(permissions[i]);
if(permissions[i].equals(Manifest.permission.ACCESS_COARSE_LOCATION) && grantResults[i] == PackageManager.PERMISSION_DENIED){
requestPermissions.add(permissions[i]);
}
}
if(!requestPermissions.isEmpty()){
ActivityCompat.requestPermissions(this, requestPermissions.toArray(new String[requestPermissions.size()]), REQUEST_PERMISSION);
}
}
private void DsData(final String Id) {
arrayList = new ArrayList<>();
build = new StringBuilder();
if(datalist.size() > 0){
for(int i = 0; i < datalist.size(); i++){
Model data = datalist.get(i);
if(DataList.size() > 0){
for(int i = 0; i < DataList.size(); i++){
Model data = DataList.get(i);
if(data.getDelivery_slip_id().equalsIgnoreCase(Id)){
datalist.remove(i);
DataList.remove(i);
}else{
if(Id != ""){
if(build.toString().length() > 0){
......@@ -244,6 +246,7 @@ public class CreateSaleBill extends AppCompatActivity implements View.OnClickLis
Constants.getToast(CreateSaleBill.this,"Please check your internet connection");
}
}
private void SetData(ArrayList<Model> dList){
CreateSaleAdapter createSaleAdapter = new CreateSaleAdapter(CreateSaleBill.this, dList);
ds_list.setLayoutManager(new LinearLayoutManager(this));
......@@ -257,9 +260,9 @@ public class CreateSaleBill extends AppCompatActivity implements View.OnClickLis
private void Remove(){
arrayList = new ArrayList<>();
build = new StringBuilder();
if(datalist.size() > 0){
for(int i = 0; i < datalist.size(); i++){
Model data = datalist.get(i);
if(DataList.size() > 0){
for(int i = 0; i < DataList.size(); i++){
Model data = DataList.get(i);
if (build.toString().length() > 0) {
build.append(Constants.PrintData(data.getDelivery_slip_id())).toString();
} else {
......@@ -278,8 +281,9 @@ public class CreateSaleBill extends AppCompatActivity implements View.OnClickLis
Constants.getToast(this, "No data");
}
}
@Override
public boolean onCreateOptionsMenu(Menu menu){
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.menu_create, menu);
globalMenuItem = menu;
if(preferenceManager.getBLUETOOTH().length()>0){
......@@ -311,7 +315,7 @@ public class CreateSaleBill extends AppCompatActivity implements View.OnClickLis
}
break;
case R.id.dashboard_connection:
bluetoothpair();
BluetoothPair();
break;
case R.id.dashboard_reload:
......@@ -328,7 +332,7 @@ public class CreateSaleBill extends AppCompatActivity implements View.OnClickLis
return super.onOptionsItemSelected(item);
}
private void bluetoothpair(){
private void BluetoothPair(){
dialog = new Dialog(this);
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
dialog.setContentView(R.layout.print_dialog);
......@@ -361,13 +365,13 @@ public class CreateSaleBill extends AppCompatActivity implements View.OnClickLis
}
if (e.getErrorStatus() != Epos2Exception.ERR_PROCESSING){
ShowMsg.showException(e, "stop", mContext);
return;
}
}finally {
}
refresh_bluetooth.setOnClickListener(v -> restartDiscovery());
}
private void restartDiscovery(){
while (true) {
try {
......@@ -490,9 +494,11 @@ public class CreateSaleBill extends AppCompatActivity implements View.OnClickLis
if (Constants.isNetworkAvailable(CreateSaleBill.this)) {
Constants.hideSoftKeyBoardOnTabClicked(v12, CreateSaleBill.this);
PrintData(last_four_digits.getText().toString(), BankId);
}else{
Constants.getToast(CreateSaleBill.this,"Please check your internet connection");
}else {
runOnUiThread(() -> Constants.getToast(CreateSaleBill.this,"Please check your internet connection"));
}
} else if(last_four_digits.getText().toString().length() > 4){
runOnUiThread(() -> Constants.getToast(CreateSaleBill.this,"Enter Last four digits only"));
}
});
bankDialog.show();
......@@ -514,6 +520,7 @@ public class CreateSaleBill extends AppCompatActivity implements View.OnClickLis
break;
}
}
private boolean runPrintReceiptSequence(){
if (!initializeObject()) {
Log.e("runPrintReceipt","");
......@@ -525,9 +532,9 @@ public class CreateSaleBill extends AppCompatActivity implements View.OnClickLis
return false;
}
if (!printData()) {
finalizeObject();
finalizeObject();
Log.e("runPrintReceipt2","");
return false;
return false;
}
return true;
}
......@@ -540,6 +547,7 @@ public class CreateSaleBill extends AppCompatActivity implements View.OnClickLis
mPrinter.setReceiveEventListener(null);
mPrinter = null;
}
@Override
public void onPtrReceive(final Printer printerObj, final int code, final PrinterStatusInfo status, final String printJobId) {
runOnUiThread(new Runnable() {
......@@ -642,19 +650,20 @@ public class CreateSaleBill extends AppCompatActivity implements View.OnClickLis
}
if (status.getPaper() == Printer.PAPER_NEAR_END) {
warningsMsg += getString(R.string.handlingmsg_warn_receipt_near_end);
}
if (status.getPaper() == Printer.PAPER_EMPTY) {
warningsMsg += "Paper Roll Is Empty";
}
if (status.getBatteryLevel() == Printer.BATTERY_LEVEL_1) {
warningsMsg += getString(R.string.handlingmsg_warn_battery_near_end);
}
if(warningsMsg.length()>0){
Constants.getToast(CreateSaleBill.this,warningsMsg);
}
Log.e("Print ======>", String.valueOf(status.getPaper()));
Log.e("Print ======>", String.valueOf(status.getPaper()));
// edtWarnings.setText(warningsMsg);
}
private boolean isPrintable(PrinterStatusInfo status) {
......@@ -669,9 +678,7 @@ public class CreateSaleBill extends AppCompatActivity implements View.OnClickLis
return false;
}
else {
}
return true;
}
......@@ -683,7 +690,6 @@ public class CreateSaleBill extends AppCompatActivity implements View.OnClickLis
mPrinter.endTransaction();
}
catch (final Exception e) {
}
try {
mPrinter.disconnect();
......@@ -699,7 +705,7 @@ public class CreateSaleBill extends AppCompatActivity implements View.OnClickLis
}
try {
//System.out.println("Checking Printer ======>"+com.epson.epos2.printer.Printer.PARAM_DEFAULT);
mPrinter.connect(preferenceManager.getBLUETOOTH(), 30000);
mPrinter.connect(preferenceManager.getBLUETOOTH(), 50000);
//Log.e("Shared Preferences Bluetooth ========>",preferenceManager.getBLUETOOTH());
}
catch (Exception e) {
......@@ -893,8 +899,6 @@ public class CreateSaleBill extends AppCompatActivity implements View.OnClickLis
method = "addText";
mPrinter.addText(textData.toString());
textData.delete(0, textData.length());
method = "addTextAlign";
mPrinter.addTextAlign(Printer.ALIGN_LEFT);
textData.append(Constants.dashed);
......@@ -907,7 +911,6 @@ public class CreateSaleBill extends AppCompatActivity implements View.OnClickLis
if (dataobject.getString("mobile") != "NA")
textData.append(" Ph No : " + dataobject.getString("mobile") + "\n");
textData.append(Constants.dashed);
method = "addText";
mPrinter.addText(textData.toString());
textData.delete(0, textData.length());
......@@ -917,10 +920,8 @@ public class CreateSaleBill extends AppCompatActivity implements View.OnClickLis
if (dataobject.has("BillDate")) {
}
if (dataobject.has("customer")) {
}
if (dataobject.has("mobile")) {
}
if (dataobject.has("bill_lines")) {
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.KITKAT) {
......@@ -1018,7 +1019,6 @@ public class CreateSaleBill extends AppCompatActivity implements View.OnClickLis
}
}
method = "addText";
mPrinter.addTextAlign(Printer.ALIGN_CENTER);
textData.append("\n" + " Tax Details " + "\n");
......@@ -1224,7 +1224,7 @@ public class CreateSaleBill extends AppCompatActivity implements View.OnClickLis
private void PrintData(String cardNo, final int batchId){
build = new StringBuilder();
for (Model data : datalist) {
for (Model data : DataList) {
if (build.toString().length() > 0) {
build.append(Constants.PrintData(data.getDelivery_slip_id()));
} else {
......@@ -1269,10 +1269,10 @@ public class CreateSaleBill extends AppCompatActivity implements View.OnClickLis
NetAmount = data.getString("total_payable");
//build.append("{"+'"'+"delivery_slip_id"+'"'+":"+'"'+preferenceManager.getPrefix()+Id+'"'+","+'"'+"manual_discount"+'"'+":"+0+"}");
//var = true;
datalist.add(new Model(Id, 0));
DataList.add(new Model(Id, 0));
//setArraylist.add(new Model(Id,0));
if (datalist.size() > 0) {
SetData(datalist);
if (DataList.size() > 0) {
SetData(DataList);
}
//pluto_pay.setVisibility(View.VISIBLE);
//pluto_Print.setVisibility(View.VISIBLE);
......@@ -1332,8 +1332,8 @@ public class CreateSaleBill extends AppCompatActivity implements View.OnClickLis
round_off.setText(Constants.IndianRupeesformat(data.getString("round_off_amount")));
netamount.setText(Constants.IndianRupeesformat(data.getString("total_payable")));
NetAmount = data.getString("total_payable");
if (datalist.size() > 0) {
SetData(datalist);
if (DataList.size() > 0) {
SetData(DataList);
}
} else {
layout.setVisibility(View.GONE);
......@@ -1424,7 +1424,7 @@ public class CreateSaleBill extends AppCompatActivity implements View.OnClickLis
generate_invoice.setVisibility(View.GONE);
data.setVisibility(View.INVISIBLE);
ds_list.setAdapter(null);
datalist.clear();
DataList.clear();
cust_name.setText("");
cust_number.setText("");
responseObj = new JSONObject(finalData);
......
package w.soulofpluto.posstock;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.text.Html;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;
import com.squareup.okhttp.Callback;
......@@ -23,121 +20,124 @@ import org.json.JSONObject;
import java.io.IOException;
import java.util.concurrent.TimeUnit;
/*
Create by Ramesh Babu
/*
Create by Ramesh Babu
*/
//9985099555
public class DashBoardActivity extends AppCompatActivity implements View.OnClickListener {
Toolbar dashboard_toolbar;
Button stock_audit,rack_qty,searchBy_Barcode, transfer;
TextView version;
Toolbar dashboard_toolbar;
Button stock_audit, rack_qty, searchBy_Barcode, transfer;
TextView version;
PreferenceManager preferenceManager;
@Override
protected void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_dashboard);
stock_audit = findViewById(R.id.stock_audit);
rack_qty = findViewById(R.id.rack_qty);
searchBy_Barcode = findViewById(R.id.searchby_barcode);
dashboard_toolbar = findViewById(R.id.dashboard_toolbar);
version = findViewById(R.id.version);
transfer = findViewById(R.id.transfer);
preferenceManager = new PreferenceManager(this);
setSupportActionBar(dashboard_toolbar);
getSupportActionBar().setTitle(getResources().getString(R.string.dashboard));
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
stock_audit .setOnClickListener(this);
rack_qty .setOnClickListener(this);
searchBy_Barcode.setOnClickListener(this);
transfer .setOnClickListener(this);
version .setText(Html.fromHtml(Constants.Ver_Text +Constants.VERSION));
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_dashboard);
stock_audit = findViewById(R.id.stock_audit);
rack_qty = findViewById(R.id.rack_qty);
searchBy_Barcode = findViewById(R.id.searchby_barcode);
dashboard_toolbar = findViewById(R.id.dashboard_toolbar);
version = findViewById(R.id.version);
transfer = findViewById(R.id.transfer);
preferenceManager = new PreferenceManager(this);
setSupportActionBar (dashboard_toolbar);
getSupportActionBar().setTitle(getResources().getString(R.string.dashboard));
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
stock_audit.setOnClickListener(this);
rack_qty.setOnClickListener (this);
searchBy_Barcode.setOnClickListener(this);
transfer.setOnClickListener (this);
version.setText (Html.fromHtml(Constants.Ver_Text + Constants.VERSION));
}
@Override
public boolean onCreateOptionsMenu(Menu menu){
getMenuInflater().inflate(R.menu.menu, menu);
return super.onCreateOptionsMenu(menu);
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.menu, menu);
return super.onCreateOptionsMenu(menu);
}
@Override
public boolean onOptionsItemSelected(@NonNull MenuItem item){
switch(item.getItemId()){
public boolean onOptionsItemSelected(@NonNull MenuItem item) {
switch (item.getItemId()) {
case R.id.dashboard_logout:
if(Constants.isNetworkAvailable(DashBoardActivity.this)){
Logout(Constants.Logout+preferenceManager.getUserId());
if (Constants.isNetworkAvailable(DashBoardActivity.this)) {
Logout(Constants.Logout + preferenceManager.getUserId());
Constants.ProgressDialogShow(DashBoardActivity.this);
}else{
Constants.getToast(DashBoardActivity.this,getResources().getString(R.string.connection));
} else {
Constants.getToast(DashBoardActivity.this, getResources().getString(R.string.connection));
}
break;
break;
case android.R.id.home:
finish();
break;
break;
}
return super.onOptionsItemSelected(item);
}
public void Logout(String Url){
public void Logout(String Url) {
final OkHttpClient client = new OkHttpClient();
client.setConnectTimeout(240, TimeUnit.SECONDS);
client.setReadTimeout(240, TimeUnit.SECONDS);
client.setWriteTimeout(240, TimeUnit.SECONDS);
final Request request = new Request.Builder()
.url(Url)
.get()
.addHeader("Content-Type", "application/json")
.build();
client.newCall(request).enqueue(new Callback(){
client.setReadTimeout(240, TimeUnit.SECONDS);
client.setWriteTimeout(240, TimeUnit.SECONDS);
final Request request = new Request.Builder()
.url(Url)
.get()
.addHeader("Content-Type", "application/json")
.build();
client.newCall(request).enqueue(new Callback() {
@Override
public void onFailure(Request request, IOException e){
Constants.ProgressDialogDismiss();
public void onFailure(Request request, IOException e) {
Constants.ProgressDialogDismiss();
}
@Override
public void onResponse(Response response) throws IOException{
public void onResponse(Response response) throws IOException {
Constants.ProgressDialogDismiss();
if(response.isSuccessful()){
if(response.isSuccessful()) {
String res = response.body().string();
try{
JSONObject jsonObject = new JSONObject(res);
if(jsonObject.has("success")){
if(jsonObject.getInt("success") == 1){
}else if(jsonObject.getInt("success") == 3){
preferenceManager.setUserId("");
preferenceManager.setLogged(false);
preferenceManager.setCustToken("");
preferenceManager.setStoreId("");
Login.logout(DashBoardActivity.this);
Constants.getToast(DashBoardActivity.this,jsonObject.getString("msg"));
}else{
Constants.getToast(DashBoardActivity.this,jsonObject.getString("msg"));
try {
JSONObject jsonObject = new JSONObject(res);
if (jsonObject.has("success")) {
if (jsonObject.getInt("success") == 1) {
} else if (jsonObject.getInt("success") == 3) {
preferenceManager.setUserId("");
preferenceManager.setLogged(false);
preferenceManager.setCustToken("");
preferenceManager.setStoreId("");
Login.logout(DashBoardActivity.this);
Constants.getToast(DashBoardActivity.this, jsonObject.getString("msg"));
} else {
Constants.getToast(DashBoardActivity.this, jsonObject.getString("msg"));
}
}
}catch(JSONException e){
e.printStackTrace();
}catch (NullPointerException np){
np.printStackTrace();
}
}
}
} catch (JSONException e) {
e.printStackTrace();
} catch (NullPointerException np) {
np.printStackTrace();
}
}
}
});
}
@Override
public void onClick(View view){
switch(view.getId()){
public void onClick(View view) {
switch (view.getId()) {
case R.id.stock_audit:
Intent in_main = new Intent(this, MainActivity.class);
this.startActivity(in_main);
break;
Intent in_main = new Intent(this, MainActivity.class);
this.startActivity(in_main);
break;
case R.id.rack_qty:
Intent in_rack = new Intent(this, RackWiseQty.class);
this.startActivity(in_rack);
break;
Intent in_rack = new Intent(this, RackWiseQty.class);
this.startActivity(in_rack);
break;
case R.id.searchby_barcode:
Intent in_search = new Intent(this, SearchByBarcode.class);
this.startActivity(in_search);
break;
}
Intent in_search = new Intent(this, SearchByBarcode.class);
this.startActivity(in_search);
break;
}
}
}
package w.soulofpluto.posstock;
/*
/*
Create by Ramesh Babu
*/
public interface DataInterface {
void onDeliveryData(int code, String data, String Id);
void onDeliveryFail(String fail);
void onDeliveryDataRemove(int code, String data);
void onDeliveryFailRemove(String fail);
void onLogoutData(int code, String data);
void onLogoutFail(String fail);
void onFinalData(int code, String finalData);
void onFinalFail(String finalFail);
void onLogoutData (int code, String data);
void onLogoutFail (String fail);
void onFinalData (int code, String finalData);
void onFinalFail (String finalFail);
void onCustomerName(int code,String name);
void onCustomerNameFail(String fail);
void onCustomerNameFail (String fail);
}
......@@ -3,15 +3,12 @@ package w.soulofpluto.posstock;
import android.content.Context;
import android.os.Handler;
import android.os.Looper;
import android.util.Log;
import com.squareup.okhttp.Callback;
import com.squareup.okhttp.MediaType;
import com.squareup.okhttp.OkHttpClient;
import com.squareup.okhttp.Request;
import com.squareup.okhttp.RequestBody;
import java.io.IOException;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.concurrent.TimeUnit;
/*
......@@ -19,59 +16,59 @@ import java.util.concurrent.TimeUnit;
*/
public class DataPresenter{
private Context context;
private DataInterface dataInterface;
private String Response;
private Context context;
private DataInterface dataInterface;
private String Response;
private PreferenceManager preferenceManager;
public DataPresenter(Context context,DataInterface dataInterface){
this.context = context;
this.dataInterface = dataInterface;
preferenceManager = new PreferenceManager(context);
this .context = context;
this .dataInterface = dataInterface;
preferenceManager = new PreferenceManager(context);
}
public void SendDeliverySlipNumber(String Url, RequestBody object, final String Id){
System.out.println("Url ====>"+Url);
System.out.println("Object ====>"+object);
System .out.println("Url ====>"+Url);
System .out.println("Object ====>"+object);
//RequestBody body = RequestBody.create(JSON, object);
final OkHttpClient client = new OkHttpClient();
client.setConnectTimeout(240, TimeUnit.SECONDS);
client.setReadTimeout(240,TimeUnit.SECONDS);
client.setWriteTimeout(240,TimeUnit.SECONDS);
client .setConnectTimeout(240, TimeUnit.SECONDS);
client .setReadTimeout(240, TimeUnit.SECONDS);
client .setWriteTimeout(240, TimeUnit.SECONDS);
Request request = new Request.Builder()
.url(Url)
.post(object)
.addHeader(Constants.Type, Constants.App_json)
.addHeader(Constants.Access_Token,preferenceManager.getCustToken())
.addHeader(Constants.Access_StoreId, preferenceManager.getStoreId())
.build();
client.newCall(request).enqueue(new Callback(){
.url(Url)
.post(object)
.addHeader(Constants.Type, Constants.App_json)
.addHeader(Constants.Access_Token, preferenceManager.getCustToken())
.addHeader(Constants.Access_StoreId, preferenceManager.getStoreId())
.build();
client .newCall(request).enqueue(new Callback(){
@Override
public void onFailure(Request request, IOException e){
//featureDataInterface.FeatureFailure(request.toString());
dataInterface.onDeliveryFail(request.toString());
System.out.println("Delivery Slip error" +e.getMessage());
dataInterface.onDeliveryFail(request.toString());
System.out.println("Delivery Slip error" +e.getMessage());
}
@Override
public void onResponse(final com.squareup.okhttp.Response response) throws IOException{
try {
Response = response.body().string();
System.out.println("Delivery Slip" + Response);
Handler handler = new Handler(Looper.getMainLooper());
handler.post(() -> dataInterface.onDeliveryData(response.code(),Response,Id));
}catch (NullPointerException np){
np.printStackTrace();
}finally {
response.body().close();
}
try {
Response = response.body().string();
System.out.println("Delivery Slip" + Response);
Handler handler = new Handler(Looper.getMainLooper());
handler.post(() -> dataInterface.onDeliveryData(response.code(),Response,Id));
}catch (NullPointerException np){
np.printStackTrace();
}finally {
response.body().close();
}
}
});
}
public void SendDeliverySlipNumberRemove(String Url, RequestBody object){
System.out.println("Url ====>"+Url);
System.out.println("Object ====>"+object);
//System.out.println("Url ====>"+Url);
//System.out.println("Object ====>"+object);
final OkHttpClient client = new OkHttpClient();
client.setConnectTimeout(240, TimeUnit.SECONDS);
client.setReadTimeout(240,TimeUnit.SECONDS);
......@@ -171,6 +168,7 @@ public class DataPresenter{
}
});
}
public void CustomerName(String Url,RequestBody object){
final OkHttpClient client = new OkHttpClient();
client.setConnectTimeout(2000, TimeUnit.SECONDS);
......@@ -192,7 +190,7 @@ public class DataPresenter{
@Override
public void onResponse(final com.squareup.okhttp.Response response) throws IOException{
Response = response.body().string();
System.out.println("Customer Response ====>" + Response);
Log.e("Customer Response ====>" , Response);
Handler handler = new Handler(Looper.getMainLooper());
handler.post(() -> dataInterface.onCustomerName(response.code(), Response));
}
......
......@@ -20,30 +20,25 @@ import java.util.ArrayList;
import java.util.HashMap;
public class DiscoveryActivity extends Activity implements View.OnClickListener, AdapterView.OnItemClickListener {
private Context mContext = null;
private Context mContext = null;
private ArrayList<HashMap<String, String>> mPrinterList = null;
private SimpleAdapter mPrinterListAdapter = null;
private FilterOption mFilterOption = null;
private FilterOption mFilterOption = null;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_discovery);
mContext = this;
Button button = (Button)findViewById(R.id.btnRestart);
mContext = this;
Button button = findViewById(R.id.btnRestart);
mPrinterList = new ArrayList<>();
button.setOnClickListener(this);
mPrinterList = new ArrayList<>();
mPrinterListAdapter = new SimpleAdapter(this, mPrinterList, R.layout.list_at,
new String[] { "PrinterName", "Target" },
new int[] { R.id.PrinterName, R.id.Target });
ListView list = (ListView)findViewById(R.id.lstReceiveData);
ListView list = findViewById(R.id.lstReceiveData);
list.setAdapter(mPrinterListAdapter);
list.setOnItemClickListener(this);
mFilterOption = new FilterOption();
mFilterOption.setDeviceType(Discovery.TYPE_PRINTER);
mFilterOption.setEpsonFilter(Discovery.FILTER_NAME);
......@@ -58,7 +53,6 @@ public class DiscoveryActivity extends Activity implements View.OnClickListener,
@Override
public void onDestroy() {
super.onDestroy();
while (true) {
try {
Discovery.stop();
......@@ -70,7 +64,6 @@ public class DiscoveryActivity extends Activity implements View.OnClickListener,
}
}
}
mFilterOption = null;
}
......@@ -81,11 +74,9 @@ public class DiscoveryActivity extends Activity implements View.OnClickListener,
restartDiscovery();
break;
default:
// Do nothing
break;
}
}
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
Intent intent = new Intent();
......
......@@ -31,6 +31,8 @@ import static w.soulofpluto.posstock.Constants.Logout;
Create by Ramesh Babu
*/
//9182811074
public class HomeActivity extends AppCompatActivity {
Toolbar home_toolbar;
static PreferenceManager preferenceManager;
......@@ -40,103 +42,104 @@ import static w.soulofpluto.posstock.Constants.Logout;
@Override
protected void onCreate(@Nullable Bundle savedInstanceState){
setContentView(R.layout.activity_home);
home_toolbar = findViewById(R.id.home_toolbar);
version = findViewById(R.id.version);
recyclerView = findViewById(R.id.menu_list);
preferenceManager = new PreferenceManager(this);
setSupportActionBar(home_toolbar);
getSupportActionBar().setTitle( Html.fromHtml("&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" + getResources().getString(R.string.home) ) );
version.setText(Html.fromHtml(Constants.Ver_Text + Constants.VERSION));
if (Constants.isNetworkAvailable(HomeActivity.this)) {
setUI();
Constants.ProgressDialogShow(HomeActivity.this);
} else {
Constants.getToast(HomeActivity.this,"Please check internet connection");
}
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_home);
home_toolbar = findViewById(R.id.home_toolbar);
version = findViewById(R.id.version);
recyclerView = findViewById(R.id.menu_list);
preferenceManager = new PreferenceManager(this);
setSupportActionBar(home_toolbar);
getSupportActionBar().setTitle( Html.fromHtml("&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" + getResources().getString(R.string.home) ) );
version.setText(Html.fromHtml(Constants.Ver_Text + Constants.VERSION));
if (Constants.isNetworkAvailable(HomeActivity.this)) {
setUI();
Constants.ProgressDialogShow(HomeActivity.this);
} else {
Constants.getToast(HomeActivity.this,"Please check internet connection");
}
super.onCreate(savedInstanceState);
}
private void setUI(){
final OkHttpClient client = new OkHttpClient();
client.setConnectTimeout(250, TimeUnit.SECONDS);
client.setReadTimeout(250, TimeUnit.SECONDS);
client.setWriteTimeout(250, TimeUnit.SECONDS);
Request request = new Request.Builder()
.url(Constants.MenuBar)
.get()
.addHeader(Constants.Type, Constants.App_json)
.addHeader(getResources().getString(R.string.accesstoken), preferenceManager.getCustToken())
.addHeader(getResources().getString(R.string.storeidtoken), preferenceManager.getStoreId())
.build();
client.newCall(request).enqueue(new Callback(){
@Override
public void onFailure(Request request, final IOException e){
runOnUiThread(() -> {
Constants.getToast(HomeActivity.this,e.getMessage());
Constants.ProgressDialogDismiss();
});
final OkHttpClient client = new OkHttpClient();
client.setConnectTimeout(250, TimeUnit.SECONDS);
client.setReadTimeout(250, TimeUnit.SECONDS);
client.setWriteTimeout(250, TimeUnit.SECONDS);
Request request = new Request.Builder()
.url(Constants.MenuBar)
.get()
.addHeader(Constants.Type, Constants.App_json)
.addHeader(getResources().getString(R.string.accesstoken), preferenceManager.getCustToken())
.addHeader(getResources().getString(R.string.storeidtoken), preferenceManager.getStoreId())
.build();
client.newCall(request).enqueue(new Callback(){
@Override
public void onFailure(Request request, final IOException e){
runOnUiThread(() -> {
Constants.getToast(HomeActivity.this,e.getMessage());
Constants.ProgressDialogDismiss();
});
}
@Override
public void onResponse(final com.squareup.okhttp.Response response) throws IOException {
try{
try {
Constants.ProgressDialogDismiss();
arrayList = new ArrayList<>();
final String Response = response.body().string();
Log.e("MenuBar Response " , Response);
if(response.code() == 200) {
final JSONObject object = new JSONObject(Response);
if (object.getInt("success") == 1) {
JSONArray jsonArray = object.getJSONArray("data");
for(int i = 0; i < jsonArray.length(); i++) {
arrayList.add(jsonArray.get(i).toString());
}
Handler handler = new Handler(Looper.getMainLooper());
handler.post(() -> {
recyclerView.setLayoutManager(new GridLayoutManager(HomeActivity.this, 2));
MenuAdapter menuAdapter = new MenuAdapter(HomeActivity.this, arrayList);
recyclerView.setAdapter(menuAdapter);
});
Log.e("Size", String.valueOf(arrayList.size()));
JSONArray jsonArray = object.getJSONArray("data");
for(int i = 0; i < jsonArray.length(); i++) {
arrayList.add(jsonArray.get(i).toString());
}
Handler handler = new Handler(Looper.getMainLooper());
handler.post(() -> {
recyclerView.setLayoutManager(new GridLayoutManager(HomeActivity.this, 2));
MenuAdapter menuAdapter = new MenuAdapter(HomeActivity.this, arrayList);
recyclerView.setAdapter(menuAdapter);
});
Log.e("Size", String.valueOf(arrayList.size()));
} else if (object.getInt("success") == 3) {
runOnUiThread(() -> {
try{
Log.e("session", object.getString("msg"));
preferenceManager.setLogged(false);
Constants.getToast(HomeActivity.this, object.getString("msg"));
Login.logout(HomeActivity.this);
}catch(JSONException e) {
e.printStackTrace();
runOnUiThread(() -> {
try{
//Log.e("session", object.getString("msg"));
preferenceManager.setLogged(false);
Constants.getToast(HomeActivity.this, object.getString("msg"));
Login.logout(HomeActivity.this);
} catch(JSONException e) {
e.printStackTrace();
}
});
});
}
}else{
runOnUiThread(() -> Constants.getToast(HomeActivity.this,Response));
} else {
runOnUiThread(() -> Constants.getToast(HomeActivity.this,Response));
}
}catch(NullPointerException | JSONException io){
} catch(NullPointerException | JSONException io) {
io.printStackTrace();
}finally{
} finally {
response.body().close();
}
}
});
}
@Override
public boolean onCreateOptionsMenu(Menu menu){
getMenuInflater().inflate(R.menu.menu, menu);
return super.onCreateOptionsMenu(menu);
}
@Override
public boolean onOptionsItemSelected(@NonNull MenuItem item){
switch(item.getItemId()){
case R.id.dashboard_logout:
if(Constants.isNetworkAvailable(HomeActivity.this)){
Logout(Logout+preferenceManager.getUserId());
Constants.ProgressDialogShow(HomeActivity.this);
}else{
Constants.getToast(HomeActivity.this,getResources().getString(R.string.connection));
}
break;
case R.id.dashboard_logout:
if(Constants.isNetworkAvailable(HomeActivity.this)){
Logout(Logout+preferenceManager.getUserId());
Constants.ProgressDialogShow(HomeActivity.this);
}else{
Constants.getToast(HomeActivity.this,getResources().getString(R.string.connection));
}
break;
}
return super.onOptionsItemSelected(item);
}
......@@ -146,7 +149,7 @@ import static w.soulofpluto.posstock.Constants.Logout;
client.setConnectTimeout(240, TimeUnit.SECONDS);
client.setReadTimeout(240,TimeUnit.SECONDS);
client.setWriteTimeout(240,TimeUnit.SECONDS);
final Request request = new Request.Builder()
final Request request = new Request.Builder()
.url(Url)
.get()
.addHeader(Constants.Type, Constants.App_json)
......@@ -163,7 +166,7 @@ import static w.soulofpluto.posstock.Constants.Logout;
Constants.ProgressDialogDismiss();
final String res = response.body().string();
try {
Log.e("Dashboard Logout ", res);
//Log.e("Dashboard Logout ", res);
if(response.code() == 200) {
JSONObject jsonObject = new JSONObject(res);
if (jsonObject.has("success")) {
......@@ -189,17 +192,18 @@ import static w.soulofpluto.posstock.Constants.Logout;
}
});
}
@Override
public void onBackPressed(){
int count = 0;
if(count>0) {
super.onBackPressed();
super.onBackPressed();
}else {
AlertDialog alert = new AlertDialog.Builder(this)
.setTitle("Are you sure you want to close this app")
.setPositiveButton("Yes", (dialogInterface, i) -> finish())
.setNegativeButton("No", (dialogInterface, i) -> {
}).show();
AlertDialog alert = new AlertDialog.Builder(this)
.setTitle("Are you sure you want to close this app")
.setPositiveButton("Yes", (dialogInterface, i) -> finish())
.setNegativeButton("No", (dialogInterface, i) -> {
}).show();
}
}
}
......@@ -18,7 +18,6 @@ import android.widget.Spinner;
import android.widget.Toast;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;
import com.squareup.okhttp.Callback;
import com.squareup.okhttp.OkHttpClient;
import com.squareup.okhttp.Request;
......@@ -39,13 +38,13 @@ import static w.soulofpluto.posstock.Constants.JSON;
public class Login extends AppCompatActivity implements View.OnClickListener, AdapterView.OnItemSelectedListener{
private EditText userId, password;
private Spinner storeId;
private Button submit;
private Spinner storeId;
private Button submit;
private ArrayList<Store> stores;
private String Response;
private int Store_Id;
private String Response;
private int Store_Id;
private PreferenceManager preferenceManager;
private String Store_Name;
private String Store_Name;
public static void logout(Context context){
Activity activity = (Activity) context;
......@@ -180,12 +179,12 @@ public class Login extends AppCompatActivity implements View.OnClickListener, Ad
}catch(JSONException je){
je.printStackTrace();
}
RequestBody body = RequestBody.create(JSON, object.toString());
RequestBody body = RequestBody.create(JSON, object.toString());
final OkHttpClient client = new OkHttpClient();
client.setConnectTimeout(240, TimeUnit.SECONDS);
client.setReadTimeout(240, TimeUnit.SECONDS);
client.setReadTimeout(240, TimeUnit.SECONDS);
client.setWriteTimeout(240, TimeUnit.SECONDS);
Request request = new Request.Builder()
Request request = new Request.Builder()
.url(Constants.Login)
.post(body)
.addHeader(Constants.Type, Constants.App_json)
......@@ -243,6 +242,7 @@ public class Login extends AppCompatActivity implements View.OnClickListener, Ad
}
});
}
@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id){
switch (parent.getId()){
......@@ -253,9 +253,11 @@ public class Login extends AppCompatActivity implements View.OnClickListener, Ad
break;
}
}
@Override
public void onNothingSelected(AdapterView<?> parent) {
}
@Override
public void onBackPressed() {
super.onBackPressed();
......
......@@ -44,18 +44,17 @@ public class MainActivity extends AppCompatActivity {
setSupportActionBar(main_toolbar);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setTitle(getResources().getString(R.string.test)+ " UserId : " + preferenceManager.getUserId());
}
@Override
protected void onStart(){
if(Constants.isNetworkAvailable(MainActivity.this)){
FetchData(Constants.Dashboard);
Constants.ProgressDialogShow(MainActivity.this);
}else{
Constants.getToast(MainActivity.this,getResources().getString(R.string.connection));
}
super.onStart();
if(Constants.isNetworkAvailable(MainActivity.this)){
FetchData(Constants.Dashboard);
Constants.ProgressDialogShow(MainActivity.this);
}else{
Constants.getToast(MainActivity.this,getResources().getString(R.string.connection));
}
super.onStart();
}
public void Logout(String Url){
......@@ -103,23 +102,23 @@ public class MainActivity extends AppCompatActivity {
@Override
public boolean onCreateOptionsMenu(Menu menu){
getMenuInflater().inflate(R.menu.menu,menu);
return super.onCreateOptionsMenu(menu);
getMenuInflater().inflate(R.menu.menu,menu);
return super.onCreateOptionsMenu(menu);
}
@Override
public boolean onOptionsItemSelected(MenuItem item){
switch(item.getItemId()){
case android.R.id.home:
finish();
break;
case R.id.dashboard_logout:
if(Constants.isNetworkAvailable(MainActivity.this)){
Logout(Constants.Logout+preferenceManager.getUserId());
Constants.ProgressDialogShow(MainActivity.this);
}else{
Constants.getToast(MainActivity.this,getResources().getString(R.string.connection));
}
case android.R.id.home:
finish();
break;
case R.id.dashboard_logout:
if(Constants.isNetworkAvailable(MainActivity.this)){
Logout(Constants.Logout+preferenceManager.getUserId());
Constants.ProgressDialogShow(MainActivity.this);
}else{
Constants.getToast(MainActivity.this,getResources().getString(R.string.connection));
}
break;
}
return super.onOptionsItemSelected(item);
......@@ -130,15 +129,15 @@ public class MainActivity extends AppCompatActivity {
try{
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT){
SimpleDateFormat currentDate = new SimpleDateFormat("yyyy-MM-dd");
Date todayDate = new Date();
Date from = getDateWithOffset(-Constants.Value, new Date());
Date todayDate = new Date();
Date from = getDateWithOffset(-Constants.Value, new Date());
String fromDate = currentDate.format(from);
String thisDate = currentDate.format(todayDate);
Log.e("Last date",fromDate);
object.put(getResources().getString(R.string.auditstatus),"In Progress");
object.put(getResources().getString(R.string.fromdate),fromDate);
object.put(getResources().getString(R.string.todate),thisDate);
object.put(getResources().getString(R.string.android_version),Constants.VERSION);
object.put(getResources().getString(R.string.fromdate), fromDate);
object.put(getResources().getString(R.string.todate), thisDate);
object.put(getResources().getString(R.string.android_version), Constants.VERSION);
}
}catch(JSONException e){
e.printStackTrace();
......@@ -148,12 +147,12 @@ public class MainActivity extends AppCompatActivity {
client.setConnectTimeout(250, TimeUnit.SECONDS);
client.setReadTimeout(250, TimeUnit.SECONDS);
client.setWriteTimeout(250, TimeUnit.SECONDS);
Request request = new Request.Builder()
Request request = new Request.Builder()
.url(Url)
.post(body)
.addHeader(Constants.Type, Constants.App_json)
.addHeader(getResources().getString(R.string.accesstoken), preferenceManager.getCustToken())
.addHeader(getResources().getString(R.string.storeidtoken),preferenceManager.getStoreId())
.addHeader(Constants.Type, Constants.App_json)
.addHeader(getResources().getString(R.string.accesstoken), preferenceManager.getCustToken())
.addHeader(getResources().getString(R.string.storeidtoken), preferenceManager.getStoreId())
.build();
client.newCall(request).enqueue(new Callback(){
@Override
......
......@@ -13,71 +13,70 @@ import androidx.recyclerview.widget.RecyclerView;
import java.util.ArrayList;
/*
Create by Ramesh Babu
Create by Ramesh Babu
*/
public class MenuAdapter extends RecyclerView.Adapter<MenuAdapter.ViewHolder> {
public class MenuAdapter extends RecyclerView.Adapter<MenuAdapter.ViewHolder> {
ArrayList<String> arrayList;
Context context;
public MenuAdapter(Context context,ArrayList<String> arrayList) {
this.context = context;
this.arrayList = arrayList;
public MenuAdapter(Context context, ArrayList<String> arrayList){
this.context = context;
this.arrayList = arrayList;
}
@NonNull
@Override
public MenuAdapter.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
LayoutInflater layoutInflater = LayoutInflater.from(parent.getContext());
View listItem = layoutInflater.inflate(R.layout.menulist_item, parent, false);
MenuAdapter.ViewHolder viewHolder = new MenuAdapter.ViewHolder(listItem);
return viewHolder;
public MenuAdapter.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType){
LayoutInflater layoutInflater = LayoutInflater.from(parent.getContext());
View listItem = layoutInflater.inflate(R.layout.menulist_item, parent, false);
MenuAdapter.ViewHolder viewHolder = new MenuAdapter.ViewHolder(listItem);
return viewHolder;
}
@Override
public void onBindViewHolder(@NonNull MenuAdapter.ViewHolder holder, final int position) {
final String data = arrayList.get(position);
holder.menu_name.setText(data);
if(data.equalsIgnoreCase("Create Delivery Slip")){
public void onBindViewHolder(@NonNull MenuAdapter.ViewHolder holder, final int position){
final String data = arrayList.get(position);
holder.menu_name.setText(data);
if (data.equalsIgnoreCase("Create Delivery Slip")) {
holder.menu_image.setImageResource(R.drawable.ic_create_delivery_slip);
}else if(data.equalsIgnoreCase("Stock Audit")){
} else if (data.equalsIgnoreCase("Stock Audit")) {
holder.menu_image.setImageResource(R.drawable.ic_stock_audit);
}else if(data.equalsIgnoreCase("Create Sale Bill")){
} else if (data.equalsIgnoreCase("Create Sale Bill")) {
holder.menu_image.setImageResource(R.drawable.ic_create_sale_bill);
}else if(data.equalsIgnoreCase("Stock OutWord")){
} else if (data.equalsIgnoreCase("Stock OutWord")) {
holder.menu_image.setImageResource(R.drawable.ic_stock_out_word);
}else if(data.equalsIgnoreCase("Stock Transfer")){
holder.menu_image.setImageResource(R.drawable.ic_stock_out_word);
}else{
} else if (data.equalsIgnoreCase("Stock Transfer")) {
holder.menu_image.setImageResource(R.drawable.ic_stock_out_word);
} else {
holder.menu_image.setImageResource(R.drawable.ic_stock_transfer);
}
//45724.48
holder.layout.setOnClickListener(view -> {
if (data.equalsIgnoreCase("Stock Audit")) {
/*Intent intent = new Intent(context,DashBoardActivity.class);
context.startActivity(intent);*/
return;
} else if(data.equalsIgnoreCase("Create Delivery Slip")) {
/*Intent intent = new Intent(context,CreateDeliverySlip.class);
context.startActivity(intent);*/
return;
} else if(data.equalsIgnoreCase("Create Sale Bill")) {
/*Intent intent = new Intent(context,CreateSaleBill.class);
context.startActivity(intent);*/
return;
} else if(data.equalsIgnoreCase("Stock OutWord")) {
Intent intent = new Intent(context, StockOutWordActivity.class);
context.startActivity(intent);
return;
} else if(data.equalsIgnoreCase("Stock Transfer")){
Intent intent = new Intent(context, StockOutWordActivity.class);
context.startActivity(intent);
return;
} else {
Intent intent = new Intent(context, StockTransferActivity.class);
context.startActivity(intent);
return;
}
}
holder.layout.setOnClickListener(view -> {
if (data.equalsIgnoreCase("Stock Audit")) {
/*Intent intent = new Intent(context,DashBoardActivity.class);
context.startActivity(intent);*/
return;
} else if (data.equalsIgnoreCase("Create Delivery Slip")) {
/* Intent intent = new Intent(context, CreateDeliverySlip.class);
context.startActivity(intent);*/
return;
} else if (data.equalsIgnoreCase("Create Sale Bill")) {
/*Intent intent = new Intent(context, CreateSaleBill.class);
context.startActivity(intent);*/
return;
} else if (data.equalsIgnoreCase("Stock OutWord")) {
Intent intent = new Intent(context, StockOutWordActivity.class);
context.startActivity(intent);
return;
} else if (data.equalsIgnoreCase("Stock Transfer")) {
Intent intent = new Intent(context, StockOutWordActivity.class);
context.startActivity(intent);
return;
} else {
Intent intent = new Intent(context, StockTransferActivity.class);
context.startActivity(intent);
return;
}
});
}
......@@ -87,14 +86,14 @@ import java.util.ArrayList;
}
public class ViewHolder extends RecyclerView.ViewHolder {
public TextView menu_name;
public ImageView menu_image;
public TextView menu_name;
public ImageView menu_image;
public LinearLayout layout;
public ViewHolder(View itemView) {
super(itemView);
menu_name = itemView.findViewById(R.id.menu_name);
menu_image = itemView.findViewById(R.id.menu_image);
layout = itemView.findViewById(R.id.layout);
menu_name = itemView.findViewById(R.id.menu_name);
menu_image = itemView.findViewById(R.id.menu_image);
layout = itemView.findViewById(R.id.layout);
}
}
}
......@@ -4,7 +4,7 @@ package w.soulofpluto.posstock;
Create by Ramesh Babu
*/
public class Model {
public class Model {
private String delivery_slip_id;
private int manual_discount;
......@@ -12,16 +12,19 @@ public class Model {
this.delivery_slip_id = Id;
this.manual_discount = discount;
}
public String getDelivery_slip_id() {
return delivery_slip_id;
}
public void setDelivery_slip_id(String delivery_slip_id) {
this.delivery_slip_id = delivery_slip_id;
}
public int getManual_discount() {
return manual_discount;
}
public void setManual_discount(int manual_discount) {
this.manual_discount = manual_discount;
}
}
}
......@@ -119,20 +119,20 @@ public class PlanDetails extends AppCompatActivity implements View.OnClickListen
}
public void PiecesClicked(View view){
boolean checked = ((RadioButton) view).isChecked();
switch(view.getId()){
case R.id.pieces:
if(checked){
status = true;
qty.setVisibility(View.INVISIBLE);
dummy_qty.setVisibility(View.INVISIBLE);
barcode.setText("");
}else{
status = false;
qty.setVisibility(View.VISIBLE);
dummy_qty.setVisibility(View.VISIBLE);
}
break;
boolean checked = ((RadioButton) view).isChecked();
switch(view.getId()){
case R.id.pieces:
if(checked){
status = true;
qty.setVisibility(View.INVISIBLE);
dummy_qty.setVisibility(View.INVISIBLE);
barcode.setText("");
}else{
status = false;
qty.setVisibility(View.VISIBLE);
dummy_qty.setVisibility(View.VISIBLE);
}
break;
}
}
......@@ -141,14 +141,14 @@ public class PlanDetails extends AppCompatActivity implements View.OnClickListen
switch (view.getId()){
case R.id.meters:
if(checked){
status = false;
qty.setVisibility(View.VISIBLE);
dummy_qty.setVisibility(View.VISIBLE);
barcode.setText("");
status = false;
qty.setVisibility(View.VISIBLE);
dummy_qty.setVisibility(View.VISIBLE);
barcode.setText("");
}else{
status = true;
qty.setVisibility(View.INVISIBLE);
dummy_qty.setVisibility(View.INVISIBLE);
status = true;
qty.setVisibility(View.INVISIBLE);
dummy_qty.setVisibility(View.INVISIBLE);
}
break;
}
......@@ -643,11 +643,11 @@ public class PlanDetails extends AppCompatActivity implements View.OnClickListen
if(obj.has(getResources().getString(R.string.success))){
if(obj.getInt(getResources().getString(R.string.success)) == 1 ){
JSONObject data = obj.getJSONObject(getResources().getString(R.string.data));
preferenceManager.setUserId(data.getString(getResources().getString(R.string.empid)));
preferenceManager.setUserId (data.getString(getResources().getString(R.string.empid)));
preferenceManager.setCustToken(data.getString(getResources().getString(R.string.usertoken)));
preferenceManager.setStoreId(data.getString(getResources().getString(R.string.storeid)));
preferenceManager.setPrefix(data.getString(getResources().getString(R.string.prefix)));
preferenceManager.setLogged(true);
preferenceManager.setPrefix (data.getString(getResources().getString(R.string.prefix)));
preferenceManager.setLogged (true);
dialog.dismiss();
}else{
Toast.makeText(PlanDetails.this,obj.getString(getResources().getString(R.string.msg)), Toast.LENGTH_SHORT).show();
......
......@@ -15,7 +15,6 @@ import android.widget.ArrayAdapter;
import android.widget.EditText;
import android.widget.Spinner;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
......@@ -35,9 +34,10 @@ import java.util.concurrent.TimeUnit;
import static w.soulofpluto.posstock.Constants.JSON;
import static w.soulofpluto.posstock.Constants.getDateWithOffset;
/*
Create by Ramesh Babu
*/
/*
Create by Ramesh Babu
*/
public class SearchByBarcode extends AppCompatActivity implements AdapterView.OnItemSelectedListener {
Toolbar searchbybarcode_toolbar;
Spinner searchbybarcode_spinner;
......@@ -87,7 +87,7 @@ import static w.soulofpluto.posstock.Constants.getDateWithOffset;
object.put(getResources().getString(R.string.android_version),Constants.VERSION);
}
}catch(JSONException e){
e.printStackTrace();
e.printStackTrace();
}
Log.e("Search", object.toString());
RequestBody body = RequestBody.create(JSON, object.toString());
......
......@@ -27,7 +27,10 @@ public class SplashActivity extends AppCompatActivity{
FirebaseApp.initializeApp(this);
FirebaseCrashlytics.getInstance().setCrashlyticsCollectionEnabled(true);
if(bluetoothAdapter!=null && bluetoothAdapter.isEnabled()){
runOnUiThread(() -> splashMethod());
/* if(bluetoothAdapter!=null && bluetoothAdapter.isEnabled()){
runOnUiThread(() -> splashMethod());
}else{
try{
......@@ -35,7 +38,7 @@ public class SplashActivity extends AppCompatActivity{
}catch(Exception e){
e.printStackTrace();
}
}
}*/
super.onCreate(savedInstanceState);
}
......
......@@ -48,33 +48,33 @@ import java.util.Random;
import java.util.concurrent.TimeUnit;
import static w.soulofpluto.posstock.Constants.JSON;
/*
Create by Ramesh Babu
*/
/*
Create by Ramesh Babu Puvvadi
*/
public class StockOutWordActivity extends AppCompatActivity implements AdapterView.OnItemSelectedListener {
Toolbar stockOut_toolbar;
PreferenceManager preferenceManager;
String Response, uomText;
ArrayList<State> stateArrayList;
ArrayList<Format> formatArrayList;
Toolbar stockOut_toolbar;
PreferenceManager preferenceManager;
String Response, uomText;
ArrayList<State> stateArrayList;
ArrayList<Format> formatArrayList;
ArrayList<StoreFormat> storeFormatArrayList;
Spinner state_spinner, format_spinner, location_spinner, uom_spinner;
int state_Id, format_Id, location_Id;
EditText qty, barcode;
String Store_Point_Id;
String[] uom = {"Units", "Meters"};
Spinner state_spinner, format_spinner, location_spinner, uom_spinner;
int state_Id, format_Id, location_Id;
EditText qty, barcode;
String Store_Point_Id;
String[] uom = {"Units", "Meters"};
ArrayList<StockBarcode> StockBarcodeArrayList;
ArrayList<Plans> arrayList;
RecyclerView stockOutWord_recyclerView;
PlanDetailsAdapter planDetailsAdapter;
Dialog dialog;
Menu menu;
TextView total_boxes, total_lines, total_qty;
HashMap<Integer, ArrayList<Plans>> hashMap;
MediaPlayer mp;
int max = 10;
int min = 0;
ArrayList<Plans> arrayList;
RecyclerView stockOutWord_recyclerView;
PlanDetailsAdapter planDetailsAdapter;
Dialog dialog;
Menu menu;
TextView total_boxes, total_lines, total_qty;
HashMap<Integer,ArrayList<Plans>> hashMap;
MediaPlayer mp;
int max = 10;
int min = 0;
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
......@@ -90,7 +90,7 @@ public class StockOutWordActivity extends AppCompatActivity implements AdapterVi
super.onCreate(savedInstanceState);
}
void setUI() {
public void setUI() {
total_boxes = findViewById(R.id.total_boxes);
total_lines = findViewById(R.id.total_lines);
total_qty = findViewById(R.id.total_qty);
......@@ -110,23 +110,23 @@ public class StockOutWordActivity extends AppCompatActivity implements AdapterVi
hashMap = new HashMap<>();
stockOutWord_recyclerView = findViewById(R.id.stockOutWord_recyclerView);
setSupportActionBar(stockOut_toolbar);
getSupportActionBar().setTitle(getResources().getString(R.string.stock_out));
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
state_spinner .setOnItemSelectedListener(this);
format_spinner .setOnItemSelectedListener(this);
uom_spinner .setOnItemSelectedListener(this);
location_spinner .setOnItemSelectedListener(this);
barcode .requestFocus();
barcode .addTextChangedListener(new Checked());
barcode . setOnFocusChangeListener((view, hasFocus) -> {
if (!hasFocus) {
} else {
Constants.hideSoftKeyboard(barcode, StockOutWordActivity.this);
}
getSupportActionBar() .setTitle(getResources().getString(R.string.stock_out));
getSupportActionBar() .setDisplayHomeAsUpEnabled(true);
state_spinner .setOnItemSelectedListener(this);
format_spinner .setOnItemSelectedListener(this);
uom_spinner .setOnItemSelectedListener(this);
location_spinner .setOnItemSelectedListener(this);
barcode .requestFocus();
barcode .addTextChangedListener(new Checked());
barcode .setOnFocusChangeListener((view, hasFocus) -> {
if(!hasFocus){
}else{
Constants.hideSoftKeyboard(barcode, StockOutWordActivity.this);
}
});
}
void getNotification() {
public void getNotification() {
runOnUiThread(() -> {
mp = MediaPlayer.create(StockOutWordActivity.this, R.raw.beep);
if (mp != null && mp.isPlaying()) {
......@@ -134,7 +134,7 @@ public class StockOutWordActivity extends AppCompatActivity implements AdapterVi
try {
mp.prepare();
mp.start();
} catch (IOException e) {
} catch(IOException e) {
e.printStackTrace();
} catch (IllegalStateException e1) {
e1.printStackTrace();
......@@ -157,8 +157,8 @@ public class StockOutWordActivity extends AppCompatActivity implements AdapterVi
dialog1.setCanceledOnTouchOutside(false);
dialog1.getWindow().setLayout(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);
dialog1.show();
TextView message = dialog1.findViewById(R.id.message);
Button ok = dialog1.findViewById(R.id.ok);
TextView message = dialog1.findViewById(R.id.message);
Button ok = dialog1.findViewById(R.id.ok);
message.setText("Already scanned this item");
ok.setOnClickListener(view -> {
dialog1.dismiss();
......@@ -181,15 +181,15 @@ public class StockOutWordActivity extends AppCompatActivity implements AdapterVi
@Override
public void onBackPressed() {
AlertDialog.Builder alert = new AlertDialog.Builder(this);
alert.setTitle("Stock OutWord");
alert.setMessage("Are you want to close app");
alert.setPositiveButton("Ok", (dialogInterface, i) -> {
super.onBackPressed();
});
alert.setNegativeButton("Cancel", (dialogInterface, i) -> {
});
alert.show();
AlertDialog.Builder alert = new AlertDialog.Builder(this);
alert.setTitle("Stock OutWord");
alert.setMessage("Are you want to close app");
alert.setPositiveButton("Ok", (dialogInterface, i) -> {
super.onBackPressed();
});
alert.setNegativeButton("Cancel", (dialogInterface, i) -> {
});
alert.show();
}
public class Checked implements TextWatcher {
......@@ -204,8 +204,8 @@ public class StockOutWordActivity extends AppCompatActivity implements AdapterVi
if (val.toString().length() > 0) {
if (val.toString().contains("\n")) {
if (Constants.isNetworkAvailable(StockOutWordActivity.this)) {
if (arrayList.size() > 0) {
if (Constants.Existing(arrayList, barcode.getText().toString().replace("\n", ""))) {
if(arrayList.size() > 0) {
if(Constants.Existing(arrayList, barcode.getText().toString().replace("\n", ""))) {
try {
getNotification();
} catch (Exception e) {
......@@ -271,109 +271,134 @@ public class StockOutWordActivity extends AppCompatActivity implements AdapterVi
break;
case R.id.Outword_tfs:
menu.findItem(R.id.Outword_box).setVisible(false);
menu.findItem(R.id.Outword_tfs).setVisible(false);
JSONObject json = new JSONObject();
try {
json.put("from_location", preferenceManager.getStoreId());
json.put("to_location", String.valueOf(location_Id));
JSONArray jsonArray = new JSONArray();
for (Map.Entry<Integer, ArrayList<Plans>> item1 : hashMap.entrySet()) {
int key = item1.getKey();
ArrayList<Plans> value = item1.getValue();
JSONArray jsonArray1 = new JSONArray();
for (Plans plan : value) {
JSONObject jsonObject = new JSONObject();
try {
jsonObject.put("barcode", plan.Barcode);
jsonObject.put("quantity", "1.0");
} catch (JSONException e) {
e.printStackTrace();
if(Constants.isNetworkAvailable(StockOutWordActivity.this)) {
menu.findItem(R.id.Outword_box).setVisible(false);
menu.findItem(R.id.Outword_tfs).setVisible(false);
JSONObject json = new JSONObject();
try {
json.put("from_location", preferenceManager.getStoreId());
json.put("to_location", String.valueOf(location_Id));
JSONArray jsonArray = new JSONArray();
for (Map.Entry<Integer, ArrayList<Plans>> item1 : hashMap.entrySet()) {
int key = item1.getKey();
ArrayList<Plans> value = item1.getValue();
JSONArray jsonArray1 = new JSONArray();
for (Plans plan : value) {
JSONObject jsonObject = new JSONObject();
try {
jsonObject.put("barcode", plan.Barcode);
jsonObject.put("quantity", "1.0");
} catch (JSONException e) {
e.printStackTrace();
}
jsonArray1.put(jsonObject);
}
jsonArray1.put(jsonObject);
}
jsonArray.put(jsonArray1);
}
Log.e("JsonArray ", jsonArray.toString());
json.put("boxes", jsonArray);
json.put("stock_point_id", Store_Point_Id);
json.put("return_to_vendor", false);
RequestBody body = RequestBody.create(JSON, json.toString());
final OkHttpClient client = new OkHttpClient();
client.setConnectTimeout(250, TimeUnit.SECONDS);
client.setReadTimeout(250, TimeUnit.SECONDS);
client.setWriteTimeout(250, TimeUnit.SECONDS);
Request request = new Request.Builder()
.url(Constants.StockTransfer)
.post(body)
.addHeader(Constants.Type, Constants.App_json)
.addHeader(getResources().getString(R.string.accesstoken), preferenceManager.getCustToken())
.addHeader(getResources().getString(R.string.storeidtoken), preferenceManager.getStoreId())
.build();
client.newCall(request).enqueue(new Callback() {
@Override
public void onFailure(Request request, final IOException e) {
runOnUiThread(() -> {
Constants.getToast(StockOutWordActivity.this, e.getMessage());
Constants.ProgressDialogDismiss();
});
jsonArray.put(jsonArray1);
}
@Override
public void onResponse(final com.squareup.okhttp.Response response) throws IOException {
try {
Constants.ProgressDialogDismiss();
final String Response = response.body().string();
Log.e("Upload Barcode", Response);
Handler handler = new Handler(Looper.getMainLooper());
handler.post(() -> {
try {
final JSONObject object1 = new JSONObject(Response);
if (response.code() == 200) {
if (object1.has(getResources().getString(R.string.success))) {
if (object1.getInt(getResources().getString(R.string.success)) == 1) {
menu.findItem(R.id.Outword_tfs).setVisible(false);
menu.findItem(R.id.Outword_box).setVisible(false);
barcode.requestFocus();
Constants.getToast(StockOutWordActivity.this, object1.getString(getResources().getString(R.string.msg)));
hashMap.clear();
arrayList.clear();
planDetailsAdapter.notifyDataSetChanged();
total_boxes.setText("Total Boxes : 0");
total_lines.setText("Total Lines : 0");
total_qty.setText("Total Qty : 0");
} else if (object1.getInt(getResources().getString(R.string.success)) == 3) {
runOnUiThread(() -> {
try {
Constants.getToast(StockOutWordActivity.this, object1.getString(getResources().getString(R.string.msg)));
} catch (JSONException e) {
json.put("boxes", jsonArray);
json.put("stock_point_id", Store_Point_Id);
json.put("return_to_vendor", false);
RequestBody body = RequestBody.create(JSON, json.toString());
final OkHttpClient client = new OkHttpClient();
client.setConnectTimeout(250, TimeUnit.SECONDS);
client.setReadTimeout(250, TimeUnit.SECONDS);
client.setWriteTimeout(250, TimeUnit.SECONDS);
Request request = new Request.Builder()
.url (Constants.StockTransfer)
.post(body)
.addHeader(Constants.Type, Constants.App_json)
.addHeader(getResources().getString(R.string.accesstoken), preferenceManager.getCustToken())
.addHeader(getResources().getString(R.string.storeidtoken), preferenceManager.getStoreId())
.build();
client.newCall(request).enqueue(new Callback() {
@Override
public void onFailure(Request request, final IOException e) {
runOnUiThread(() -> {
Constants.getToast(StockOutWordActivity.this, e.getMessage());
Constants.ProgressDialogDismiss();
});
}
@Override
public void onResponse(final com.squareup.okhttp.Response response) throws IOException {
try {
Constants.ProgressDialogDismiss();
final String Response = response.body().string();
Log.e("Upload Barcode", Response);
Handler handler = new Handler(Looper.getMainLooper());
handler.post(() -> {
try {
final JSONObject object1 = new JSONObject(Response);
if (response.code() == 200) {
if (object1.has(getResources().getString(R.string.success))) {
if (object1.getInt(getResources().getString(R.string.success)) == 1) {
menu.findItem(R.id.Outword_tfs).setVisible(false);
menu.findItem(R.id.Outword_box).setVisible(false);
barcode.requestFocus();
runOnUiThread(() -> {
try{
getShowDialog(object1.getString("msg"));
}catch(JSONException e) {
e.printStackTrace();
}
});
} else {
Constants.getToast(StockOutWordActivity.this, object1.getString(getResources().getString(R.string.msg)));
}
});
hashMap.clear();
arrayList.clear();
planDetailsAdapter.notifyDataSetChanged();
total_boxes.setText("Total Boxes : 0");
total_lines.setText("Total Lines : 0");
total_qty.setText( "Total Qty : 0");
} else if (object1.getInt(getResources().getString(R.string.success)) == 3) {
runOnUiThread(() -> {
try {
Constants.getToast(StockOutWordActivity.this, object1.getString(getResources().getString(R.string.msg)));
} catch (JSONException e) {
e.printStackTrace();
}
});
} else {
Constants.getToast(StockOutWordActivity.this, object1.getString(getResources().getString(R.string.msg)));
}
}
}
} catch (JSONException e) {
e.printStackTrace();
}
} catch (JSONException e) {
e.printStackTrace();
}
});
} catch (NullPointerException io) {
io.printStackTrace();
} finally {
response.body().close();
});
} catch (NullPointerException io) {
io.printStackTrace();
} finally {
response.body().close();
}
}
}
});
} catch (JSONException e) {
e.printStackTrace();
});
} catch (JSONException e) {
e.printStackTrace();
}
}else{
Constants.getToast(StockOutWordActivity.this,getResources().getString(R.string.connection));
}
break;
}
return super.onOptionsItemSelected(item);
}
public void getCall() {
public void getShowDialog(String msg) {
final Dialog dialog1 = new Dialog(this);
dialog1.requestWindowFeature(Window.FEATURE_NO_TITLE);
dialog1.setContentView(R.layout.activity_dialog);
dialog1.setCancelable(false);
dialog1.setCanceledOnTouchOutside(false);
dialog1.getWindow().setLayout(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);
dialog1.show();
TextView message = dialog1.findViewById(R.id.message);
Button ok = dialog1.findViewById(R.id.ok);
message.setText(msg);
ok.setOnClickListener(view -> {
dialog1.dismiss();
});
}
public void getCall() {
final OkHttpClient client = new OkHttpClient();
client.setConnectTimeout(240, TimeUnit.SECONDS);
client.setReadTimeout(240, TimeUnit.SECONDS);
......@@ -397,7 +422,6 @@ public class StockOutWordActivity extends AppCompatActivity implements AdapterVi
public void onResponse(final com.squareup.okhttp.Response response) throws IOException {
Constants.ProgressDialogDismiss();
Response = response.body().string();
//Log.e("GET CALL =====>", Response);
try {
Handler handler = new Handler(Looper.getMainLooper());
handler.post(() -> {
......@@ -457,7 +481,7 @@ public class StockOutWordActivity extends AppCompatActivity implements AdapterVi
});
}
public void UploadBarcode(final String Barcode, final String qty, final int Id) {
public void UploadBarcode(final String Barcode, final String qty, final int Id) {
JSONObject object = new JSONObject();
try{
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT){
......@@ -468,6 +492,7 @@ public class StockOutWordActivity extends AppCompatActivity implements AdapterVi
}catch(JSONException e){
e.printStackTrace();
}
Log.e("Upload Barcode", object.toString());
RequestBody body = RequestBody.create(JSON, object.toString());
final OkHttpClient client = new OkHttpClient();
......@@ -485,10 +510,11 @@ public class StockOutWordActivity extends AppCompatActivity implements AdapterVi
@Override
public void onFailure(Request request, final IOException e) {
runOnUiThread(() -> {
Constants.getToast(StockOutWordActivity.this, e.getMessage());
Constants.ProgressDialogDismiss();
Constants.getToast(StockOutWordActivity.this, e.getMessage());
Constants.ProgressDialogDismiss();
});
}
//9866272552
@Override
public void onResponse(final com.squareup.okhttp.Response response) throws IOException {
try {
......@@ -552,7 +578,8 @@ public class StockOutWordActivity extends AppCompatActivity implements AdapterVi
}
});
}
private void DoLogin() {
public void DoLogin() {
dialog = new Dialog(StockOutWordActivity.this);
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
dialog.setContentView(R.layout.dialog_session);
......@@ -577,7 +604,8 @@ public class StockOutWordActivity extends AppCompatActivity implements AdapterVi
}
});
}
private void doLogin(String userId, String pass) {
public void doLogin(String userId, String pass) {
JSONObject object = new JSONObject();
try {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
......@@ -590,12 +618,12 @@ public class StockOutWordActivity extends AppCompatActivity implements AdapterVi
} catch (JSONException e) {
e.printStackTrace();
}
RequestBody body = RequestBody.create(JSON, object.toString());
RequestBody body = RequestBody.create(JSON, object.toString());
final OkHttpClient client = new OkHttpClient();
client.setConnectTimeout(100, TimeUnit.SECONDS);
client.setReadTimeout(100, TimeUnit.SECONDS);
client.setWriteTimeout(100, TimeUnit.SECONDS);
Request request = new Request.Builder()
client.setReadTimeout (100, TimeUnit.SECONDS);
client.setWriteTimeout (100, TimeUnit.SECONDS);
Request request = new Request.Builder()
.url(Constants.Login)
.post(body)
.addHeader(Constants.Type, Constants.App_json)
......@@ -618,7 +646,7 @@ public class StockOutWordActivity extends AppCompatActivity implements AdapterVi
handler.post(() -> {
if (response.code() == 200) {
try {
JSONObject obj = new JSONObject(Response);
JSONObject obj = new JSONObject(Response);
if (obj.has(getResources().getString(R.string.success))) {
if (obj.getInt(getResources().getString(R.string.success)) == 1) {
JSONObject data = obj.getJSONObject(getResources().getString(R.string.data));
......@@ -649,6 +677,7 @@ public class StockOutWordActivity extends AppCompatActivity implements AdapterVi
}
});
}
@RequiresApi(api = Build.VERSION_CODES.N)
public void DeleteBarcode(final Plans plans1, final int position, ArrayList<Plans> plansArrayList) {
int k = 0;
......@@ -662,9 +691,9 @@ public class StockOutWordActivity extends AppCompatActivity implements AdapterVi
}
} else {
if( k > 0 ) {
menu.findItem(R.id.Outword_box).setVisible(true);
menu.findItem(R.id.Outword_box).setVisible(true);
}else {
menu.findItem(R.id.Outword_box).setVisible(false);
menu.findItem(R.id.Outword_box).setVisible(false);
}
k++;
}
......@@ -681,7 +710,7 @@ public class StockOutWordActivity extends AppCompatActivity implements AdapterVi
}
}
runOnUiThread(() -> {
total_qty.setText("Total Qty :" + arrayList.size());
total_qty.setText("Total Qty :" + arrayList.size());
total_lines.setText("Total Lines :" + tempArrayList.size());
});
synchronized (hashMap) {
......@@ -707,7 +736,6 @@ public class StockOutWordActivity extends AppCompatActivity implements AdapterVi
ce.getMessage();
}
}
//Log.e("HashMap Items =====>", String.valueOf(hashMap.size()));
runOnUiThread(() -> total_boxes.setText("Total Boxes :" + hashMap.size()));
} else {
runOnUiThread(() -> {
......@@ -779,7 +807,7 @@ public class StockOutWordActivity extends AppCompatActivity implements AdapterVi
}
}
private void getStorePointId(String storeId) {
public void getStorePointId(String storeId) {
final OkHttpClient client = new OkHttpClient();
client.setConnectTimeout(240, TimeUnit.SECONDS);
client.setReadTimeout(240, TimeUnit.SECONDS);
......@@ -803,7 +831,7 @@ public class StockOutWordActivity extends AppCompatActivity implements AdapterVi
public void onResponse(final com.squareup.okhttp.Response response) throws IOException {
Constants.ProgressDialogDismiss();
Response = response.body().string();
Log.e("StateFormat =====>", Response);
//Log.e("StateFormat =====>", Response);
try {
Handler handler = new Handler(Looper.getMainLooper());
handler.post(() -> {
......@@ -829,31 +857,30 @@ public class StockOutWordActivity extends AppCompatActivity implements AdapterVi
});
}
private void getStateFormatAPI(int state_id, int format_id) {
public void getStateFormatAPI(int state_id, int format_id) {
final OkHttpClient client = new OkHttpClient();
client.setConnectTimeout(240, TimeUnit.SECONDS);
client.setReadTimeout(240, TimeUnit.SECONDS);
client.setWriteTimeout(240, TimeUnit.SECONDS);
Request request = new Request.Builder()
.url(Constants.ToStoreFormat + state_id + "/" + format_id)
.addHeader(Constants.Type, Constants.App_json)
.addHeader(getResources().getString(R.string.accesstoken), preferenceManager.getCustToken())
.addHeader(Constants.Type, Constants.App_json)
.addHeader(getResources().getString(R.string.accesstoken), preferenceManager.getCustToken())
.addHeader(getResources().getString(R.string.storeidtoken), preferenceManager.getStoreId())
.build();
client.newCall(request).enqueue(new com.squareup.okhttp.Callback() {
@Override
public void onFailure(Request request, IOException e) {
Constants.ProgressDialogDismiss();
if (e.getCause() != null && e.getCause() instanceof UnknownHostException) {
} else {
runOnUiThread(() -> Constants.getToast(StockOutWordActivity.this, e.getMessage()));
if(e.getCause() != null && e.getCause() instanceof UnknownHostException){
}else{
runOnUiThread(() -> Constants.getToast(StockOutWordActivity.this, e.getMessage()));
}
}
@Override
public void onResponse(final com.squareup.okhttp.Response response) throws IOException {
Constants.ProgressDialogDismiss();
Response = response.body().string();
Log.e("StateFormat =====>", Response);
try {
Handler handler = new Handler(Looper.getMainLooper());
handler.post(() -> {
......@@ -913,15 +940,15 @@ public class StockOutWordActivity extends AppCompatActivity implements AdapterVi
});
}
private void getFormatAPI(int state_id) {
public void getFormatAPI(int state_id) {
final OkHttpClient client = new OkHttpClient();
client.setConnectTimeout(240, TimeUnit.SECONDS);
client.setReadTimeout(240, TimeUnit.SECONDS);
client.setWriteTimeout(240, TimeUnit.SECONDS);
Request request = new Request.Builder()
.url(Constants.ToFormat + state_id)
.addHeader(Constants.Type, Constants.App_json)
.addHeader(getResources().getString(R.string.accesstoken), preferenceManager.getCustToken())
.addHeader(Constants.Type, Constants.App_json)
.addHeader(getResources().getString(R.string.accesstoken), preferenceManager.getCustToken())
.addHeader(getResources().getString(R.string.storeidtoken), preferenceManager.getStoreId())
.build();
client.newCall(request).enqueue(new com.squareup.okhttp.Callback() {
......@@ -930,15 +957,13 @@ public class StockOutWordActivity extends AppCompatActivity implements AdapterVi
Constants.ProgressDialogDismiss();
if (e.getCause() != null && e.getCause() instanceof UnknownHostException) {
} else {
runOnUiThread(() -> Constants.getToast(StockOutWordActivity.this, e.getMessage()));
runOnUiThread(() -> Constants.getToast(StockOutWordActivity.this, e.getMessage()));
}
}
@Override
public void onResponse(final com.squareup.okhttp.Response response) throws IOException {
Constants.ProgressDialogDismiss();
Response = response.body().string();
Log.e("To Format =====>", Response);
try {
Handler handler = new Handler(Looper.getMainLooper());
handler.post(() -> {
......@@ -952,7 +977,6 @@ public class StockOutWordActivity extends AppCompatActivity implements AdapterVi
format.setStore_format("Select");
formatArrayList.add(format);
if (obj.getInt(getResources().getString(R.string.success)) == 1) {
Log.e("Response =====>", obj.toString());
JSONArray jsonArray = obj.getJSONArray("data");
for (int i = 0; i < jsonArray.length(); i++) {
JSONObject jsonObject = jsonArray.getJSONObject(i);
......@@ -1002,7 +1026,7 @@ public class StockOutWordActivity extends AppCompatActivity implements AdapterVi
public void onNothingSelected(AdapterView<?> adapterView) {
}
void setUpdateUI() {
public void setUpdateUI() {
if (arrayList.size() > 0) {
total_qty.setText("Total Qty :" + arrayList.size());
ArrayList<Integer> tempArrayList = new ArrayList<>();
......@@ -1010,7 +1034,7 @@ public class StockOutWordActivity extends AppCompatActivity implements AdapterVi
Plans plans = arrayList.get(i);
if (plans.getStatus()) {
} else {
tempArrayList.add(1);
tempArrayList.add(1);
}
}
total_lines.setText("Total Lines :" + tempArrayList.size());
......@@ -1019,12 +1043,4 @@ public class StockOutWordActivity extends AppCompatActivity implements AdapterVi
total_boxes.setText("Total Boxes :" + hashMap.size());
}
}
}
}
\ No newline at end of file
......@@ -22,8 +22,6 @@ import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import com.squareup.okhttp.Callback;
import com.squareup.okhttp.OkHttpClient;
import com.squareup.okhttp.Request;
......@@ -33,14 +31,14 @@ import org.json.JSONObject;
import java.io.IOException;
import java.net.UnknownHostException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.concurrent.TimeUnit;
import static w.soulofpluto.posstock.Constants.JSON;
import static w.soulofpluto.posstock.Constants.JsonFormatData;
/*
/*
Create by Ramesh Babu
*/
public class StockReceived extends AppCompatActivity implements View.OnClickListener {
EditText tfSid;
Toolbar StockReceived_toolbar;
......@@ -66,28 +64,32 @@ public class StockReceived extends AppCompatActivity implements View.OnClickList
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_stock_received);
tfSid = findViewById(R.id.tfsid);
tfs_Number = findViewById(R.id.tfs_Number);
StockReceived_recyclerView = findViewById(R.id.stockReceived_recylerView);
StockReceived_toolbar = findViewById(R.id.stockReceived_toolbar);
transfer_qty = findViewById(R.id.transfer_qty);
pending_qty = findViewById(R.id.pending_qty);
received_qty = findViewById(R.id.received_qty);
stock_received = findViewById(R.id.stock_received);
preferenceManager = new PreferenceManager(StockReceived.this);
boxInfoArrayList = new ArrayList<>();
tfSid = findViewById(R.id.tfsid);
tfs_Number = findViewById(R.id.tfs_Number);
StockReceived_recyclerView = findViewById(R.id.stockReceived_recylerView);
StockReceived_toolbar = findViewById(R.id.stockReceived_toolbar);
transfer_qty = findViewById(R.id.transfer_qty);
pending_qty = findViewById(R.id.pending_qty);
received_qty = findViewById(R.id.received_qty);
stock_received = findViewById(R.id.stock_received);
preferenceManager = new PreferenceManager(StockReceived.this);
boxInfoArrayList = new ArrayList<>();
tfSid.addTextChangedListener(new Checked());
stock_received.setOnClickListener(this);
try {
try{
if(getIntent().getStringExtra("key") != null) {
value = getIntent().getStringExtra("key");
setSupportActionBar(StockReceived_toolbar);
getSupportActionBar().setTitle(getResources().getString(R.string.stock_received) + " | " + value);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getCall();
if (Constants.isNetworkAvailable(this)) {
getCall();
}else{
runOnUiThread(() -> Constants.getToast(StockReceived.this,getResources().getString(R.string.connection)));
}
}
} catch (NullPointerException np) {
np.printStackTrace();
}catch (NullPointerException np) {
np.printStackTrace();
}
}
......@@ -121,12 +123,15 @@ public class StockReceived extends AppCompatActivity implements View.OnClickList
case R.id.stock_received:
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.N) {
String str[] = received_qty.getText().toString().split(":");
if(!str[1].trim().equalsIgnoreCase("0") && boxInfoArrayList.stream().map(BoxInfo::getStatus).anyMatch(Boolean.TRUE::equals)) {
try{
//Log.e("BoxInfo List ====>", JsonFormatData(Tfs_Id, Box_Id, boxInfoArrayList, preferenceManager.getStoreId()));
Constants.ProgressDialogShow(StockReceived.this);
FinalRequest(JsonFormatData(Tfs_Id, Box_Id, boxInfoArrayList, preferenceManager.getStoreId()));
}catch(JSONException e){
if (!str[1].trim().equalsIgnoreCase("0") && boxInfoArrayList.stream().map(BoxInfo::getStatus).anyMatch(Boolean.TRUE::equals)) {
try {
if(Constants.isNetworkAvailable(this)) {
Constants.ProgressDialogShow(StockReceived.this);
FinalRequest(JsonFormatData(Tfs_Id, Box_Id, boxInfoArrayList, preferenceManager.getStoreId()));
}else{
runOnUiThread(() -> Constants.getToast(StockReceived.this,getResources().getString(R.string.connection)));
}
} catch(JSONException e) {
e.printStackTrace();
}
} else {
......@@ -225,13 +230,19 @@ public class StockReceived extends AppCompatActivity implements View.OnClickList
@Override
public void onTextChanged(CharSequence val, int i, int i1, int i2) {
try {
if (!TextUtils.isEmpty(tfSid.getText().toString())) {
if (val.toString().length() > 0) {
if (val.toString().trim().contains("\n")) {
Log.e("Barcode",val.toString());
if (val.toString().contains("\n")) {
Log.e("Barcode1",val.toString());
if (Constants.isNetworkAvailable(StockReceived.this)) {
if (boxInfoArrayList.size() > 0) {
boolean itemExistsBasedOnProp = boxInfoArrayList.stream().map(BoxInfo::getBarcode).anyMatch(val.toString().replace("\n", "")::equals);
//Log.e("Barcode value =====>", String.valueOf(itemExistsBasedOnProp));
Log.e("Barcode arraysize==>",val.toString());
//String value1[] = val.toString().split("\n");
String value = val.toString().replace("\n","");
Log.e("Value size ======>", String.valueOf(value.length()));
boolean itemExistsBasedOnProp = boxInfoArrayList.stream().map(BoxInfo::getBarcode).anyMatch(value.replace(" ","")::equals);
//boolean itemExistsBasedOnProp = boxInfoArrayList.stream().map(BoxInfo::getBarcode).anyMatch(val.toString().replace("\n", "")::equals);
Log.e("Barcode value =====>", String.valueOf(itemExistsBasedOnProp));
if (itemExistsBasedOnProp) {
for (int k = 0; k < boxInfoArrayList.size(); k++) {
BoxInfo boxInfo = boxInfoArrayList.get(k);
......@@ -249,6 +260,7 @@ public class StockReceived extends AppCompatActivity implements View.OnClickList
tfSid.setText("");
tfSid.requestFocus();
} else {
Log.e("Insert ," , "else" );
BoxInfo boxInfo1 = new BoxInfo(boxInfo.getBarcode(), boxInfo.getUom(), boxInfo.getTransfer_qty(), "1", "0", true);
boxInfoArrayList.set(k, boxInfo1);
adapter.notifyDataSetChanged();
......@@ -256,7 +268,7 @@ public class StockReceived extends AppCompatActivity implements View.OnClickList
val3 = val3 + 1;
runOnUiThread(() -> {
transfer_qty.setText("Sent : " + val1);
pending_qty.setText("Pending : " + val2);
pending_qty.setText( "Pending : " + val2);
received_qty.setText("Received : " + val3);
tfSid.setText("");
tfSid.requestFocus();
......@@ -282,10 +294,10 @@ public class StockReceived extends AppCompatActivity implements View.OnClickList
}
}
} else {
Constants.getToast(StockReceived.this, "Enter TFS No");
//Constants.getToast(StockReceived.this, "Enter TFS No");
//tfSid.setText("");
tfSid.requestFocus();
}
}
} catch (NullPointerException jo) {
jo.getMessage();
}
......@@ -304,7 +316,7 @@ public class StockReceived extends AppCompatActivity implements View.OnClickList
.url(Constants.GetTFSBoxNumbers + val)
.get()
.addHeader(Constants.Type, Constants.App_json)
.addHeader(getResources().getString(R.string.accesstoken), preferenceManager.getCustToken())
.addHeader(getResources().getString(R.string.accesstoken) , preferenceManager.getCustToken())
.addHeader(getResources().getString(R.string.storeidtoken), preferenceManager.getStoreId())
.build();
client.newCall(request).enqueue(new Callback() {
......@@ -361,6 +373,7 @@ public class StockReceived extends AppCompatActivity implements View.OnClickList
}
});
}
private void GetTFSBoxDetailsByBarcode(String val, String id) {
final OkHttpClient client = new OkHttpClient();
client.setConnectTimeout(240, TimeUnit.SECONDS);
......@@ -443,10 +456,10 @@ public class StockReceived extends AppCompatActivity implements View.OnClickList
public void PostRequest(String res) {
JSONObject jsonObject = new JSONObject();
try {
try{
jsonObject.put("tfs_number", res);
} catch (JSONException je) {
je.printStackTrace();
}catch(JSONException je) {
je.printStackTrace();
}
com.squareup.okhttp.RequestBody body = com.squareup.okhttp.RequestBody.create(JSON, jsonObject.toString());
final OkHttpClient client = new OkHttpClient();
......
......@@ -19,7 +19,8 @@ import static w.soulofpluto.posstock.StockReceived.startData;
public class StockTransferActivity extends AppCompatActivity {
EditText tfs_number;
Toolbar StockTransfer_toolbar;
Toolbar StockTransfer_toolbar;
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
setContentView(R.layout.activity_stock_transfer);
......@@ -63,6 +64,8 @@ public class StockTransferActivity extends AppCompatActivity {
if (Constants.isNetworkAvailable(StockTransferActivity.this)) {
startData(StockTransferActivity.this,val.toString().replace("\n",""));
tfs_number.setText("");
//tfs_number.requestFocus();
//return;
}
}
} else {
......
......@@ -67,8 +67,8 @@
<string name="apply_promotion">apply_promotion_on_scan</string>
<string name="qty_name">quantity</string>
<string name="items">delivery_slip_items</string>
<string name="stock_transfer">Stock Transfer</string>
<string name="stock_out">Stock Out</string>
<string name="stock_transfer">Stock Recieved</string>
<string name="stock_out">Stock Transfer</string>
<string name="stock_received">Stock Received</string>
<string name="create_title">Create Delivery Slip</string>
<string name="resolve_promotions">Resolve Promotions</string>
......
......@@ -5,7 +5,7 @@ buildscript {
jcenter()
}
dependencies {
classpath "com.android.tools.build:gradle:4.0.1"
classpath "com.android.tools.build:gradle:7.2.1"
classpath 'com.google.gms:google-services:4.3.10'
classpath 'com.google.firebase:firebase-crashlytics-gradle:2.7.1'
// NOTE: Do not place your application dependencies here; they belong
......
#Wed Jan 27 12:34:28 IST 2021
#Tue Oct 03 13:32:00 IST 2023
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.1.1-all.zip
#!/usr/bin/env sh
#!/bin/sh
#
# Copyright © 2015-2021 the original authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
##############################################################################
##
## Gradle start up script for UN*X
##
#
# Gradle start up script for POSIX generated by Gradle.
#
# Important for running:
#
# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
# noncompliant, but you have some other compliant shell such as ksh or
# bash, then to run this script, type that shell name before the whole
# command line, like:
#
# ksh Gradle
#
# Busybox and similar reduced shells will NOT work, because this script
# requires all of these POSIX shell features:
# * functions;
# * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
# «${var#prefix}», «${var%suffix}», and «$( cmd )»;
# * compound commands having a testable exit status, especially «case»;
# * various built-in commands including «command», «set», and «ulimit».
#
# Important for patching:
#
# (2) This script targets any POSIX shell, so it avoids extensions provided
# by Bash, Ksh, etc; in particular arrays are avoided.
#
# The "traditional" practice of packing multiple parameters into a
# space-separated string is a well documented source of bugs and security
# problems, so this is (mostly) avoided, by progressively accumulating
# options in "$@", and eventually passing that to Java.
#
# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
# see the in-line comments for details.
#
# There are tweaks for specific operating systems such as AIX, CygWin,
# Darwin, MinGW, and NonStop.
#
# (3) This script is generated from the Groovy template
# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# within the Gradle project.
#
# You can find Gradle at https://github.com/gradle/gradle/.
#
##############################################################################
# Attempt to set APP_HOME
# Resolve links: $0 may be a link
PRG="$0"
# Need this for relative symlinks.
while [ -h "$PRG" ] ; do
ls=`ls -ld "$PRG"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
PRG="$link"
else
PRG=`dirname "$PRG"`"/$link"
fi
app_path=$0
# Need this for daisy-chained symlinks.
while
APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
[ -h "$app_path" ]
do
ls=$( ls -ld "$app_path" )
link=${ls#*' -> '}
case $link in #(
/*) app_path=$link ;; #(
*) app_path=$APP_HOME$link ;;
esac
done
SAVED="`pwd`"
cd "`dirname \"$PRG\"`/" >/dev/null
APP_HOME="`pwd -P`"
cd "$SAVED" >/dev/null
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
APP_NAME="Gradle"
APP_BASE_NAME=`basename "$0"`
APP_BASE_NAME=${0##*/}
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS=""
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum"
MAX_FD=maximum
warn () {
echo "$*"
}
} >&2
die () {
echo
echo "$*"
echo
exit 1
}
} >&2
# OS specific support (must be 'true' or 'false').
cygwin=false
msys=false
darwin=false
nonstop=false
case "`uname`" in
CYGWIN* )
cygwin=true
;;
Darwin* )
darwin=true
;;
MINGW* )
msys=true
;;
NONSTOP* )
nonstop=true
;;
case "$( uname )" in #(
CYGWIN* ) cygwin=true ;; #(
Darwin* ) darwin=true ;; #(
MSYS* | MINGW* ) msys=true ;; #(
NONSTOP* ) nonstop=true ;;
esac
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
# Determine the Java command to use to start the JVM.
if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
# IBM's JDK on AIX uses strange locations for the executables
JAVACMD="$JAVA_HOME/jre/sh/java"
JAVACMD=$JAVA_HOME/jre/sh/java
else
JAVACMD="$JAVA_HOME/bin/java"
JAVACMD=$JAVA_HOME/bin/java
fi
if [ ! -x "$JAVACMD" ] ; then
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
......@@ -81,7 +132,7 @@ Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
else
JAVACMD="java"
JAVACMD=java
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
......@@ -89,84 +140,95 @@ location of your Java installation."
fi
# Increase the maximum file descriptors if we can.
if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
MAX_FD_LIMIT=`ulimit -H -n`
if [ $? -eq 0 ] ; then
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
MAX_FD="$MAX_FD_LIMIT"
fi
ulimit -n $MAX_FD
if [ $? -ne 0 ] ; then
warn "Could not set maximum file descriptor limit: $MAX_FD"
fi
else
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
fi
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
case $MAX_FD in #(
max*)
MAX_FD=$( ulimit -H -n ) ||
warn "Could not query maximum file descriptor limit"
esac
case $MAX_FD in #(
'' | soft) :;; #(
*)
ulimit -n "$MAX_FD" ||
warn "Could not set maximum file descriptor limit to $MAX_FD"
esac
fi
# For Darwin, add options to specify how the application appears in the dock
if $darwin; then
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
fi
# Collect all arguments for the java command, stacking in reverse order:
# * args from the command line
# * the main class name
# * -classpath
# * -D...appname settings
# * --module-path (only if needed)
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
# For Cygwin or MSYS, switch paths to Windows format before running java
if "$cygwin" || "$msys" ; then
APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
JAVACMD=$( cygpath --unix "$JAVACMD" )
# For Cygwin, switch paths to Windows format before running java
if $cygwin ; then
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
JAVACMD=`cygpath --unix "$JAVACMD"`
# We build the pattern for arguments to be converted via cygpath
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
SEP=""
for dir in $ROOTDIRSRAW ; do
ROOTDIRS="$ROOTDIRS$SEP$dir"
SEP="|"
done
OURCYGPATTERN="(^($ROOTDIRS))"
# Add a user-defined pattern to the cygpath arguments
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
fi
# Now convert the arguments - kludge to limit ourselves to /bin/sh
i=0
for arg in "$@" ; do
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
else
eval `echo args$i`="\"$arg\""
for arg do
if
case $arg in #(
-*) false ;; # don't mess with options #(
/?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
[ -e "$t" ] ;; #(
*) false ;;
esac
then
arg=$( cygpath --path --ignore --mixed "$arg" )
fi
i=$((i+1))
# Roll the args list around exactly as many times as the number of
# args, so each arg winds up back in the position where it started, but
# possibly modified.
#
# NB: a `for` loop captures its iteration list before it begins, so
# changing the positional parameters here affects neither the number of
# iterations, nor the values presented in `arg`.
shift # remove old arg
set -- "$@" "$arg" # push replacement arg
done
case $i in
(0) set -- ;;
(1) set -- "$args0" ;;
(2) set -- "$args0" "$args1" ;;
(3) set -- "$args0" "$args1" "$args2" ;;
(4) set -- "$args0" "$args1" "$args2" "$args3" ;;
(5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
(6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
(7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
(8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
(9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
esac
fi
# Escape application args
save () {
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
echo " "
}
APP_ARGS=$(save "$@")
# Collect all arguments for the java command, following the shell quoting and substitution rules
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
cd "$(dirname "$0")"
fi
# Collect all arguments for the java command;
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
# shell script including quotes and variable substitutions, so put them in
# double quotes to make sure that they get re-expanded; and
# * put everything else in single quotes, so that it's not re-expanded.
set -- \
"-Dorg.gradle.appname=$APP_BASE_NAME" \
-classpath "$CLASSPATH" \
org.gradle.wrapper.GradleWrapperMain \
"$@"
# Use "xargs" to parse quoted args.
#
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
#
# In Bash we could simply go:
#
# readarray ARGS < <( xargs -n1 <<<"$var" ) &&
# set -- "${ARGS[@]}" "$@"
#
# but POSIX shell has neither arrays nor command substitution, so instead we
# post-process each arg (as a line of input to sed) to backslash-escape any
# character that might be a shell metacharacter, then use eval to reverse
# that process (while maintaining the separation between arguments), and wrap
# the whole thing up as a single "set" statement.
#
# This will of course break if any of these variables contains a newline or
# an unmatched quote.
#
eval "set -- $(
printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |
xargs -n1 |
sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
tr '\n' ' '
)" '"$@"'
exec "$JAVACMD" "$@"
@rem
@rem Copyright 2015 the original author or authors.
@rem
@rem Licensed under the Apache License, Version 2.0 (the "License");
@rem you may not use this file except in compliance with the License.
@rem You may obtain a copy of the License at
@rem
@rem https://www.apache.org/licenses/LICENSE-2.0
@rem
@rem Unless required by applicable law or agreed to in writing, software
@rem distributed under the License is distributed on an "AS IS" BASIS,
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@rem See the License for the specific language governing permissions and
@rem limitations under the License.
@rem
@if "%DEBUG%" == "" @echo off
@rem ##########################################################################
@rem
......@@ -13,15 +29,18 @@ if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
@rem Resolve any "." and ".." in APP_HOME to make it shorter.
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS=
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto init
if "%ERRORLEVEL%" == "0" goto execute
echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
......@@ -35,7 +54,7 @@ goto fail
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
if exist "%JAVA_EXE%" goto init
if exist "%JAVA_EXE%" goto execute
echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
......@@ -45,28 +64,14 @@ echo location of your Java installation.
goto fail
:init
@rem Get command-line arguments, handling Windows variants
if not "%OS%" == "Windows_NT" goto win9xME_args
:win9xME_args
@rem Slurp the command line arguments.
set CMD_LINE_ARGS=
set _SKIP=2
:win9xME_args_slurp
if "x%~1" == "x" goto execute
set CMD_LINE_ARGS=%*
:execute
@rem Setup the command line
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
:end
@rem End local scope for the variables with windows NT shell
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment