From 1902fc6a8c36c58eb7f6067058e7a4bfc356faf9 Mon Sep 17 00:00:00 2001 From: malinowskikam Date: Thu, 14 Oct 2021 11:19:45 +0200 Subject: [PATCH] Assigning bulk cn fixed --- app/src/main/assets/pages/Policy.js | 1 - .../openimis/imispolicies/MainActivity.java | 143 ------------------ .../org/openimis/imispolicies/SQLHandler.java | 6 +- 3 files changed, 3 insertions(+), 147 deletions(-) diff --git a/app/src/main/assets/pages/Policy.js b/app/src/main/assets/pages/Policy.js index 63115e82..9a97ff65 100644 --- a/app/src/main/assets/pages/Policy.js +++ b/app/src/main/assets/pages/Policy.js @@ -44,7 +44,6 @@ $(document).ready(function () { $('#txtExpiryDate').val(ExpiryDate); if(Android.IsBulkCNUsed()) { - console.log(typeof $Policy[0]["ControlNumber"]); if($Policy[0]["ControlNumber"]) { $('#AssignedControlNumber').val($Policy[0]["ControlNumber"]).prop('readonly', true); } else { diff --git a/app/src/main/java/org/openimis/imispolicies/MainActivity.java b/app/src/main/java/org/openimis/imispolicies/MainActivity.java index 33ed7d61..9d344180 100644 --- a/app/src/main/java/org/openimis/imispolicies/MainActivity.java +++ b/app/src/main/java/org/openimis/imispolicies/MainActivity.java @@ -426,29 +426,6 @@ public void onClick(DialogInterface dialog, int id) { } }); -// Showing Alert Dialog - alertDialog2.show(); - } - - public void openDialogMsg(String msg) { - AlertDialog.Builder alertDialog2 = new AlertDialog.Builder( - MainActivity.this); - -// Setting Dialog Title - alertDialog2.setTitle(getResources().getString(R.string.Incomplete)); - alertDialog2.setMessage(msg); - -// Setting Icon to Dialog - // alertDialog2.setIcon(R.drawable.delete); - -// Setting Positive "Yes" Btn - alertDialog2.setPositiveButton(getResources().getString(R.string.Ok), - new DialogInterface.OnClickListener() { - public void onClick(DialogInterface dialog, int which) { - // Write your code here to execute after dialog - } - }); - // Showing Alert Dialog alertDialog2.show(); } @@ -619,44 +596,6 @@ public String getMasterDataText2(String fileName, String password) { return aBuffer; } - public String getMasterDataText(String filename) { - ca.unZip(filename); - String fname = "MasterData.txt"; - try { - String dir = global.getSubdirectory("Database"); - File myFile = new File(dir, fname);//"/"+dir+"/MasterData.txt" -// BufferedReader myReader = new BufferedReader( -// new InputStreamReader( -// new FileInputStream(myFile), "UTF32")); - FileInputStream fIn = new FileInputStream(myFile); - BufferedReader myReader = new BufferedReader(new InputStreamReader(fIn)); - aBuffer = myReader.readLine(); - - myReader.close(); -/* Scanner in = new Scanner(new FileReader("/"+dir+"/MasterData.txt")); - StringBuilder sb = new StringBuilder(); - while(in.hasNext()) { - sb.append(in.next()); - } - in.close(); - aBuffer = sb.toString();*/ - } catch (IOException e) { - e.printStackTrace(); - } - return aBuffer; - } - - private int getCheckedMenuItem() { - Menu menu = navigationView.getMenu(); - for (int i = 0; i < menu.size(); i++) { - MenuItem menuItem = menu.getItem(i); - if (menuItem.isChecked()) - return menuItem.getItemId(); - } - return -1; - } - - private boolean copyDatabase(Context context) { try { InputStream inputStream = getApplicationContext().getAssets().open("database/" + SQLHandler.DBNAME); @@ -985,88 +924,6 @@ public static boolean hasPermissions(Context context, String... permissions) { return true; } - public void LoginDialogBox(final String page) { - if (!ca.CheckInternetAvailable()) - return; - - global = (Global) MainActivity.this.getApplicationContext(); - // get prompts.xml view - LayoutInflater li = LayoutInflater.from(this); - View promptsView = li.inflate(R.layout.login_dialog, null); - - AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(this); - - // set prompts.xml to alertdialog builder - alertDialogBuilder.setView(promptsView); - - final TextView username = (TextView) promptsView.findViewById(R.id.UserName); - final TextView password = (TextView) promptsView.findViewById(R.id.Password); - - username.setText(global.getOfficerCode()); - - // set dialog message - alertDialogBuilder - .setCancelable(false) - .setPositiveButton(MainActivity.this.getResources().getString(R.string.button_ok), - new DialogInterface.OnClickListener() { - public void onClick(DialogInterface dialog, int id) { - if (!username.getText().toString().equals("") && !password.getText().toString().equals("")) { - - new Thread() { - public void run() { - ClientAndroidInterface cai = new ClientAndroidInterface(context); - isUserLogged = cai.LoginToken(username.getText().toString(), password.getText().toString()); - - runOnUiThread(new Runnable() { - @Override - public void run() { - SetLoggedIn(MainActivity.this.getResources().getString(R.string.Login), MainActivity.this.getResources().getString(R.string.Logout)); - } - }); - - runOnUiThread(new Runnable() { - @Override - public void run() { - if (isUserLogged) { - if (page.equals("Enquire")) { - Intent intent = new Intent(MainActivity.this, Enquire.class); - startActivity(intent); - Toast.makeText(MainActivity.this, MainActivity.this.getResources().getString(R.string.Login_Successful), Toast.LENGTH_LONG).show(); - } - if (page.equals("Reports")) { - Intent intent = new Intent(MainActivity.this, Reports.class); - startActivity(intent); - Toast.makeText(MainActivity.this, MainActivity.this.getResources().getString(R.string.Login_Successful), Toast.LENGTH_LONG).show(); - } - - } else { - ca.ShowDialog(MainActivity.this.getResources().getString(R.string.LoginFail)); - } - } - }); - - } - }.start(); - - - } else { - Toast.makeText(MainActivity.this, MainActivity.this.getResources().getString(R.string.Enter_Credentials), Toast.LENGTH_LONG).show(); - } - } - }).setNegativeButton(MainActivity.this.getResources().getString(R.string.button_cancel), - new DialogInterface.OnClickListener() { - public void onClick(DialogInterface dialog, int id) { - dialog.cancel(); - } - }); - - // create alert dialog - AlertDialog alertDialog = alertDialogBuilder.create(); - - // show it - alertDialog.show(); - } - public String getSelectedLanguage() { return selectedLanguage; } diff --git a/app/src/main/java/org/openimis/imispolicies/SQLHandler.java b/app/src/main/java/org/openimis/imispolicies/SQLHandler.java index 06f089ed..747c7a8d 100644 --- a/app/src/main/java/org/openimis/imispolicies/SQLHandler.java +++ b/app/src/main/java/org/openimis/imispolicies/SQLHandler.java @@ -863,13 +863,13 @@ public int getFreeCNCount(String officerCode, String productCode) { public int getAssignedCNCount(String officerCode) { return getCount(tblBulkControlNumbers, - "PolicyId IS NOT NULL AND OfficerCode = ?", + "PolicyId IS NOT NULL AND UPPER(OfficerCode) = UPPER(?)", new String[]{officerCode}); } public int getFreeCNCount(String officerCode) { return getCount(tblBulkControlNumbers, - "PolicyId IS NULL AND OfficerCode = ?", + "PolicyId IS NULL AND UPPER(OfficerCode) = UPPER(?)", new String[]{officerCode}); } @@ -957,7 +957,7 @@ public boolean assignCnToPolicy(int policyId, String controlNumber) { } else { openDatabase(); JSONArray policyData = cursorToJsonArray(mDatabase.rawQuery( - "SELECT po.PolicyValue, UPPER(pr.ProductCode) FROM tblPolicy po INNER JOIN tblProduct pr on pr.ProdId=po.ProdIdgit s WHERE PolicyId = ?", + "SELECT po.PolicyValue, UPPER(pr.ProductCode) as ProductCode FROM tblPolicy po INNER JOIN tblProduct pr on pr.ProdId=po.ProdId WHERE PolicyId = ?", new String[]{String.valueOf(policyId)})); if (policyData.length() == 0) {