basic fines info finished
authordrizea <danielrizea27@gmail.com>
Sat, 7 Jul 2012 10:23:40 +0000 (13:23 +0300)
committerdrizea <danielrizea27@gmail.com>
Sat, 7 Jul 2012 10:23:40 +0000 (13:23 +0300)
Open-ILS/src/Android/res/layout/fines.xml
Open-ILS/src/Android/res/layout/fines_list_item.xml [new file with mode: 0644]
Open-ILS/src/Android/res/values/colors.xml
Open-ILS/src/Android/res/values/strings.xml
Open-ILS/src/Android/src/org/evergreen/android/accountAccess/AccountAccess.java
Open-ILS/src/Android/src/org/evergreen/android/accountAccess/fines/FinesActivity.java
Open-ILS/src/Android/src/org/evergreen/android/accountAccess/fines/FinesRecord.java [new file with mode: 0644]

index 6be2116..feb41cf 100644 (file)
          </TableLayout>
 
         
+         <TextView 
+             android:layout_width="fill_parent"
+             android:layout_height="wrap_content"
+             android:text="@string/overdue_materials"
+             android:textSize="18sp"
+             android:paddingTop="10dip"
+             android:paddingBottom="5dip"
+             />
 
        <ListView 
          android:id="@+id/fines_overdue_materials_list"
diff --git a/Open-ILS/src/Android/res/layout/fines_list_item.xml b/Open-ILS/src/Android/res/layout/fines_list_item.xml
new file mode 100644 (file)
index 0000000..860067d
--- /dev/null
@@ -0,0 +1,55 @@
+<?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
index 9f562e4..b406692 100644 (file)
@@ -34,4 +34,5 @@
        
     <color name="white">#ffffff</color>
     <color name="blue">#1e90ff</color>
+    <color name="red">#ff0000</color>
 </resources>
index 47f36d9..4c4d804 100644 (file)
@@ -40,5 +40,6 @@
     <string name="total_owned">Total Owned </string>
     <string name="total_paid">Total Paid</string>
     <string name="balance_owed">Balance Owed</string>
+    <string name="overdue_materials">Overdue Materials</string>
     
 </resources>
\ No newline at end of file
index 5c4f052..fd89ddc 100644 (file)
@@ -9,6 +9,7 @@ import java.util.List;
 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;
@@ -183,8 +184,8 @@ public class AccountAccess {
         * 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 :
@@ -936,11 +937,26 @@ public class AccountAccess {
                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-----------------------------------//
index 94148b6..94ad2c2 100644 (file)
@@ -1,12 +1,21 @@
 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;
 
@@ -19,7 +28,7 @@ public class FinesActivity extends Activity{
        
        private TextView balance_owed;
        
-       private ListView overdue_materials;
+       private ListView lv;
        
        private Runnable getFinesInfo;
        
@@ -27,12 +36,16 @@ public class FinesActivity extends Activity{
        
        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);
@@ -42,6 +55,12 @@ public class FinesActivity extends Activity{
                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() {
@@ -50,10 +69,19 @@ public class FinesActivity extends Activity{
                                
                                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]+"");
@@ -66,4 +94,74 @@ public class FinesActivity extends Activity{
                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;
+       }
+    }
 }
diff --git a/Open-ILS/src/Android/src/org/evergreen/android/accountAccess/fines/FinesRecord.java b/Open-ILS/src/Android/src/org/evergreen/android/accountAccess/fines/FinesRecord.java
new file mode 100644 (file)
index 0000000..d27be89
--- /dev/null
@@ -0,0 +1,49 @@
+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";
+                       
+       }
+}