Commit 167ae635 authored by Nastuzzi Samy's avatar Nastuzzi Samy

Improvments

Use GESSALES route to cancel if it is possible (to indicate who canceled)
Better edit management
Better right management
parent e73c95e7
......@@ -6,6 +6,7 @@ import android.app.AlarmManager;
import android.app.DownloadManager;
import android.app.PendingIntent;
import android.content.BroadcastReceiver;
import android.content.ComponentName;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
......@@ -102,8 +103,17 @@ public abstract class BaseActivity extends InternetActivity {
});
}
protected void hasRights(final String title, final String[] rightList, final Runnable runnable) { hasRights(title, rightList, false, runnable);}
protected void hasRights(final String title, final String[] rightList, final boolean needToBeSuper, final Runnable runnable) {
protected void hasRights(final String title, final String[] rightList, final Runnable runnablePos) { hasRights(title, rightList, false, runnablePos);}
protected void hasRights(final String title, final String[] rightList, final boolean needToBeSuper, final Runnable runnablePos) {
hasRights(title, rightList, false, runnablePos, new Runnable() {
@Override
public void run() {
dialog.errorDialog(BaseActivity.this, title, nemopaySession.forbidden(rightList, needToBeSuper));
}
});
}
protected void hasRights(final String title, final String[] rightList, final Runnable runnablePos, final Runnable runnableNeg) { hasRights(title, rightList, false, runnablePos, runnableNeg);}
protected void hasRights(final String title, final String[] rightList, final boolean needToBeSuper, final Runnable runnablePos, final Runnable runnableNeg) {
dialog.startLoading(BaseActivity.this, getString(R.string.information_collection), getString(R.string.user_rights_list_collecting));
new Thread() {
@Override
......@@ -130,7 +140,7 @@ public abstract class BaseActivity extends InternetActivity {
@Override
public void run() {
dialog.stopLoading();
runnable.run();
runnablePos.run();
}
});
......@@ -149,7 +159,7 @@ public abstract class BaseActivity extends InternetActivity {
@Override
public void run() {
dialog.stopLoading();
runnable.run();
runnablePos.run();
}
});
else {
......@@ -157,7 +167,7 @@ public abstract class BaseActivity extends InternetActivity {
@Override
public void run() {
dialog.stopLoading();
dialog.errorDialog(BaseActivity.this, title, nemopaySession.forbidden(rightList, needToBeSuper));
runnableNeg.run();
}
});
}
......
......@@ -139,7 +139,27 @@ public class BuyerInfoActivity extends BaseActivity {
@Override
public void run() {
try {
nemopaySession.cancelTransaction(article.get("fundation_id").intValue(), article.get("purchase_id").intValue());
hasRights(getString(R.string.configurate), new String[]{
"GESSALES"
}, new Runnable() {
@Override
public void run() {
try {
nemopaySession.cancelTransaction(article.get("fundation_id").intValue(), article.get("purchase_id").intValue(), true);
} catch (Exception e) {
Log.e(LOG_TAG, "error: " + e.getMessage());
}
}
}, new Runnable() {
@Override
public void run() {
try {
nemopaySession.cancelTransaction(article.get("fundation_id").intValue(), article.get("purchase_id").intValue(), false);
} catch (Exception e) {
Log.e(LOG_TAG, "error: " + e.getMessage());
}
}
});
Thread.sleep(100);
runOnUiThread(new Runnable() {
......
......@@ -145,7 +145,20 @@ public class EditActivity extends ArticleGroupActivity {
switchCotisant.setChecked(config.getPrintCotisant());
swtich18.setChecked(config.getPrint18());
configButton.setVisibility(View.GONE);
configButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(final View view) {
hasRights(getString(R.string.configurate), new String[]{
"STAFF",
"GESAPPLICATIONS"
}, new Runnable() {
@Override
public void run() {
configDialog();
}
});
}
});
final AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(EditActivity.this);
alertDialogBuilder
......
......@@ -183,7 +183,7 @@ public class SellActivity extends ArticleGroupActivity {
configButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(final View view) {
hasRights(getString(R.string.configurate_by_default), new String[]{
hasRights(getString(R.string.configurate), new String[]{
"STAFF",
"GESAPPLICATIONS"
}, new Runnable() {
......
......@@ -216,21 +216,36 @@ public class NemopaySession {
}
);
}
public int cancelTransaction(final int foundationId, final int purchaseId) throws Exception {
public int cancelTransaction(final int foundationId, final int purchaseId) throws Exception { return cancelTransaction(foundationId, purchaseId, false); }
public int cancelTransaction(final int foundationId, final int purchaseId, final boolean hasSalesRights) throws Exception {
if (!isConnected())
throw new Exception(this.notLogged);
return request(
"POSS3",
"cancel",
new HashMap<String, Object>() {{
put("fun_id", foundationId);
put("pur_id", purchaseId);
}},
new String[]{
"POSS3"
}
);
if (hasSalesRights)
return request(
"POSS3",
"cancel",
new HashMap<String, Object>() {{
put("fun_id", foundationId);
put("pur_id", purchaseId);
}},
new String[]{
"POSS3"
}
);
else
return request(
"GESSALES",
"cancelTransactionRow",
new HashMap<String, Object>() {{
put("fun_id", foundationId);
put("pur_id", purchaseId);
}},
new String[]{
"POSS3",
"GESSALES"
}
);
}
public int setTransaction(final String badgeId, final List<List<Integer>> articleList) throws Exception { return setTransaction(badgeId, articleList, this.foundationId); }
......
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