Hold creation almoast finished
authordrizea <danielrizea27@gmail.com>
Thu, 5 Jul 2012 11:35:22 +0000 (14:35 +0300)
committerdrizea <danielrizea27@gmail.com>
Thu, 5 Jul 2012 11:35:22 +0000 (14:35 +0300)
Open-ILS/src/Android/res/layout/place_hold.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/holds/PlaceHold.java
Open-ILS/src/Android/src/org/evergreen/android/globals/GlobalConfigs.java
Open-ILS/src/Android/src/org/evergreen/android/searchCatalog/Organisation.java

index 22f196e..800816a 100644 (file)
                            android:text="@string/contact_telephone"
                            />
                        
-                       <TextView 
+                       <EditText
                            android:id="@+id/hold_contact_telephone"
                            android:layout_width="0dip"
                            android:layout_height="wrap_content"
                            android:gravity="center"
                            />    
            </LinearLayout>
-            
+                <LinearLayout 
+               android:layout_width="fill_parent"
+               android:layout_height="wrap_content"
+               android:orientation="horizontal"
+               >
+                       <TextView 
+                           android:layout_width="0dip"
+                           android:layout_height="wrap_content"
+                           android:layout_weight="2"
+                           android:text="@string/thaw_date"
+                           />
+                       
+                       <EditText 
+                           android:id="@+id/hold_thaw_date"
+                           android:layout_width="0dip"
+                           android:layout_height="wrap_content"
+                           android:layout_weight="4"
+                           android:gravity="center"
+                           />
+                       
+                       
+           </LinearLayout>
        </LinearLayout>
     
     </ScrollView>
index 7835ade..13f524d 100644 (file)
@@ -23,7 +23,7 @@
     <string name="contact_telephone">Contact tel</string>
     <string name="enable_phone_notification"> Phone notification</string>
     <string name="contact_email_address">Contact email address </string>
-    <string name="enable_email_notification"></string>
+    <string name="enable_email_notification">Email notification</string>
     <string name="pickup_location">Pickup location</string>
     <string name="expiration_date">Expiration Date</string>
     <string name="suspend_hold">Suspend Hold</string>
@@ -33,5 +33,5 @@
     <string name="back">Back</string>
     <string name="update_hold">Update Hold</string>
     <string name="cancel_hold_dialog_message">Are you sure you want to cancel this hold?</string>
-    
+    <string name="thaw_date">Automatically activate hold one</string>
 </resources>
