Commit c81470dc by User

added print option

parent d63feb8f
<component name="ProjectCodeStyleConfiguration">
<code_scheme name="Project" version="173">
<JetCodeStyleSettings>
<option name="PACKAGES_TO_USE_STAR_IMPORTS">
<value>
<package name="java.util" alias="false" withSubpackages="false" />
<package name="kotlinx.android.synthetic" alias="false" withSubpackages="true" />
<package name="io.ktor" alias="false" withSubpackages="true" />
</value>
</option>
<option name="PACKAGES_IMPORT_LAYOUT">
<value>
<package name="" alias="false" withSubpackages="true" />
<package name="java" alias="false" withSubpackages="true" />
<package name="javax" alias="false" withSubpackages="true" />
<package name="kotlin" alias="false" withSubpackages="true" />
<package name="" alias="true" withSubpackages="true" />
</value>
</option>
</JetCodeStyleSettings>
<codeStyleSettings language="XML">
<indentOptions>
<option name="CONTINUATION_INDENT_SIZE" value="4" />
......
......@@ -5,7 +5,7 @@
<configuration PROFILE_NAME="Debug" CONFIG_NAME="Debug" />
</configurations>
</component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_7" project-jdk-name="1.8" project-jdk-type="JavaSDK">
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" project-jdk-name="1.8" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/build/classes" />
</component>
<component name="ProjectType">
......
apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
android {
compileSdkVersion 30
......@@ -6,7 +7,7 @@ android {
defaultConfig {
applicationId "w.soulofpluto.posstock"
minSdkVersion 16
minSdkVersion 17
targetSdkVersion 30
versionCode 1
versionName "1.0"
......@@ -17,9 +18,23 @@ android {
buildTypes {
release {
minifyEnabled false
shrinkResources false
zipAlignEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
defaultConfig {
ndk {
abiFilters 'armeabi' //, 'x86', ' 'x86_64', 'arm64-v8a'
}
}
compileOptions {
sourceCompatibility 1.8
targetCompatibility 1.8
}
}
dependencies {
......@@ -36,6 +51,11 @@ dependencies {
implementation 'com.squareup.retrofit2:converter-gson:2.2.0'
implementation 'com.squareup.okhttp3:logging-interceptor:3.8.0'
implementation platform('com.google.firebase:firebase-bom:28.4.0')
implementation 'com.google.firebase:firebase-analytics'
implementation files('libs/ePOS2.jar')
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
......
{
"project_info": {
"project_number": "503097399483",
"project_id": "posstockandsale",
"storage_bucket": "posstockandsale.appspot.com"
},
"client": [
{
"client_info": {
"mobilesdk_app_id": "1:503097399483:android:836d8165b3e50f7be6f19e",
"android_client_info": {
"package_name": "w.soulofpluto.posstock"
}
},
"oauth_client": [
{
"client_id": "503097399483-trqntkot7dvg8sv0eou1n766ug8ikt24.apps.googleusercontent.com",
"client_type": 1,
"android_info": {
"package_name": "w.soulofpluto.posstock",
"certificate_hash": "0c48f6fd7e869b837d0608cb7c2cdbc084c0552b"
}
},
{
"client_id": "503097399483-2fmt335f3lug1ds4a2sjkmqir5onssje.apps.googleusercontent.com",
"client_type": 3
}
],
"api_key": [
{
"current_key": "AIzaSyASvVmZ2XqEbqjJfEZOzIewIgPFrRRvIPM"
}
],
"services": {
"appinvite_service": {
"other_platform_oauth_client": [
{
"client_id": "503097399483-2fmt335f3lug1ds4a2sjkmqir5onssje.apps.googleusercontent.com",
"client_type": 3
}
]
}
}
}
],
"configuration_version": "1"
}
\ No newline at end of file
......@@ -7,6 +7,13 @@
<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"/>
<application
android:allowBackup="true"
......@@ -14,10 +21,16 @@
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_back_round"
android:supportsRtl="true"
android:usesCleartextTraffic="true"
android:requestLegacyExternalStorage="true"
android:theme="@style/AppTheme.NoActionBar"
android:networkSecurityConfig="@xml/network_security_config">
<meta-data
android:name="firebase_crashlytics_collection_enabled"
android:value="true" />
<activity
android:name=".SplashActivity"
android:windowSoftInputMode="adjustNothing"
......@@ -30,10 +43,22 @@
<activity
android:name=".Login"
android:windowSoftInputMode="adjustPan"
android:windowSoftInputMode="adjustResize|stateHidden"
android:screenOrientation="portrait">
</activity>
<activity
android:name=".HomeActivity"
android:windowSoftInputMode="adjustNothing"
android:screenOrientation="portrait"
android:configChanges="keyboardHidden|screenSize">
</activity>
<activity
android:name=".DiscoveryActivity"
android:windowSoftInputMode="adjustNothing"
android:screenOrientation="portrait"
android:configChanges="keyboardHidden|screenSize">
</activity>
<activity
android:name=".DashBoardActivity"
android:windowSoftInputMode="adjustNothing"
android:screenOrientation="portrait"
......@@ -63,6 +88,18 @@
android:screenOrientation="portrait"
android:configChanges="keyboardHidden|screenSize">
</activity>
<activity
android:name=".CreateDeliverySlip"
android:windowSoftInputMode="adjustResize|stateHidden"
android:screenOrientation="portrait"
android:configChanges="keyboardHidden|screenSize">
</activity>
<activity
android:name=".CreateSaleBill"
android:windowSoftInputMode="adjustResize|stateHidden"
android:screenOrientation="portrait"
android:configChanges="keyboardHidden|screenSize">
</activity>
</application>
</manifest>
\ No newline at end of file
package w.soulofpluto.posstock;
/*
Create by Ramesh Babu
*/
public class Barcode {
String barcode, empId;
int qty;
public Barcode(String Barcode, int Qty, String empId){
this.barcode = Barcode;
this.qty = Qty;
this.empId = empId;
}
public String getBarcode() {
return barcode;
}
public void setBarcode(String barcode) {
this.barcode = barcode;
}
public int getQty() {
return qty;
}
public void setQty(int qty) {
this.qty = qty;
}
public String getEmpId() {
return empId;
}
public void setEmpId(String empId) {
this.empId = empId;
}
}
package w.soulofpluto.posstock;
import android.app.Activity;
import android.app.ProgressDialog;
import android.content.Context;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.util.Log;
import android.view.Gravity;
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.io.IOException;
import java.security.MessageDigest;
import java.text.NumberFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.Locale;
/*
Create by Ramesh Babu
*/
public class Constants{
//public static String BASE_URL = "http://182.18.167.139/";
public static String BASE_URL = "http://posapi.plutokm.com/";
//public static String BASE_URL = "https://2bc746.emporter.eu/";
//public static String BASE_URL = "https://68c783.emporter.eu/";
//public static String BASE_URL = "https://e0ca19.emporter.eu/";
public static String BASE_URL = "https://6d70e4.emporter.eu/";
//public static String BASE_URL = "http://posapi.plutokm.com/";
//public static String BASE_URL = "https://7fad42.emporter.eu/";
public static String MenuBar = Constants.BASE_URL + "/Users/generateUserMenuBarLinksForAndroidApp";
public static String Logout = Constants.BASE_URL + "/login/doLogout/";
public static String Login = Constants.BASE_URL + "/login/doLogin";
public static String StoreId = Constants.BASE_URL + "login/getStoresMappedToUser/";
......@@ -34,6 +45,7 @@ public class Constants{
public static String BarcodeComplete = Constants.BASE_URL + "/stockaudit/batchScanningCompleted";
public static String RackWiseQty = Constants.BASE_URL + "/stockaudit/stockAuditPlanBarcodesScannedInformation";
public static String BarcodeSearch = Constants.BASE_URL + "/stockaudit/stockAuditBarcodeRackInformation";
public static String GenerateSlip = Constants.BASE_URL + "/Sales/generateDeliverySlip";
public static String Type = "Content-Type";
public static String App_json = "application/json";
public static MediaType JSON = MediaType.parse("application/json; charset=utf-8");
......@@ -50,8 +62,10 @@ public class Constants{
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 = 7;
public static int Value = 7 ;
public static final String dashed = "------------------------------------------------"+"\n";
public static ProgressDialog progressDialog;
public static StringBuilder stringBuilder;
public static void getToast(Context context, String data){
Toast toast = Toast.makeText(context, data, Toast.LENGTH_SHORT);
......@@ -63,12 +77,46 @@ public class Constants{
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=#F31505><b>Total Items : </b></font>"+"<font color=#000000><b>"+count+"</b></font>";
}
public static String getTotalMRP(String count){
return "<font color=#F31505><b>Total MRP : </b></font>"+"<font color=#000000><b>"+count+"</b></font>";
}
public static String getBarcode(String count){
return "<font color=#6A95A5A6><b>Barcode : </b></font>"+"<font color=#000000><b>"+count+"</b></font>";
}
public static String getCode(String count){
return "<font color=#6A95A5A6><b>Disc Amt : </b></font>"+"<font color=#000000><b>"+count+"</b></font>";
}
public static String getMRP(String count){
return "<font color=#6A95A5A6><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=#6A95A5A6><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=#6A95A5A6><b>NetPayable : </b></font>"+"<font color=#FE3004><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 String IndianRupeesFormat(String amount){
NumberFormat formatter = NumberFormat.getCurrencyInstance(new Locale("en", "in"));
String moneyString = formatter.format(Double.valueOf(amount));
return moneyString;
//return formatter.format(amount);
}
public static void ProgressDialogShow(Context context){
progressDialog = new ProgressDialog(context);
progressDialog.setMessage("Loading Please wait ...");
......@@ -82,6 +130,13 @@ public class Constants{
}
}
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 getSHA256(String data){
StringBuffer sb = new StringBuffer();
try{
......@@ -146,4 +201,455 @@ public class Constants{
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){
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){
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){
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){
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){
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+" ";
}
return null;
}
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+" ";
}
return null;
}
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+" ";
}
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;
}
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){
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+" ";
}
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+" ";
}
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+" ";
}
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;
}
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;
}
return null;
}
public static String IndianRupeesformat(String amount){
NumberFormat formatter = NumberFormat.getCurrencyInstance(new Locale("en", "in"));
String moneyString = formatter.format(Double.valueOf(amount));
return moneyString;
//return formatter.format(amount);
}
public static void hideKeyboard(Activity activity){
InputMethodManager imm = (InputMethodManager) activity.getSystemService(Activity.INPUT_METHOD_SERVICE);
//Find the currently focused view, so we can grab the correct window token from it.
View view = activity.getCurrentFocus();
//If no view currently has focus, create a new one, just so we can grab a window token from it
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 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"+'"'+":"+'"'+'"'+"}");
return stringBuilder.toString();
}
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"+'"'+":"+'"'+'"'+"}");
return stringBuilder.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;
import android.os.Looper;
import android.text.Editable;
import android.text.Html;
import android.text.TextUtils;
import android.text.TextWatcher;
import android.util.Log;
import android.view.KeyEvent;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.Window;
import android.view.inputmethod.EditorInfo;
import android.widget.AdapterView;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.EditText;
import android.widget.ImageView;
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;
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;
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;
/*
Create by Ramesh Babu
*/
public class CreateDeliverySlip extends AppCompatActivity implements AdapterView.OnItemClickListener, ReceiveListener, TextView.OnEditorActionListener {
Toolbar createDeliverySlip_toolbar;
EditText barcode_enter, empId;
List<CreateResponse> arrayList;
LinearLayout header_items;
CheckBox checkBox;
PreferenceManager preferenceManager;
RecyclerView deliveryslip_list;
TextView totalItems, totalMrp, totalDis, totalNetMrp;
ArrayList<Barcode> list;
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;
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);
barcode_enter = findViewById(R.id.barcode_enter);
deliveryslip_list = findViewById(R.id.deliveryslip_list);
totalItems = findViewById(R.id.totalItems);
totalMrp = findViewById(R.id.totalMrp);
totalDis = findViewById(R.id.totalDis);
totalNetMrp = findViewById(R.id.totalNetMrp);
empId = findViewById(R.id.emp_id);
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());
checkBox.setChecked(true);
barcode_enter.requestFocus();
barcode_enter.setOnEditorActionListener(this);
Log.e("Access Token ====> ", preferenceManager.getCustToken());
valid_print.setOnClickListener(view -> {
if(preferenceManager.getBLUETOOTH().length()>0) {
if (list.size() > 0) {
//print = true;
if (Constants.isNetworkAvailable(CreateDeliverySlip.this)) {
Constants.ProgressDialogShow(CreateDeliverySlip.this);
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");
}
});
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);
} else {
Constants.getToast(CreateDeliverySlip.this, getResources().getString(R.string.connection));
}
} else {
Constants.getToast(CreateDeliverySlip.this, "Please Scan Barcode Items");
}
});
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) {
return false;
}
@Override
public void onSwiped(@NonNull RecyclerView.ViewHolder viewHolder, int direction) {
final CreateResponse.Datum deletedCourse = versionList.get(viewHolder.getAdapterPosition());
final int position = viewHolder.getAdapterPosition();
versionList.remove(viewHolder.getAdapterPosition());
deliverySlipAdapter.notifyItemRemoved(viewHolder.getAdapterPosition());
for (Barcode barcode : list) {
if (barcode.getBarcode().equalsIgnoreCase(deletedCourse.getBarcode())) {
list.remove(barcode);
break;
}
}
if(list.size()<1){
header_items.setVisibility(View.GONE);
if(checkBox.isChecked()){
barcode_enter.requestFocus();
}else{
empId.setText("");
empId.requestFocus();
}
}
if (Constants.isNetworkAvailable(CreateDeliverySlip.this)) {
Constants.ProgressDialogShow(CreateDeliverySlip.this);
GenerateDeliverySlip("scan", "", "N",false);
} else {
Constants.getToast(CreateDeliverySlip.this, getResources().getString(R.string.connection));
}
}
}).attachToRecyclerView(deliveryslip_list);
super.onCreate(savedInstanceState);
}
private boolean runPrintReceiptSequence() {
if (!initializeObject()) {
Log.e("initialize Object >>", "runPrintReceipt");
return false;
}
if (!createReceiptData()) {
System.out.println("runPrintReceipt1");
finalizeObject();
return false;
}
if (!printData()) {
finalizeObject();
Log.e("Print Data ====>", "runPrintReceipt2");
return false;
}
return true;
}
private boolean connectPrinter() {
boolean isBeginTransaction = false;
if (mPrinter == null) {
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());
} catch (Exception e) {
ShowMsg.showException(e, "connect", CreateDeliverySlip.this);
return false;
}
try {
mPrinter.beginTransaction();
isBeginTransaction = true;
} catch (Exception e) {
ShowMsg.showException(e, "beginTransaction", CreateDeliverySlip.this);
}
if (isBeginTransaction == false) {
try {
mPrinter.disconnect();
} catch (Epos2Exception e) {
// Do nothing
return false;
}
}
return true;
}
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() {
@Override
public void onFailure(Request request, IOException e) {
Constants.ProgressDialogDismiss();
}
@Override
public void onResponse(Response response) throws IOException {
try {
Constants.ProgressDialogDismiss();
final String res = response.body().string();
if (response.code() == 200) {
Log.e("Dashboard Logout ", res);
JSONObject jsonObject = new JSONObject(res);
if (jsonObject.has("success")) {
if (jsonObject.getInt("success") == 1) {
preferenceManager.setUserId("");
preferenceManager.setLogged(false);
preferenceManager.setCustToken("");
preferenceManager.setStoreId("");
preferenceManager.setBLUETOOTH("");
Login.logout(CreateDeliverySlip.this);
} else if(jsonObject.has("msg")) {
Constants.getToast(CreateDeliverySlip.this, jsonObject.getString("msg"));
}
}
} else {
runOnUiThread(() -> Constants.getToast(CreateDeliverySlip.this, res));
}
} catch (JSONException e) {
e.printStackTrace();
} catch (NullPointerException np) {
np.printStackTrace();
}
}
});
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case android.R.id.home:
finish();
break;
case R.id.dashboard_logout:
if (Constants.isNetworkAvailable(CreateDeliverySlip.this)) {
Logout(Logout + preferenceManager.getUserId());
Constants.ProgressDialogShow(CreateDeliverySlip.this);
} else {
Constants.getToast(CreateDeliverySlip.this, getResources().getString(R.string.connection));
}
try {
Discovery.stop();
break;
} catch (Epos2Exception e1) {
System.out.println("Output =====>" + e1.getMessage());
}
break;
case R.id.dashboard_connection:
bluetoothPair();
break;
case R.id.dashboard_reload:
startActivity(getIntent());
finish();
try {
Discovery.stop();
break;
} catch (Epos2Exception e1) {
System.out.println("Output =====>" + e1.getMessage());
}
break;
}
return super.onOptionsItemSelected(item);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.menu_create, menu);
globalMenuItem = menu;
if (preferenceManager.getBLUETOOTH().length() > 0) {
//System.out.println("connection ====>"+preferenceManager.getBLUETOOTH().length());
globalMenuItem.findItem(R.id.dashboard_connection).setIcon(R.drawable.ic_bluetooth_indicator);
} else {
//System.out.println("connection1 ====>"+preferenceManager.getBLUETOOTH());
globalMenuItem.findItem(R.id.dashboard_connection).setIcon(R.drawable.ic_bluetooth_signal_indicator);
}
return super.onCreateOptionsMenu(menu);
}
private boolean isPrintable(PrinterStatusInfo status) {
if (status == null) {
return false;
}
if (status.getConnection() == Printer.FALSE) {
return false;
} else if (status.getOnline() == Printer.FALSE) {
return false;
} else {
}
return true;
}
private boolean printData() {
if (mPrinter == null) {
return false;
}
if (!connectPrinter()) {
return false;
}
PrinterStatusInfo status = mPrinter.getStatus();
dispPrinterWarnings(status);
if (!isPrintable(status)) {
ShowMsg.showMsg(makeErrorMessage(status), CreateDeliverySlip.this);
try {
mPrinter.disconnect();
} catch (Exception ex) {
// Do nothing
}
return false;
}
try {
mPrinter.sendData(Printer.PARAM_DEFAULT);
} catch (Exception e) {
ShowMsg.showException(e, "sendData", CreateDeliverySlip.this);
try {
mPrinter.disconnect();
} catch (Exception ex) {
// Do nothing
}
return false;
}
return true;
}
private void finalizeObject() {
if (mPrinter == null) {
return;
}
mPrinter.clearCommandBuffer();
mPrinter.setReceiveEventListener(null);
mPrinter = null;
}
void getPrint() {
try {
if (responseobj.has("data")) {
System.out.println("Response Data =============>" + responseobj);
JSONObject dataobj = responseobj.getJSONObject("data");
mPrinter.addTextSize(2, 2);
mPrinter.addTextAlign(Printer.ALIGN_CENTER);
mPrinter.addText(" * ESTIMATION SLIP * " + "\n");
mPrinter.addTextSize(1, 1);
mPrinter.addFeedLine(1);
mPrinter.addTextAlign(Printer.ALIGN_LEFT);
mPrinter.addText("Date : " + dataobj.getString("dsdate") + "\n");
mPrinter.addTextAlign(Printer.ALIGN_LEFT);
mPrinter.addText(Constants.dashed);
if (dataobj.has("ds_lines")) {
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.KITKAT) {
mPrinter.addTextAlign(Printer.ALIGN_LEFT);
mPrinter.addText("SL Barcode Qty MRP Disc Amount " + "\n");
mPrinter.addTextAlign(Printer.ALIGN_LEFT);
mPrinter.addText(Constants.dashed);
JSONObject da = dataobj.getJSONObject("ds_lines");
Iterator<String> keys = da.keys();
while (keys.hasNext()) {
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);
JSONArray bill_data = new JSONArray(da.getString(key));
for (int i = 0; i < bill_data.length(); i++) {
JSONObject bill_object = bill_data.getJSONObject(i);
mPrinter.addTextAlign(Printer.ALIGN_LEFT);
mPrinter.addText(Constants.SL(bill_object.getString("sno")) +
Constants.Barcode(bill_object.getString("barcode"))
+ Constants.Qty(bill_object.getString("qty")) + Constants.Mrp(bill_object.getString("item_rsp"))
+ Constants.Dis(bill_object.getString("qty_disc"))
+ Constants.Total(bill_object.getString("qty_amount_after_discount")));
mPrinter.addTextAlign(Printer.ALIGN_LEFT);
mPrinter.addText(" SM : " + bill_object.getString("sm") + " " + bill_object.getString("section") + "\n");
mPrinter.addText(Constants.dashed);
}
}
}
}
}
mPrinter.addTextAlign(Printer.ALIGN_LEFT);
mPrinter.addText("Gross Amount : " + Constants.Gross(dataobj.getString("total_grossamount")) + "\n");
mPrinter.addText("Total Discount : " + Constants.TotalSavings(dataobj.getString("total_promodisc")) + "\n\n");
mPrinter.addTextAlign(Printer.ALIGN_CENTER);
mPrinter.addTextSize(2, 2);
mPrinter.addText("Total Qty : " + dataobj.getString("total_qty") + "\n");
mPrinter.addText("Net Payable : " + dataobj.getString("total_payable") + "\n");
mPrinter.addTextSize(1, 1);
mPrinter.addFeedLine(1);
mPrinter.addTextAlign(Printer.ALIGN_CENTER);
mPrinter.addText(" Biller : " + dataobj.getString("biller") + "\n");
mPrinter.addFeedLine(1);
mPrinter.addBarcode(dataobj.getString("dsno"),
Printer.BARCODE_CODE39,
Printer.HRI_BELOW,
Printer.FONT_A,
2,
100);
mPrinter.addFeedLine(2);
mPrinter.addTextSize(4, 4);
mPrinter.addTextAlign(Printer.ALIGN_CENTER);
mPrinter.addText(dataobj.getString("dsno_last_number") + "\n\n");
mPrinter.addCut(Printer.CUT_FEED);
mPrinter.addTextSize(1, 1);
mPrinter.addFeedLine(1);
}
} catch (JSONException jo) {
jo.printStackTrace();
} catch (Epos2Exception e) {
e.printStackTrace();
} catch (Exception e) {
System.out.println("Error Message ======>" + e.getMessage());
//ShowMsg.showException(e, method, CreateDeliverySlip.this);
}
}
private boolean createReceiptData() {
String method = "";
StringBuilder textData = new StringBuilder();
Constants.ProgressDialogDismiss();
if (print) {
print = false;
if (mPrinter == null) {
return false;
}
getPrint();
} else {
for (int k = 0; k < 2; k++) {
if (mPrinter == null) {
return false;
}
getPrint();
}
runOnUiThread(() -> {
valid.setVisibility(View.GONE);
valid_print.setVisibility(View.GONE);
arrayList.clear();
list.clear();
deliveryslip_list.setAdapter(null);
totalItems.setText("");
totalNetMrp.setText("");
totalMrp.setText("");
totalDis.setText("");
});
}
mPrinter = null;
return true;
}
private boolean initializeObject() {
try {
mPrinter = new Printer(1, 6, CreateDeliverySlip.this);
} catch (Exception e) {
ShowMsg.showException(e, "Printer", CreateDeliverySlip.this);
Constants.ProgressDialogDismiss();
return false;
}
mPrinter.setReceiveEventListener(this);
return true;
}
private void updateButtonState(boolean state) {
valid.setEnabled(state);
System.out.println("Data State Enables===>" + state);
}
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
try {
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"));
dialog.dismiss();
preferenceManager.setBLUETOOTH(item.get("Target"));
invalidateOptionsMenu();
} catch (NullPointerException np) {
np.printStackTrace();
}
}
private String makeErrorMessage(PrinterStatusInfo status) {
String msg = "";
if (status.getOnline() == Printer.FALSE) {
msg += getString(R.string.handlingmsg_err_offline);
}
if (status.getConnection() == Printer.FALSE) {
msg += getString(R.string.handlingmsg_err_no_response);
}
if (status.getCoverOpen() == Printer.TRUE) {
msg += getString(R.string.handlingmsg_err_cover_open);
}
if (status.getPaper() == Printer.PAPER_EMPTY) {
msg += getString(R.string.handlingmsg_err_receipt_end);
}
if (status.getPaperFeed() == Printer.TRUE || status.getPanelSwitch() == Printer.SWITCH_ON) {
msg += getString(R.string.handlingmsg_err_paper_feed);
}
if (status.getErrorStatus() == Printer.MECHANICAL_ERR || status.getErrorStatus() == Printer.AUTOCUTTER_ERR) {
msg += getString(R.string.handlingmsg_err_autocutter);
msg += getString(R.string.handlingmsg_err_need_recover);
}
if (status.getErrorStatus() == Printer.UNRECOVER_ERR) {
msg += getString(R.string.handlingmsg_err_unrecover);
}
if (status.getErrorStatus() == Printer.AUTORECOVER_ERR) {
if (status.getAutoRecoverError() == Printer.HEAD_OVERHEAT) {
msg += getString(R.string.handlingmsg_err_overheat);
msg += getString(R.string.handlingmsg_err_head);
}
if (status.getAutoRecoverError() == Printer.MOTOR_OVERHEAT) {
msg += getString(R.string.handlingmsg_err_overheat);
msg += getString(R.string.handlingmsg_err_motor);
}
if (status.getAutoRecoverError() == Printer.BATTERY_OVERHEAT) {
msg += getString(R.string.handlingmsg_err_overheat);
msg += getString(R.string.handlingmsg_err_battery);
}
if (status.getAutoRecoverError() == Printer.WRONG_PAPER) {
msg += getString(R.string.handlingmsg_err_wrong_paper);
}
}
if (status.getBatteryLevel() == Printer.BATTERY_LEVEL_0) {
msg += getString(R.string.handlingmsg_err_battery_real_end);
}
return msg;
}
private void disconnectPrinter() {
if (mPrinter == null) {
return;
}
try {
mPrinter.endTransaction();
} catch (final Exception e) {
}
try {
mPrinter.disconnect();
} catch (final Exception e) {
}
finalizeObject();
}
@Override
public void onPtrReceive(Printer printer, final int code, final PrinterStatusInfo printerStatusInfo, String s) {
runOnUiThread(new Runnable() {
@Override
public synchronized void run() {
ShowMsg.showResult(code, makeErrorMessage(printerStatusInfo), CreateDeliverySlip.this);
dispPrinterWarnings(printerStatusInfo);
updateButtonState(true);
new Thread(new Runnable() {
@Override
public void run() {
disconnectPrinter();
}
}).start();
}
});
}
private void dispPrinterWarnings(PrinterStatusInfo status) {
//EditText edtWarnings = (EditText)findViewById(R.id.edtWarnings);
String warningsMsg = "";
if (status == null) {
return;
}
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(CreateDeliverySlip.this, warningsMsg);
}
// edtWarnings.setText(warningsMsg);
}
@Override
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
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 =============>","");
Constants.hideKeyboard(this);
if(Constants.isNetworkAvailable(this)){
GenerateDeliverySlip("scan", barcode_enter.getText().toString().trim(), "N", false);
Constants.ProgressDialogShow(CreateDeliverySlip.this);
}else {
Constants.getToast(CreateDeliverySlip.this,"Please check internet connection");
}
}
}
}
return false;
}
public class Checked implements TextWatcher {
@Override
public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {
}
@Override
public void onTextChanged(CharSequence val, int i, int i1, int i2) {
try {
if (val.toString().length() > 0) {
if (val.toString().contains("\n")) {
if (Constants.isNetworkAvailable(CreateDeliverySlip.this)) {
Constants.ProgressDialogShow(CreateDeliverySlip.this);
GenerateDeliverySlip("scan", val.toString().trim(), "N",false);
} else {
Constants.getToast(CreateDeliverySlip.this, getResources().getString(R.string.connection));
}
}
}
} catch (NullPointerException np) {
np.printStackTrace();
}
}
@Override
public void afterTextChanged(Editable editable) {
}
}
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);
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);
jsonArray.put(jsonObject);
}
}
Log.e("Test", trim);
if (trim.length() > 0) {
jsonObject = new JSONObject();
jsonObject.put(getResources().getString(R.string.barcode_name), trim);
jsonObject.put(getResources().getString(R.string.qty_name), 1);
jsonObject.put(getResources().getString(R.string.empid), empId.getText().toString());
jsonArray.put(jsonObject);
}
if (list.size() > 0 || trim.length() > 0) {
object.put(getResources().getString(R.string.items), jsonArray);
//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);
client.setWriteTimeout(250, TimeUnit.SECONDS);
Request request = new Request.Builder()
.url(Constants.GenerateSlip)
.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(CreateDeliverySlip.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("Barcode Search", Response);
Handler handler = new Handler(Looper.getMainLooper());
handler.post(() -> {
try {
if(response.code() == 200){
responseobj = new JSONObject(Response);
if(responseobj.getInt("success") == 1){
if(scan.equalsIgnoreCase("save")){
valid_print.setVisibility(View.GONE);
valid.setVisibility(View.VISIBLE);
header_items.setVisibility(View.GONE);
if(responseobj.has("data")){
updateButtonState(false);
if (!runPrintReceiptSequence()) {
updateButtonState(true);
}
}
}else if(var){
header_items.setVisibility(View.VISIBLE);
valid_print.setVisibility(View.VISIBLE);
valid.setVisibility(View.GONE);
if (responseobj.has("data")) {
if (barcode_enter.getText().toString().length() > 0)
list.add(new Barcode(barcode_enter.getText().toString().trim(), 1, empId.getText().toString()));
barcode_enter.setText("");
barcode_enter.requestFocus();
versionList = new Gson().fromJson(String.valueOf(responseobj.getJSONArray(getResources().getString(R.string.data))),
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));
deliverySlipAdapter = new DeliverySlipAdapter(CreateDeliverySlip.this, versionList);
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.netpayable))))));
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)));
} else {
valid_print.setVisibility(View.GONE);
valid.setVisibility(View.VISIBLE);
header_items.setVisibility(View.VISIBLE);
//List<CreateResponse> versionList = new Gson().fromJson(Response, new TypeToken<List<CreateResponse>>() {}.getType());
if (responseobj.has("data")) {
if (barcode_enter.getText().toString().length() > 0)
list.add(new Barcode(barcode_enter.getText().toString().trim(), 1, empId.getText().toString()));
barcode_enter.setText("");
barcode_enter.requestFocus();
versionList = new Gson().fromJson(String.valueOf(responseobj.getJSONArray(getResources().getString(R.string.data))),
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));
deliverySlipAdapter = new DeliverySlipAdapter(CreateDeliverySlip.this, versionList);
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.netpayable))))));
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)));
}
} else if (responseobj.getInt("success") == 3) {
runOnUiThread(() -> {
try {
Constants.getToast(CreateDeliverySlip.this, responseobj.getString(getResources().getString(R.string.msg)));
Login.logout(CreateDeliverySlip.this);
} catch (JSONException e) {
e.printStackTrace();
}
});
} else if (responseobj.has(getResources().getString(R.string.msg))) {
runOnUiThread(() -> {
try {
Constants.getToast(CreateDeliverySlip.this, responseobj.getString(getResources().getString(R.string.msg)));
//barcode_enter.setText("");
barcode_enter.requestFocus();
} catch (JSONException e) {
e.printStackTrace();
}
});
}
}else {
runOnUiThread(() -> Constants.getToast(CreateDeliverySlip.this,Response));
}
} catch (JSONException e) {
e.printStackTrace();
}
});
} catch (NullPointerException io) {
io.printStackTrace();
} finally {
response.body().close();
}
}
});
} else {
Constants.ProgressDialogDismiss();
Constants.getToast(CreateDeliverySlip.this, "No Barcode Scanned Items");
totalItems.setText("");
totalMrp.setText("");
valid.setVisibility(View.GONE);
}
}
} catch (JSONException e) {
e.printStackTrace();
}catch (NullPointerException npe){
npe.printStackTrace();
}
}
private void bluetoothPair() {
dialog = new Dialog(this);
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
dialog.setContentView(R.layout.print_dialog);
dialog.getWindow().setLayout(LinearLayout.LayoutParams.FILL_PARENT, LinearLayout.LayoutParams.FILL_PARENT);
dialog.show();
bluetooth_list = dialog.findViewById(R.id.bluetooth_list);
ImageView refresh_bluetooth = dialog.findViewById(R.id.refresh_bluetooth);
mPrinterList = new ArrayList<HashMap<String, String>>();
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) {
Discovery.stop();
initial = false;
Discovery.start(this, mFilterOption, mDiscoveryListener);
// Constants.ProgressDialogShow(this);
} else {
try {
Discovery.start(this, mFilterOption, mDiscoveryListener);
Constants.ProgressDialogShow(this);
} catch (Exception e) {
//Log.e("Exception =======>",e.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;
}
} finally {
}
refresh_bluetooth.setOnClickListener(v -> restartDiscovery());
}
private void restartDiscovery() {
while (true) {
try {
Discovery.stop();
break;
} catch (Epos2Exception e) {
if (e.getErrorStatus() != Epos2Exception.ERR_PROCESSING) {
ShowMsg.showException(e, "stop", CreateDeliverySlip.this);
return;
}
}
}
mPrinterList.clear();
mPrinterListAdapter.notifyDataSetChanged();
try {
Discovery.start(this, mFilterOption, mDiscoveryListener);
Constants.ProgressDialogShow(this);
} catch (Exception e) {
ShowMsg.showException(e, "stop", CreateDeliverySlip.this);
}
}
private DiscoveryListener mDiscoveryListener = deviceInfo -> runOnUiThread(new Runnable() {
@Override
public synchronized void run() {
initial = true;
HashMap<String, String> item = new HashMap<>();
item.put("PrinterName", deviceInfo.getDeviceName());
item.put("Target", deviceInfo.getTarget());
mPrinterList.add(item);
mPrinterListAdapter.notifyDataSetChanged();
Constants.ProgressDialogDismiss();
}
});
}
package w.soulofpluto.posstock;
import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;
import java.util.List;
/*
Create by Ramesh Babu
*/
public class CreateResponse {
@SerializedName("success")
@Expose
private Integer success;
@SerializedName("data")
@Expose
private List<Datum> data = null;
@SerializedName("promo_suggestions")
@Expose
private List<Object> promoSuggestions = null;
@SerializedName("total_qty")
@Expose
private Integer totalQty;
@SerializedName("net_payable")
@Expose
private Integer netPayable;
@SerializedName("last_scanned_barcode")
@Expose
private String lastScannedBarcode;
@SerializedName("barcode_images")
@Expose
private List<Object> barcodeImages = null;
@SerializedName("transaction_start_time")
@Expose
private String transactionStartTime;
@SerializedName("transaction_start_microtime")
@Expose
private Long transactionStartMicrotime;
public Integer getSuccess() {
return success;
}
public void setSuccess(Integer success) {
this.success = success;
}
public List<Datum> getData() {
return data;
}
public void setData(List<Datum> data) {
this.data = data;
}
public List<Object> getPromoSuggestions() {
return promoSuggestions;
}
public void setPromoSuggestions(List<Object> promoSuggestions) {
this.promoSuggestions = promoSuggestions;
}
public Integer getTotalQty() {
return totalQty;
}
public void setTotalQty(Integer totalQty) {
this.totalQty = totalQty;
}
public Integer getNetPayable() {
return netPayable;
}
public void setNetPayable(Integer netPayable) {
this.netPayable = netPayable;
}
public String getLastScannedBarcode() {
return lastScannedBarcode;
}
public void setLastScannedBarcode(String lastScannedBarcode) {
this.lastScannedBarcode = lastScannedBarcode;
}
public List<Object> getBarcodeImages() {
return barcodeImages;
}
public void setBarcodeImages(List<Object> barcodeImages) {
this.barcodeImages = barcodeImages;
}
public String getTransactionStartTime() {
return transactionStartTime;
}
public void setTransactionStartTime(String transactionStartTime) {
this.transactionStartTime = transactionStartTime;
}
public Long getTransactionStartMicrotime() {
return transactionStartMicrotime;
}
public void setTransactionStartMicrotime(Long transactionStartMicrotime) {
this.transactionStartMicrotime = transactionStartMicrotime;
}
public class Datum {
@SerializedName("barcode")
@Expose
private String barcode;
@SerializedName("emp_id")
@Expose
private String empId;
@SerializedName("quantity")
@Expose
private Integer quantity;
@SerializedName("promo_disc")
@Expose
private Integer promoDisc;
@SerializedName("item_rsp")
@Expose
private String itemRsp;
@SerializedName("net_payable")
@Expose
private Integer netPayable;
@SerializedName("issis")
@Expose
private Integer issis;
@SerializedName("uom")
@Expose
private String uom;
@SerializedName("emp_name")
@Expose
private String empName;
@SerializedName("item_level_promo_name")
@Expose
private String itemLevelPromoName;
@SerializedName("bill_level_promo_name")
@Expose
private String billLevelPromoName;
@SerializedName("discount_code")
@Expose
private String discountCode;
@SerializedName("promo_suggested")
@Expose
private String promoSuggested;
@SerializedName("suggested_promo_id")
@Expose
private Integer suggestedPromoId;
@SerializedName("color_code")
@Expose
private String colorCode;
public String getBarcode() {
return barcode;
}
public void setBarcode(String barcode) {
this.barcode = barcode;
}
public String getEmpId() {
return empId;
}
public void setEmpId(String empId) {
this.empId = empId;
}
public Integer getQuantity() {
return quantity;
}
public void setQuantity(Integer quantity) {
this.quantity = quantity;
}
public Integer getPromoDisc() {
return promoDisc;
}
public void setPromoDisc(Integer promoDisc) {
this.promoDisc = promoDisc;
}
public String getItemRsp() {
return itemRsp;
}
public void setItemRsp(String itemRsp) {
this.itemRsp = itemRsp;
}
public Integer getNetPayable() {
return netPayable;
}
public void setNetPayable(Integer netPayable) {
this.netPayable = netPayable;
}
public Integer getIssis() {
return issis;
}
public void setIssis(Integer issis) {
this.issis = issis;
}
public String getUom() {
return uom;
}
public void setUom(String uom) {
this.uom = uom;
}
public String getEmpName() {
return empName;
}
public void setEmpName(String empName) {
this.empName = empName;
}
public String getItemLevelPromoName() {
return itemLevelPromoName;
}
public void setItemLevelPromoName(String itemLevelPromoName) {
this.itemLevelPromoName = itemLevelPromoName;
}
public String getBillLevelPromoName() {
return billLevelPromoName;
}
public void setBillLevelPromoName(String billLevelPromoName) {
this.billLevelPromoName = billLevelPromoName;
}
public String getDiscountCode() {
return discountCode;
}
public void setDiscountCode(String discountCode) {
this.discountCode = discountCode;
}
public String getPromoSuggested() {
return promoSuggested;
}
public void setPromoSuggested(String promoSuggested) {
this.promoSuggested = promoSuggested;
}
public Integer getSuggestedPromoId() {
return suggestedPromoId;
}
public void setSuggestedPromoId(Integer suggestedPromoId) {
this.suggestedPromoId = suggestedPromoId;
}
public String getColorCode() {
return colorCode;
}
public void setColorCode(String colorCode) {
this.colorCode = colorCode;
}
}
}
\ No newline at end of file
package w.soulofpluto.posstock;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import androidx.recyclerview.widget.RecyclerView;
import java.util.ArrayList;
/*
Create by Ramesh Babu
*/
public class CreateSaleAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>{
private Context context;
private ArrayList<Model> List;
public CreateSaleAdapter(Context context, ArrayList<Model> list){
this.context = context;
this.List = list;
}
@Override
public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup viewGroup, int i){
LayoutInflater layoutInflater = LayoutInflater.from(viewGroup.getContext());
View listItem = layoutInflater.inflate(R.layout.custom_list_item, viewGroup, false);
CreateSaleAdapter.ViewHolder viewHolder = new CreateSaleAdapter.ViewHolder(listItem);
return viewHolder;
}
@Override
public void onBindViewHolder(final RecyclerView.ViewHolder viewHolder, final int position){
final Model model = List.get(position);
((ViewHolder)viewHolder).Id.setText(model.getDelivery_slip_id());
((ViewHolder)viewHolder).remove.setOnClickListener(new View.OnClickListener(){
@Override
public void onClick(View v){
List.remove(position);
notifyDataSetChanged();
((CreateSaleBill)context).SetData(model.getDelivery_slip_id());
}
});
}
@Override
public int getItemCount(){
return List.size();
}
public class ViewHolder extends RecyclerView.ViewHolder{
private TextView Id;
private ImageView remove;
public ViewHolder(View itemView){
super(itemView);
this.Id = itemView.findViewById(R.id.Id);
this.remove = itemView.findViewById(R.id.remove);
}
}
}
package w.soulofpluto.posstock;
import android.Manifest;
import android.app.Dialog;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.Build;
import android.os.Bundle;
import android.text.Editable;
import android.text.TextUtils;
import android.text.TextWatcher;
import android.util.Log;
import android.view.KeyEvent;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.Window;
import android.view.inputmethod.EditorInfo;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.SimpleAdapter;
import android.widget.Spinner;
import android.widget.TextView;
import android.widget.Toast;
import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;
import androidx.core.app.ActivityCompat;
import androidx.core.content.ContextCompat;
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.squareup.okhttp.RequestBody;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import static w.soulofpluto.posstock.Constants.DeliveryslipAmt;
import static w.soulofpluto.posstock.Constants.DeliveryslipQty;
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;
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 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;
@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);
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);
//last_four_digits = findViewById(R.id.last_four_digits);
generate_invoice = findViewById(R.id.generate_invoice);
//bank_details = findViewById(R.id.bank_details);
preferenceManager = new PreferenceManager(this);
store_location.setText(preferenceManager.getStoreName());
//pluto_pay.setOnClickListener(this);
pluto_Print.setOnClickListener(this);
generate_invoice.setOnClickListener(this);
send.setOnClickListener(this);
setSupportActionBar(main_toolbar);
getSupportActionBar().setTitle(" Create Sale Bill ");
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
builder = new StringBuilder();
//build = new StringBuilder();
datalist = new ArrayList<>();
requestRuntimePermission();
mContext = this;
dataPresenter = new DataPresenter(this,(DataInterface)this);
ds_Number.setOnEditorActionListener(this);
cust_number.addTextChangedListener(new AutoChecked());
}
class AutoChecked implements TextWatcher {
public void afterTextChanged(Editable s){
try{
if(s.toString().length() == 10){
cust_name.requestFocus();
JSONObject object = new JSONObject();
try {
object.put("customer_phone",s.toString());
} catch (JSONException e) {
e.printStackTrace();
}
RequestBody body = RequestBody.create(JSON,object.toString());
dataPresenter.CustomerName(Constants.BASE_URL+"/Customers/getCustomerByPhoneNumber",body);
}
}catch(NumberFormatException nfe){
nfe.printStackTrace();
}
}
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
}
public void onTextChanged(CharSequence s, int start, int before, int count) {
}
}
@Override
protected void onResume(){
super.onResume();
}
private void requestRuntimePermission() {
if(Build.VERSION.SDK_INT < Build.VERSION_CODES.M){
return;
}
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(permissionLocation == PackageManager.PERMISSION_DENIED) {
requestPermissions.add(Manifest.permission.ACCESS_COARSE_LOCATION);
}
if(!requestPermissions.isEmpty()) {
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){
return;
}
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.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 (data.getDelivery_slip_id().equalsIgnoreCase(Id)) {
datalist.remove(i);
} else {
if (Id != "") {
if (build.toString().length() > 0) {
arrayList.add(data.getDelivery_slip_id());
build.append(Constants.PrintData(data.getDelivery_slip_id()));
} else {
arrayList.add(data.getDelivery_slip_id());
build.append(Constants.PrintData1(data.getDelivery_slip_id()));
}
}
}
}
if (Id != "") {
if (build.toString().length() > 0) {
build.append(Constants.PrintData(Id)).toString();
} else {
build.append(Constants.PrintData1(Id)).toString();
}
Log.e("Array List Data ====>" , Id);
Log.e("Array List Data1 ===>" , String.valueOf(arrayList));
}
} else {
if (Id != "") {
if (build.toString().length() > 0) {
build.append(Constants.PrintData(Id)).toString();
} else {
build.append(Constants.PrintData1(Id)).toString();
}
Log.e("Array List Data ====>" , Id);
Log.e("Array List Data1 ===>" , String.valueOf(arrayList));
//Collections.sort(arrayList);
} else {
layout.setVisibility(View.GONE);
Constants.getToast(this, "No data");
//Constants.ProgressDialogDismiss();
}
}
Log.e("Formation Data ===========>" , Constants.formdata(build.toString(), cust_name.getText().toString(), cust_number.getText().toString()));
RequestBody body = RequestBody.create(JSON, Constants.formdata(build.toString(), cust_name.getText().toString(), cust_number.getText().toString()));
if(Constants.isNetworkAvailable(this)) {
dataPresenter.SendDeliverySlipNumber(Constants.BASE_URL + "/Sales/pre_sale_check", body,Id);
Constants.ProgressDialogShow(CreateSaleBill.this);
}else{
Constants.getToast(CreateSaleBill.this,"Please check your internet connection");
}
}
private void SetData(ArrayList<Model> dList){
CreateSaleAdapter benifitsAdapter = new CreateSaleAdapter(CreateSaleBill.this, dList);
ds_list.setLayoutManager(new LinearLayoutManager(this));
ds_list.setAdapter(benifitsAdapter);
}
public void SetData(String Id){
//System.out.println("Data =====>" + Id);
//System.out.println("Before =====>" + datalist.size());
for(int i = 0; i < datalist.size(); i++)
Log.e("Before After =====>" , String.valueOf(datalist.size()));
Remove();
}
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 (build.toString().length() > 0) {
build.append(Constants.PrintData(data.getDelivery_slip_id())).toString();
} else {
build.append(Constants.PrintData1(data.getDelivery_slip_id())).toString();
}
}
RequestBody body = RequestBody.create(JSON, Constants.formdata(build.toString(), cust_name.getText().toString(), cust_number.getText().toString()));
if(Constants.isNetworkAvailable(CreateSaleBill.this)) {
dataPresenter.SendDeliverySlipNumberremove(Constants.BASE_URL + "/Sales/pre_sale_check", body);
Constants.ProgressDialogShow(CreateSaleBill.this);
}else{
Constants.getToast(CreateSaleBill.this,"Please check your internet connection");
}
} else {
//Constants.ProgressDialogDismiss();
layout.setVisibility(View.GONE);
Constants.getToast(this, "No data");
}
}
@Override
public boolean onCreateOptionsMenu(Menu menu){
getMenuInflater().inflate(R.menu.menu_create, menu);
globalMenuItem = menu;
if(preferenceManager.getBLUETOOTH().length()>0){
//System.out.println("connection ====>"+preferenceManager.getBLUETOOTH().length());
globalMenuItem.findItem(R.id.dashboard_connection).setIcon(R.drawable.ic_bluetooth_indicator);
}else{
//System.out.println("connection1 ====>"+preferenceManager.getBLUETOOTH());
globalMenuItem.findItem(R.id.dashboard_connection).setIcon(R.drawable.ic_bluetooth_signal_indicator);
}
return super.onCreateOptionsMenu(menu);
}
@Override
public void onBackPressed(){
super.onBackPressed();
}
@Override
public boolean onOptionsItemSelected(MenuItem item){
switch(item.getItemId()){
case android.R.id.home:
finish();
break;
case R.id.dashboard_logout:
Logout(preferenceManager.getUserId());
try {
Discovery.stop();
break;
}catch (Epos2Exception e1){
Log.e("Output =====>",e1.getMessage());
}
break;
case R.id.dashboard_connection:
bluetoothpair();
break;
case R.id.dashboard_reload:
startActivity(getIntent());
finish();
try {
Discovery.stop();
break;
}catch (Epos2Exception e1){
//Log.e("Output =====>",e1.getMessage());
}
break;
}
return super.onOptionsItemSelected(item);
}
private void bluetoothpair(){
dialog = new Dialog(this);
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
dialog.setContentView(R.layout.print_dialog);
dialog.getWindow().setLayout(LinearLayout.LayoutParams.FILL_PARENT, LinearLayout.LayoutParams.FILL_PARENT);
dialog.show();
bluetooth_list = dialog.findViewById(R.id.bluetooth_list);
ImageView refresh_bluetooth = dialog.findViewById(R.id.refresh_bluetooth);
mPrinterList = new ArrayList<HashMap<String,String>>();
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{
//Constants.ProgressDialogDismiss();
//18072
if(initial) {
Discovery.stop();
initial = false;
Discovery.start(this, mFilterOption, mDiscoveryListener);
Constants.ProgressDialogShow(this);
}else{
Discovery.start(this, mFilterOption, mDiscoveryListener);
Constants.ProgressDialogShow(this);
}
}catch(Epos2Exception e){
try {
Discovery.start(this, mFilterOption, mDiscoveryListener);
Constants.ProgressDialogShow(this);
}catch (Epos2Exception e1){
e1.getMessage();
}
if (e.getErrorStatus() != Epos2Exception.ERR_PROCESSING){
ShowMsg.showException(e, "stop", mContext);
return;
}
}finally {
}
refresh_bluetooth.setOnClickListener(v -> restartDiscovery());
}
private void restartDiscovery(){
while (true) {
try {
//Constants.ProgressDialogDismiss();
Discovery.stop();
break;
}
catch (Epos2Exception e) {
if (e.getErrorStatus() != Epos2Exception.ERR_PROCESSING) {
ShowMsg.showException(e, "stop", mContext);
return;
}
}
}
mPrinterList.clear();
mPrinterListAdapter.notifyDataSetChanged();
try {
Discovery.start(this, mFilterOption, mDiscoveryListener);
Constants.ProgressDialogShow(this);
}
catch (Exception e) {
ShowMsg.showException(e, "stop", mContext);
}
}
private DiscoveryListener mDiscoveryListener = deviceInfo -> runOnUiThread(new Runnable(){
@Override
public synchronized void run(){
initial = true;
HashMap<String, String> item = new HashMap<String, String>();
item.put("PrinterName", deviceInfo.getDeviceName());
item.put("Target", deviceInfo.getTarget());
mPrinterList.add(item);
mPrinterListAdapter.notifyDataSetChanged();
Constants.ProgressDialogDismiss();
}
});
private void Logout(String Id){
if(Constants.isNetworkAvailable(CreateSaleBill.this)){
dataPresenter.Logout(Constants.BASE_URL + "/login/doLogout/" + Id);
Constants.ProgressDialogShow(CreateSaleBill.this);
}else{
Constants.getToast(CreateSaleBill.this,"Please check your internet connection");
}
}
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
try {
Intent intent = new Intent();
HashMap<String, String> item = mPrinterList.get(position);
intent.putExtra(getString(R.string.title_target), item.get("Target"));
dialog.dismiss();
preferenceManager.setBLUETOOTH(item.get("Target"));
invalidateOptionsMenu();
}catch (NullPointerException np){
np.printStackTrace();
}
}
@Override
public void onClick(View v) {
switch (v.getId()) {
case R.id.pluto_Print:
print = true;
updateButtonState(false);
if(!runPrintReceiptSequence()){
updateButtonState(true);
}
break;
case R.id.generate_invoice:
if(preferenceManager.getBLUETOOTH().length()>0) {
bankdialog = new Dialog(this);
bankdialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
bankdialog.setCancelable(false);
bankdialog.setContentView(R.layout.dialog);
final Spinner bank_names = bankdialog.findViewById(R.id.bank_names);
last_four_digits = bankdialog.findViewById(R.id.last_four_digits);
last_four_digits.setOnEditorActionListener(this);
Button bank_submit = bankdialog.findViewById(R.id.bank_submit);
ImageView dialog_close = bankdialog.findViewById(R.id.dialog_close);
final ArrayList<String> arrayList = new ArrayList<>();
arrayList.add("Select Bank");
arrayList.add("Canara Bank");
arrayList.add("State Bank of India");
arrayList.add("Lakshmi Vilas Bank");
final ArrayList<Integer> arrayList1 = new ArrayList<>();
arrayList1.add(0);
arrayList1.add(6);
arrayList1.add(3);
arrayList1.add(4);
ArrayAdapter<String> adapter = new ArrayAdapter<>(this, android.R.layout.simple_list_item_1, arrayList);
bank_names.setAdapter(adapter);
bank_names.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
BankName = arrayList.get(position);
BankId = arrayList1.get(position);
}
@Override
public void onNothingSelected(AdapterView<?> parent) {
}
});
dialog_close.setOnClickListener(v1 -> bankdialog.dismiss());
bank_submit.setOnClickListener(v12 -> {
if (BankName.equalsIgnoreCase("Select Bank") && last_four_digits.getText().toString().length() == 0) {
Constants.getToast(CreateSaleBill.this, "Please Select Bank and Enter last four digits");
} else if (BankName.equalsIgnoreCase("Select Bank")) {
Constants.getToast(CreateSaleBill.this, "Please Select Bank ");
} else if (last_four_digits.getText().toString().length() == 0) {
Constants.getToast(CreateSaleBill.this, "Enter last four digits");
} else if (last_four_digits.getText().toString().length() == 4) {
//dialog.dismiss();
if (Constants.isNetworkAvailable(CreateSaleBill.this)) {
Constants.hideSoftKeyBoardOnTabClicked(v12, CreateSaleBill.this);
PrintData(last_four_digits.getText().toString(), BankId);
//Constants.ProgreesDialogShow(CreateSaleBill.this);
}else{
Constants.getToast(CreateSaleBill.this,"Please check your internet connection");
}
}
});
bankdialog.show();
}else{
Constants.getToast(this,"Please Pair Bluetooth Printer");
}
break;
case R.id.send:
if (TextUtils.isEmpty(ds_Number.getText().toString())) {
Constants.getToast(CreateSaleBill.this, "Enter Delivery Slip Id");
} else {
if(preferenceManager.getBLUETOOTH().length()>0){
DsData(preferenceManager.getPrefix() + ds_Number.getText().toString());
Constants.hideKeyboard(this);
}else{
Constants.getToast(CreateSaleBill.this,"Please Connect Bluetooth Printer");
}
}
break;
}
}
private boolean runPrintReceiptSequence(){
if (!initializeObject()) {
Log.e("runPrintReceipt","");
return false;
}
if (!createReceiptData()) {
Log.e("runPrintReceipt1","");
finalizeObject();
return false;
}
if (!printData()) {
finalizeObject();
Log.e("runPrintReceipt2","");
return false;
}
return true;
}
private void finalizeObject(){
if (mPrinter == null) {
return;
}
mPrinter.clearCommandBuffer();
mPrinter.setReceiveEventListener(null);
mPrinter = null;
}
@Override
public void onPtrReceive(final Printer printerObj, final int code, final PrinterStatusInfo status, final String printJobId) {
runOnUiThread(new Runnable() {
@Override
public synchronized void run() {
ShowMsg.showResult(code, makeErrorMessage(status), mContext);
dispPrinterWarnings(status);
updateButtonState(true);
new Thread(new Runnable() {
@Override
public void run() {
disconnectPrinter();
}
}).start();
}
});
}
private String makeErrorMessage(PrinterStatusInfo status){
String msg = "";
if (status.getOnline() == Printer.FALSE){
msg += getString(R.string.handlingmsg_err_offline);
}
if (status.getConnection() == Printer.FALSE){
msg += getString(R.string.handlingmsg_err_no_response);
}
if (status.getCoverOpen() == Printer.TRUE){
msg += getString(R.string.handlingmsg_err_cover_open);
}
if (status.getPaper() == Printer.PAPER_EMPTY){
msg += getString(R.string.handlingmsg_err_receipt_end);
}
if (status.getPaperFeed() == Printer.TRUE || status.getPanelSwitch() == Printer.SWITCH_ON){
msg += getString(R.string.handlingmsg_err_paper_feed);
}
if (status.getErrorStatus() == Printer.MECHANICAL_ERR || status.getErrorStatus() == Printer.AUTOCUTTER_ERR){
msg += getString(R.string.handlingmsg_err_autocutter);
msg += getString(R.string.handlingmsg_err_need_recover);
}
if (status.getErrorStatus() == Printer.UNRECOVER_ERR){
msg += getString(R.string.handlingmsg_err_unrecover);
}
if (status.getErrorStatus() == Printer.AUTORECOVER_ERR){
if (status.getAutoRecoverError() == Printer.HEAD_OVERHEAT) {
msg += getString(R.string.handlingmsg_err_overheat);
msg += getString(R.string.handlingmsg_err_head);
}
if (status.getAutoRecoverError() == Printer.MOTOR_OVERHEAT){
msg += getString(R.string.handlingmsg_err_overheat);
msg += getString(R.string.handlingmsg_err_motor);
}
if (status.getAutoRecoverError() == Printer.BATTERY_OVERHEAT){
msg += getString(R.string.handlingmsg_err_overheat);
msg += getString(R.string.handlingmsg_err_battery);
}
if (status.getAutoRecoverError() == Printer.WRONG_PAPER){
msg += getString(R.string.handlingmsg_err_wrong_paper);
}
}
if (status.getBatteryLevel() == Printer.BATTERY_LEVEL_0){
msg += getString(R.string.handlingmsg_err_battery_real_end);
}
return msg;
}
private boolean printData(){
if(mPrinter == null){
return false;
}
if (!connectPrinter()) {
return false;
}
PrinterStatusInfo status = mPrinter.getStatus();
dispPrinterWarnings(status);
if (!isPrintable(status)) {
ShowMsg.showMsg(makeErrorMessage(status), mContext);
try {
mPrinter.disconnect();
}
catch (Exception ex) {
// Do nothing
}
return false;
}
try {
mPrinter.sendData(Printer.PARAM_DEFAULT);
}
catch (Exception e) {
ShowMsg.showException(e, "sendData", mContext);
try {
mPrinter.disconnect();
}
catch (Exception ex) {
// Do nothing
}
return false;
}
return true;
}
private void dispPrinterWarnings(PrinterStatusInfo status) {
//EditText edtWarnings = (EditText)findViewById(R.id.edtWarnings);
String warningsMsg = "";
if (status == null) {
return;
}
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()));
// edtWarnings.setText(warningsMsg);
}
private boolean isPrintable(PrinterStatusInfo status) {
if (status == null) {
return false;
}
if (status.getConnection() == Printer.FALSE) {
return false;
}
else if (status.getOnline() == Printer.FALSE) {
return false;
}
else {
}
return true;
}
private void disconnectPrinter() {
if (mPrinter == null) {
return;
}
try {
mPrinter.endTransaction();
}
catch (final Exception e) {
}
try {
mPrinter.disconnect();
}
catch (final Exception e) {
}
finalizeObject();
}
private boolean connectPrinter() {
boolean isBeginTransaction = false;
if (mPrinter == null) {
return false;
}
try {
//System.out.println("Checking Printer ======>"+com.epson.epos2.printer.Printer.PARAM_DEFAULT);
mPrinter.connect(preferenceManager.getBLUETOOTH(), 30000);
//Log.e("Shared Preferences Bluetooth ========>",preferenceManager.getBLUETOOTH());
}
catch (Exception e) {
ShowMsg.showException(e, "connect", mContext);
return false;
}
try {
mPrinter.beginTransaction();
isBeginTransaction = true;
}
catch (Exception e) {
ShowMsg.showException(e, "beginTransaction", mContext);
}
if (isBeginTransaction == false) {
try {
mPrinter.disconnect();
}
catch (Epos2Exception e) {
// Do nothing
return false;
}
}
return true;
}
private boolean initializeObject(){
try{
mPrinter = new Printer(1,6,mContext);
}
catch (Exception e) {
ShowMsg.showException(e, "Printer", mContext);
Constants.ProgressDialogDismiss();
return false;
}
mPrinter.setReceiveEventListener(this);
return true;
}
private void updateButtonState(boolean state) {
pluto_Print.setEnabled(state);
Log.e("Data State Enables===>", String.valueOf(state));
}
private boolean createReceiptData(){
String method = "";
StringBuilder textData = new StringBuilder();
Constants.ProgressDialogDismiss();
if(print){
print = false;
try {
if (mPrinter == null) {
return false;
}
if (responseobj.has("data")) {
Log.e("Response Data =============>" , String.valueOf(responseobj));
JSONObject dataobj = responseobj.getJSONObject("data");
JSONObject dataobject = dataobj.getJSONObject("invoice_data");
if (dataobject.has("website")) {
if (dataobject.getString("website").equalsIgnoreCase("www.kanchivml.com")) {
try {
Bitmap vml = BitmapFactory.decodeResource(getResources(), R.drawable.vara);
method = "addTextAlign";
mPrinter.addTextAlign(Printer.ALIGN_CENTER);
method = "addImage";
mPrinter.addImage(vml, 0, 0,
vml.getWidth(),
vml.getHeight(),
Printer.COLOR_1,
Printer.MODE_MONO,
Printer.HALFTONE_DITHER,
Printer.PARAM_DEFAULT,
Printer.COMPRESS_AUTO);
method = "addFeedLine";
mPrinter.addFeedLine(1);
} catch (Epos2Exception eps) {
eps.getMessage();
}
} else if (dataobject.getString("website").equalsIgnoreCase("www.themandir.com")) {
try {
Bitmap vml = BitmapFactory.decodeResource(getResources(), R.drawable.mandir);
method = "addTextAlign";
mPrinter.addTextAlign(Printer.ALIGN_CENTER);
method = "addImage";
mPrinter.addImage(vml, 0, 0,
vml.getWidth(),
vml.getHeight(),
Printer.COLOR_1,
Printer.MODE_MONO,
Printer.HALFTONE_DITHER,
Printer.PARAM_DEFAULT,
Printer.COMPRESS_AUTO);
method = "addFeedLine";
mPrinter.addFeedLine(1);
} catch (Epos2Exception eps) {
eps.getMessage();
}
} else if (dataobject.getString("website").equalsIgnoreCase("www.klmfashionmall.com")) {
try {
Bitmap vml = BitmapFactory.decodeResource(getResources(), R.drawable.klm);
method = "addTextAlign";
mPrinter.addTextAlign(Printer.ALIGN_CENTER);
method = "addImage";
mPrinter.addImage(vml, 0, 0,
vml.getWidth(),
vml.getHeight(),
Printer.COLOR_1,
Printer.MODE_MONO,
Printer.HALFTONE_DITHER,
Printer.PARAM_DEFAULT,
Printer.COMPRESS_AUTO);
method = "addFeedLine";
mPrinter.addFeedLine(1);
} catch (Epos2Exception eps) {
eps.getMessage();
}
} else if (dataobject.getString("website").equalsIgnoreCase("www.kalamandir.com")) {
try {
Bitmap vml = BitmapFactory.decodeResource(getResources(), R.drawable.kala);
method = "addTextAlign";
mPrinter.addTextAlign(Printer.ALIGN_CENTER);
method = "addImage";
mPrinter.addImage(vml, 0, 0,
vml.getWidth(),
vml.getHeight(),
Printer.COLOR_1,
Printer.MODE_MONO,
Printer.HALFTONE_DITHER,
Printer.PARAM_DEFAULT,
Printer.COMPRESS_AUTO);
method = "addFeedLine";
mPrinter.addFeedLine(1);
} catch (Epos2Exception eps) {
eps.getMessage();
}
}
}
if (dataobject.has("company_name")) {
method = "addTextAlign";
mPrinter.addTextAlign(Printer.ALIGN_CENTER);
mPrinter.addFeedLine(1);
textData.append(dataobject.getString("company_name") + "\n");
method = "addText";
mPrinter.addText(textData.toString());
textData.delete(0, textData.length());
}
if (dataobject.has("store_name")) {
method = "addTextAlign";
mPrinter.addTextAlign(Printer.ALIGN_CENTER);
textData.append(dataobject.getString("store_name") + "\n");
method = "addText";
mPrinter.addText(textData.toString());
textData.delete(0, textData.length());
}
if (dataobject.has("addr2")) {
method = "addTextAlign";
mPrinter.addTextAlign(Printer.ALIGN_CENTER);
textData.append(dataobject.getString("addr1") + "\n" + dataobject.getString("addr2") + "\n");
Log.e("Data ======>" , dataobject.getString("addr3"));
if (dataobject.getString("addr3").equalsIgnoreCase("null")) {
} else {
textData.append(dataobject.getString("addr3") + "\n");
}
method = "addText";
mPrinter.addText(textData.toString());
textData.delete(0, textData.length());
}
if (dataobject.has("showroom_phone_no")) {
method = "addTextAlign";
mPrinter.addTextAlign(Printer.ALIGN_CENTER);
textData.append(dataobject.getString("showroom_phone_no") + "\n \n");
method = "addText";
mPrinter.addText(textData.toString());
textData.delete(0, textData.length());
}
if (dataobject.has("website")) {
method = "addTextAlign";
mPrinter.addTextAlign(Printer.ALIGN_CENTER);
textData.append(dataobject.getString("website") + "\n");
method = "addText";
mPrinter.addText(textData.toString());
textData.delete(0, textData.length());
}
if (dataobject.has("gstno")) {
method = "addTextAlign";
mPrinter.addTextAlign(Printer.ALIGN_CENTER);
textData.append("GSTIN : " + dataobject.getString("gstno") + "\n\n");
textData.append("\n");
textData.append("Retail Invoice \n");
method = "addText";
mPrinter.addText(textData.toString());
textData.delete(0, textData.length());
method = "addTextAlign";
mPrinter.addTextAlign(Printer.ALIGN_LEFT);
textData.append(Constants.dashed);
textData.append(" Memo No : " + dataobject.getString("memono") + "\n");
textData.append(" Date : " + dataobject.getString("BillDate") + "\n");
Log.e("name ===================>" , dataobject.getString("customer"));
if (dataobject.getString("customer") != "NA")
textData.append(" Customer : " + dataobject.getString("customer") + "\n");
Log.e("name ===================>" , dataobject.getString("mobile"));
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());
}
if (dataobject.has("memono")) {
}
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) {
method = "addTextAlign";
mPrinter.addTextAlign(Printer.ALIGN_LEFT);
textData.append(" SL Barcode Qty MRP Disc Amount " + "\n");
mPrinter.addText(textData.toString());
textData.delete(0, textData.length());
method = "addTextAlign";
mPrinter.addTextAlign(Printer.ALIGN_LEFT);
textData.append(Constants.dashed);
mPrinter.addText(textData.toString());
textData.delete(0, textData.length());
JSONObject da = dataobject.getJSONObject("bill_lines");
Iterator<String> keys = da.keys();
while (keys.hasNext()) {
String key = keys.next();
if (da.get(key) instanceof JSONArray) {
// do something with jsonObject here
Log.e("Connection =====>" , String.valueOf(da));
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);
method = "addTextAlign";
mPrinter.addTextAlign(Printer.ALIGN_LEFT);
textData.append(" " + Constants.SL(bill_object.getString("sno")) +
Constants.Barcode(bill_object.getString("barcode"))
+ Constants.Qty(bill_object.getString("qty")) + Constants.Mrp(bill_object.getString("item_rsp"))
+ Constants.Dis(bill_object.getString("item_qty_disc"))
+ Constants.Total(bill_object.getString("item_qty_payable_amount")));
mPrinter.addText(textData.toString());
textData.delete(0, textData.length());
method = "addTextAlign";
mPrinter.addTextAlign(Printer.ALIGN_LEFT);
textData.append(" HSN " + bill_object.getString("hsn") + " " + "Gst %" + bill_object.getString("gst_per") + " "
+ " Gst Amt " + bill_object.getString("gst_amount") + "\n");
mPrinter.addText(textData.toString());
textData.delete(0, textData.length());
mPrinter.addTextAlign(Printer.ALIGN_LEFT);
textData.append(" SM " + bill_object.getString("sm") + " " + bill_object.getString("perticulars") + "\n");
textData.append(Constants.dashed);
mPrinter.addText(textData.toString());
textData.delete(0, textData.length());
}
}
}
}
}
method = "addText";
mPrinter.addTextAlign(Printer.ALIGN_LEFT);
textData.append(" Gross Amount : " + Constants.Gross(dataobject.getString("total_mrp")) + "\n");
textData.append(" Total Savings : " + Constants.TotalSavings(dataobject.getString("total_saving")) + "\n\n");
method = "addText";
mPrinter.addText(textData.toString());
textData.delete(0, textData.length());
method = "addText";
mPrinter.addTextAlign(Printer.ALIGN_CENTER);
method = "addTextSize";
mPrinter.addTextSize(2, 1);
method = "addText";
mPrinter.addText("Total Qty : " + dataobject.getString("total_qty") + "\n");
mPrinter.addText("Net Amount : " + dataobject.getString("total_payable") + "\n");
mPrinter.addText(textData.toString());
textData.delete(0, textData.length());
method = "addTextSize";
mPrinter.addTextSize(1, 1);
method = "addFeedLine";
mPrinter.addFeedLine(1);
method = "addText";
mPrinter.addText(textData.toString());
textData.delete(0, textData.length());
mPrinter.addTextAlign(Printer.ALIGN_LEFT);
textData.append(Constants.dashed);
mPrinter.addText(textData.toString());
textData.delete(0, textData.length());
if (dataobject.has("mop")) {
JSONArray mop = dataobject.getJSONArray("mop");
Log.e("Mop =====>" , String.valueOf(mop));
textData.delete(0, textData.length());
for (int L = 0; L < mop.length(); L++) {
JSONObject object = mop.getJSONObject(L);
method = "addTextAlign";
mPrinter.addTextAlign(Printer.ALIGN_LEFT);
method = "addText";
mPrinter.addText(" " + Constants.RecievedCashText(object.getString("paidtype")) + Constants.RecievedCash(object.getString("paidamount")) + "\n");
}
}
method = "addText";
mPrinter.addTextAlign(Printer.ALIGN_CENTER);
textData.append("\n" + " Tax Details " + "\n");
method = "addText";
mPrinter.addText(textData.toString());
textData.delete(0, textData.length());
method = "addTextAlign";
mPrinter.addTextAlign(Printer.ALIGN_LEFT);
textData.append(Constants.dashed);
mPrinter.addText(textData.toString());
textData.delete(0, textData.length());
method = "addText";
mPrinter.addTextAlign(Printer.ALIGN_LEFT);
textData.append(" GST% Taxable CGST SGST IGST " + "\n");
mPrinter.addText(textData.toString());
textData.delete(0, textData.length());
if (dataobject.has("gst_lines")) {
JSONArray TaxArray = new JSONArray(dataobject.getString("gst_lines"));
for (int j = 0; j < TaxArray.length(); j++) {
JSONObject taxoObject = TaxArray.getJSONObject(j);
JSONObject taxdata = new JSONObject();
method = "addText";
mPrinter.addTextAlign(Printer.ALIGN_LEFT);
textData.append(" " + Constants.GST(taxoObject.getString("gst_per").trim()) + Constants.Taxable(taxoObject.getString("taxable"))
+ Constants.CGST(taxoObject.getString("cgst")) + Constants.CGST(taxoObject.getString("sgst"))
+ Constants.CGST(taxoObject.getString("igst")) + "\n");
mPrinter.addText(textData.toString());
textData.delete(0, textData.length());
}
if (dataobject.has("gst_total")) {
JSONObject jsonObject = new JSONObject(dataobject.getString("gst_total"));
method = "addText";
textData.append(" Total " + Constants.Taxable(jsonObject.getString("t_taxable")) + Constants.CGST(jsonObject.getString("t_cgst"))
+ Constants.CGST(jsonObject.getString("t_sgst")) + Constants.CGST(jsonObject.getString("t_igst")) + "\n");
mPrinter.addText(textData.toString());
textData.delete(0, textData.length());
}
}
method = "addText";
textData.append(Constants.dashed);
mPrinter.addText(textData.toString());
textData.delete(0, textData.length());
method = "addText";
mPrinter.addTextAlign(Printer.ALIGN_LEFT);
textData.append(" Biller : " + dataobject.getString("biller") + "\n");
mPrinter.addText(textData.toString());
textData.delete(0, textData.length());
method = "addText";
mPrinter.addTextAlign(Printer.ALIGN_CENTER);
textData.append("\n Delivery Slip Summary\n\n");
mPrinter.addText(textData.toString());
textData.delete(0, textData.length());
if (dataobject.has("ds_numbers")) {
JSONArray dslipArray = dataobject.getJSONArray("ds_numbers");
Log.e("DS NUMBERS =====>" , String.valueOf(dslipArray));
method = "addText";
mPrinter.addTextAlign(Printer.ALIGN_LEFT);
textData.append(" DS Number Qty Amount ");
mPrinter.addText(textData.toString());
textData.delete(0, textData.length());
for (int m = 0; m < dslipArray.length(); m++) {
JSONObject object = dslipArray.getJSONObject(m);
method = "addTextAlign";
mPrinter.addTextAlign(Printer.ALIGN_LEFT);
method = "addText";
mPrinter.addText(" " + Constants.Deliveryslipnumber(object.getString("ds_no")) + DeliveryslipQty(object.getString("qty")) + DeliveryslipAmt(object.getString("ds_amount")));
textData.delete(0, textData.length());
}
}
method = "addText";
textData.append("\n" + Constants.dashed);
mPrinter.addText(textData.toString());
textData.delete(0, textData.length());
method = "addTextSize";
mPrinter.addTextSize(2, 2);
method = "addText";
mPrinter.addTextAlign(Printer.ALIGN_CENTER);
mPrinter.addText(dataobject.getString("memono") + "\n\n");
method = "addTextSize";
mPrinter.addTextSize(1, 1);
Bitmap logoData1 = BitmapFactory.decodeResource(getResources(), R.drawable.cash_paid);
final int barcodeWidth = 2;
final int barcodeHeight = 100;
if (mPrinter == null) {
return false;
}
try {
method = "addTextAlign";
mPrinter.addTextAlign(Printer.ALIGN_CENTER);
method = "addImage";
mPrinter.addImage(logoData1, 0, 0,
logoData1.getWidth(),
logoData1.getHeight(),
Printer.COLOR_1,
Printer.MODE_MONO,
Printer.HALFTONE_DITHER,
Printer.PARAM_DEFAULT,
Printer.COMPRESS_AUTO);
method = "addFeedLine";
mPrinter.addFeedLine(1);
} catch (Epos2Exception eps) {
eps.getMessage();
}
if (dataobject.has("ds_number_last_numbers")) {
JSONArray dsArray = dataobject.getJSONArray("ds_number_last_numbers");
Log.e("DS NUMBERS =====>" , String.valueOf(dsArray));
for (int n = 0; n < dsArray.length(); n++) {
method = "addText";
mPrinter.addTextAlign(Printer.ALIGN_CENTER);
method = "addTextSize";
mPrinter.addTextSize(5, 5);
method = "addText";
mPrinter.addText("\n" + dsArray.get(n) + "\n");
}
}
method = "addCut";
mPrinter.addCut(Printer.CUT_FEED);
textData.delete(0, textData.length());
method = "addTextSize";
mPrinter.addTextSize(1, 1);
method = "addFeedLine";
mPrinter.addFeedLine(1);
}
} catch (JSONException jo) {
jo.printStackTrace();
} catch (Epos2Exception e) {
e.printStackTrace();
} catch (Exception e) {
Log.e("Error Message ======>" , e.getMessage());
ShowMsg.showException(e, method, mContext);
return false;
}
}else {
for (int k = 0; k < 2; k++) {
try {
if (mPrinter == null) {
return false;
}
if (responseobj.has("data")) {
Log.e("Response Data =============>" , String.valueOf(responseobj));
JSONObject dataobj = responseobj.getJSONObject("data");
JSONObject dataobject = dataobj.getJSONObject("invoice_data");
if (dataobject.has("website")) {
if (dataobject.getString("website").equalsIgnoreCase("www.kanchivml.com")) {
try {
Bitmap vml = BitmapFactory.decodeResource(getResources(), R.drawable.vara);
method = "addTextAlign";
mPrinter.addTextAlign(Printer.ALIGN_CENTER);
method = "addImage";
mPrinter.addImage(vml, 0, 0,
vml.getWidth(),
vml.getHeight(),
Printer.COLOR_1,
Printer.MODE_MONO,
Printer.HALFTONE_DITHER,
Printer.PARAM_DEFAULT,
Printer.COMPRESS_AUTO);
method = "addFeedLine";
mPrinter.addFeedLine(1);
} catch (Epos2Exception eps) {
eps.getMessage();
}
} else if (dataobject.getString("website").equalsIgnoreCase("www.themandir.com")) {
try {
Bitmap vml = BitmapFactory.decodeResource(getResources(), R.drawable.mandir);
method = "addTextAlign";
mPrinter.addTextAlign(Printer.ALIGN_CENTER);
method = "addImage";
mPrinter.addImage(vml, 0, 0,
vml.getWidth(),
vml.getHeight(),
Printer.COLOR_1,
Printer.MODE_MONO,
Printer.HALFTONE_DITHER,
Printer.PARAM_DEFAULT,
Printer.COMPRESS_AUTO);
method = "addFeedLine";
mPrinter.addFeedLine(1);
} catch (Epos2Exception eps) {
eps.getMessage();
}
} else if (dataobject.getString("website").equalsIgnoreCase("www.klmfashionmall.com")) {
try {
Bitmap vml = BitmapFactory.decodeResource(getResources(), R.drawable.klm);
method = "addTextAlign";
mPrinter.addTextAlign(Printer.ALIGN_CENTER);
method = "addImage";
mPrinter.addImage(vml, 0, 0,
vml.getWidth(),
vml.getHeight(),
Printer.COLOR_1,
Printer.MODE_MONO,
Printer.HALFTONE_DITHER,
Printer.PARAM_DEFAULT,
Printer.COMPRESS_AUTO);
method = "addFeedLine";
mPrinter.addFeedLine(1);
} catch (Epos2Exception eps) {
eps.getMessage();
}
} else if (dataobject.getString("website").equalsIgnoreCase("www.kalamandir.com")) {
try {
Bitmap vml = BitmapFactory.decodeResource(getResources(), R.drawable.kala);
method = "addTextAlign";
mPrinter.addTextAlign(Printer.ALIGN_CENTER);
method = "addImage";
mPrinter.addImage(vml, 0, 0,
vml.getWidth(),
vml.getHeight(),
Printer.COLOR_1,
Printer.MODE_MONO,
Printer.HALFTONE_DITHER,
Printer.PARAM_DEFAULT,
Printer.COMPRESS_AUTO);
method = "addFeedLine";
mPrinter.addFeedLine(1);
} catch (Epos2Exception eps) {
eps.getMessage();
}
}
}
if (dataobject.has("company_name")) {
method = "addTextAlign";
mPrinter.addTextAlign(Printer.ALIGN_CENTER);
mPrinter.addFeedLine(1);
textData.append(dataobject.getString("company_name") + "\n");
method = "addText";
mPrinter.addText(textData.toString());
textData.delete(0, textData.length());
}
if (dataobject.has("store_name")) {
method = "addTextAlign";
mPrinter.addTextAlign(Printer.ALIGN_CENTER);
textData.append(dataobject.getString("store_name") + "\n");
method = "addText";
mPrinter.addText(textData.toString());
textData.delete(0, textData.length());
}
if (dataobject.has("addr2")) {
method = "addTextAlign";
mPrinter.addTextAlign(Printer.ALIGN_CENTER);
textData.append(dataobject.getString("addr1") + "\n" + dataobject.getString("addr2") + "\n");
Log.e("Data ======>" , dataobject.getString("addr3"));
if (dataobject.getString("addr3").equalsIgnoreCase("null")) {
} else {
textData.append(dataobject.getString("addr3") + "\n");
}
method = "addText";
mPrinter.addText(textData.toString());
textData.delete(0, textData.length());
}
if (dataobject.has("showroom_phone_no")) {
method = "addTextAlign";
mPrinter.addTextAlign(Printer.ALIGN_CENTER);
textData.append(dataobject.getString("showroom_phone_no") + "\n \n");
method = "addText";
mPrinter.addText(textData.toString());
textData.delete(0, textData.length());
}
if (dataobject.has("website")) {
method = "addTextAlign";
mPrinter.addTextAlign(Printer.ALIGN_CENTER);
textData.append(dataobject.getString("website") + "\n");
method = "addText";
mPrinter.addText(textData.toString());
textData.delete(0, textData.length());
}
if (dataobject.has("gstno")) {
method = "addTextAlign";
mPrinter.addTextAlign(Printer.ALIGN_CENTER);
textData.append("GSTIN : " + dataobject.getString("gstno") + "\n\n");
textData.append("\n");
textData.append("Retail Invoice \n");
method = "addText";
mPrinter.addText(textData.toString());
textData.delete(0, textData.length());
method = "addTextAlign";
mPrinter.addTextAlign(Printer.ALIGN_LEFT);
textData.append(Constants.dashed);
textData.append(" Memo No : " + dataobject.getString("memono") + "\n");
textData.append(" Date : " + dataobject.getString("BillDate") + "\n");
Log.e("name ===================>" , dataobject.getString("customer"));
if (dataobject.getString("customer") != "NA")
textData.append(" Customer : " + dataobject.getString("customer") + "\n");
Log.e("name ===================>" , dataobject.getString("mobile"));
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());
}
if (dataobject.has("memono")) {
}
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) {
method = "addTextAlign";
mPrinter.addTextAlign(Printer.ALIGN_LEFT);
textData.append(" SL Barcode Qty MRP Disc Amount " + "\n");
mPrinter.addText(textData.toString());
textData.delete(0, textData.length());
method = "addTextAlign";
mPrinter.addTextAlign(Printer.ALIGN_LEFT);
textData.append(Constants.dashed);
mPrinter.addText(textData.toString());
textData.delete(0, textData.length());
JSONObject da = dataobject.getJSONObject("bill_lines");
Iterator<String> keys = da.keys();
while (keys.hasNext()) {
String key = keys.next();
if (da.get(key) instanceof JSONArray) {
// do something with jsonObject here
Log.e("Connection =====>" , String.valueOf(da));
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);
method = "addTextAlign";
mPrinter.addTextAlign(Printer.ALIGN_LEFT);
textData.append(" " + Constants.SL(bill_object.getString("sno")) +
Constants.Barcode(bill_object.getString("barcode"))
+ Constants.Qty(bill_object.getString("qty")) + Constants.Mrp(bill_object.getString("item_rsp"))
+ Constants.Dis(bill_object.getString("item_qty_disc"))
+ Constants.Total(bill_object.getString("item_qty_payable_amount")));
mPrinter.addText(textData.toString());
textData.delete(0, textData.length());
method = "addTextAlign";
mPrinter.addTextAlign(Printer.ALIGN_LEFT);
textData.append(" HSN " + bill_object.getString("hsn") + " " + "Gst %" + bill_object.getString("gst_per") + " "
+ " Gst Amt " + bill_object.getString("gst_amount") + "\n");
mPrinter.addText(textData.toString());
textData.delete(0, textData.length());
mPrinter.addTextAlign(Printer.ALIGN_LEFT);
textData.append(" SM " + bill_object.getString("sm") + " " + bill_object.getString("perticulars") + "\n");
textData.append(Constants.dashed);
mPrinter.addText(textData.toString());
textData.delete(0, textData.length());
}
}
}
}
}
method = "addText";
mPrinter.addTextAlign(Printer.ALIGN_LEFT);
textData.append(" Gross Amount : " + Constants.Gross(dataobject.getString("total_mrp")) + "\n");
textData.append(" Total Savings : " + Constants.TotalSavings(dataobject.getString("total_saving")) + "\n\n");
method = "addText";
mPrinter.addText(textData.toString());
textData.delete(0, textData.length());
method = "addText";
mPrinter.addTextAlign(Printer.ALIGN_CENTER);
method = "addTextSize";
mPrinter.addTextSize(2, 1);
method = "addText";
mPrinter.addText("Total Qty : " + dataobject.getString("total_qty") + "\n");
mPrinter.addText("Net Amount : " + dataobject.getString("total_payable") + "\n");
/*textData.append("Total Qty : " + dataobject.getString("total_qty")+"\n");
textData.append("Net Amount : " + dataobject.getString("total_payable")+"\n");*/
mPrinter.addText(textData.toString());
textData.delete(0, textData.length());
method = "addTextSize";
mPrinter.addTextSize(1, 1);
method = "addFeedLine";
mPrinter.addFeedLine(1);
method = "addText";
mPrinter.addText(textData.toString());
textData.delete(0, textData.length());
mPrinter.addTextAlign(Printer.ALIGN_LEFT);
textData.append(Constants.dashed);
mPrinter.addText(textData.toString());
textData.delete(0, textData.length());
if (dataobject.has("mop")) {
JSONArray mop = dataobject.getJSONArray("mop");
Log.e("Mop =====>" , String.valueOf(mop));
textData.delete(0, textData.length());
for (int L = 0; L < mop.length(); L++) {
JSONObject object = mop.getJSONObject(L);
method = "addTextAlign";
mPrinter.addTextAlign(Printer.ALIGN_LEFT);
method = "addText";
mPrinter.addText(" " + Constants.RecievedCashText(object.getString("paidtype")) + Constants.RecievedCash(object.getString("paidamount")) + "\n");
}
}
method = "addText";
mPrinter.addTextAlign(Printer.ALIGN_CENTER);
textData.append("\n" + " Tax Details " + "\n");
method = "addText";
mPrinter.addText(textData.toString());
textData.delete(0, textData.length());
method = "addTextAlign";
mPrinter.addTextAlign(Printer.ALIGN_LEFT);
textData.append(Constants.dashed);
mPrinter.addText(textData.toString());
textData.delete(0, textData.length());
method = "addText";
mPrinter.addTextAlign(Printer.ALIGN_LEFT);
textData.append(" GST% Taxable CGST SGST IGST " + "\n");
mPrinter.addText(textData.toString());
textData.delete(0, textData.length());
if (dataobject.has("gst_lines")) {
JSONArray TaxArray = new JSONArray(dataobject.getString("gst_lines"));
for (int j = 0; j < TaxArray.length(); j++) {
JSONObject taxoObject = TaxArray.getJSONObject(j);
JSONObject taxdata = new JSONObject();
method = "addText";
mPrinter.addTextAlign(Printer.ALIGN_LEFT);
textData.append(" " + Constants.GST(taxoObject.getString("gst_per").trim()) + Constants.Taxable(taxoObject.getString("taxable"))
+ Constants.CGST(taxoObject.getString("cgst")) + Constants.CGST(taxoObject.getString("sgst"))
+ Constants.CGST(taxoObject.getString("igst")) + "\n");
mPrinter.addText(textData.toString());
textData.delete(0, textData.length());
}
if (dataobject.has("gst_total")) {
JSONObject jsonObject = new JSONObject(dataobject.getString("gst_total"));
method = "addText";
textData.append(" Total " + Constants.Taxable(jsonObject.getString("t_taxable")) + Constants.CGST(jsonObject.getString("t_cgst"))
+ Constants.CGST(jsonObject.getString("t_sgst")) + Constants.CGST(jsonObject.getString("t_igst")) + "\n");
mPrinter.addText(textData.toString());
textData.delete(0, textData.length());
}
}
method = "addText";
textData.append(Constants.dashed);
mPrinter.addText(textData.toString());
textData.delete(0, textData.length());
method = "addText";
mPrinter.addTextAlign(Printer.ALIGN_LEFT);
textData.append(" Biller : " + dataobject.getString("biller") + "\n");
mPrinter.addText(textData.toString());
textData.delete(0, textData.length());
method = "addText";
mPrinter.addTextAlign(Printer.ALIGN_CENTER);
textData.append("\n Delivery Slip Summary\n\n");
mPrinter.addText(textData.toString());
textData.delete(0, textData.length());
if (dataobject.has("ds_numbers")) {
JSONArray dslipArray = dataobject.getJSONArray("ds_numbers");
Log.e("DS NUMBERS =====>" , String.valueOf(dslipArray));
method = "addText";
mPrinter.addTextAlign(Printer.ALIGN_LEFT);
textData.append(" DS Number Qty Amount ");
mPrinter.addText(textData.toString());
textData.delete(0, textData.length());
for (int m = 0; m < dslipArray.length(); m++) {
JSONObject object = dslipArray.getJSONObject(m);
method = "addTextAlign";
mPrinter.addTextAlign(Printer.ALIGN_LEFT);
method = "addText";
mPrinter.addText(" " + Constants.Deliveryslipnumber(object.getString("ds_no")) + DeliveryslipQty(object.getString("qty")) + DeliveryslipAmt(object.getString("ds_amount")));
textData.delete(0, textData.length());
}
}
method = "addText";
textData.append("\n" + Constants.dashed);
mPrinter.addText(textData.toString());
textData.delete(0, textData.length());
method = "addTextSize";
mPrinter.addTextSize(2, 2);
method = "addText";
mPrinter.addTextAlign(Printer.ALIGN_CENTER);
mPrinter.addText(dataobject.getString("memono") + "\n\n");
method = "addTextSize";
mPrinter.addTextSize(1, 1);
Bitmap logoData1 = BitmapFactory.decodeResource(getResources(), R.drawable.cash_paid);
final int barcodeWidth = 2;
final int barcodeHeight = 100;
if (mPrinter == null) {
return false;
}
try {
method = "addTextAlign";
mPrinter.addTextAlign(Printer.ALIGN_CENTER);
method = "addImage";
mPrinter.addImage(logoData1, 0, 0,
logoData1.getWidth(),
logoData1.getHeight(),
Printer.COLOR_1,
Printer.MODE_MONO,
Printer.HALFTONE_DITHER,
Printer.PARAM_DEFAULT,
Printer.COMPRESS_AUTO);
method = "addFeedLine";
mPrinter.addFeedLine(1);
} catch (Epos2Exception eps) {
eps.getMessage();
}
if (dataobject.has("ds_number_last_numbers")) {
JSONArray dsArray = dataobject.getJSONArray("ds_number_last_numbers");
Log.e("DS NUMBERS =====>" , String.valueOf(dsArray));
for (int n = 0; n < dsArray.length(); n++) {
method = "addText";
mPrinter.addTextAlign(Printer.ALIGN_CENTER);
method = "addTextSize";
mPrinter.addTextSize(5, 5);
method = "addText";
mPrinter.addText("\n" + dsArray.get(n) + "\n");
}
}
method = "addCut";
mPrinter.addCut(Printer.CUT_FEED);
textData.delete(0, textData.length());
method = "addTextSize";
mPrinter.addTextSize(1, 1);
method = "addFeedLine";
mPrinter.addFeedLine(1);
}
} catch (JSONException jo) {
jo.printStackTrace();
} catch (Epos2Exception e) {
e.printStackTrace();
} catch (Exception e) {
Log.e("Error Message ======>" , e.getMessage());
ShowMsg.showException(e, method, mContext);
return false;
}
}
}
textData = null;
return true;
}
@Override
protected void onDestroy() {
/* if(connection1!= null)
unbindService(connection1);*/
super.onDestroy();
}
@Override
protected void onPause() {
super.onPause();
}
private void PrintData(String cardNo, final int batchId){
build = new StringBuilder();
for (Model data : datalist) {
if (build.toString().length() > 0) {
build.append(Constants.PrintData(data.getDelivery_slip_id()));
} else {
build.append(Constants.PrintData1(data.getDelivery_slip_id()));
}
}
JSONObject object = new JSONObject();
try {
object.put("bank_mapping_id", batchId);
object.put("card_number", cardNo);
object.put("amount", Float.parseFloat(NetAmount));
} catch (JSONException e) {
e.printStackTrace();
}
if(Constants.isNetworkAvailable(CreateSaleBill.this)){
RequestBody body = RequestBody.create(JSON, Constants.formdata1(build.toString(), cust_name.getText().toString(), cust_number.getText().toString(), object));
dataPresenter.FinalData(Constants.BASE_URL + "/Sales/pre_sale_check",body);
Constants.ProgressDialogShow(CreateSaleBill.this);
}else{
Constants.getToast(CreateSaleBill.this,"Please check your internet connection");
}
}
@Override
public void onDeliveryData(int code, final String res, String Id) {
try {
Constants.ProgressDialogDismiss();
if (code == 200) {
final JSONObject object = new JSONObject(res);
if (object.has("success")) {
if (object.getInt("success") == 1) {
layout.setVisibility(View.VISIBLE);
data.setVisibility(View.VISIBLE);
generate_invoice.setVisibility(View.VISIBLE);
ds_Number.setText("");
JSONObject data = object.getJSONObject("data");
gross_amount.setText(Constants.IndianRupeesformat(data.getString("total_gross")));
discount_amount.setText(Constants.IndianRupeesformat(data.getString("total_promo_discount")));
round_off.setText(Constants.IndianRupeesformat(data.getString("round_off_amount")));
netamount.setText(Constants.IndianRupeesformat(data.getString("total_payable")));
NetAmount = data.getString("total_payable");
//build.append("{"+'"'+"delivery_slip_id"+'"'+":"+'"'+preferenceManager.getPrefix()+Id+'"'+","+'"'+"manual_discount"+'"'+":"+0+"}");
//var = true;
datalist.add(new Model(Id, 0));
//setArraylist.add(new Model(Id,0));
if (datalist.size() > 0) {
SetData(datalist);
}
//pluto_pay.setVisibility(View.VISIBLE);
//pluto_Print.setVisibility(View.VISIBLE);
} else {
layout.setVisibility(View.GONE);
generate_invoice.setVisibility(View.GONE);
runOnUiThread(() -> {
try {
Constants.getToast(CreateSaleBill.this, object.getString("msg"));
//Login.logout(CreateSaleBill.this);
} catch (JSONException e) {
e.printStackTrace();
}
});
}
}
} else {
runOnUiThread(() -> Constants.getToast(CreateSaleBill.this, res));
}
} catch (JSONException e) {
e.printStackTrace();
} catch (NullPointerException io) {
io.printStackTrace();
}
}
@Override
public void onDeliveryFail(final String fail) {
runOnUiThread(new Runnable() {
@Override
public void run() {
Constants.ProgressDialogDismiss();
Constants.getToast(CreateSaleBill.this, fail);
}
});
}
@Override
public void onDeliveryDataRemove(int code, final String res) {
try {
Constants.ProgressDialogDismiss();
if (code == 200) {
final JSONObject obj = new JSONObject(res);
if (obj.has("success")) {
if (obj.getInt("success") == 1) {
layout.setVisibility(View.VISIBLE);
ds_Number.setText("");
JSONObject data = obj.getJSONObject("data");
gross_amount.setText(Constants.IndianRupeesformat(data.getString("total_gross")));
discount_amount.setText(Constants.IndianRupeesformat(data.getString("total_promo_discount")));
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);
}
} else {
layout.setVisibility(View.GONE);
//bank_details.setVisibility(View.GONE);
runOnUiThread(() -> {
try {
Constants.getToast(CreateSaleBill.this, obj.getString("msg"));
Login.logout(CreateSaleBill.this);
} catch (JSONException e) {
e.printStackTrace();
}
});
}
}
} else {
runOnUiThread(new Runnable() {
@Override
public void run() {
Constants.getToast(CreateSaleBill.this, res);
}
});
}
} catch (JSONException e) {
e.printStackTrace();
} catch (NullPointerException io) {
io.printStackTrace();
}
}
@Override
public void onDeliveryFailRemove(final String fail) {
runOnUiThread(new Runnable() {
@Override
public void run() {
Constants.ProgressDialogDismiss();
Constants.getToast(CreateSaleBill.this,fail);
}
});
}
@Override
public void onLogoutData(int code, final String remove) {
try {
Constants.ProgressDialogDismiss();
if (code == 200) {
final JSONObject object = new JSONObject(remove);
//stores = new ArrayList<>();
if (object.has("success")) {
if (object.getInt("success") == 1) {
//JSONObject data = object.getJSONObject("data");
runOnUiThread(new Runnable() {
@Override
public void run() {
try {
Constants.getToast(CreateSaleBill.this, object.getString("msg"));
preferenceManager.setUserId("");
preferenceManager.setLogged(false);
preferenceManager.setCustToken("");
preferenceManager.setBLUETOOTH("");
Login.logout(CreateSaleBill.this);
} catch (JSONException e) {
e.printStackTrace();
}
}
});
} else {
runOnUiThread(() -> {
try {
Constants.getToast(CreateSaleBill.this, object.getString("msg"));
Login.logout(CreateSaleBill.this);
} catch (JSONException e) {
e.printStackTrace();
}
});
}
}
}else{
runOnUiThread(() -> Constants.getToast(CreateSaleBill.this,remove));
}
} catch (JSONException e) {
e.printStackTrace();
}catch (NullPointerException np){
np.printStackTrace();
}
}
@Override
public void onLogoutFail(final String fail) {
runOnUiThread(new Runnable() {
@Override
public void run() {
Constants.ProgressDialogDismiss();
Constants.getToast(CreateSaleBill.this,fail);
}
});
}
@Override
public void onFinalData(int code, String finalData) {
try{
Constants.ProgressDialogDismiss();
bankdialog.dismiss();
if (code == 200) {
pluto_Print.setVisibility(View.VISIBLE);
generate_invoice.setVisibility(View.GONE);
data.setVisibility(View.INVISIBLE);
ds_list.setAdapter(null);
datalist.clear();
cust_name.setText("");
cust_number.setText("");
responseobj = new JSONObject(finalData);
if(responseobj.has("success")) {
if (responseobj.getInt("success") == 1) {
updateButtonState(false);
if (!runPrintReceiptSequence()) {
updateButtonState(true);
}
} else {
runOnUiThread(() -> {
try {
Constants.getToast(CreateSaleBill.this, responseobj.getString("msg"));
Login.logout(CreateSaleBill.this);
} catch (JSONException e) {
e.printStackTrace();
}
});
}
}
} else {
Constants.getToast(CreateSaleBill.this, finalData);
}
} catch (JSONException e) {
e.printStackTrace();
} catch (NullPointerException np) {
np.printStackTrace();
}
}
@Override
public void onFinalFail(final String finalFail) {
runOnUiThread(() -> {
Constants.ProgressDialogDismiss();
Constants.getToast(CreateSaleBill.this,finalFail);
bankdialog.dismiss();
pluto_Print.setVisibility(View.GONE);
generate_invoice.setVisibility(View.VISIBLE);
data.setVisibility(View.VISIBLE);
});
}
@Override
public void onCustomerName(int code, final String name) {
if(code == 200){
runOnUiThread(() -> {
try{
final JSONObject object = new JSONObject(name);
if(object.has("success")){
if(object.getInt("success") == 1){
JSONObject jsonObject = object.getJSONObject("data");
//if(jsonObject.getString("customer_name"))
if(jsonObject.getString("customer_name").isEmpty()){
cust_name.setText("");
}else {
cust_name.setText(jsonObject.getString("customer_name"));
ds_Number.requestFocus();
}
}else{
}
}
}catch(JSONException e){
e.printStackTrace();
}
});
}else{
runOnUiThread(() -> Constants.getToast(CreateSaleBill.this,name));
}
}
@Override
public void onCustomerNameFail(String fail) {
runOnUiThread(() -> {
//cust_name.setText(name);
});
}
@Override
public boolean onEditorAction(TextView v, int actionId, KeyEvent event){
if(v.getId() == R.id.ds_Number) {
if (TextUtils.isEmpty(ds_Number.getText().toString())) {
Constants.getToast(CreateSaleBill.this, "Enter Delivery Slip Id");
} 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 =============>","");
DsData(preferenceManager.getPrefix() + ds_Number.getText().toString());
Constants.hideKeyboard(this);
}
}
}else if(v.getId() == R.id.last_four_digits){
if (BankName.equalsIgnoreCase("Select Bank") && last_four_digits.getText().toString().length() == 0) {
Constants.getToast(CreateSaleBill.this, "Please Select Bank and Enter last four digits");
} else if (BankName.equalsIgnoreCase("Select Bank")) {
Constants.getToast(CreateSaleBill.this, "Please Select Bank ");
} else if (last_four_digits.getText().toString().length() == 0) {
Constants.getToast(CreateSaleBill.this, "Enter last four digits");
} else if (last_four_digits.getText().toString().length() == 4) {
if (Constants.isNetworkAvailable(CreateSaleBill.this)) {
Constants.hideSoftKeyBoardOnTabClicked(v, CreateSaleBill.this);
PrintData(last_four_digits.getText().toString(), BankId);
}else{
Constants.getToast(CreateSaleBill.this,"Please check your internet connection");
}
}
}
return false;
}
}
......@@ -9,6 +9,7 @@ import android.content.Context;
import android.text.Html;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.view.Window;
import android.widget.Button;
......@@ -39,7 +40,7 @@ public class CustomAdapter extends RecyclerView.Adapter<CustomAdapter.ViewHolder
final Plans items = arrayList.get(position);
holder.plan_id.setText("PLAN ID : "+items.getPlanId());
holder.plan_name.setText("NAME : "+items.getName());
holder.view_section.setOnClickListener(new View.OnClickListener(){
holder.view_section.setOnClickListener(new OnClickListener(){
@Override
public void onClick(View view){
final Dialog dialog = new Dialog(context);
......@@ -54,7 +55,8 @@ public class CustomAdapter extends RecyclerView.Adapter<CustomAdapter.ViewHolder
ImageView close = dialog.findViewById(R.id.close);
section.setText(Html.fromHtml(Constants.Sec +items.getSection()));
division.setText(Html.fromHtml(Constants.div+items.getDivision()));
close.setOnClickListener(new View.OnClickListener(){
close.setOnClickListener(new OnClickListener(){
@Override
public void onClick(View view){
dialog.dismiss();
......@@ -62,7 +64,7 @@ public class CustomAdapter extends RecyclerView.Adapter<CustomAdapter.ViewHolder
});
}
});
holder.start_scan.setOnClickListener(new View.OnClickListener(){
holder.start_scan.setOnClickListener(new OnClickListener(){
@Override
public void onClick(View view){
PlanDetails.start(context,items);
......
......@@ -29,7 +29,7 @@ import java.util.concurrent.TimeUnit;
public class DashBoardActivity extends AppCompatActivity implements View.OnClickListener {
Toolbar dashboard_toolbar;
Button stock_audit,rack_qty,searchby_barcode;
Button stock_audit,rack_qty,searchby_barcode, transfer;
TextView version;
PreferenceManager preferenceManager;
@Override
......@@ -39,14 +39,17 @@ public class DashBoardActivity extends AppCompatActivity implements View.OnClick
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);
dashboard_toolbar = findViewById(R.id.dashboard_toolbar);
version = findViewById(R.id.version);
preferenceManager= new PreferenceManager(this);
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
......@@ -65,6 +68,10 @@ public class DashBoardActivity extends AppCompatActivity implements View.OnClick
Constants.getToast(DashBoardActivity.this,getResources().getString(R.string.connection));
}
break;
case android.R.id.home:
finish();
break;
}
return super.onOptionsItemSelected(item);
}
......@@ -98,7 +105,7 @@ public class DashBoardActivity extends AppCompatActivity implements View.OnClick
preferenceManager.setLogged(false);
preferenceManager.setCustToken("");
preferenceManager.setStoreId("");
Login.logout(DashBoardActivity.this,preferenceManager.getStoreId());
Login.logout(DashBoardActivity.this);
}else{
Constants.getToast(DashBoardActivity.this,jsonObject.getString("msg"));
}
......@@ -130,28 +137,4 @@ public class DashBoardActivity extends AppCompatActivity implements View.OnClick
break;
}
}
@Override
public void onBackPressed(){
int count = 0;
if(count>0){
super.onBackPressed();
}else{
AlertDialog alert = new AlertDialog.Builder(this)
.setTitle("Are you sure you want to close this app")
//.setMessage("Are you sure to Exit")
.setPositiveButton("Yes", new DialogInterface.OnClickListener(){
@Override
public void onClick(DialogInterface dialogInterface, int i){
finish();
}
})
.setNegativeButton("No", new DialogInterface.OnClickListener(){
@Override
public void onClick(DialogInterface dialogInterface, int i){
}
})
.show();
}
}
}
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 onCustomerName(int code,String name);
void onCustomerNameFail(String fail);
}
package w.soulofpluto.posstock;
import android.content.Context;
import android.os.Handler;
import android.os.Looper;
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.TimeUnit;
/*
Create by Ramesh Babu
*/
public class DataPresenter{
public static final MediaType JSON = MediaType.parse("application/json; charset=utf-8");
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);
}
public void SendDeliverySlipNumber(String Url, RequestBody object, final String Id){
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);
Request request = new Request.Builder()
.url(Url)
.post(object)
.addHeader("Content-Type", "application/json")
.addHeader("Pos-Access-Token",preferenceManager.getCustToken())
.addHeader("Pos-User-Access-Store-Id", 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());
}
@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(new Runnable() {
@Override
public void run() {
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);
//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);
Request request = new Request.Builder()
.url(Url)
.post(object)
.addHeader("Content-Type", "application/json")
.addHeader("Pos-Access-Token",preferenceManager.getCustToken())
.addHeader("Pos-User-Access-Store-Id", preferenceManager.getStoreId())
.build();
client.newCall(request).enqueue(new Callback(){
@Override
public void onFailure(Request request, IOException e){
//featureDataInterface.FeatureFailure(request.toString());
dataInterface.onDeliveryFailRemove(request.toString());
System.out.println("Delivery Slip remove 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 Remove" + Response);
Handler handler = new Handler(Looper.getMainLooper());
handler.post(new Runnable() {
@Override
public void run() {
dataInterface.onDeliveryDataRemove(response.code(),Response);
}
});
}catch (NullPointerException np){
np.printStackTrace();
}finally {
response.body().close();
}
}
});
}
public void FinalData(String Url, RequestBody 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);
Request request = new Request.Builder()
.url(Url)
.post(object)
.addHeader("Content-Type", "application/json")
.addHeader(context.getResources().getString(R.string.accesstoken),preferenceManager.getCustToken())
.addHeader(context.getResources().getString(R.string.storeidtoken),preferenceManager.getStoreId())
.build();
client.newCall(request).enqueue(new Callback(){
@Override
public void onFailure(Request request, IOException e){
//featureDataInterface.FeatureFailure(request.toString());
dataInterface.onFinalFail(request.toString());
System.out.println("singup1 error" +e.getMessage());
}
@Override
public void onResponse(final com.squareup.okhttp.Response response) throws IOException{
try {
Response = response.body().string();
System.out.println("Signup1 Response" + Response);
Handler handler = new Handler(Looper.getMainLooper());
handler.post(() -> dataInterface.onFinalData(response.code(),Response));
}catch (NullPointerException np){
np.printStackTrace();
}finally {
response.body().close();
}
}
});
}
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);
Request request = new Request.Builder()
.url(Url)
.get()
.addHeader("Content-Type", "application/json")
.addHeader(context.getResources().getString(R.string.accesstoken),preferenceManager.getCustToken())
.addHeader(context.getResources().getString(R.string.storeidtoken),preferenceManager.getStoreId())
.build();
client.newCall(request).enqueue(new Callback(){
@Override
public void onFailure(Request request, IOException e){
dataInterface.onLogoutFail(request.toString());
System.out.println("cart count error ====>" +e.getMessage());
}
@Override
public void onResponse(final com.squareup.okhttp.Response response) throws IOException{
Response = response.body().string();
System.out.println("cart count Response ====>" +Response);
Handler handler = new Handler(Looper.getMainLooper());
handler.post(new Runnable(){
@Override
public void run(){
dataInterface.onLogoutData(response.code(),Response);
}
});
}
});
}
public void CustomerName(String Url,RequestBody object){
final OkHttpClient client = new OkHttpClient();
client.setConnectTimeout(2000, TimeUnit.SECONDS);
client.setReadTimeout(2000,TimeUnit.SECONDS);
client.setWriteTimeout(2000,TimeUnit.SECONDS);
System.out.println("Url ====>"+Url);
System.out.println("Object ====>"+object);
System.out.println("Token ====>"+preferenceManager.getCustToken());
final Request request = new Request.Builder()
.url(Url)
.post(object)
.addHeader("Content-Type", "application/json")
.addHeader("Pos-Access-Token", preferenceManager.getCustToken())
.addHeader("Pos-User-Access-Store-Id", preferenceManager.getStoreId())
.build();
client.newCall(request).enqueue(new Callback(){
@Override
public void onFailure(Request request, IOException e){
dataInterface.onCustomerNameFail(request.toString());
System.out.println("Customer error ====>" +e.getMessage());
}
@Override
public void onResponse(final com.squareup.okhttp.Response response) throws IOException{
Response = response.body().string();
System.out.println("Customer Response ====>" + Response);
Handler handler = new Handler(Looper.getMainLooper());
handler.post(new Runnable() {
@Override
public void run() {
dataInterface.onCustomerName(response.code(), Response);
}
});
}
});
}
}
package w.soulofpluto.posstock;
/*
Create by Ramesh Babu
*/
import android.content.Context;
import android.text.Html;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;
import java.util.List;
public class DeliverySlipAdapter extends RecyclerView.Adapter<DeliverySlipAdapter.ViewHolder> {
public List<CreateResponse.Datum> arrayList;
public Context context;
public DeliverySlipAdapter(Context context, List<CreateResponse.Datum> list){
this.context = context;
this.arrayList = list;
}
@NonNull
@Override
public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
LayoutInflater layoutInflater = LayoutInflater.from(parent.getContext());
View listItem = layoutInflater.inflate(R.layout.delivery_list_item, parent, false);
DeliverySlipAdapter.ViewHolder viewHolder = new DeliverySlipAdapter.ViewHolder(listItem);
return viewHolder;
}
@Override
public void onBindViewHolder(@NonNull ViewHolder holder, int position) {
CreateResponse.Datum datum = arrayList.get(position);
if(TextUtils.isEmpty(datum.getItemLevelPromoName())){
holder.item_level_promotion.setVisibility(View.GONE);
}else{
holder.item_level_promotion.setVisibility(View.VISIBLE);
holder.item_level_promotion.setText(datum.getItemLevelPromoName());
}
holder.create_barcode.setText(Html.fromHtml(Constants.getBarcode(datum.getBarcode())));
holder.create_empid.setText(Html.fromHtml(Constants.getEmpId(datum.getEmpId())));
holder.create_dis.setText(Html.fromHtml(Constants.getCode(Constants.IndianRupeesFormat(String.valueOf(datum.getPromoDisc())))));
holder.create_mrp.setText(Html.fromHtml(Constants.getMRP(Constants.IndianRupeesFormat(datum.getItemRsp()))));
holder.create_netpay.setText(Html.fromHtml(Constants.getNetPayable(Constants.IndianRupeesFormat(datum.getNetPayable().toString()))));
}
@Override
public int getItemCount() {
return arrayList.size();
}
public class ViewHolder extends RecyclerView.ViewHolder{
public TextView create_barcode,create_empid,create_mrp,create_dis,create_netpay,item_level_promotion;
public ViewHolder(View itemView){
super(itemView);
create_barcode = itemView.findViewById(R.id.create_barcode);
create_empid = itemView.findViewById(R.id.create_empid);
create_mrp = itemView.findViewById(R.id.create_mrp);
create_dis = itemView.findViewById(R.id.create_dis);
create_netpay = itemView.findViewById(R.id.create_netpay);
item_level_promotion = itemView.findViewById(R.id.item_level_promotion);
}
}
}
package w.soulofpluto.posstock;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.Button;
import android.widget.ListView;
import android.widget.SimpleAdapter;
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 java.util.ArrayList;
import java.util.HashMap;
public class DiscoveryActivity extends Activity implements View.OnClickListener, AdapterView.OnItemClickListener {
private Context mContext = null;
private ArrayList<HashMap<String, String>> mPrinterList = null;
private SimpleAdapter mPrinterListAdapter = 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);
button.setOnClickListener(this);
mPrinterList = new ArrayList<HashMap<String, String>>();
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);
list.setAdapter(mPrinterListAdapter);
list.setOnItemClickListener(this);
mFilterOption = new FilterOption();
mFilterOption.setDeviceType(Discovery.TYPE_PRINTER);
mFilterOption.setEpsonFilter(Discovery.FILTER_NAME);
try {
Discovery.start(this, mFilterOption, mDiscoveryListener);
}
catch (Exception e) {
ShowMsg.showException(e, "start", mContext);
}
}
@Override
public void onDestroy() {
super.onDestroy();
while (true) {
try {
Discovery.stop();
break;
}
catch (Epos2Exception e) {
if (e.getErrorStatus() != Epos2Exception.ERR_PROCESSING) {
break;
}
}
}
mFilterOption = null;
}
@Override
public void onClick(View v) {
switch (v.getId()) {
case R.id.btnRestart:
restartDiscovery();
break;
default:
// Do nothing
break;
}
}
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
Intent intent = new Intent();
HashMap<String, String> item = mPrinterList.get(position);
intent.putExtra(getString(R.string.title_target), item.get("Target"));
setResult(RESULT_OK, intent);
finish();
}
private void restartDiscovery() {
while (true) {
try {
Discovery.stop();
break;
}
catch (Epos2Exception e) {
if (e.getErrorStatus() != Epos2Exception.ERR_PROCESSING) {
ShowMsg.showException(e, "stop", mContext);
return;
}
}
}
mPrinterList.clear();
mPrinterListAdapter.notifyDataSetChanged();
try {
Discovery.start(this, mFilterOption, mDiscoveryListener);
}
catch (Exception e) {
ShowMsg.showException(e, "stop", mContext);
}
}
private DiscoveryListener mDiscoveryListener = new DiscoveryListener() {
@Override
public void onDiscovery(final DeviceInfo deviceInfo) {
runOnUiThread(new Runnable() {
@Override
public synchronized void run() {
HashMap<String, String> item = new HashMap<String, String>();
item.put("PrinterName", deviceInfo.getDeviceName());
item.put("Target", deviceInfo.getTarget());
mPrinterList.add(item);
mPrinterListAdapter.notifyDataSetChanged();
}
});
}
};
}
package w.soulofpluto.posstock;
import android.Manifest;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
import android.text.Html;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.RelativeLayout;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;
import androidx.core.app.ActivityCompat;
import androidx.core.content.ContextCompat;
import androidx.recyclerview.widget.GridLayoutManager;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import com.squareup.okhttp.Callback;
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.nio.channels.InterruptedByTimeoutException;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.TimeUnit;
import static w.soulofpluto.posstock.Constants.JSON;
import static w.soulofpluto.posstock.Constants.Logout;
/*
Create by Ramesh Babu
*/
public class HomeActivity extends AppCompatActivity implements View.OnClickListener {
Toolbar home_toolbar;
static PreferenceManager preferenceManager;
TextView version;
ArrayList<String> arrayList;
RecyclerView recyclerView;
private static final int REQUEST_PERMISSION = 100;
@Override
protected void onCreate(@Nullable Bundle savedInstanceState){
setContentView(R.layout.activity_home);
requestRuntimePermission();
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(getResources().getString(R.string.home));
version.setText(Html.fromHtml(Constants.Ver_Text +Constants.VERSION));
if(Constants.isNetworkAvailable(HomeActivity.this)) {
setUI();
} else {
Constants.getToast(HomeActivity.this,"Please check internet connection");
}
super.onCreate(savedInstanceState);
}
private void requestRuntimePermission() {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) {
return;
}
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 (permissionLocation == PackageManager.PERMISSION_DENIED) {
requestPermissions.add(Manifest.permission.ACCESS_COARSE_LOCATION);
}
if (!requestPermissions.isEmpty()) {
ActivityCompat.requestPermissions(this, requestPermissions.toArray(new String[requestPermissions.size()]), REQUEST_PERMISSION);
}
//ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE,Manifest.permission.ACCESS_BACKGROUND_LOCATION}, REQUEST_PERMISSION);
}
@Override
public void onRequestPermissionsResult(int requestCode, @NonNull String permissions[], @NonNull int[] grantResults) {
if (requestCode != REQUEST_PERMISSION || grantResults.length == 0) {
return;
}
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.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 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(new Runnable(){
@Override
public void run(){
Constants.getToast(HomeActivity.this,e.getMessage());
Constants.ProgressDialogDismiss();
}
});
}
@Override
public void onResponse(final com.squareup.okhttp.Response response) throws IOException{
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(new Runnable() {
@Override
public void run() {
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(new Runnable() {
@Override
public void run() {
try {
Log.e("session", object.getString("msg"));
Constants.getToast(HomeActivity.this, object.getString("msg"));
Login.logout(HomeActivity.this);
} catch (JSONException e) {
e.printStackTrace();
}
}
});
}
}else{
runOnUiThread(() -> Constants.getToast(HomeActivity.this,Response));
}
}catch(NullPointerException | JSONException io){
io.printStackTrace();
}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;
}
return super.onOptionsItemSelected(item);
}
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")
.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, IOException e){
Constants.ProgressDialogDismiss();
}
@Override
public void onResponse(Response response) throws IOException{
Constants.ProgressDialogDismiss();
final String res = response.body().string();
try{
Log.e("Dashboard Logout ", res);
if(response.code() == 200) {
JSONObject jsonObject = new JSONObject(res);
if (jsonObject.has("success")) {
if (jsonObject.getInt("success") == 1) {
preferenceManager.setUserId("");
preferenceManager.setLogged(false);
preferenceManager.setCustToken("");
preferenceManager.setStoreId("");
preferenceManager.setBLUETOOTH("");
Login.logout(HomeActivity.this);
} else {
Constants.getToast(HomeActivity.this, jsonObject.getString("msg"));
}
}
} else {
runOnUiThread(() -> Constants.getToast(HomeActivity.this, res));
}
} catch (JSONException e) {
e.printStackTrace();
} catch (NullPointerException np) {
np.printStackTrace();
}
}
});
}
@Override
public void onBackPressed(){
int count = 0;
if(count>0){
super.onBackPressed();
}else{
AlertDialog alert = new AlertDialog.Builder(this)
.setTitle("Are you sure you want to close this app")
//.setMessage("Are you sure to Exit")
.setPositiveButton("Yes", new DialogInterface.OnClickListener(){
@Override
public void onClick(DialogInterface dialogInterface, int i){
finish();
}
})
.setNegativeButton("No", new DialogInterface.OnClickListener(){
@Override
public void onClick(DialogInterface dialogInterface, int i){
}
})
.show();
}
}
@Override
public void onClick(View view) {
switch (view.getId()){
/* case R.id.layout1:
Intent intent = new Intent(HomeActivity.this,DashBoardActivity.class);
startActivity(intent);
break;*/
}
}
}
......@@ -49,7 +49,7 @@ public class Login extends AppCompatActivity implements View.OnClickListener, Ad
private PreferenceManager preferenceManager;
private String Store_Name;
public static void logout(Context context, String id){
public static void logout(Context context){
Activity activity = (Activity) context;
Intent in_logout = new Intent(context, Login.class);
in_logout.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
......@@ -118,8 +118,8 @@ public class Login extends AppCompatActivity implements View.OnClickListener, Ad
@Override
public void run(){
try{
JSONObject object = new JSONObject(Response);
if(response.code() == 200){
JSONObject object = new JSONObject(Response);
stores = new ArrayList<>();
if(object.has(getResources().getString(R.string.success))){
if(object.getInt(getResources().getString(R.string.success)) == 1){
......@@ -142,6 +142,13 @@ public class Login extends AppCompatActivity implements View.OnClickListener, Ad
storeId.setAdapter(null);
}
}
}else{
runOnUiThread(new Runnable() {
@Override
public void run() {
Constants.getToast(Login.this,Response);
}
});
}
}catch(JSONException e){
e.printStackTrace();
......@@ -266,7 +273,7 @@ public class Login extends AppCompatActivity implements View.OnClickListener, Ad
if (Store_Name != null)
preferenceManager.setStoreName(Store_Name);
preferenceManager.setLogged(true);
Intent in = new Intent(Login.this, DashBoardActivity.class);
Intent in = new Intent(Login.this, HomeActivity.class);
startActivity(in);
finish();
} else {
......
......@@ -85,7 +85,7 @@ public class MainActivity extends AppCompatActivity {
preferenceManager.setLogged(false);
preferenceManager.setCustToken("");
preferenceManager.setStoreId("");
Login.logout(MainActivity.this,preferenceManager.getStoreId());
Login.logout(MainActivity.this);
}else{
Constants.getToast(MainActivity.this,jsonObject.getString(getResources().getString(R.string.msg)));
}
......@@ -222,7 +222,7 @@ public class MainActivity extends AppCompatActivity {
preferenceManager.setLogged(false);
preferenceManager.setCustToken("");
preferenceManager.setStoreId("");
Login.logout(MainActivity.this,preferenceManager.getStoreId());
Login.logout(MainActivity.this);
}
}
}
......
package w.soulofpluto.posstock;
import android.content.Context;
import android.content.Intent;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;
import java.util.ArrayList;
/*
Create by Ramesh Babu
*/
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;
}
@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;
}
@Override
public void onBindViewHolder(@NonNull MenuAdapter.ViewHolder holder, final int position) {
final String data = arrayList.get(position);
holder.menu_name.setText(data);
holder.layout.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if(data.equalsIgnoreCase("Stock Audit")){
Intent intent = new Intent(context,DashBoardActivity.class);
context.startActivity(intent);
}else if(data.equalsIgnoreCase("Create Delivery Slip")){
Intent intent = new Intent(context,CreateDeliverySlip.class);
context.startActivity(intent);
}else{
Intent intent = new Intent(context,CreateSaleBill.class);
context.startActivity(intent);
}
}
});
}
@Override
public int getItemCount() {
return arrayList.size();
}
public class ViewHolder extends RecyclerView.ViewHolder{
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);
}
}
}
package w.soulofpluto.posstock;
/*
Create by Ramesh Babu
*/
public class Model {
private String delivery_slip_id;
private int manual_discount;
public Model(String Id, int discount){
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;
}
}
......@@ -570,7 +570,7 @@ public class PlanDetails extends AppCompatActivity implements View.OnClickListen
try {
final JSONObject jsonObject = new JSONObject(res);
if (jsonObject.has(getResources().getString(R.string.success))) {
if (jsonObject.getInt(getResources().getString(R.string.success)) == 1) {
if(jsonObject.getInt(getResources().getString(R.string.success)) == 1){
runOnUiThread(new Runnable() {
@Override
public void run() {
......@@ -585,14 +585,14 @@ public class PlanDetails extends AppCompatActivity implements View.OnClickListen
}
});
} else if (jsonObject.getInt(getResources().getString(R.string.success)) == 3) {
}else if (jsonObject.getInt(getResources().getString(R.string.success)) == 3){
runOnUiThread(new Runnable() {
@Override
public void run() {
try {
try{
Constants.getToast(PlanDetails.this, jsonObject.getString(getResources().getString(R.string.msg)));
DoLogin();
} catch (JSONException e) {
}catch(JSONException e){
e.printStackTrace();
}
}
......
......@@ -11,7 +11,7 @@ import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;
import java.util.ArrayList;
/*
/*
Create by Ramesh Babu
*/
......
......@@ -22,6 +22,7 @@ public class PreferenceManager {
public static final String ID = "ID";
public static final String BLUETOOTH = "bluetooth";
public static final String STORENAME = "storeName";
public static final String KEY_USER_LOGIN = "userlogin";
public static final String APP_SHARED_PREFS = PreferenceManager.class.getSimpleName();
public static SharedPreferences _sharedPrefs;
public static SharedPreferences.Editor _prefsEditor;
......@@ -38,6 +39,16 @@ public class PreferenceManager {
_prefsEditor.remove(KEY_USER_ID);
_prefsEditor.apply();
}
public void setKeyUserLogin(String userLogin){
_prefsEditor.putString(KEY_USER_LOGIN,userLogin);
_prefsEditor.apply();
}
public String getKeyUserLogin(){
return _sharedPrefs.getString(KEY_USER_LOGIN,"");
}
public void setFirstName(String firstName){
_prefsEditor.putString(FIRST_NAME,firstName);
_prefsEditor.apply();
......
......@@ -181,7 +181,7 @@ public class RackWiseQty extends AppCompatActivity implements AdapterView.OnItem
preferenceManager.setLogged(false);
preferenceManager.setCustToken("");
preferenceManager.setStoreId("");
Login.logout(RackWiseQty.this,preferenceManager.getStoreId());
Login.logout(RackWiseQty.this);
}
}
}
......@@ -334,7 +334,7 @@ public class RackWiseQty extends AppCompatActivity implements AdapterView.OnItem
preferenceManager.setLogged(false);
preferenceManager.setCustToken("");
preferenceManager.setStoreId("");
Login.logout(RackWiseQty.this,preferenceManager.getStoreId());
Login.logout(RackWiseQty.this);
}
}
}
......
......@@ -322,7 +322,7 @@ import static w.soulofpluto.posstock.Constants.getDateWithOffset;
preferenceManager.setLogged(false);
preferenceManager.setCustToken("");
preferenceManager.setStoreId("");
Login.logout(SearchByBarcode.this,preferenceManager.getStoreId());
Login.logout(SearchByBarcode.this);
}
}
}
......
package w.soulofpluto.posstock;
import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import com.epson.epos2.Epos2CallbackCode;
import com.epson.epos2.Epos2Exception;
public class ShowMsg {
public static void showException(Exception e, String method, Context context) {
String msg = "";
if (e instanceof Epos2Exception) {
msg = String.format(
"%s\n\t%s\n%s\n\t%s",
context.getString(R.string.title_err_code),
getEposExceptionText(((Epos2Exception) e).getErrorStatus()),
context.getString(R.string.title_err_method),
method);
}
else {
msg = e.toString();
}
show(msg, context);
}
public static void showResult(int code, String errMsg, Context context) {
String msg = "";
if (errMsg.isEmpty()) {
msg = String.format(
"\t%s\n\t%s\n",
context.getString(R.string.title_msg_result),
getCodeText(code));
}
else {
msg = String.format(
"\t%s\n\t%s\n\n\t%s\n\t%s\n",
context.getString(R.string.title_msg_result),
getCodeText(code),
context.getString(R.string.title_msg_description),
errMsg);
}
show(msg, context);
}
public static void showMsg(String msg, Context context) {
show(msg, context);
}
private static void show(String msg, Context context) {
AlertDialog.Builder alertDialog = new AlertDialog.Builder(context);
alertDialog.setMessage(msg);
alertDialog.setPositiveButton("OK", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
return ;
}
});
alertDialog.create();
alertDialog.show();
}
private static String getEposExceptionText(int state) {
String return_text = "";
switch (state) {
case Epos2Exception.ERR_PARAM:
return_text = "ERR_PARAM";
break;
case Epos2Exception.ERR_CONNECT:
return_text = "ERR_CONNECT";
break;
case Epos2Exception.ERR_TIMEOUT:
return_text = "ERR_TIMEOUT";
break;
case Epos2Exception.ERR_MEMORY:
return_text = "ERR_MEMORY";
break;
case Epos2Exception.ERR_ILLEGAL:
return_text = "ERR_ILLEGAL";
break;
case Epos2Exception.ERR_PROCESSING:
return_text = "ERR_PROCESSING";
break;
case Epos2Exception.ERR_NOT_FOUND:
return_text = "ERR_NOT_FOUND";
break;
case Epos2Exception.ERR_IN_USE:
return_text = "ERR_IN_USE";
break;
case Epos2Exception.ERR_TYPE_INVALID:
return_text = "ERR_TYPE_INVALID";
break;
case Epos2Exception.ERR_DISCONNECT:
return_text = "ERR_DISCONNECT";
break;
case Epos2Exception.ERR_ALREADY_OPENED:
return_text = "ERR_ALREADY_OPENED";
break;
case Epos2Exception.ERR_ALREADY_USED:
return_text = "ERR_ALREADY_USED";
break;
case Epos2Exception.ERR_BOX_COUNT_OVER:
return_text = "ERR_BOX_COUNT_OVER";
break;
case Epos2Exception.ERR_BOX_CLIENT_OVER:
return_text = "ERR_BOX_CLIENT_OVER";
break;
case Epos2Exception.ERR_UNSUPPORTED:
return_text = "ERR_UNSUPPORTED";
break;
case Epos2Exception.ERR_FAILURE:
return_text = "ERR_FAILURE";
break;
default:
return_text = String.format("%d", state);
break;
}
return return_text;
}
private static String getCodeText(int state) {
String return_text = "";
switch (state) {
case Epos2CallbackCode.CODE_SUCCESS:
return_text = "PRINT_SUCCESS";
break;
case Epos2CallbackCode.CODE_PRINTING:
return_text = "PRINTING";
break;
case Epos2CallbackCode.CODE_ERR_AUTORECOVER:
return_text = "ERR_AUTORECOVER";
break;
case Epos2CallbackCode.CODE_ERR_COVER_OPEN:
return_text = "ERR_COVER_OPEN";
break;
case Epos2CallbackCode.CODE_ERR_CUTTER:
return_text = "ERR_CUTTER";
break;
case Epos2CallbackCode.CODE_ERR_MECHANICAL:
return_text = "ERR_MECHANICAL";
break;
case Epos2CallbackCode.CODE_ERR_EMPTY:
return_text = "ERR_EMPTY";
break;
case Epos2CallbackCode.CODE_ERR_UNRECOVERABLE:
return_text = "ERR_UNRECOVERABLE";
break;
case Epos2CallbackCode.CODE_ERR_FAILURE:
return_text = "ERR_FAILURE";
break;
case Epos2CallbackCode.CODE_ERR_NOT_FOUND:
return_text = "ERR_NOT_FOUND";
break;
case Epos2CallbackCode.CODE_ERR_SYSTEM:
return_text = "ERR_SYSTEM";
break;
case Epos2CallbackCode.CODE_ERR_PORT:
return_text = "ERR_PORT";
break;
case Epos2CallbackCode.CODE_ERR_TIMEOUT:
return_text = "ERR_TIMEOUT";
break;
case Epos2CallbackCode.CODE_ERR_JOB_NOT_FOUND:
return_text = "ERR_JOB_NOT_FOUND";
break;
case Epos2CallbackCode.CODE_ERR_SPOOLER:
return_text = "ERR_SPOOLER";
break;
case Epos2CallbackCode.CODE_ERR_BATTERY_LOW:
return_text = "ERR_BATTERY_LOW";
break;
case Epos2CallbackCode.CODE_ERR_TOO_MANY_REQUESTS:
return_text = "ERR_TOO_MANY_REQUESTS";
break;
case Epos2CallbackCode.CODE_ERR_REQUEST_ENTITY_TOO_LARGE:
return_text = "ERR_REQUEST_ENTITY_TOO_LARGE";
break;
case Epos2CallbackCode.CODE_CANCELED:
return_text = "CODE_CANCELED";
break;
case Epos2CallbackCode.CODE_ERR_NO_MICR_DATA:
return_text = "ERR_NO_MICR_DATA";
break;
case Epos2CallbackCode.CODE_ERR_ILLEGAL_LENGTH:
return_text = "ERR_ILLEGAL_LENGTH";
break;
case Epos2CallbackCode.CODE_ERR_NO_MAGNETIC_DATA:
return_text = "ERR_NO_MAGNETIC_DATA";
break;
case Epos2CallbackCode.CODE_ERR_RECOGNITION:
return_text = "ERR_RECOGNITION";
break;
case Epos2CallbackCode.CODE_ERR_READ:
return_text = "ERR_READ";
break;
case Epos2CallbackCode.CODE_ERR_NOISE_DETECTED:
return_text = "ERR_NOISE_DETECTED";
break;
case Epos2CallbackCode.CODE_ERR_PAPER_JAM:
return_text = "ERR_PAPER_JAM";
break;
case Epos2CallbackCode.CODE_ERR_PAPER_PULLED_OUT:
return_text = "ERR_PAPER_PULLED_OUT";
break;
case Epos2CallbackCode.CODE_ERR_CANCEL_FAILED:
return_text = "ERR_CANCEL_FAILED";
break;
case Epos2CallbackCode.CODE_ERR_PAPER_TYPE:
return_text = "ERR_PAPER_TYPE";
break;
case Epos2CallbackCode.CODE_ERR_WAIT_INSERTION:
return_text = "ERR_WAIT_INSERTION";
break;
case Epos2CallbackCode.CODE_ERR_ILLEGAL:
return_text = "ERR_ILLEGAL";
break;
case Epos2CallbackCode.CODE_ERR_INSERTED:
return_text = "ERR_INSERTED";
break;
case Epos2CallbackCode.CODE_ERR_WAIT_REMOVAL:
return_text = "ERR_WAIT_REMOVAL";
break;
case Epos2CallbackCode.CODE_ERR_DEVICE_BUSY:
return_text = "ERR_DEVICE_BUSY";
break;
case Epos2CallbackCode.CODE_ERR_IN_USE:
return_text = "ERR_IN_USE";
break;
case Epos2CallbackCode.CODE_ERR_CONNECT:
return_text = "ERR_CONNECT";
break;
case Epos2CallbackCode.CODE_ERR_DISCONNECT:
return_text = "ERR_DISCONNECT";
break;
case Epos2CallbackCode.CODE_ERR_MEMORY:
return_text = "ERR_MEMORY";
break;
case Epos2CallbackCode.CODE_ERR_PROCESSING:
return_text = "ERR_PROCESSING";
break;
case Epos2CallbackCode.CODE_ERR_PARAM:
return_text = "ERR_PARAM";
break;
default:
return_text = String.format("%d", state);
break;
}
return return_text;
}
}
package w.soulofpluto.posstock;
import android.app.AlertDialog;
import android.bluetooth.BluetoothAdapter;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import com.google.firebase.FirebaseApp;
/*
Create by Ramesh Babu
*/
public class SplashActivity extends AppCompatActivity{
PreferenceManager preferenceManager;
BluetoothAdapter bluetoothAdapter;
private int REQUEST_ENABLE_BT = 1;
@Override
protected void onCreate(@Nullable Bundle savedInstanceState){
setContentView(R.layout.activity_splash);
preferenceManager = new PreferenceManager(this);
bluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
FirebaseApp.initializeApp(this);
//FirebaseCrashlytics.getInstance().setCrashlyticsCollectionEnabled(true);
//FirebaseApp.getInstance().setAutomaticResourceManagementEnabled(true);
//FirebaseCrashlytics.getInstance().setCrashlyticsCollectionEnabled(true);
//FirebaseApp.getInstance().
if(bluetoothAdapter!=null && bluetoothAdapter.isEnabled()){
runOnUiThread(() -> splashMethod());
//throw new RuntimeException("Test Crash");
}else{
//Constants.getToast(this,"Please Enable your bluetooth device");
try {
showDialog("Please Enable your bluetooth device");
} catch (Exception e) {
e.printStackTrace();
}
}
super.onCreate(savedInstanceState);
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == REQUEST_ENABLE_BT) {
if (resultCode == RESULT_OK) {
Constants.getToast(this,"BlueTooth Turned On");
runOnUiThread(new Runnable(){
@Override
public void run(){
splashMethod();
}
});
super.onCreate(savedInstanceState);
//Toast.makeText(MainActivity.this, "BlueTooth Turned On", Toast.LENGTH_LONG).show();
} else {
//Toast.makeText(MainActivity.this, "Cancelled", Toast.LENGTH_LONG).show();
Constants.getToast(this,"Cancelled");
}
}
}
public void showDialog(final String phone) throws Exception
{
AlertDialog.Builder builder = new AlertDialog.Builder(SplashActivity.this);
builder.setMessage(phone);
builder.setPositiveButton("OK", new DialogInterface.OnClickListener()
{
@Override
public void onClick(DialogInterface dialog, int which)
{
Intent enableBtIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE);
startActivityForResult(enableBtIntent, REQUEST_ENABLE_BT);
dialog.dismiss();
}
});
builder.setNegativeButton("Cancel", new DialogInterface.OnClickListener()
{
@Override
public void onClick(DialogInterface dialog, int which)
{
dialog.dismiss();
}
});
builder.show();
}
public void splashMethod(){
Handler handler = new Handler();
......@@ -33,7 +99,7 @@ public class SplashActivity extends AppCompatActivity{
/*startActivity(new Intent(SplashActivity.this, MainActivity.class));
finish();*/
if(preferenceManager.isLogged()){
startActivity(new Intent(SplashActivity.this, DashBoardActivity.class));
startActivity(new Intent(SplashActivity.this, HomeActivity.class));
finish();
}else{
startActivity(new Intent(SplashActivity.this, Login.class));
......
<vector android:height="24dp" android:viewportHeight="510"
android:viewportWidth="510" android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="#ffffff" android:pathData="M311.1,255l58.65,58.65c7.65,-17.851 10.2,-38.25 10.2,-58.65c0,-20.4 -5.101,-40.8 -10.2,-58.65L311.1,255zM446.25,119.85L415.65,153c15.3,30.6 25.5,66.3 25.5,102s-10.2,71.4 -25.5,102l30.6,30.6c25.5,-38.25 38.25,-86.699 38.25,-135.149S471.75,158.1 446.25,119.85zM349.35,145.35L204,0h-25.5v193.8L61.2,76.5l-35.7,35.7L168.3,255L25.5,397.8l35.7,35.7l117.3,-117.3V510H204l145.35,-145.35L239.7,255L349.35,145.35zM229.5,96.9l48.45,48.45L229.5,193.8V96.9zM277.95,364.65L229.5,413.1V316.2L277.95,364.65z"/>
</vector>
<vector android:height="24dp" android:viewportHeight="510"
android:viewportWidth="510" android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="#FF000000" android:pathData="M311.1,255l58.65,58.65c7.65,-17.851 10.2,-38.25 10.2,-58.65c0,-20.4 -5.101,-40.8 -10.2,-58.65L311.1,255zM446.25,119.85L415.65,153c15.3,30.6 25.5,66.3 25.5,102s-10.2,71.4 -25.5,102l30.6,30.6c25.5,-38.25 38.25,-86.699 38.25,-135.149S471.75,158.1 446.25,119.85zM349.35,145.35L204,0h-25.5v193.8L61.2,76.5l-35.7,35.7L168.3,255L25.5,397.8l35.7,35.7l117.3,-117.3V510H204l145.35,-145.35L239.7,255L349.35,145.35zM229.5,96.9l48.45,48.45L229.5,193.8V96.9zM277.95,364.65L229.5,413.1V316.2L277.95,364.65z"/>
</vector>
<vector android:height="24dp" android:viewportHeight="477.867"
android:viewportWidth="477.867" android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="#ffff" android:pathData="M409.6,0c-9.426,0 -17.067,7.641 -17.067,17.067v62.344C304.667,-5.656 164.478,-3.386 79.411,84.479c-40.09,41.409 -62.455,96.818 -62.344,154.454c0,9.426 7.641,17.067 17.067,17.067S51.2,248.359 51.2,238.933c0.021,-103.682 84.088,-187.717 187.771,-187.696c52.657,0.01 102.888,22.135 138.442,60.976l-75.605,25.207c-8.954,2.979 -13.799,12.652 -10.82,21.606s12.652,13.799 21.606,10.82l102.4,-34.133c6.99,-2.328 11.697,-8.88 11.674,-16.247v-102.4C426.667,7.641 419.026,0 409.6,0z"/>
<path android:fillColor="#ffff" android:pathData="M443.733,221.867c-9.426,0 -17.067,7.641 -17.067,17.067c-0.021,103.682 -84.088,187.717 -187.771,187.696c-52.657,-0.01 -102.888,-22.135 -138.442,-60.976l75.605,-25.207c8.954,-2.979 13.799,-12.652 10.82,-21.606c-2.979,-8.954 -12.652,-13.799 -21.606,-10.82l-102.4,34.133c-6.99,2.328 -11.697,8.88 -11.674,16.247v102.4c0,9.426 7.641,17.067 17.067,17.067s17.067,-7.641 17.067,-17.067v-62.345c87.866,85.067 228.056,82.798 313.122,-5.068c40.09,-41.409 62.455,-96.818 62.344,-154.454C460.8,229.508 453.159,221.867 443.733,221.867z"/>
</vector>
<vector android:height="48dp" android:viewportHeight="510.986"
android:viewportWidth="510.986" android:width="48dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="#ffffff" android:pathData="M447.486,0c-29.181,0 -54.575,20.226 -61.577,48H242.466c-10.55,0 -20.47,4.109 -27.931,11.569L9.212,264.893c-12.282,12.282 -12.282,32.266 0,44.548l192.333,192.333c6.141,6.141 14.208,9.211 22.274,9.211s16.133,-3.07 22.274,-9.211L451.417,296.45c7.46,-7.461 11.569,-17.38 11.569,-27.931V138.38c6.169,-3.172 12.003,-6.858 17.329,-11.102c20.065,-15.987 30.671,-38.042 30.671,-63.778C510.986,28.486 482.5,0 447.486,0zM447.986,268.52c0,6.544 -2.548,12.696 -7.176,17.324L235.486,491.168c-6.434,6.434 -16.901,6.434 -23.335,0L19.818,298.835c-6.433,-6.434 -6.433,-16.901 0,-23.335L225.142,70.176C229.77,65.548 235.922,63 242.466,63h189.02c9.098,0 16.5,7.402 16.5,16.5v49.274c-13.084,5.388 -27.495,8.491 -41.343,9.604C404.122,119.011 387.529,104 367.486,104c-21.78,0 -39.5,17.72 -39.5,39.5s17.72,39.5 39.5,39.5c18.316,0 33.756,-12.532 38.206,-29.471c14.033,-0.931 28.617,-3.722 42.294,-8.648V268.52zM365.81,150.811c7.258,1.663 15.357,2.669 23.906,2.97c-3.894,8.387 -12.392,14.22 -22.231,14.22c-13.509,0 -24.5,-10.991 -24.5,-24.5s10.991,-24.5 24.5,-24.5c11.904,0 21.847,8.535 24.044,19.805c-8.081,-0.195 -15.688,-1.085 -22.368,-2.616c-4.036,-0.927 -8.061,1.597 -8.986,5.635C359.25,145.862 361.773,149.885 365.81,150.811zM470.967,115.547c-2.523,2.01 -5.195,3.875 -7.981,5.608V79.5c0,-17.369 -14.131,-31.5 -31.5,-31.5h-29.964c6.542,-19.307 24.973,-33 45.964,-33c26.743,0 48.5,21.757 48.5,48.5C495.986,84.808 487.568,102.319 470.967,115.547z"/>
</vector>
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:background="@color/bg">
<androidx.appcompat.widget.Toolbar
android:id="@+id/main_toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="@drawable/background_all"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
app:theme="@style/ThemeOverlay.AppCompat"
app:elevation="0dp"
app:contentInsetEnd="0dp"
app:contentInsetLeft="0dp"
app:contentInsetRight="0dp"
app:contentInsetStart="0dp"
app:contentInsetStartWithNavigation="0dp"
app:titleTextColor="@android:color/white"
app:titleTextAppearance="@style/Toolbartitleheader">
</androidx.appcompat.widget.Toolbar>
<TextView
android:layout_below="@+id/main_toolbar"
android:id="@+id/store_location"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:layout_marginLeft="20dp"
android:layout_marginRight="15dp"
android:text="KLM"
android:textSize="18dp"
style="@style/textfont"
android:textColor="@android:color/black"/>
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/cust_num"
android:layout_marginTop="10dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/store_location"
android:layout_marginLeft="15dp"
android:layout_marginRight="15dp">
<EditText
android:id="@+id/cust_number"
android:layout_below="@+id/cust_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Mobile Number"
android:inputType="number"
android:textSize="16dp"
style="@style/textfont"
android:maxLength="10"
android:singleLine="true"/>
</com.google.android.material.textfield.TextInputLayout>
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/cust_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/cust_num"
android:layout_marginTop="10dp">
<EditText
android:id="@+id/cust_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Customer Name"
android:layout_marginLeft="15dp"
android:layout_marginRight="15dp"
style="@style/textfont"
android:textSize="16dp"
android:singleLine="true"/>
</com.google.android.material.textfield.TextInputLayout>
<LinearLayout
android:id="@+id/layout_ds"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/cust_layout"
android:weightSum="1"
android:gravity="center"
android:layout_marginLeft="20dp"
android:layout_marginRight="15dp">
<com.google.android.material.textfield.TextInputLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:id="@+id/ds"
android:layout_below="@+id/cust_num"
android:layout_weight="0.8">
<EditText
android:id="@+id/ds_Number"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="number"
android:layout_marginRight="15dp"
android:singleLine="true"
android:paddingLeft="8dp"
android:textSize="16dp"
style="@style/textfont"
android:hint="Delivery Slip Number"
android:layout_gravity="center"/>
</com.google.android.material.textfield.TextInputLayout>
<Button
android:id="@+id/send"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="Add"
android:layout_weight="0.2"
android:minHeight="45dp"
android:layout_gravity="center"
style="@style/textfont"
android:background="@drawable/background_all"
android:textColor="@android:color/white"
/>
</LinearLayout>
<LinearLayout
android:id="@+id/layout"
android:layout_below="@+id/layout_ds"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_margin="20dp"
android:visibility="gone">
<LinearLayout
android:id="@+id/data"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:visibility="invisible">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:weightSum="1"
android:layout_marginTop="10dp"
>
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="Gross Amount"
android:layout_weight="0.4"
style="@style/textfont"
android:textColor="@android:color/black"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=":"
style="@style/textfont"
android:textColor="@android:color/black"/>
<TextView
android:id="@+id/gross_amount"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="Gross Amount"
android:layout_weight="0.6"
style="@style/textfont"
android:textColor="@android:color/black"
android:layout_marginLeft="10dp"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:weightSum="1"
android:layout_marginTop="10dp"
>
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="Discount Amount"
style="@style/textfont"
android:layout_weight="0.4"
android:textColor="@android:color/black"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=":"
style="@style/textfont"
android:textColor="@android:color/black"/>
<TextView
android:id="@+id/discount_amount"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="Discount Amount"
style="@style/textfont"
android:layout_weight="0.6"
android:textColor="@android:color/black"
android:layout_marginLeft="10dp"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:weightSum="1"
android:layout_marginTop="10dp"
>
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="Round Off"
style="@style/textfont"
android:layout_weight="0.4"
android:textColor="@android:color/black"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=":"
style="@style/textfont"
android:textColor="@android:color/black"/>
<TextView
android:id="@+id/round_off"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="RoundOff"
style="@style/textfont"
android:layout_weight="0.6"
android:textColor="@android:color/black"
android:layout_marginLeft="10dp"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:weightSum="1"
android:layout_marginTop="10dp"
>
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="Net Amount"
android:layout_weight="0.4"
android:textColor="@android:color/black"
style="@style/textfont"
android:textSize="18dp"
android:textStyle="bold"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=":"
android:textColor="@android:color/black"
style="@style/textfont"
android:textSize="18dp"
android:textStyle="bold"/>
<TextView
android:id="@+id/netamount"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="Net Amount"
android:layout_weight="0.6"
android:textColor="@android:color/black"
style="@style/textfont"
android:layout_marginLeft="10dp"
android:textSize="18dp"
android:textStyle="bold"/>
</LinearLayout>
</LinearLayout>
<Button
android:id="@+id/generate_invoice"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=" Generate Invoice "
android:textAllCaps="false"
android:background="@drawable/background_all"
android:textColor="@android:color/white"
android:textSize="16dp"
style="@style/textfont"
android:layout_marginRight="5dp"
android:layout_marginTop="10dp"/>
<Button
android:id="@+id/pluto_Print"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="@android:color/white"
android:background="@android:color/holo_blue_dark"
android:layout_marginTop="15dp"
android:layout_alignParentBottom="true"
android:text="PRINT"
style="@style/textfont"
android:visibility="gone"
android:minHeight="40dp"/>
<androidx.recyclerview.widget.RecyclerView
android:layout_marginTop="15dp"
android:id="@+id/ds_list"
android:layout_width="match_parent"
android:layout_height="wrap_content">
</androidx.recyclerview.widget.RecyclerView>
<!-- <ListView
android:layout_marginTop="15dp"
android:id="@+id/ds_list"
android:layout_width="match_parent"
android:layout_height="match_parent">
</ListView>-->
</LinearLayout>
</RelativeLayout>
\ No newline at end of file
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/bg">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_above="@+id/layout"
android:layout_alignParentTop="true">
<androidx.appcompat.widget.Toolbar
android:id="@+id/createdeliveryslip_toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="@drawable/background_all"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
app:contentInsetEnd="0dp"
app:contentInsetLeft="0dp"
app:contentInsetRight="0dp"
app:contentInsetStart="0dp"
app:contentInsetStartWithNavigation="0dp"
app:elevation="0dp"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
app:theme="@style/ThemeOverlay.AppCompat"
app:titleTextAppearance="@style/Toolbartitleheader"
app:titleTextColor="@android:color/white"></androidx.appcompat.widget.Toolbar>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<androidx.cardview.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="5dp"
app:cardCornerRadius="3dp">
<LinearLayout
android:id="@+id/header_items"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:visibility="gone">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:orientation="horizontal">
<TextView
android:id="@+id/totalItems"
style="@style/textfont"
android:layout_width="0dp"
android:textStyle="bold"
android:layout_height="wrap_content"
android:layout_weight="0.50" />
<TextView
android:id="@+id/totalMrp"
style="@style/textfont"
android:layout_width="0dp"
android:textStyle="bold"
android:layout_height="wrap_content"
android:layout_weight="0.50" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:orientation="horizontal">
<TextView
android:id="@+id/totalDis"
style="@style/textfont"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.50"
android:text="Total Disc"
android:visibility="invisible" />
<TextView
android:id="@+id/totalNetMrp"
style="@style/textfont"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.50"
android:text="Net MRP"
android:visibility="invisible" />
</LinearLayout>
</LinearLayout>
</androidx.cardview.widget.CardView>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:orientation="horizontal"
android:weightSum="1">
<CheckBox
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/checked"/>
<com.google.android.material.textfield.TextInputLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.30">
<EditText
android:id="@+id/emp_id"
style="@style/textfont"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:hint="Sales Person"
android:singleLine="true"
android:textColor="@android:color/black" />
</com.google.android.material.textfield.TextInputLayout>
<com.google.android.material.textfield.TextInputLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.70">
<EditText
android:id="@+id/barcode_enter"
style="@style/textfont"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginRight="5dp"
android:hint="Barcode"
android:singleLine="true"
android:textColor="@android:color/black" />
</com.google.android.material.textfield.TextInputLayout>
</LinearLayout>
</LinearLayout>
<!-- <androidx.cardview.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/bg">
</androidx.cardview.widget.CardView> -->
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/deliveryslip_list"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="3dp"
android:layout_above="@+id/layout">
</androidx.recyclerview.widget.RecyclerView>
</LinearLayout>
<LinearLayout
android:id="@+id/layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_alignParentBottom="true">
<Button
android:id="@+id/valid"
style="@style/textfont"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_margin="3dp"
android:background="@drawable/background_all"
android:text="@string/resolve_promotions"
android:textColor="@android:color/white"
android:visibility="gone" />
<Button
android:id="@+id/valid_print"
style="@style/textfont"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_margin="3dp"
android:background="@drawable/background_all"
android:text="@string/print"
android:textColor="@android:color/white"
android:visibility="gone" />
</LinearLayout>
</RelativeLayout>
\ No newline at end of file
......@@ -60,6 +60,19 @@
android:padding="10dp"/>
<Button
android:id="@+id/transfer"
android:layout_width="200dp"
android:layout_height="wrap_content"
android:text="@string/transfer"
android:layout_margin="10dp"
style="@style/headerfont"
android:textColor="@android:color/white"
android:background="@drawable/background_all"
android:padding="10dp"
android:visibility="gone"/>
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content">
......
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" android:background="#FFFFFF">
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/btn_restart"
android:id="@+id/btnRestart"
android:layout_marginBottom="10dp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/title_printerlist"
android:id="@+id/txtList"
android:layout_marginTop="5dp"
android:textColor="#000000" />
<ListView
android:id="@+id/lstReceiveData"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:cacheColorHint="#ffffff">
</ListView>
</LinearLayout>
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/bg">
<androidx.appcompat.widget.Toolbar
android:id="@+id/home_toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="@drawable/background_all"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
app:theme="@style/ThemeOverlay.AppCompat"
app:elevation="0dp"
app:contentInsetEnd="0dp"
app:contentInsetLeft="0dp"
app:contentInsetRight="0dp"
app:contentInsetStart="0dp"
app:contentInsetStartWithNavigation="0dp"
app:titleTextColor="@android:color/white"
app:titleTextAppearance="@style/Toolbartitleheader">
</androidx.appcompat.widget.Toolbar>
<!-- <LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<RelativeLayout
android:id="@+id/layout"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.50"
android:gravity="center"
android:background="@android:color/white"
android:layout_margin="2dp">
<ImageView
android:id="@+id/image"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@mipmap/ic_launcher"
android:layout_centerHorizontal="true"
android:layout_margin="5dp"
/>
<TextView
android:layout_below="@+id/image"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Create Delivery Slip"
style="@style/textfont"
android:layout_centerHorizontal="true"
android:layout_margin="5dp"/>
</RelativeLayout>
<RelativeLayout
android:id="@+id/layout1"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.50"
android:gravity="center"
android:background="@android:color/white"
android:layout_margin="2dp">
<ImageView
android:id="@+id/image1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@mipmap/ic_launcher"
android:layout_centerHorizontal="true"
android:layout_margin="5dp"
/>
<TextView
android:layout_below="@+id/image1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:text="Stock Audit"
style="@style/textfont"
android:layout_margin="5dp"/>
</RelativeLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<RelativeLayout
android:id="@+id/layout2"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.50"
android:gravity="center"
android:background="@android:color/white"
android:layout_margin="2dp">
<ImageView
android:id="@+id/image2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@mipmap/ic_launcher"
android:layout_centerHorizontal="true"
android:layout_margin="5dp"
/>
<TextView
android:layout_below="@+id/image2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Create Delivery Slip"
style="@style/textfont"
android:layout_centerHorizontal="true"
android:layout_margin="5dp"/>
</RelativeLayout>
<RelativeLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.50"
android:layout_margin="2dp">
</RelativeLayout>
</LinearLayout>
-->
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/menu_list"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
<TextView
android:id="@+id/version"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:text="Version : 1.0"
android:layout_alignParentRight="true"
style="@style/textfont"
android:layout_margin="10dp"
/>
</RelativeLayout>
</LinearLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<androidx.cardview.widget.CardView android:layout_width="match_parent"
android:layout_height="wrap_content"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_margin="3dp"
app:cardCornerRadius="3dp"
xmlns:android="http://schemas.android.com/apk/res/android">
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:weightSum="1"
android:layout_gravity="center"
android:layout_margin="5dp">
<TextView
android:id="@+id/Id"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.7"
android:textSize="16dp"
style="@style/textfont"
android:textColor="@android:color/black"
android:layout_gravity="center"/>
<ImageView
android:id="@+id/remove"
android:layout_width="wrap_content"
android:contentDescription="TODO"
android:layout_height="wrap_content"
android:background="@drawable/ic_delete"
android:layout_gravity="center"/>
</LinearLayout>
</LinearLayout>
</androidx.cardview.widget.CardView>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<androidx.cardview.widget.CardView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_margin="5dp"
android:background="@color/bg"
app:cardCornerRadius="3dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:id="@+id/item_level_promotion"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
style="@style/textfont"
android:textStyle="bold"
android:layout_margin="5dp"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:weightSum="1"
android:layout_margin="5dp">
<TextView
android:id="@+id/create_barcode"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.50"
android:layout_marginRight="5dp"
style="@style/textfont"/>
<TextView
android:id="@+id/create_empid"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.50"
android:layout_marginLeft="5dp"
style="@style/textfont"/>
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="@color/bg"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:weightSum="1"
android:layout_margin="5dp">
<TextView
android:id="@+id/create_mrp"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.50"
android:layout_marginRight="5dp"
style="@style/textfont"/>
<TextView
android:id="@+id/create_dis"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.50"
android:layout_marginLeft="5dp"
style="@style/textfont"/>
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="@color/bg"/>
<TextView
android:id="@+id/create_netpay"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
style="@style/textfont"
android:layout_margin="5dp"/>
</LinearLayout>
</androidx.cardview.widget.CardView>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_gravity="bottom"
android:layout_margin="10dp">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="15dp"
android:text="Select Payment Method"
style="@style/textfont"
android:textSize="18sp"
android:textStyle="bold"
android:textColor="@android:color/black"/>
<ImageView
android:id="@+id/dialog_close"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@android:drawable/ic_menu_close_clear_cancel"
android:layout_alignParentRight="true"
android:layout_centerInParent="true"/>
</RelativeLayout>
<Spinner
android:id="@+id/bank_names"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:layout_marginBottom="10dp"
>
</Spinner>
<com.google.android.material.textfield.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<EditText
android:id="@+id/last_four_digits"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Enter last four digits"
android:layout_margin="10dp"
android:maxLength="4"
style="@style/textfont"
android:inputType="number"/>
</com.google.android.material.textfield.TextInputLayout>
<Button
android:id="@+id/bank_submit"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Submit"
android:layout_margin="10dp"
style="@style/textfont"
android:background="@drawable/background_all"
android:textColor="@android:color/white"/>
</LinearLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<TwoLineListItem xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:mode="twoLine"
android:orientation="horizontal"
android:paddingBottom="2dip"
android:paddingTop="2dip" >
<TextView
android:id="@+id/PrinterName"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:textSize="30sp"
android:textColor="#000000" />
<TextView
android:id="@+id/Target"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/PrinterName"
android:layout_alignStart="@+id/PrinterName" android:layout_below="@+id/PrinterName"
android:layout_margin="5dp"
android:textSize="20sp"
android:textColor="#000000" />
</TwoLineListItem>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<androidx.cardview.widget.CardView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:background="@android:color/white"
app:cardCornerRadius="3dp"
android:layout_margin="3dp">
<LinearLayout
android:id="@+id/layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:gravity="center"
android:layout_margin="15dp">
<ImageView
android:id="@+id/menu_image"
android:src="@mipmap/ic_launcher"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<TextView
android:id="@+id/menu_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
style="@style/textfont"
android:textColor="@android:color/black"
android:text="name"/>
</LinearLayout>
</androidx.cardview.widget.CardView>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:layout_margin="5dp">
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@color/colorPrimary"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Bluetooth Devices List"
android:layout_margin="10dp"
android:textColor="@android:color/white"/>
<ImageView
android:id="@+id/refresh_bluetooth"
android:layout_width="wrap_content"
android:contentDescription="TODO"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:background="@drawable/ic_refresh"
android:layout_alignParentRight="true"
android:layout_margin="10dp"/>
</RelativeLayout>
<ListView
android:id="@+id/bluetooth_list"
android:layout_width="match_parent"
android:layout_height="match_parent">
</ListView>
</LinearLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<menu
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<item
android:id="@+id/dashboard_connection"
android:icon="@drawable/ic_bluetooth_signal_indicator"
android:title="connection"
app:showAsAction="always"/>
<!-- <item
android:id="@+id/option1"
android:orderInCategory="1"
android:title="Connected"
android:icon="@drawable/ic_bluetooth_indicator"
app:showAsAction="ifRoom|collapseActionView"/>-->
<item
android:id="@+id/dashboard_reload"
android:icon="@drawable/ic_refresh"
android:title="Reload"
app:showAsAction="always"/>
<item
android:id="@+id/dashboard_logout"
android:icon="@drawable/ic_power"
android:title="Delete"
app:showAsAction="always"/>
</menu>
\ No newline at end of file
......@@ -18,6 +18,7 @@
<string name="no_stores">No Stores Available</string>
<string name="login">Login</string>
<string name="dashboard">DashBoard</string>
<string name="home">Home</string>
<string name="test">Plans List</string>
<string name="spalsh">Splash Screen</string>
......@@ -27,6 +28,7 @@
<string name="stockaudit"> Stock Audit Plans </string>
<string name="rackreport"> Rack Wise Qty </string>
<string name="searchbarcode"> SEARCH BY BARCODE </string>
<string name="transfer"> STOCK TRANSFER </string>
<string name="ok"> OK </string>
<string name="relogin"> ReLogin </string>
<string name="pieces">Pieces</string>
......@@ -55,7 +57,116 @@
<string name="plan_details">Plan Details</string>
<string name="key">key</string>
<string name="action">action</string>
<string name="promotions">clear_promotion</string>
<string name="barcode_name">barcode</string>
<string name="apply_promotion">apply_promotion_on_scan</string>
<string name="qty_name">quantity</string>
<string name="items">delivery_slip_items</string>
<string name="create_title">Create Delivery Slip</string>
<string name="resolve_promotions">Resolve Promotions</string>
<string name="save">Save</string>
<string name="print">Print</string>
<string name="totalqty">total_qty</string>
<string name="netpayable">net_payable</string>
<!--<string name="section"><font color=#cc0029>SECTION :</font></string>-->
<string name="scanning">Barcode Scanning...</string>
<string name="btn_discovery">Discovery</string>
<string name="title_target">Target</string>
<string name="title_printerseries">Printer Series</string>
<string name="title_lang">Lang</string>
<string name="btn_samplereceipt">Sample Receipt</string>
<string name="btn_samplecoupon">Sample Coupon</string>
<string name="btn_restart">Restart</string>
<string name="title_activity_discovery">DiscoveryActivity</string>
<string name="title_printerlist">Printer List</string>
<string name="default_target">TCP:192.168.192.168</string>
<string name="title_warnings">Printer Warnings</string>
<string name="print_job_id">ABC123</string>
<string name="title_err_code">Error Code</string>
<string name="title_err_method">Method</string>
<string name="title_msg_result">Result</string>
<string name="title_msg_description">Description</string>
<string name="printerseries_m10">TM-m10 Series</string>
<string name="printerseries_m30">TM-m30 Series</string>
<string name="printerseries_p20">TM-P20 Series</string>
<string name="printerseries_p60">TM-P60 Series</string>
<string name="printerseries_p60ii">TM-P60II Series</string>
<string name="printerseries_p80">TM-P80 Series</string>
<string name="printerseries_t20">TM-T20 Series</string>
<string name="printerseries_t60">TM-T60 Series</string>
<string name="printerseries_t70">TM-T70 Series</string>
<string name="printerseries_t81">TM-T81 Series</string>
<string name="printerseries_t82">TM-T82 Series</string>
<string name="printerseries_t83">TM-T83 Series</string>
<string name="printerseries_t83iii">TM-T83III Series</string>
<string name="printerseries_t88">TM-T88 Series</string>
<string name="printerseries_t90">TM-T90 Series</string>
<string name="printerseries_t90kp">TM-T90KP Series</string>
<string name="printerseries_t100">TM-T100 Series</string>
<string name="printerseries_u220">TM-U220 Series</string>
<string name="printerseries_u330">TM-U330 Series</string>
<string name="printerseries_l90">TM-L90 Series</string>
<string name="printerseries_h6000">TM-H6000 Series</string>
<string name="printSpeed_1">1</string>
<string name="printSpeed_2">2</string>
<string name="printSpeed_3">3</string>
<string name="printSpeed_4">4</string>
<string name="printSpeed_5">5</string>
<string name="printSpeed_6">6</string>
<string name="printSpeed_7">7</string>
<string name="printSpeed_8">8</string>
<string name="printSpeed_9">9</string>
<string name="printSpeed_10">10</string>
<string name="printSpeed_11">11</string>
<string name="printSpeed_12">12</string>
<string name="printSpeed_13">13</string>
<string name="printSpeed_14">14</string>
<string name="printDensity_DIP">DIP</string>
<string name="printDensity_70">70%</string>
<string name="printDensity_75">75%</string>
<string name="printDensity_80">80%</string>
<string name="printDensity_85">85%</string>
<string name="printDensity_90">90%</string>
<string name="printDensity_95">95%</string>
<string name="printDensity_100">100%</string>
<string name="printDensity_105">105%</string>
<string name="printDensity_110">110%</string>
<string name="printDensity_115">115%</string>
<string name="printDensity_120">120%</string>
<string name="printDensity_125">125%</string>
<string name="printDensity_130">130%</string>
<string name="paperWidth_58">58mm</string>
<string name="paperWidth_60">60mm</string>
<string name="paperWidth_80">80mm</string>
<string name="lang_ank">ANK</string>
<string name="lang_japanese">JAPANESE</string>
<string name="lang_chinese">CHINESE</string>
<string name="lang_taiwan">TAIWAN</string>
<string name="lang_korean">KOREAN</string>
<string name="lang_thai">THAI</string>
<string name="lang_southasia">SOUTH ASIA</string>
<string name="action_settings">Settings</string>
<string name="handlingmsg_warn_receipt_near_end">Roll paper is nearly end.\n</string>
<string name="handlingmsg_warn_battery_near_end">Battery level of printer is low.\n</string>
<string name="handlingmsg_err_no_response">Please check the connection of the printer and the mobile terminal.\nConnection get lost.\n</string>
<string name="handlingmsg_err_cover_open">Please close roll paper cover.\n</string>
<string name="handlingmsg_err_receipt_end">Please check roll paper.\n</string>
<string name="handlingmsg_err_paper_feed">Please release a paper feed switch.\n</string>
<string name="handlingmsg_err_autocutter">Please remove jammed paper and close roll paper cover.\nRemove any jammed paper or foreign substances in the printer, and then turn the printer off and turn the printer on again.\n</string>
<string name="handlingmsg_err_need_recover">Then, If the printer doesn\'t recover from error, please cycle the power switch.\n</string>
<string name="handlingmsg_err_unrecover">Please cycle the power switch of the printer.\nIf same errors occurred even power cycled, the printer may out of order.</string>
<string name="handlingmsg_err_overheat">Please wait until error LED of the printer turns off. \n</string>
<string name="handlingmsg_err_head">Print head of printer is hot.\n</string>
<string name="handlingmsg_err_motor">Motor Driver IC of printer is hot.\n</string>
<string name="handlingmsg_err_battery">Battery of printer is hot.\n</string>
<string name="handlingmsg_err_wrong_paper">Please set correct roll paper.\n</string>
<string name="handlingmsg_err_battery_real_end">Please connect AC adapter or change the battery.\nBattery of printer is almost empty.\n</string>
<string name="handlingmsg_err_offline">Printer is offline.\n</string>
</resources>
\ No newline at end of file
......@@ -6,7 +6,7 @@ buildscript {
}
dependencies {
classpath "com.android.tools.build:gradle:4.0.1"
classpath 'com.google.gms:google-services:4.3.10'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
......
commit d63feb8fdb72f68521dd7549ad08cee51e87d815 (HEAD -> master, origin/master)
Author: User <ramesh.puvvadi@gmail.com>
Date: Tue Mar 9 15:26:47 2021 +0530
few changes
commit 2db0454684c6aa50ae9003313dd46ba97fe5ec39
Author: User <ramesh.puvvadi@gmail.com>
Date: Tue Mar 2 14:09:07 2021 +0530
added keyboard open searchbybarcode
commit 40384fd7c5a43b38bc1cf7d16063f7a34be26af3
Author: User <ramesh.puvvadi@gmail.com>
Date: Mon Feb 22 13:12:48 2021 +0530
initial commit
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