3 MyOPACSPage.prototype = new Page();
4 MyOPACSPage.prototype.constructor = Page;
5 MyOPACSPage.baseClass = Page.constructor;
7 function MyOPACSPage() {
8 var session_id = location.search.substring(
9 location.search.indexOf("session") + 8 ); /*md5 session key*/
11 this.user = UserSession.instance();
12 this.user.verifySession(session_id);
15 MyOPACSPage.prototype.init = function() {
19 MyOPACSPage.prototype.draw = function(type) {
21 debug("Fleshing User");
23 this.infoPane = getById("my_opac_info_pane");
24 this.infoTable = getById("my_opac_info_table");
26 removeChildren(this.infoPane);
27 removeChildren(this.infoTable);
28 this.infoPane.appendChild(this.infoTable);
32 this.buildNavBox(true);
34 this.checkCell = getById("my_opac_checked");
35 this.holdsCell = getById("my_opac_holds");
36 this.profileCell = getById("my_opac_profile");
37 this.finesCell = getById("my_opac_fines");
39 check = getById("my_opac_checked_link");
40 holds = getById("my_opac_holds_link");
41 profile = getById("my_opac_profile_link");
42 fines = getById("my_opac_fines_link");
45 check.onclick = function() { obj.drawCheckedOut(); };
46 holds.onclick = function() { obj.drawHolds(); };
47 profile.onclick = function() { obj.drawProfile(); };
48 fines.onclick = function() { obj.drawFines(); };
51 case "holds": this.drawHolds(); break;
52 case "profile": this.drawProfile(); break;
53 case "fines": this.drawFines(); break;
55 default:this.drawCheckedOut();
60 MyOPACSPage.prototype.setLink = function(cell) {
61 remove_css_class(this.checkCell, "my_opac_link_cell_active");
62 remove_css_class(this.holdsCell, "my_opac_link_cell_active");
63 remove_css_class(this.profileCell, "my_opac_link_cell_active");
64 remove_css_class(this.finesCell, "my_opac_link_cell_active");
65 add_css_class(cell, "my_opac_link_cell_active");
68 MyOPACSPage.prototype.drawCheckedOut = function() {
69 removeChildren(this.infoTable);
70 removeChildren(this.infoPane);
71 this.infoPane.appendChild(this.infoTable);
72 this.setLink(this.checkCell);
73 this.getCheckedOut(_drawCheckedOut);
76 MyOPACSPage.prototype.drawHolds = function() {
77 removeChildren(this.infoTable);
78 removeChildren(this.infoPane);
79 this.infoPane.appendChild(this.infoTable);
80 this.setLink(this.holdsCell);
84 MyOPACSPage.prototype.drawProfile = function() {
85 removeChildren(this.infoTable);
86 removeChildren(this.infoPane);
87 this.infoPane.appendChild(this.infoTable);
88 this.setLink(this.profileCell);
92 MyOPACSPage.prototype.drawFines = function() {
93 removeChildren(this.infoTable);
94 removeChildren(this.infoPane);
95 this.infoPane.appendChild(this.infoTable);
96 this.setLink(this.finesCell);
99 function _drawCheckedOut(obj, data) {
101 if(data == null) return;
102 //obj.infoPane.appendChild(obj.infoTable);
103 var circRow = obj.infoTable.insertRow(obj.infoTable.rows.length);
105 var tcell = circRow.insertCell(circRow.cells.length)
106 tcell.appendChild(mktext("Title"));
107 var dcell = circRow.insertCell(circRow.cells.length);
108 dcell.appendChild(mktext("Due Date"));
109 var drcell = circRow.insertCell(circRow.cells.length);
110 drcell.appendChild(mktext("Duration"));
111 var bcell = circRow.insertCell(circRow.cells.length);
112 bcell.appendChild(mktext("Barcode"));
113 var ccell = circRow.insertCell(circRow.cells.length);
114 ccell.appendChild(mktext("Circulating Library"));
115 var rcell = circRow.insertCell(circRow.cells.length);
116 rcell.appendChild(mktext("Renewals Remaining"));
117 var rbcell = circRow.insertCell(circRow.cells.length);
118 rbcell.appendChild(mktext("Renew?"));
120 add_css_class(tcell, "my_opac_info_table_header");
121 add_css_class(dcell, "my_opac_info_table_header");
122 add_css_class(drcell, "my_opac_info_table_header");
123 add_css_class(bcell, "my_opac_info_table_header");
124 add_css_class(ccell, "my_opac_info_table_header");
125 add_css_class(rcell, "my_opac_info_table_header");
126 add_css_class(rbcell, "my_opac_info_table_header");
129 if(data.length < 1) {
130 debug("No circs exist for this user");
131 circRow = obj.infoTable.insertRow(obj.infoTable.rows.length);
132 circRow.insertCell(0).appendChild(
133 mktext("No items currently checked out"));
137 for( var index in data ) {
139 var circ = data[index].circ;
140 var record = data[index].record;
141 var copy = data[index].copy;
142 circRow = obj.infoTable.insertRow(obj.infoTable.rows.length);
145 //var due = new Date(parseInt(circ.due_date() + "000")).toLocaleString();
146 var due = circ.due_date();
148 /* chop the 'time' portion of the date */
149 due = due.replace(/[0-9][0-9]:.*$/,"");
151 var title_href = createAppElement("a");
152 title_href.setAttribute("href","?sub_frame=1&target=record_detail&record=" + record.doc_id() );
153 title_href.setAttribute("target","_top"); /* escape to the outermost frame */
154 title_href.appendChild(mktext(record.title()));
156 var renewbox = elem("input",
157 {type:"checkbox", id:"renew_checkbox_" + record.doc_id()});
159 /* grab circ lib name */
160 var org = obj._getOrgUnit(copy.circ_lib());
163 /* for each circulation, build a row of data */
164 var titleCell = circRow.insertCell(circRow.cells.length);
165 var dueCell = circRow.insertCell(circRow.cells.length);
166 var durationCell = circRow.insertCell(circRow.cells.length);
167 var barcodeCell = circRow.insertCell(circRow.cells.length);
168 var circLibCell = circRow.insertCell(circRow.cells.length);
169 var renewRemainCell = circRow.insertCell(circRow.cells.length);
170 var renewCell = circRow.insertCell(circRow.cells.length);
172 add_css_class(titleCell, "my_opac_profile_cell");
173 add_css_class(dueCell, "my_opac_profile_cell");
174 add_css_class(durationCell, "my_opac_profile_cell");
175 add_css_class(barcodeCell, "my_opac_profile_cell");
176 add_css_class(circLibCell, "my_opac_profile_cell");
177 add_css_class(renewRemainCell, "my_opac_profile_cell");
178 add_css_class(renewCell, "my_opac_profile_cell");
180 titleCell.appendChild(title_href);
181 dueCell.appendChild(mktext(due));
182 durationCell.appendChild(mktext(circ.duration()));
183 barcodeCell.appendChild(mktext(copy.barcode()));
184 circLibCell.appendChild(mktext(org));
185 renewRemainCell.appendChild(mktext(circ.renewal_remaining()));
186 renewCell.appendChild(renewbox);
193 MyOPACSPage.prototype.getCheckedOut = function(callback) {
195 /* grab our circs and records */
196 var request = new RemoteRequest(
198 "open-ils.circ.actor.user.checked_out",
199 this.user.getSessionId() );
202 request.setCompleteCallback(
205 callback(obj, req.getResultObject());
213 MyOPACSPage.prototype._drawProfile = function() {
215 this.user.fleshMe(true);
216 var infot = elem("table");
217 this.infoTable.insertRow(0).insertCell(0).appendChild(infot);
218 this.infoTable.insertRow(1).insertCell(0).appendChild(
219 elem("div",{id:"my_opac_update_info"}));
221 var urow = infot.insertRow(infot.rows.length);
222 var prow = infot.insertRow(infot.rows.length);
223 var erow = infot.insertRow(infot.rows.length);
224 var brow = infot.insertRow(infot.rows.length);
225 var arow = infot.insertRow(infot.rows.length);
226 var a2row = infot.insertRow(infot.rows.length);
228 var ucell = urow.insertCell(urow.cells.length);
229 var ucell2 = urow.insertCell(urow.cells.length);
230 var ucell3 = urow.insertCell(urow.cells.length);
232 var pcell = prow.insertCell(prow.cells.length);
233 var pcell2 = prow.insertCell(prow.cells.length);
234 var pcell3 = prow.insertCell(prow.cells.length);
236 var ecell = erow.insertCell(erow.cells.length);
237 var ecell2 = erow.insertCell(erow.cells.length);
238 var ecell3 = erow.insertCell(erow.cells.length);
240 var bcell = brow.insertCell(brow.cells.length);
241 var bcell2 = brow.insertCell(brow.cells.length);
242 var bcell3 = brow.insertCell(brow.cells.length);
244 add_css_class(ucell, "my_opac_info_table_header");
245 add_css_class(pcell, "my_opac_info_table_header");
246 add_css_class(ecell, "my_opac_info_table_header");
247 add_css_class(bcell, "my_opac_info_table_header");
249 add_css_class(ucell2, "my_opac_profile_cell");
250 add_css_class(pcell2, "my_opac_profile_cell");
251 add_css_class(ecell2, "my_opac_profile_cell");
252 add_css_class(bcell2, "my_opac_profile_cell");
254 add_css_class(ucell3, "my_opac_profile_cell");
255 add_css_class(pcell3, "my_opac_profile_cell");
256 add_css_class(ecell3, "my_opac_profile_cell");
257 add_css_class(bcell3, "my_opac_profile_cell");
259 var ubold = elem("b");
260 var pbold = elem("b");
261 var ebold = elem("b");
262 var bbold = elem("b");
263 var abold = elem("b");
265 var uclick = elem("a",
266 {id:"uname_link",href:"javascript:void(0);",
267 style:"text-decoration:underline;"}, null, "Change");
269 var pclick = elem("a",
270 {id:"passwd_link",href:"javascript:void(0);",
271 style:"text-decoration:underline;"}, null, "Change");
273 var eclick = elem("a",
274 {id:"email_link",href:"javascript:void(0);",
275 style:"text-decoration:underline;"}, null, "Change");
278 uclick.onclick = function() { obj.updateUsername(); }
279 pclick.onclick = function() { obj.updatePassword(); }
280 eclick.onclick = function() { obj.updateEmail(); }
282 ucell.appendChild(mktext("Username"));
283 ubold.appendChild(mktext(this.user.userObject.usrname()));
284 ucell2.appendChild(ubold);
285 ucell3.appendChild(uclick);
287 pcell.appendChild(mktext("Password"));
288 pbold.appendChild(mktext("N/A"));
289 pcell2.appendChild(pbold);
290 pcell3.appendChild(pclick);
292 ecell.appendChild(mktext("Email Address"));
293 ebold.appendChild(mktext(this.user.userObject.email()));
294 ecell2.appendChild(ebold);
295 ecell3.appendChild(eclick);
297 bcell.appendChild(mktext("Active Barcode"));
298 bbold.appendChild(mktext(this.user.userObject.card().barcode()));
299 bcell2.appendChild(bbold);
300 bcell3.appendChild(mktext(" "));
302 var addrTable = elem("table");
303 add_css_class(addrTable, "my_opac_addr_table");
304 var row = addrTable.insertRow(0);
305 var mailing = row.insertCell(0);
306 var space = row.insertCell(1);
307 var billing = row.insertCell(2);
309 space.setAttribute("style","width: 30px");
310 space.appendChild(mktext(" "));
312 var addr = this.user.userObject.mailing_address();
313 mailing.appendChild(this.mkAddrTable("Mailing Address", addr));
315 addr = this.user.userObject.billing_address();
316 billing.appendChild(this.mkAddrTable("Billing Address", addr));
318 this.infoPane.appendChild(elem("br"));
320 this.infoPane.appendChild(elem("hr"));
321 this.infoPane.appendChild(elem("br"));
322 this.infoPane.appendChild(addrTable);
328 MyOPACSPage.prototype.mkAddrTable = function(type, addr) {
329 var table = elem("table");
331 var header_row = table.insertRow(table.rows.length);
332 var header_cell = header_row.insertCell(0);
333 add_css_class(header_cell,"my_opac_info_table_header");
334 header_cell.id = "header_cell";
335 header_cell.colSpan = 2;
336 header_cell.setAttribute("colspan", "2");
337 header_cell.appendChild(mktext(type));
339 var s1row = table.insertRow(table.rows.length);
340 var s2row = table.insertRow(table.rows.length);
341 var cityrow = table.insertRow(table.rows.length);
342 var ziprow = table.insertRow(table.rows.length);
343 var staterow = table.insertRow(table.rows.length);
345 var s1cell = s1row.insertCell(0);
346 var s2cell = s2row.insertCell(0);
347 var citycell = cityrow.insertCell(0);
348 var zipcell = ziprow.insertCell(0);
349 var statecell = staterow.insertCell(0);
351 add_css_class(s1cell, "my_opac_info_table_header");
352 add_css_class(s2cell, "my_opac_info_table_header");
353 add_css_class(citycell, "my_opac_info_table_header");
354 add_css_class(zipcell, "my_opac_info_table_header");
355 add_css_class(statecell, "my_opac_info_table_header");
357 s1cell.appendChild(mktext("Address 1"));
358 s2cell.appendChild(mktext("Address 2"));
359 citycell.appendChild(mktext("City"));
360 zipcell.appendChild(mktext("Zip"));
361 statecell.appendChild(mktext("State"));
364 s1cell = s1row.insertCell(1);
365 s2cell = s2row.insertCell(1);
366 citycell = cityrow.insertCell(1);
367 zipcell = ziprow.insertCell(1);
368 statecell = staterow.insertCell(1);
370 add_css_class(s1cell, "my_opac_profile_cell");
371 add_css_class(s2cell, "my_opac_profile_cell");
372 add_css_class(citycell, "my_opac_profile_cell");
373 add_css_class(zipcell, "my_opac_profile_cell");
374 add_css_class(statecell, "my_opac_profile_cell");
377 s1cell.appendChild(mktext(addr.street1()));
378 s2cell.appendChild(mktext(addr.street2()));
379 citycell.appendChild(mktext(addr.city()));
380 zipcell.appendChild(mktext(addr.post_code()));
381 statecell.appendChild(mktext(addr.state()));
387 MyOPACSPage.prototype.updateUsername = function() {
388 var div = getById("my_opac_update_info");
390 /* user clicks to close */
391 if(getById("my_opac_update_usrname")) {
398 var ut = elem("input",{type:"text",id:"new_uname"});
399 var but = elem("input",{type:"submit",value:"Update"});
400 var table = elem("table");
401 table.id = "my_opac_update_usrname";
402 var row = table.insertRow(0);
405 add_css_class(table,"my_opac_update_table");
407 var c0 = row.insertCell(0);
408 var c1 = row.insertCell(1);
409 var c2 = row.insertCell(2);
411 c0.appendChild(mktext("Enter new username: " ));
415 div.appendChild(elem("br"));
416 div.appendChild(table);
418 try{ut.focus();}catch(E){}
420 /* verify looks ok, send the update request */
422 but.onclick = function() {
423 var uname = getById("new_uname").value;
424 if(uname == null || uname == "") {
425 alert("Please enter a username");
428 var resp = obj.user.updateUsername(uname);
429 if(resp) alert("Username updated successfully");
430 else{ alert("Username update failed"); return; }
436 MyOPACSPage.prototype.updatePassword = function() {
437 var div = getById("my_opac_update_info");
439 /* user clicks to close */
440 if(getById("my_opac_update_password")) {
446 var ut = elem("input",{type:"password",size:"15",id:"old_password"});
447 var ut2 = elem("input",{type:"password",size:"15",id:"new_password_1"});
448 var ut3 = elem("input",{type:"password",size:"15",id:"new_password_2"});
449 var but = elem("input",{type:"submit",value:"Update"});
451 var table = elem("table");
452 table.id = "my_opac_update_password";
453 add_css_class(table,"my_opac_update_table");
455 var row = table.insertRow(0);
457 var c0 = row.insertCell(0);
458 var c1 = row.insertCell(1);
459 var c2 = row.insertCell(2);
460 var c3 = row.insertCell(3);
461 var c4 = row.insertCell(4);
462 var c5 = row.insertCell(5);
463 var c6 = row.insertCell(6);
465 c0.appendChild(mktext("Current password: " ));
468 c2.appendChild(mktext("New password: " ));
471 c4.appendChild(mktext("Repeat new password: " ));
475 div.appendChild(elem("br"));
476 div.appendChild(table);
479 try{ut.focus();}catch(E){}
481 /* verify looks ok, send the update request */
483 but.onclick = function() {
485 var old = getById("old_password").value;
486 var p1 = getById("new_password_1").value;
487 var p2 = getById("new_password_2").value;
489 if(!old || !p1 || !p2) {
490 alert("Please fill in all fields");
495 alert("New passwords do not match");
499 var resp = obj.user.updatePassword(old, p1);
500 if(resp) alert("Password updated successfully");
501 else {alert("Password change failed"); return; }
508 MyOPACSPage.prototype.updateEmail = function(){
509 var div = getById("my_opac_update_info");
511 /* user clicks to close */
512 if(getById("my_opac_update_usrname")) {
519 var ut = elem("input",{type:"text",id:"new_email"});
520 var but = elem("input",{type:"submit",value:"Update"});
521 var table = elem("table");
522 table.id = "my_opac_update_usrname";
523 var row = table.insertRow(0);
525 add_css_class(table,"my_opac_update_table");
527 var c0 = row.insertCell(0);
528 var c1 = row.insertCell(1);
529 var c2 = row.insertCell(2);
531 c0.appendChild(mktext("Enter new email address: " ));
535 div.appendChild(elem("br"));
536 div.appendChild(table);
538 try{ut.focus();}catch(E){}
540 /* verify looks ok, send the update request */
542 but.onclick = function() {
543 var uname = getById("new_email").value;
544 if(uname == null || uname == "") {
545 alert("Please enter a valid email address");
548 var resp = obj.user.updateEmail(uname);
549 if(resp) alert("Email updated successfully");
550 else{ alert("Email update failed"); return; }
557 MyOPACSPage.prototype._drawHolds = function() {
559 var holds = this.grabHolds();
560 var table = this.infoTable;
561 var row = table.insertRow(table.rows.length);
563 var cell = row.insertCell(row.cells.length);
564 add_css_class(cell, "my_opac_info_table_header");
565 cell.appendChild(mktext("Title"));
567 cell = row.insertCell(row.cells.length);
568 add_css_class(cell, "my_opac_info_table_header");
569 cell.appendChild(mktext("Author"));
571 cell = row.insertCell(row.cells.length);
572 add_css_class(cell, "my_opac_info_table_header");
573 cell.appendChild(mktext("Format(s)"));
575 cell = row.insertCell(row.cells.length);
576 add_css_class(cell, "my_opac_info_table_header");
577 cell.appendChild(mktext("Pickup Location"));
579 cell = row.insertCell(row.cells.length);
580 add_css_class(cell, "my_opac_info_table_header");
581 cell.appendChild(mktext("Notify Email"));
583 cell = row.insertCell(row.cells.length);
584 add_css_class(cell, "my_opac_info_table_header");
585 cell.appendChild(mktext("Notify Phone"));
587 for( var idx = 0; idx != holds.length; idx++ ) {
588 _doCallbackDance(table, holds[idx]);
592 function _doCallbackDance(table, hold) {
593 if(hold == null) return;
594 debug("Setting holds callback with hold " + hold.id() );
595 var func = function(rec) {_drawHoldsRow(table, hold, rec)};
597 /* grab the record that is held */
598 if(hold.hold_type() == "M")
599 fetchMetaRecord(hold.target(), func);
601 if(hold.hold_type() == "T")
602 fetchRecord(hold.target(), func);
607 function _drawHoldsRow(table, hold, record) {
609 if(record == null || record.length == 0) return;
610 debug("In holds callback with hold " + hold );
612 var row = table.insertRow(table.rows.length);
613 var cell = row.insertCell(row.cells.length);
615 add_css_class(cell, "my_opac_profile_cell");
616 cell.style.width = "35%";
617 cell.appendChild(mktext(record.title()));
618 cell = row.insertCell(row.cells.length);
619 add_css_class(cell, "my_opac_profile_cell");
620 cell.appendChild(mktext(record.author()));
622 cell = row.insertCell(row.cells.length);
623 add_css_class(cell, "my_opac_profile_cell");
625 var formats = hold.holdable_formats();
626 if(formats == null || formats == "") /* only metarecord holds have holdable_formats */
627 formats = modsFormatToMARC(record.types_of_resource()[0]);
629 cell.appendChild(_mkFormatList(formats));
631 cell = row.insertCell(row.cells.length);
632 add_css_class(cell, "my_opac_profile_cell");
633 cell.appendChild(mktext(findOrgUnit(hold.pickup_lib()).name()));
635 cell = row.insertCell(row.cells.length);
636 add_css_class(cell, "my_opac_profile_cell");
637 cell.appendChild(mktext(hold.email_notify()));
638 cell = row.insertCell(row.cells.length);
639 add_css_class(cell, "my_opac_profile_cell");
640 cell.appendChild(mktext(hold.phone_notify()));
644 function _mkFormatList(formats) {
646 var div = elem("div");
647 var seen = new Object();
648 for( var i = 0; i!= formats.length; i++ ) {
649 var form = MARCFormatToMods(formats.charAt(i));
650 if(seen[form]) continue;
651 div.appendChild(mkResourceImage(form));
660 MyOPACSPage.prototype.grabHolds = function() {
662 var req = new RemoteRequest(
664 "open-ils.circ.holds.retrieve",
665 this.user.session_id,
666 this.user.userObject.id() );
668 return req.getResultObject();
680 /* ----------------------------------------------------------------- ========== ------------ */
684 MyOPACSPage.prototype.drawPersonal = function() {
685 this.personalBox = new Box();
686 this.personalBox.init(
687 "Edit User Information", false, false);
691 var uname_div = createAppElement("div");
692 var uname_href = createAppElement("a");
693 uname_href.onclick = function() {obj.buildUpdateUname();}
694 uname_href.setAttribute("href", "javascript:void(0)");
695 uname_href.appendChild(mktext("Change Username"));
697 uname_div.appendChild(mktext("Username is "));
698 var bold = createAppElement("b");
699 bold.appendChild(mktext(this.user.username));
700 uname_div.appendChild(bold);
701 uname_div.appendChild(createAppElement("br"));
702 uname_div.appendChild(uname_href);
703 this.personalBox.addItem( uname_div,"edit_username");
705 this.personalBox.addItem( createAppElement("hr"),"break");
707 var password_href = createAppElement("a");
708 password_href.setAttribute("href", "javascript:void(0)");
709 password_href.onclick = function() {obj.buildUpdatePassword();}
710 password_href.appendChild(mktext("Change Password"));
711 this.personalBox.addItem( password_href,"edit_password");
713 this.personalBox.addItem( createAppElement("hr"),"break2");
715 var email_div = createAppElement("div");
716 var email_href = createAppElement("a");
717 email_href.onclick = function() {obj.buildUpdateEmail();}
718 email_href.setAttribute("href", "javascript:void(0)");
719 email_href.appendChild(mktext("Change Email Address"));
721 var em = this.user.userObject.email();
722 if(!em) em = "[empty]";
724 email_div.appendChild(mktext("Email address is "));
725 var bold = createAppElement("b");
726 bold.appendChild(mktext(em));
727 email_div.appendChild(bold);
728 email_div.appendChild(createAppElement("br"));
729 email_div.appendChild(email_href);
730 this.personalBox.addItem( email_div,"edit_email");
733 this.personal.appendChild(this.personalBox.getNode());
737 MyOPACSPage.prototype.buildUpdateEmail = function() {
738 var item = this.personalBox.findByKey("edit_email");
739 var node = item.getNode();
741 if(node.childNodes.length > 1) {
742 node.removeChild(node.childNodes[1]);
746 var newEmail = createAppElement("input");
747 newEmail.setAttribute("type", "text");
748 newEmail.id = "new_email";
750 var newEmail2 = createAppElement("input");
751 newEmail2.setAttribute("type", "text");
752 newEmail2.id = "new_email2";
754 var button = createAppElement("input");
755 button.setAttribute("type", "submit");
756 button.setAttribute("value", "Submit");
759 button.onclick = function() {
761 var em = getById("new_email").value;
762 var em2 = getById("new_email2").value;
764 alert("Email addresses do not match");
767 var resp = obj.user.updateEmail(em);
768 if(resp) { alert("Email updated successfully"); obj.draw();}
771 var node = obj.personalBox.findByKey("edit_email").getNode();
772 node.removeChild(node.childNodes[1]);
776 var chunk = createAppElement("div");
777 chunk.className = "edit_personal_active";
779 chunk.appendChild(createAppElement("br"));
780 chunk.appendChild(mktext("Enter New Email:"));
781 chunk.appendChild(newEmail);
782 chunk.appendChild(createAppElement("br"));
783 chunk.appendChild(createAppElement("br"));
784 chunk.appendChild(mktext("Repeat New Email:"));
785 chunk.appendChild(createAppElement("br"));
786 chunk.appendChild(newEmail2);
787 chunk.appendChild(createAppElement("br"));
788 chunk.appendChild(createAppElement("br"));
789 chunk.appendChild(mktext(" "));
791 var center = createAppElement("center");
792 center.appendChild(button);
793 chunk.appendChild(center);
795 node.appendChild(chunk);
796 try { newEmail.focus(); } catch(E){}
800 MyOPACSPage.prototype.buildUpdateUname = function() {
801 var item = this.personalBox.findByKey("edit_username");
802 var node = item.getNode();
804 if(node.childNodes.length > 1) {
805 node.removeChild(node.childNodes[1]);
809 var newName = createAppElement("input");
810 newName.setAttribute("type", "text");
811 newName.id = "new_uname";
813 var button = createAppElement("input");
814 button.setAttribute("type", "submit");
815 button.setAttribute("value", "Submit");
818 button.onclick = function() {
820 var resp = obj.user.updateUsername(getById("new_uname").value);
821 if(resp) { alert("Username updated successfully"); obj.draw()}
822 else { alert("Username update failed"); return; }
824 var node = obj.personalBox.findByKey("edit_username").getNode();
825 node.removeChild(node.childNodes[1]);
829 var chunk = createAppElement("div");
830 chunk.className = "edit_personal_active";
832 chunk.appendChild(createAppElement("br"));
833 chunk.appendChild(mktext("Enter New Username:"));
834 chunk.appendChild(newName);
835 chunk.appendChild(createAppElement("br"));
836 chunk.appendChild(createAppElement("br"));
837 chunk.appendChild(mktext(" "));
839 var center = createAppElement("center");
840 center.appendChild(button);
841 chunk.appendChild(center);
843 //chunk.appendChild(createAppElement("br"));
844 //chunk.appendChild(createAppElement("br"));
845 node.appendChild(chunk);
846 try { newName.focus(); } catch(E){}
849 MyOPACSPage.prototype.buildUpdatePassword = function() {
850 var item = this.personalBox.findByKey("edit_password");
851 var node = item.getNode();
852 if(node.childNodes.length > 1) {
853 node.removeChild(node.childNodes[1]);
857 var oldPassword = createAppElement("input");
858 oldPassword.setAttribute("type", "password");
859 oldPassword.id = "old_password";
861 var newPassword = createAppElement("input");
862 newPassword.setAttribute("type", "password");
863 newPassword.id = "new_password";
865 var newPassword2 = createAppElement("input");
866 newPassword2.setAttribute("type", "password");
867 newPassword2.id = "new_password2";
870 var button = createAppElement("input");
871 button.setAttribute("type", "submit");
872 button.setAttribute("value", "Submit");
875 button.onclick = function() {
877 var new1 = getById("new_password").value;
878 var new2 = getById("new_password2").value;
879 var old = getById("old_password").value;
882 alert("Passwords do not match");
886 var resp = obj.user.updatePassword(old, new1);
887 if(resp) { alert("Password updated successfully"); }
890 var node = obj.personalBox.findByKey("edit_password").getNode();
891 node.removeChild(node.childNodes[1]);
894 var chunk = createAppElement("div");
895 chunk.className = "edit_personal_active";
897 chunk.appendChild(createAppElement("br"));
898 chunk.appendChild(mktext("Current Password:"));
899 chunk.appendChild(oldPassword);
900 chunk.appendChild(createAppElement("br"));
902 chunk.appendChild(createAppElement("br"));
903 chunk.appendChild(mktext("Enter New Password:"));
904 chunk.appendChild(newPassword);
905 chunk.appendChild(createAppElement("br"));
907 chunk.appendChild(createAppElement("br"));
908 chunk.appendChild(mktext("Re-Enter New Password:"));
909 chunk.appendChild(newPassword2);
910 chunk.appendChild(createAppElement("br"));
911 chunk.appendChild(createAppElement("br"));
913 chunk.appendChild(mktext(" "));
915 var center = createAppElement("center");
916 center.appendChild(button);
917 chunk.appendChild(center);
919 //chunk.appendChild(createAppElement("br"));
920 node.appendChild(chunk);
921 try { newPassword.focus(); } catch(E){}
927 MyOPACSPage.prototype.getCheckedOut = function() {
929 this.checkedOutBox = new Box();
930 this.checkedOutBox.init(
931 "Items Checked Out", false, false);
932 this.checkedOutBox.sortByKey();
935 var request = new RemoteRequest(
937 "open-ils.circ.actor.user.checked_out",
938 this.user.getSessionId() );
941 request.setCompleteCallback(
943 obj._addCircs(req.getResultObject());
952 MyOPACSPage.prototype._addCircs = function(data) {
954 if(data.length < 1) {
955 debug("No circs exist for this user");
956 this.checkedOutBox.addItem(
957 mktext("No items currently checked out") );
961 for( var index in data ) {
963 var circ = data[index].circ;
964 var record = data[index].record;
965 var copy = data[index].copy;
968 var due = new Date(parseInt(circ.due_date() + "000")).toLocaleString();
969 /* chop the 'time' portion of the date */
970 due = due.replace(/[0-9][0-9]:[0-9][0-9]:[0-9][0-9]/,"");
972 var title_href = createAppElement("a");
973 title_href.setAttribute("href","?sub_frame=1&target=record_detail&record=" + record.doc_id() );
974 title_href.setAttribute("target","_top"); /* escape to the outermost frame */
975 title_href.appendChild(mktext(record.title()));
977 /* grab circ lib name */
978 var org = this._getOrgUnit(copy.circ_lib());
981 /* for each circulation, build a small table of data */
982 var table = createAppElement("table");
983 this._mkCircRow(table, "Title", title_href);
984 this._mkCircRow(table, "Due Date", mktext(due));
985 this._mkCircRow(table, "Duration", mktext(circ.duration()));
986 this._mkCircRow(table, "Barcode", mktext(copy.barcode()));
987 this._mkCircRow(table, "Circulating Library", mktext(org));
990 this.checkedOutBox.addItem(table);
992 if(index < data.length - 1)
993 this.checkedOutBox.addItem(createAppElement("hr"));
998 MyOPACSPage.prototype._mkCircRow = function(table, title, data) {
999 var row = table.insertRow(table.rows.length);
1000 var cell = row.insertCell(row.cells.length);
1001 cell.appendChild(mktext(title));
1002 cell = row.insertCell(row.cells.length);
1003 cell.appendChild(data);
1007 MyOPACSPage.prototype._getOrgUnit = function(org_id) {
1008 var request = new RemoteRequest(
1010 "open-ils.actor.org_unit.retrieve",
1011 this.user.getSessionId(),
1014 return request.getResultObject();