option to checkin items before marking them damaged. Need to make these prettier :)
authorphasefx <phasefx@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Fri, 6 Mar 2009 23:42:07 +0000 (23:42 +0000)
committerphasefx <phasefx@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Fri, 6 Mar 2009 23:42:07 +0000 (23:42 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/trunk@12460 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/xul/staff_client/chrome/content/main/constants.js
Open-ILS/xul/staff_client/server/cat/util.js
Open-ILS/xul/staff_client/server/locale/en-US/cat.properties

index c1b9fd6..7264aa2 100644 (file)
@@ -12,10 +12,10 @@ const PERMS_DIR      = 0755;
 
 const my_constants = {
        'magical_statuses' : {
-               '1' : { 'disable_in_copy_editor' : true, 'block_mark_item_action' : true }, /* | Checked out    | t */
-               '3' : { 'disable_in_copy_editor' : true, 'block_mark_item_action' : true }, /* | Lost           | f */
-               '6' : { 'disable_in_copy_editor' : true, 'block_mark_item_action' : true }, /* | In transit     | t */
-               '8' : { 'disable_in_copy_editor' : true, 'block_mark_item_action' : false } /* | On holds shelf | t */
+               '1' : { 'disable_in_copy_editor' : true, 'block_mark_item_damaged' : false, 'block_mark_item_action' : true }, /* | Checked out    | t */
+               '3' : { 'disable_in_copy_editor' : true, 'block_mark_item_damaged' : false, 'block_mark_item_action' : true }, /* | Lost           | f */
+               '6' : { 'disable_in_copy_editor' : true, 'block_mark_item_damaged' : false, 'block_mark_item_action' : true }, /* | In transit     | t */
+               '8' : { 'disable_in_copy_editor' : true, 'block_mark_item_damaged' : false, 'block_mark_item_action' : false } /* | On holds shelf | t */
        }
 }
 
index 48a7597..d2c9a61 100644 (file)
@@ -283,7 +283,7 @@ cat.util.mark_item_damaged = function(copy_ids) {
                for (var i = 0; i < copies.length; i++) {
                        var status = copies[i].status(); if (typeof status == 'object') status = status.id();
                        if (typeof my_constants.magical_statuses[ status ] != 'undefined') 
-                               if (my_constants.magical_statuses[ status ].block_mark_item_action) magic_status = true;
+                               if (my_constants.magical_statuses[ status ].block_mark_item_damaged) magic_status = true;
                }
                if (magic_status) {
                
@@ -304,6 +304,49 @@ cat.util.mark_item_damaged = function(copy_ids) {
                                var count = 0;
                                for (var i = 0; i < copies.length; i++) {
                                        try {
+
+                        var my_circ = network.simple_request('FM_CIRC_RETRIEVE_VIA_COPY',[ses(),copies[i].id(),1]);
+                        if (typeof my_circ.ilsevent == 'undefined') { 
+                            JSAN.use('OpenILS.data'); var data = new OpenILS.data(); data.stash_retrieve();
+                            my_circ = my_circ[0];
+                            if (typeof my_circ != 'undefined') {
+                                if (! my_circ.checkin_time() ) {
+                                    var due_date = my_circ.due_date() ? my_circ.due_date().substr(0,10) : null;
+                                    var auto_checkin = String( data.hash.aous['circ.auto_checkin_on_mark_damage'] ) == 'true';
+                                    JSAN.use('patron.util');
+                                    var patron_obj = patron.util.retrieve_fleshed_au_via_id( ses(), my_circ.usr() );
+                                    var patron_name = ( patron_obj.prefix() ? patron_obj.prefix() + ' ' : '') +
+                                        patron_obj.family_name() + ', ' +
+                                        patron_obj.first_given_name() + ' ' +
+                                        ( patron_obj.second_given_name() ? patron_obj.second_given_name() + ' ' : '' ) +
+                                        ( patron_obj.suffix() ? patron_obj.suffix() : '')
+                                        + ' : ' + patron_obj.card().barcode()
+                                    var msg = $("catStrings").getFormattedString('staff.cat.util.mark_item_damaged.item_circulating_to_patron', [ 
+                                        copies[i].barcode(),
+                                        patron_name,
+                                        my_circ.due_date().substr(0,10)]); // FIXME: need to replace date handling
+                                    JSAN.use('util.date'); var today = util.date.formatted_date(new Date(),'%F');
+                                    var r2 = auto_checkin ? 1 : error.yns_alert(
+                                        msg,
+                                        document.getElementById('catStrings').getString('staff.cat.util.mark_item_damaged.checkin.title'),
+                                        document.getElementById('catStrings').getString('staff.cat.util.mark_item_damaged.checkin.no_checkin'),
+                                        document.getElementById('catStrings').getString('staff.cat.util.mark_item_damaged.checkin.normal_checkin'),
+                                        due_date ? (today > due_date ? document.getElementById('catStrings').getString('staff.cat.util.mark_item_damaged.checkin.forgiving_checkin') : null) : null,
+                                        document.getElementById('catStrings').getString('staff.cat.util.mark_item_damaged.checkin.confirm_action')
+                                    );
+                                    JSAN.use('circ.util');
+                                    switch(r2) {
+                                        case 1:
+                                            circ.util.checkin_via_barcode( ses(), { 'barcode' : copies[i].barcode(), 'noop' : 1 } );
+                                        break;
+                                        case 2:
+                                            circ.util.checkin_via_barcode( ses(), { 'barcode' : copies[i].barcode(), 'noop' : 1 }, due_date );
+                                        break;
+                                    }
+                                }
+                            }
+                        }
+
                                                var robj = network.simple_request('MARK_ITEM_DAMAGED',[ses(),copies[i].id()]);
                                                if (typeof robj.ilsevent != 'undefined') {
                             switch(robj.textcode) {
index bd43c5f..27112b2 100644 (file)
@@ -339,6 +339,12 @@ staff.cat.util.mark_item_damaged.md_title=Mark Damaged
 staff.cat.util.mark_item_damaged.md_ok_label=OK
 staff.cat.util.mark_item_damaged.md_cancel_label=Cancel
 staff.cat.util.mark_item_damaged.md_confirm_action=Check here to confirm this action
+staff.cat.util.mark_item_damaged.checkin.title=Checkin Item Before Marking Damaged?
+staff.cat.util.mark_item_damaged.checkin.normal_checkin=Normal Checkin
+staff.cat.util.mark_item_damaged.checkin.no_checkin=Cancel
+staff.cat.util.mark_item_damaged.checkin.forgiving_checkin=Forgiving Checkin
+staff.cat.util.mark_item_damaged.checkin.confirm_action=Check here to confirm this action
+staff.cat.util.mark_item_damaged.item_circulating_to_patron=Item %1$s is checked out to patron, %2$s, and is due on %3$s. 
 staff.cat.util.mark_item_damaged.charge_patron_prompt.message=Item %1$s will be marked damaged.  Was returned on %3$s by %2$s.  Charge this patron $%4$s for the damage?
 staff.cat.util.mark_item_damaged.charge_patron_prompt.title=Charge Patron For Damaged Item?
 staff.cat.util.mark_item_damaged.charge_patron_prompt.ok_label=OK