\ No newline at end of file
index 03c3b62..15e05fa 100644 (file)
@@ -166,7 +166,7 @@ public class AccountAccess {
         *  @param : authtoken, ahr OSRFObject 
         *  @returns : hash with messages : "success" : 1 field or 
         */
-       public static String METHOD_CREATE_HOLD = "     open-ils.circ.holds.create";
+       public static String METHOD_CREATE_HOLD = "open-ils.circ.holds.create";
        
        //Used for Fines 
        
@@ -817,19 +817,26 @@ public class AccountAccess {
                return response;
        }
        
-       public Object createHold(Integer recordID){
+       public Object createHold(Integer recordID, Integer pickup_lib, boolean email_notify, boolean phone_notify, String phone, boolean suspendHold, String expire_time,String thaw_date){
                
        OSRFObject ahr = new OSRFObject("ahr");
        ahr.put("target", recordID);
        ahr.put("usr", userID);
        ahr.put("requestor", userID);
-       ahr.put("hold_type", "T");
-       ahr.put("pickup_lib", 4);
-       ahr.put("selection_ou",8);
        
-       //selection_ou from where it was selected 
-       //pick_up lib
-       //type
+       //do not set hold type, the systems knows the hold type
+       //ahr.put("hold_type", "T");
+       ahr.put("pickup_lib", pickup_lib); //pick-up lib
+       ahr.put("phone_notify", phone);
+       ahr.put("email_notify", email_notify);
+       ahr.put("expire_time",expire_time);
+       //frozen set, what this means ? 
+       ahr.put("frozen", suspendHold);
+       //only if it is frozen
+       ahr.put("thaw_date",thaw_date);
+       
+       //extra parameters (not mandatory for hold creation)
+
        
        Object response = Utils.doRequest(conn,SERVICE_CIRC, METHOD_CREATE_HOLD, new Object[]{authToken,ahr});
                
index dfad352..11eb9c9 100644 (file)
@@ -1,21 +1,29 @@
 package org.evergreen.android.accountAccess.holds;
 
 import java.util.Calendar;
+import java.util.Date;
 
 import org.evergreen.android.R;
 import org.evergreen.android.accountAccess.AccountAccess;
+import org.evergreen.android.globals.GlobalConfigs;
 import org.evergreen.android.searchCatalog.RecordInfo;
 
 import android.app.Activity;
 import android.app.DatePickerDialog;
 import android.os.Bundle;
 import android.text.format.DateFormat;
-import android.text.format.Time;
 import android.view.View;
 import android.view.View.OnClickListener;
+import android.widget.AdapterView;
+import android.widget.AdapterView.OnItemSelectedListener;
+import android.widget.ArrayAdapter;
 import android.widget.Button;
+import android.widget.CheckBox;
+import android.widget.CompoundButton;
+import android.widget.CompoundButton.OnCheckedChangeListener;
 import android.widget.DatePicker;
 import android.widget.EditText;
+import android.widget.Spinner;
 import android.widget.TextView;
 
 public class PlaceHold extends Activity{
@@ -35,12 +43,30 @@ public class PlaceHold extends Activity{
        
        private EditText expiration_date;
        
+       private EditText phone_number;
+       
+       private CheckBox phone_notification;
+       
+       private CheckBox email_notification;
+       
        private Button placeHold;
        
        private Button cancel;
        
+       private CheckBox suspendHold;
+       
+       private Spinner orgSelector;
+       
        private DatePickerDialog datePicker = null;
        
+       private DatePickerDialog thaw_datePicker = null;
+       
+       private EditText thaw_date_edittext;
+       
+       private Date expire_date = null;
+       
+       private Date thaw_date = null;
+       
        @Override
        protected void onCreate(Bundle savedInstanceState) {
                super.onCreate(savedInstanceState);
@@ -59,15 +85,22 @@ public class PlaceHold extends Activity{
                cancel = (Button) findViewById(R.id.cancel_hold);
                placeHold = (Button) findViewById(R.id.place_hold);
                expiration_date = (EditText) findViewById(R.id.hold_expiration_date);
-               
+               phone_notification = (CheckBox) findViewById(R.id.hold_enable_phone_notification);
+               phone_number= (EditText) findViewById(R.id.hold_contact_telephone);
+               email_notification = (CheckBox) findViewById(R.id.hold_enable_email_notification);
+               suspendHold = (CheckBox) findViewById(R.id.hold_suspend_hold);
+               orgSelector = (Spinner) findViewById(R.id.hold_pickup_location);
+               thaw_date_edittext = (EditText) findViewById(R.id.hold_thaw_date);
                screen_title.setText("Place Hold");
                
                recipient.setText(accountAccess.userName);
                title.setText(record.title);
                author.setText(record.author);
                physical_description.setText(record.physical_description);
-               
-               System.out.println(record.title + " " + record.author);
+
+               //hide edit text
+               disableView(thaw_date_edittext);
+               disableView(phone_number);
                
                cancel.setOnClickListener(new OnClickListener() {
                        @Override
@@ -82,25 +115,63 @@ public class PlaceHold extends Activity{
                        @Override
                        public void onClick(View v) {
                                
-                               //accountAccess.createHold(record_id);
+                               
                                
                                accountAccess.getHoldPreCreateInfo(record_id, 4);
+                               accountAccess.isHoldPossible(4, record_id);
+                               
+                               String expire_date_s = null;
+                               String thaw_date_s = null;
+                               if(expire_date != null)
+                                       expire_date_s = GlobalConfigs.getStringDate(expire_date);
+                               if(thaw_date != null)
+                                       thaw_date_s = GlobalConfigs.getStringDate(thaw_date);
+                               
+                               accountAccess.createHold(record_id,4,email_notification.isChecked(),phone_notification.isChecked(),phone_number.getText().toString(),suspendHold.isChecked(),expire_date_s,thaw_date_s);
                        }
                });
                
                
+               phone_notification.setOnCheckedChangeListener(new OnCheckedChangeListener() {
+                       
+                       @Override
+                       public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
+
+                               if(isChecked){
+                                       enableView(phone_number);
+                               }
+                               else
+                                       disableView(phone_number);
+                       }
+               });
+               
+               suspendHold.setOnCheckedChangeListener(new OnCheckedChangeListener() {
+                       
+                       @Override
+                       public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
+                               
+                               if(isChecked){
+                                       enableView(thaw_date_edittext);
+                               }else
+                               {
+                                       disableView(thaw_date_edittext);
+                               }
+                       }
+               });
                
                Calendar cal = Calendar.getInstance();
+               
                datePicker = new DatePickerDialog(this,
                         new DatePickerDialog.OnDateSetListener() {
                 
                         public void onDateSet(DatePicker view, int year,
                                                             int monthOfYear, int dayOfMonth)
                         {
-                                   Time chosenDate = new Time();
-                                   chosenDate.set(dayOfMonth, monthOfYear, year);
-                                   long dtDob = chosenDate.toMillis(true);
-                                   CharSequence strDate = DateFormat.format("MMMM dd, yyyy", dtDob);
+                                
+
+                                   Date chosenDate = new Date(year, monthOfYear,dayOfMonth);                 
+                                   expire_date = chosenDate;
+                                   CharSequence strDate = DateFormat.format("MMMM dd, yyyy", chosenDate);
                                    expiration_date.setText(strDate);
                                    //set current date          
                        }}, cal.get(Calendar.YEAR),cal.get(Calendar.MONTH), cal.get(Calendar.DAY_OF_MONTH));
@@ -112,6 +183,54 @@ public class PlaceHold extends Activity{
                        }
                });
                
+               thaw_datePicker = new DatePickerDialog(this,
+                        new DatePickerDialog.OnDateSetListener() {
+                
+                        public void onDateSet(DatePicker view, int year,
+                                                            int monthOfYear, int dayOfMonth)
+                        {
+                                
+                                               
+                                   Date chosenDate = new Date(year, monthOfYear,dayOfMonth);                 
+                                   thaw_date = chosenDate;
+                                   CharSequence strDate = DateFormat.format("MMMM dd, yyyy", chosenDate);
+                                   expiration_date.setText(strDate);
+                                   //set current date          
+                       }}, cal.get(Calendar.YEAR),cal.get(Calendar.MONTH), cal.get(Calendar.DAY_OF_MONTH));
+       
+               thaw_date_edittext.setOnClickListener(new OnClickListener() {
+                       
+                       @Override
+                       public void onClick(View v) {
+                               thaw_datePicker.show(); 
+                       }
+               });
+               
+               
+               ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,android.R.layout.simple_spinner_item,list);
+        orgSelector.setAdapter(adapter);
+       
+        orgSelector.setSelection();
+        
+        orgSelectorn.setOnItemSelectedListener(new OnItemSelectedListener() {
+                       @Override
+                       public void onItemSelected(AdapterView<?> arg0, View arg1,
+                                       int ID, long arg3) {
+                               //select the specific organization
+                               search.selectOrganisation(globalConfigs.organisations.get(ID));
+                               
+                       }
+       }
+       
+       public void disableView(View view){
+               
+               //view.setFocusable(false);
+               
+               view.setVisibility(View.INVISIBLE);
+       }
+       
+       public void enableView(View view){
+               view.setVisibility(View.VISIBLE);
        }
        
 }
index c3b88b2..8fe5210 100644 (file)
@@ -97,6 +97,9 @@ public class GlobalConfigs {
                                AccountAccess ac = AccountAccess.getAccountAccess(GlobalConfigs.httpAddress);
                                ac.authenticate();
                                
+                               //TODO getorg hidding levels
+                               //getOrgHiddentDepth();
+                               
                                return true;
                        }
                        return false;
@@ -262,6 +265,32 @@ public class GlobalConfigs {
                        loadedOrgTree = true;
                }
        }
+       
+       public void getOrgHiddentDepth(){
+               
+               // logic can be found in the opac_utils.js file in web/opac/common/js
+               
+               
+               for(int i=0; i<organisations.size();i++){
+                       
+                       AccountAccess ac = AccountAccess.getAccountAccess();
+                       
+                       Object obj = ac.fetchOrgSettings(organisations.get(i).id, "opac.org_unit_hiding.depth");
+                       
+                       
+               }
+               
+       }
+       
+       
+       
+       public static String getStringDate(Date date){
+               
+               final SimpleDateFormat sdf = new SimpleDateFormat(GlobalConfigs.datePattern);
+                 
+               return sdf.format(date);
+               
+       }
        //parse from opac methods query results to Java date
        public static Date parseDate(String dateString){
                
index 6213c75..13cbab5 100644 (file)
@@ -14,6 +14,8 @@ public class Organisation {
        
        public Integer canHaveVolumesBool = null;
        
+       public Integer hiddenDepth = null;
+       
        //used for indent display
        public String padding = "";