Commit 9794eeb3 authored by Nastuzzi Samy's avatar Nastuzzi Samy
Browse files

Card management

Prepare to add contributions
Prepare to add accounts
parent b38dc7ba
......@@ -39,7 +39,7 @@
<activity android:name=".BuyerInfoActivity"
android:configChanges="orientation"
android:screenOrientation="portrait" />
<activity android:name=".ReadCardInfoActivity"
<activity android:name=".CardManagementActivity"
android:configChanges="orientation"
android:screenOrientation="portrait" />
</application>
......
package fr.utc.simde.payutc;
import android.app.Activity;
import android.app.ProgressDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.support.v7.app.AlertDialog;
import android.util.Log;
import android.view.View;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;
import com.fasterxml.jackson.databind.JsonNode;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
import java.util.Locale;
import fr.utc.simde.payutc.tools.CASConnexion;
import fr.utc.simde.payutc.tools.Config;
......@@ -395,11 +387,11 @@ public abstract class BaseActivity extends NFCActivity {
}.start();
}
protected void startReadCardInfoActivity(final Activity activity) {
protected void startCardManagementActivity(final Activity activity) {
hasRights(getString(R.string.user_rights_list_collecting), new String[]{"STAFF", "POSS3", "GESUSERS"}, new Runnable() {
@Override
public void run() {dialog.startLoading(activity, activity.getResources().getString(R.string.information_collection), activity.getResources().getString(R.string.buyer_info_collecting));
activity.startActivity(new Intent(activity, ReadCardInfoActivity.class));
activity.startActivity(new Intent(activity, CardManagementActivity.class));
}
});
}
......
......@@ -97,7 +97,7 @@ public class FoundationsOptionsActivity extends BaseActivity {
@Override
public void onItemClick(AdapterView<?> parent, View view, final int position, long id) {
if (position == 2)
startReadCardInfoActivity(FoundationsOptionsActivity.this);
startCardManagementActivity(FoundationsOptionsActivity.this);
else if (position == 6)
keyNemopayDialog();
else if (position == 7)
......
......@@ -3,6 +3,9 @@ package fr.utc.simde.payutc.tools;
import android.app.Activity;
import android.util.Log;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
......@@ -43,6 +46,23 @@ public class Ginger {
public HTTPRequest getRequest() { return this.request; }
public int addCotisation(final String login, final String paid) throws Exception {
return request(
login + "/cotisations",
new HashMap<String, String>() {{
put("debut", new SimpleDateFormat("yyyy-MM-dd").format(new Date()));
put("fin", (Integer.parseInt(new SimpleDateFormat("MM").format(new Date())) > 8 ? Integer.toString(Integer.parseInt(new SimpleDateFormat("yyyy").format(new Date())) + 1) : new SimpleDateFormat("yyyy").format(new Date())) + "-08-31");
put("montant", paid);
}}
);
}
public int getInfoFromBadge(final String badgeId) throws Exception {
return request(
"badge/" + badgeId
);
}
public int getInfo(final String login) throws Exception {
return request(
login
......@@ -50,14 +70,21 @@ public class Ginger {
}
protected int request(final String request) throws Exception { return request(request, new HashMap<String, String>()); }
protected int request(final String request, Map<String, String> getArgs) throws Exception {
protected int request(final String request, Map<String, String> postArgs) throws Exception {
Log.d(LOG_TAG, "url: " + url + request);
getArgs.put("key", this.key);
this.request = new HTTPRequest(url + request);
this.request.setGet(getArgs);
int responseCode = this.request.get();
int responseCode;
if (postArgs.size() == 0) {
this.request.setGet(new HashMap<String, String>(){{ put("key", key); }});
responseCode = this.request.get();
}
else {
postArgs.put("key", key);
this.request.setPost(postArgs);
responseCode = this.request.post();
}
if (responseCode == 200)
return 200;
......
......@@ -66,9 +66,6 @@ public class HTTPRequest {
try {
this.request = (HttpURLConnection) (new URL(this.url + get)).openConnection();
//this.request.setRequestMethod("GET");
//this.request.setRequestProperty("User-Agent", "Application PayUTC");
//this.request.setRequestProperty("Cookie", getCookiesHeader());
this.request.setUseCaches(false);
this.request.setDoInput(true);
updateCookies(this.request.getHeaderFields().get("Set-Cookie"));
......@@ -85,6 +82,7 @@ public class HTTPRequest {
}
}
this.request.disconnect();
return getResponseCode();
}
......@@ -127,6 +125,7 @@ public class HTTPRequest {
}
}
this.request.disconnect();
return getResponseCode();
}
......
......@@ -205,14 +205,32 @@
<TextView
android:layout_width="150dp"
android:layout_height="wrap_content"
android:textColor="#000000"
android:text="@string/short_tag" />
android:text="@string/short_tag"
android:textColor="#000000" />
<TextView
android:id="@+id/text_short_tag"
android:textColor="#000000"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
android:layout_height="wrap_content"
android:textColor="#000000" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
<TextView
android:layout_width="150dp"
android:layout_height="wrap_content"
android:text="@string/solde"
android:textColor="#000000" />
<TextView
android:id="@+id/text_solde"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#000000" />
</LinearLayout>
<TextView
......@@ -346,6 +364,25 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:layout_width="150dp"
android:layout_height="wrap_content"
android:textColor="#000000"
android:text="@string/tag" />
<TextView
android:id="@+id/text_tag_ginger"
android:textColor="#000000"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
</LinearLayout>
</ScrollView>
......@@ -355,10 +392,25 @@
android:layout_alignParentBottom="true"
android:orientation="horizontal">
<Button
android:id="@+id/add_new_card"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:text="@string/add_new_card" />
<Button
android:id="@+id/read_new_card"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:text="@string/read_new_card" />
<Button
android:id="@+id/contribute"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:text="@string/contribute" />
</LinearLayout>
</RelativeLayout>
\ No newline at end of file
......@@ -3,10 +3,8 @@
<string-array name="options">
<item>Mode annulation</item>
<item>Modifier les articles</item>
<item>Lire une carte</item>
<item>Gestion des cartes/cotisations</item>
<item>Lire un QR Code</item>
<item>Créer une cotisation extérieure</item>
<item>Ajouter une carte</item>
<item>Modifier la clé Nemopay</item>
<item>Modifier la clé Ginger</item>
</string-array>
......
......@@ -48,7 +48,9 @@
<string name="lastname">Nom</string>
<string name="email">Email</string>
<string name="adult">Adulte</string>
<string name="contribute">Cotiser</string>
<string name="cotisant">Cotisant</string>
<string name="solde">Solde</string>
<string name="tag_id">ID tag</string>
<string name="tag">Numéro de badge</string>
<string name="short_tag">Numéro raccourci</string>
......@@ -75,6 +77,7 @@
<string name="cas_error_service_connection">Erreur lors de la connexion au service depuis le CAS</string>
<string name="cas_error_service_linking">Erreur lors de la connexion entre le CAS et le service</string>
<string name="badge_connection">Connexion par badge</string>
<string name="badge_read">Lecture d\'un badge</string>
<string name="badge_waiting">En attente de lecture d\'un badge</string>
<string name="badge_app_not_registered">Il est nécessaire que l\'application soit enregistrée pour permettre la connexion via badge</string>
<string name="badge_recognization">Authentification du badge</string>
......@@ -92,7 +95,7 @@
<string name="nemopay_error_registering">Application non enregistrée</string>
<string name="nemopay_information">Informations de la part de Nemopay</string>
<string name="key">Clé d\'application</string>
<string name="key_registration">Enregistrement de l\'appareil</string>
<string name="key_registration">Enregistrement de la clé</string>
<string name="key_explication">Pour pouvoir fonctionner, l\'application a besoin d\'être enregistrée sous un nom précis et daté (date automatiquement ajoutée si non détectée). Ceci permettra par la suite de donner des droits à cet appareil</string>
<string name="key_name">Nom - Date</string>
<string name="key_description">Description</string>
......@@ -111,7 +114,8 @@
<string name="article_error_0_categorie_not_0">Toutes les catégories sont vides</string>
<string name="buyer_info_collecting">Récupération des informations de la personne</string>
<string name="user_searching">Identification de la personne</string>
<string name="user_info_collecting">Identification de la personne</string>
<string name="user_nemopay_info_collecting">Identification de la personne auprès de Nemopay</string>
<string name="user_ginger_info_collecting">Identification de la personne auprès de Ginger</string>
<string name="user_not_recognized">Personne non reconnue</string>
<string name="user_rights_list_collecting">Récupération des droits de la personne</string>
<string name="user_error_collecting">Impossible de récupérer les infos de la personne</string>
......@@ -129,9 +133,11 @@
<string name="can_cancel">Permettre l\'annulation</string>
<string name="cant_cancel">L\'application a été configurée pour ne pas permettre l\'annulation d\'une transaction (contacter un adminstrateur pour annuler)</string>
<string name="read_card_information">Informations de la carte</string>
<string name="read_new_card">Lire une carte</string>
<string name="add_new_card">Ajouter</string>
<string name="read_new_card">Lire</string>
<string name="ginger_information">Informations de la part de Ginger</string>
<string name="ginger_no_key">Aucune clé n\'a été donnée</string>
<string name="contribute_already">La personne est déjà cotisante</string>
<string name="print_mode">Mode d\'affichage</string>
<string name="filters">Filtres d\'affichage</string>
......
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