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 / Phone"));
583 cell = row.insertCell(row.cells.length);
584 add_css_class(cell, "my_opac_info_table_header");
585 cell.appendChild(mktext("Cancel"));
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));
630 cell.noWrap = "nowrap";
631 cell.setAttribute("nowrap", "nowrap");
633 cell = row.insertCell(row.cells.length);
634 add_css_class(cell, "my_opac_profile_cell");
635 cell.appendChild(mktext(findOrgUnit(hold.pickup_lib()).name()));
637 cell = row.insertCell(row.cells.length);
638 add_css_class(cell, "my_opac_profile_cell");
639 cell.appendChild(_buildChangeEmailNotify(hold));
640 cell.appendChild(elem("br"));
641 cell.appendChild(_buildChangePhoneNotify(hold));
643 cell = row.insertCell(row.cells.length);
644 var a = elem("a",{href:"javascript:void(0);",
645 style:"text-decoration:underline"},null, "Cancel");
646 a.onclick = function(){_cancelHoldRequest(hold);};
647 add_css_class(cell, "my_opac_profile_cell");
651 function _cancelHoldRequest(hold) {
652 alert("Canceling hold " + hold.id());
655 function _buildChangeEmailNotify(hold) {
656 var a = elem("a",{href:"javascript:void(0);",
657 style:"text-decoration:underline"},null, hold.email_notify());
658 var et1 = elem("input",{type:"text",size:"20"});
659 var et2 = elem("input",{type:"text",size:"20"});
660 var box = new PopupBox(a);
661 var but = elem("input",{type:"submit",value:"Submit"});
662 var can = elem("input",{type:"submit",value:"Cancel"});
664 but.onclick = function(){
665 var ret = _submitUpdateNotifyEmail(hold);
668 can.onclick = function(){ box.hide(); };
670 box.title("Change Holds Notification Email");
671 box.addText("Enter new notification email");
674 box.addText("Repeat email");
677 box.makeGroup([ but, can ]);
679 a.onclick = function(){box.show();}
683 /* return true to show success */
684 function _submitUpdateNotifyEmail(hold) {
685 alert("updating email for hold " + hold.id());
689 function _submitUpdateNotifyPhone(hold) {
690 alert("updating phone for hold " + hold.id());
695 function _buildChangePhoneNotify(hold) {
697 var a = elem("a",{href:"javascript:void(0);",
698 style:"text-decoration:underline"},null, hold.phone_notify());
700 var et1 = elem("input",{type:"text",size:"10"});
701 var box = new PopupBox(a);
702 var but = elem("input",{type:"submit",value:"Submit"});
703 var can = elem("input",{type:"submit",value:"Cancel"});
705 but.onclick = function(){
706 var ret = _submitUpdateNotifyPhone(hold);
709 can.onclick = function(){ box.hide(); };
711 box.title("Change Holds Notification Phone Number");
712 box.addText("Enter new notification number");
715 box.makeGroup([ but, can ]);
717 a.onclick = function(){box.show();}
722 function _mkFormatList(formats) {
724 var div = elem("div");
725 var seen = new Object();
726 for( var i = 0; i!= formats.length; i++ ) {
727 var form = MARCFormatToMods(formats.charAt(i));
728 if(seen[form]) continue;
729 div.appendChild(mkResourceImage(form));
738 MyOPACSPage.prototype.grabHolds = function() {
740 var req = new RemoteRequest(
742 "open-ils.circ.holds.retrieve",
743 this.user.session_id,
744 this.user.userObject.id() );
746 return req.getResultObject();
758 /* ----------------------------------------------------------------- ========== ------------ */
762 MyOPACSPage.prototype.drawPersonal = function() {
763 this.personalBox = new Box();
764 this.personalBox.init(
765 "Edit User Information", false, false);
769 var uname_div = createAppElement("div");
770 var uname_href = createAppElement("a");
771 uname_href.onclick = function() {obj.buildUpdateUname();}
772 uname_href.setAttribute("href", "javascript:void(0)");
773 uname_href.appendChild(mktext("Change Username"));
775 uname_div.appendChild(mktext("Username is "));
776 var bold = createAppElement("b");
777 bold.appendChild(mktext(this.user.username));
778 uname_div.appendChild(bold);
779 uname_div.appendChild(createAppElement("br"));
780 uname_div.appendChild(uname_href);
781 this.personalBox.addItem( uname_div,"edit_username");
783 this.personalBox.addItem( createAppElement("hr"),"break");
785 var password_href = createAppElement("a");
786 password_href.setAttribute("href", "javascript:void(0)");
787 password_href.onclick = function() {obj.buildUpdatePassword();}
788 password_href.appendChild(mktext("Change Password"));
789 this.personalBox.addItem( password_href,"edit_password");
791 this.personalBox.addItem( createAppElement("hr"),"break2");
793 var email_div = createAppElement("div");
794 var email_href = createAppElement("a");
795 email_href.onclick = function() {obj.buildUpdateEmail();}
796 email_href.setAttribute("href", "javascript:void(0)");
797 email_href.appendChild(mktext("Change Email Address"));
799 var em = this.user.userObject.email();
800 if(!em) em = "[empty]";
802 email_div.appendChild(mktext("Email address is "));
803 var bold = createAppElement("b");
804 bold.appendChild(mktext(em));
805 email_div.appendChild(bold);
806 email_div.appendChild(createAppElement("br"));
807 email_div.appendChild(email_href);
808 this.personalBox.addItem( email_div,"edit_email");
811 this.personal.appendChild(this.personalBox.getNode());
815 MyOPACSPage.prototype.buildUpdateEmail = function() {
816 var item = this.personalBox.findByKey("edit_email");
817 var node = item.getNode();
819 if(node.childNodes.length > 1) {
820 node.removeChild(node.childNodes[1]);
824 var newEmail = createAppElement("input");
825 newEmail.setAttribute("type", "text");
826 newEmail.id = "new_email";
828 var newEmail2 = createAppElement("input");
829 newEmail2.setAttribute("type", "text");
830 newEmail2.id = "new_email2";
832 var button = createAppElement("input");
833 button.setAttribute("type", "submit");
834 button.setAttribute("value", "Submit");
837 button.onclick = function() {
839 var em = getById("new_email").value;
840 var em2 = getById("new_email2").value;
842 alert("Email addresses do not match");
845 var resp = obj.user.updateEmail(em);
846 if(resp) { alert("Email updated successfully"); obj.draw();}
849 var node = obj.personalBox.findByKey("edit_email").getNode();
850 node.removeChild(node.childNodes[1]);
854 var chunk = createAppElement("div");
855 chunk.className = "edit_personal_active";
857 chunk.appendChild(createAppElement("br"));
858 chunk.appendChild(mktext("Enter New Email:"));
859 chunk.appendChild(newEmail);
860 chunk.appendChild(createAppElement("br"));
861 chunk.appendChild(createAppElement("br"));
862 chunk.appendChild(mktext("Repeat New Email:"));
863 chunk.appendChild(createAppElement("br"));
864 chunk.appendChild(newEmail2);
865 chunk.appendChild(createAppElement("br"));
866 chunk.appendChild(createAppElement("br"));
867 chunk.appendChild(mktext(" "));
869 var center = createAppElement("center");
870 center.appendChild(button);
871 chunk.appendChild(center);
873 node.appendChild(chunk);
874 try { newEmail.focus(); } catch(E){}
878 MyOPACSPage.prototype.buildUpdateUname = function() {
879 var item = this.personalBox.findByKey("edit_username");
880 var node = item.getNode();
882 if(node.childNodes.length > 1) {
883 node.removeChild(node.childNodes[1]);
887 var newName = createAppElement("input");
888 newName.setAttribute("type", "text");
889 newName.id = "new_uname";
891 var button = createAppElement("input");
892 button.setAttribute("type", "submit");
893 button.setAttribute("value", "Submit");
896 button.onclick = function() {
898 var resp = obj.user.updateUsername(getById("new_uname").value);
899 if(resp) { alert("Username updated successfully"); obj.draw()}
900 else { alert("Username update failed"); return; }
902 var node = obj.personalBox.findByKey("edit_username").getNode();
903 node.removeChild(node.childNodes[1]);
907 var chunk = createAppElement("div");
908 chunk.className = "edit_personal_active";
910 chunk.appendChild(createAppElement("br"));
911 chunk.appendChild(mktext("Enter New Username:"));
912 chunk.appendChild(newName);
913 chunk.appendChild(createAppElement("br"));
914 chunk.appendChild(createAppElement("br"));
915 chunk.appendChild(mktext(" "));
917 var center = createAppElement("center");
918 center.appendChild(button);
919 chunk.appendChild(center);
921 //chunk.appendChild(createAppElement("br"));
922 //chunk.appendChild(createAppElement("br"));
923 node.appendChild(chunk);
924 try { newName.focus(); } catch(E){}
927 MyOPACSPage.prototype.buildUpdatePassword = function() {
928 var item = this.personalBox.findByKey("edit_password");
929 var node = item.getNode();
930 if(node.childNodes.length > 1) {
931 node.removeChild(node.childNodes[1]);
935 var oldPassword = createAppElement("input");
936 oldPassword.setAttribute("type", "password");
937 oldPassword.id = "old_password";
939 var newPassword = createAppElement("input");
940 newPassword.setAttribute("type", "password");
941 newPassword.id = "new_password";
943 var newPassword2 = createAppElement("input");
944 newPassword2.setAttribute("type", "password");
945 newPassword2.id = "new_password2";
948 var button = createAppElement("input");
949 button.setAttribute("type", "submit");
950 button.setAttribute("value", "Submit");
953 button.onclick = function() {
955 var new1 = getById("new_password").value;
956 var new2 = getById("new_password2").value;
957 var old = getById("old_password").value;
960 alert("Passwords do not match");
964 var resp = obj.user.updatePassword(old, new1);
965 if(resp) { alert("Password updated successfully"); }
968 var node = obj.personalBox.findByKey("edit_password").getNode();
969 node.removeChild(node.childNodes[1]);
972 var chunk = createAppElement("div");
973 chunk.className = "edit_personal_active";
975 chunk.appendChild(createAppElement("br"));
976 chunk.appendChild(mktext("Current Password:"));
977 chunk.appendChild(oldPassword);
978 chunk.appendChild(createAppElement("br"));
980 chunk.appendChild(createAppElement("br"));
981 chunk.appendChild(mktext("Enter New Password:"));
982 chunk.appendChild(newPassword);
983 chunk.appendChild(createAppElement("br"));
985 chunk.appendChild(createAppElement("br"));
986 chunk.appendChild(mktext("Re-Enter New Password:"));
987 chunk.appendChild(newPassword2);
988 chunk.appendChild(createAppElement("br"));
989 chunk.appendChild(createAppElement("br"));
991 chunk.appendChild(mktext(" "));
993 var center = createAppElement("center");
994 center.appendChild(button);
995 chunk.appendChild(center);
997 //chunk.appendChild(createAppElement("br"));
998 node.appendChild(chunk);
999 try { newPassword.focus(); } catch(E){}
1005 MyOPACSPage.prototype.getCheckedOut = function() {
1007 this.checkedOutBox = new Box();
1008 this.checkedOutBox.init(
1009 "Items Checked Out", false, false);
1010 this.checkedOutBox.sortByKey();
1013 var request = new RemoteRequest(
1015 "open-ils.circ.actor.user.checked_out",
1016 this.user.getSessionId() );
1019 request.setCompleteCallback(
1021 obj._addCircs(req.getResultObject());
1030 MyOPACSPage.prototype._addCircs = function(data) {
1032 if(data.length < 1) {
1033 debug("No circs exist for this user");
1034 this.checkedOutBox.addItem(
1035 mktext("No items currently checked out") );
1039 for( var index in data ) {
1041 var circ = data[index].circ;
1042 var record = data[index].record;
1043 var copy = data[index].copy;
1046 var due = new Date(parseInt(circ.due_date() + "000")).toLocaleString();
1047 /* chop the 'time' portion of the date */
1048 due = due.replace(/[0-9][0-9]:[0-9][0-9]:[0-9][0-9]/,"");
1050 var title_href = createAppElement("a");
1051 title_href.setAttribute("href","?sub_frame=1&target=record_detail&record=" + record.doc_id() );
1052 title_href.setAttribute("target","_top"); /* escape to the outermost frame */
1053 title_href.appendChild(mktext(record.title()));
1055 /* grab circ lib name */
1056 var org = this._getOrgUnit(copy.circ_lib());
1059 /* for each circulation, build a small table of data */
1060 var table = createAppElement("table");
1061 this._mkCircRow(table, "Title", title_href);
1062 this._mkCircRow(table, "Due Date", mktext(due));
1063 this._mkCircRow(table, "Duration", mktext(circ.duration()));
1064 this._mkCircRow(table, "Barcode", mktext(copy.barcode()));
1065 this._mkCircRow(table, "Circulating Library", mktext(org));
1068 this.checkedOutBox.addItem(table);
1070 if(index < data.length - 1)
1071 this.checkedOutBox.addItem(createAppElement("hr"));
1076 MyOPACSPage.prototype._mkCircRow = function(table, title, data) {
1077 var row = table.insertRow(table.rows.length);
1078 var cell = row.insertCell(row.cells.length);
1079 cell.appendChild(mktext(title));
1080 cell = row.insertCell(row.cells.length);
1081 cell.appendChild(data);
1085 MyOPACSPage.prototype._getOrgUnit = function(org_id) {
1086 var request = new RemoteRequest(
1088 "open-ils.actor.org_unit.retrieve",
1089 this.user.getSessionId(),
1092 return request.getResultObject();