--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>
+<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent" >
+
+
+ <TableRow
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ >
+
+ <TextView
+ android:id="@+id/fines_title"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:layout_weight="10"
+
+
+ />
+
+ <TextView
+ android:id="@+id/fines_balance_owed"
+ android:layout_width="fill_parent"
+ android:layout_height="fill_parent"
+ android:textColor="@color/red"
+ android:textStyle="bold"
+ android:layout_weight="4"
+ android:layout_gravity="right"
+ />
+
+ </TableRow>
+
+ <TableRow
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ >
+
+ <TextView
+ android:id="@+id/fines_author"
+ android:layout_width="fill_parent"
+ android:layout_height="fill_parent"
+ android:layout_weight="10"
+ />
+
+ <TextView
+ android:id="@+id/fines_status"
+ android:layout_width="fill_parent"
+ android:layout_height="fill_parent"
+ android:textStyle="bold"
+ android:layout_weight="4"
+ android:layout_gravity="right"
+ />
+ </TableRow>
+
+</TableLayout>
\ No newline at end of file
import java.util.Map;
import org.evergreen.android.accountAccess.checkout.CircRecord;
+import org.evergreen.android.accountAccess.fines.FinesRecord;
import org.evergreen.android.accountAccess.holds.HoldRecord;
import org.evergreen.android.globals.Utils;
import org.evergreen.android.searchCatalog.RecordInfo;
* containing : transaction, circ, record
* @param : authToken, userID
* @returns : array of objects, must investigate
- */
- public static String METHOD_FETCH_TRANSACTIONS = "open-ils.actor.user.transactions.have_charged.fleshed";
+ */
+ public static String METHOD_FETCH_TRANSACTIONS = "open-ils.actor.user.transactions.have_charge.fleshed";
/** The METHOD_FETCH_MONEY_BILLING
* description :
return fines;
}
- private Object getTransactions(){
+ public ArrayList<FinesRecord> getTransactions(){
+
+ ArrayList<FinesRecord> finesRecords = new ArrayList<FinesRecord>();
Object transactions = Utils.doRequest(conn,SERVICE_ACTOR, METHOD_FETCH_TRANSACTIONS, new Object[]{authToken,userID});
- return transactions;
+
+ //get Array
+
+ List<Map<String,OSRFObject>> list = (List<Map<String,OSRFObject>>)transactions;
+
+ for(int i=0;i<list.size();i++){
+
+ Map<String,OSRFObject> item = list.get(i);
+
+ FinesRecord record = new FinesRecord(item.get("circ"),item.get("record"),item.get("transaction"));
+ finesRecords.add(record);
+ }
+
+ return finesRecords;
}
//---------------------------------------Book bags-----------------------------------//
package org.evergreen.android.accountAccess.fines;
+import java.util.ArrayList;
+import java.util.List;
+
import org.evergreen.android.R;
import org.evergreen.android.accountAccess.AccountAccess;
import android.app.Activity;
import android.app.ProgressDialog;
import android.content.Context;
+import android.graphics.Color;
import android.os.Bundle;
+import android.util.Log;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.TextView;
private TextView balance_owed;
- private ListView overdue_materials;
+ private ListView lv;
private Runnable getFinesInfo;
private ProgressDialog progressDialog;
+ private OverdueMaterialsArrayAdapter listAdapter;
+
+
private Context context;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.fines);
+ lv = (ListView) findViewById(R.id.fines_overdue_materials_list);
total_owned = (TextView) findViewById(R.id.fines_total_owned);
total_paid = (TextView) findViewById(R.id.fines_total_paid);
ac = AccountAccess.getAccountAccess();
+
+ ArrayList<FinesRecord> finesRecords = new ArrayList<FinesRecord>();
+ listAdapter = new OverdueMaterialsArrayAdapter(context, R.layout.fines_list_item,finesRecords);
+ lv.setAdapter(listAdapter);
+
+
progressDialog = ProgressDialog.show(this, null, "Retrieving fines");
getFinesInfo = new Runnable() {
final float[] fines = ac.getFinesSummary();
+ final ArrayList<FinesRecord> finesRecords = ac.getTransactions();
+
runOnUiThread(new Runnable() {
@Override
public void run() {
+ listAdapter.clear();
+
+ for(int i=0;i<finesRecords.size();i++)
+ listAdapter.add(finesRecords.get(i));
+
+ listAdapter.notifyDataSetChanged();
+
total_owned.setText(fines[0]+"");
total_paid.setText(fines[1]+"");
balance_owed.setText(fines[2]+"");
Thread getFinesTh = new Thread(getFinesInfo);
getFinesTh.start();
}
+
+ class OverdueMaterialsArrayAdapter extends ArrayAdapter<FinesRecord> {
+ private static final String tag = "CheckoutArrayAdapter";
+
+ private TextView fineTitle;
+ private TextView fineAuthor;
+ private TextView fineBalanceOwed;
+ private TextView fineStatus;
+
+ private List<FinesRecord> records = new ArrayList<FinesRecord>();
+
+ public OverdueMaterialsArrayAdapter(Context context, int textViewResourceId,
+ List<FinesRecord> objects) {
+ super(context, textViewResourceId, objects);
+ this.records = objects;
+ }
+
+ public int getCount() {
+ return this.records.size();
+ }
+
+ public FinesRecord getItem(int index) {
+ return this.records.get(index);
+ }
+
+ public View getView(int position, View convertView, ViewGroup parent) {
+ View row = convertView;
+
+ // Get item
+ final FinesRecord record = getItem(position);
+
+ if(row == null){
+
+ Log.d(tag, "Starting XML view more infaltion ... ");
+ LayoutInflater inflater = (LayoutInflater) this.getContext()
+ .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
+ row = inflater.inflate(R.layout.fines_list_item, parent, false);
+ Log.d(tag, "Successfully completed XML view more Inflation!");
+
+
+ }
+ // Get reference to TextView - title
+ fineTitle = (TextView) row.findViewById(R.id.fines_title);
+
+ // Get reference to TextView author
+ fineAuthor = (TextView) row.findViewById(R.id.fines_author);
+
+ //Get hold status
+ fineBalanceOwed = (TextView) row.findViewById(R.id.fines_balance_owed);
+
+ fineStatus = (TextView) row.findViewById(R.id.fines_status);
+ //set text
+
+
+ //set raw information
+ fineTitle.setText(record.title);
+ fineAuthor.setText(record.author);
+ fineBalanceOwed.setText(record.balance_owed);
+ //status.setText(record.getHoldStatus());
+ fineStatus.setText(record.getStatus());
+
+ if(record.getStatus().equals("returned")){
+ fineStatus.setTextColor(Color.argb(255, 0, 255, 0));
+ }
+ else
+ fineStatus.setTextColor(Color.argb(255, 255, 0, 0));
+
+ return row;
+ }
+ }
}
--- /dev/null
+package org.evergreen.android.accountAccess.fines;
+
+import java.util.Date;
+
+import org.evergreen.android.globals.GlobalConfigs;
+import org.opensrf.util.OSRFObject;
+
+public class FinesRecord {
+
+ public String title;
+
+ public String author;
+
+ public Date checkoutDate;
+
+ public Date dueDate;
+
+ public Date dateReturned;
+
+ public String balance_owed;
+
+ private Date checkin_time;
+
+ public FinesRecord(OSRFObject circ, OSRFObject mvr_record, OSRFObject mbts_transaction){
+
+
+ title = mvr_record.getString("title");
+ author = mvr_record.getString("author");
+
+ balance_owed = mbts_transaction.getString("total_owed");
+
+ if(circ.get("checkin_time") != null){
+ checkin_time = GlobalConfigs.parseDate(circ.getString("checkin_time"));
+ }
+ else
+ checkin_time = null;
+
+ }
+
+ //if returned or fines still acumulating
+ public String getStatus(){
+
+ if(checkin_time != null)
+ return "returned";
+
+ return "fines accruing";
+
+ }
+}