merging admin interface from the dojo-admin branch
[Evergreen.git] / Open-ILS / web / conify / global / actor / org_unit.html
1 <!--
2 # Copyright (C) 2008  Georgia Public Library Service / Equinox Software, Inc
3 # Mike Rylander <miker@esilibrary.com>
4
5 # This program is free software; you can redistribute it and/or
6 # modify it under the terms of the GNU General Public License
7 # as published by the Free Software Foundation; either version 2
8 # of the License, or (at your option) any later version.
9
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 # GNU General Public License for more details.
14 -->
15 <html xmlns="http://www.w3.org/1999/xhtml">
16         <head>
17                 <title>Confiy :: Global :: Actor :: Org Units</title>
18
19                 <style type="text/css">
20                         @import url("/js/dojo/dojo/resources/dojo.css");
21                         @import url("/js/dojo/dijit/themes/tundra/tundra.css");
22                         @import url("/js/dojo/dojox/widget/Toaster/Toaster.css");
23                 </style>
24
25                 <style>
26                         html, body
27                         {
28                                 height: 100%;
29                                 width: 100%;
30                                 margin: 0px 0px 0px 0px;
31                                 padding: 0px 0px 0px 0px;
32                                 overflow: hidden;
33                         }
34
35                         th
36                         {
37                                 text-align: right;
38                                 font-weight: bold;
39                                 padding-left: 20px;
40                                 padding-right: 5px;
41                         }
42                 </style>
43
44                 <!-- The OpenSRF API writ JS -->
45                 <script language='javascript' src='/opac/common/js/utils.js' type='text/javascript'></script>
46                 <script language='javascript' src='/opac/common/js/Cookies.js' type='text/javascript'></script>
47                 <script language='javascript' src='/opac/common/js/CGI.js' type='text/javascript'></script>
48                 <script language='javascript' src='/opac/common/js/JSON_v1.js' type='text/javascript'></script>
49
50                 <!-- Fieldmapper objects -->
51                 <script language='javascript' src='/opac/common/js/fmall.js' type='text/javascript'></script>
52
53                 <!-- Dojo goodness -->
54                 <script type="text/javascript" src="/js/dojo/dojo/dojo.js" djConfig="parseOnLoad: true"></script>
55                 <script type="text/javascript" src="/js/dojo/dijit/dijit.js"></script>
56
57                 <script type="text/javascript" src="org_unit.js"></script>
58
59         </head>
60
61         <body class="tundra" id='pagebody'>
62
63                 <div dojoType="dijit.layout.SplitContainer" orientation="horizontal" style="height: 100%">
64
65                         <div dojoType="dijit.layout.ContentPane" sizeShare="100">
66                                 <script type="dojo/method">
67
68                                         var ou_list_data = { label : 'shortname', identifier : 'id' };
69                                         window.dirtyStore = [];
70                 
71                                         pCRUD.request({
72                                                 method : 'open-ils.permacrud.search.aou.atomic',
73                                                 timeout : 15,
74                                                 params : [ ses, { id : { "!=" : null } }, { order_by : { aou : 'shortname' } } ],
75                                                 onerror : function (r) { throw 'Problem fetching org units';},
76                                                 oncomplete : function (r) {
77                                                         window._ou_list = r.recv().content();
78                                                         window._ou_data = aou.toStoreData( window._ou_list );
79                                                         window.ou_list_store = new dojo.data.ItemFileWriteStore({ data : window._ou_data });
80
81                                                         window.ou_list_store.onSet = function (item, attr, o, n) {
82                                                                 if (attr == 'ischanged') return;
83                                                                 if (n == o) return;
84                                                                 this.setValue( item, 'ischanged', 1);
85                                                         };
86
87                                                         dojo.addOnUnload( function (event) {
88
89                                                                 ou_list_store.fetch({
90                                                                         query : { ischanged : 1 },
91                                                                         queryOptions : { deep : true },
92                                                                         onItem : function (item, req) { try { if (this.isItem( item )) window.dirtyStore.push( item ); } catch (e) { /* meh */ } },
93                                                                         scope : ou_list_store
94                                                                 });
95
96                                                                 if (dirtyStore.length > 0) {
97                                                                         var confirmation = confirm(
98                                                                                 'There are unsaved modified Organizational Units!  '+
99                                                                                 'OK to save these changes, Cancel to abandon them.'
100                                                                         );
101
102                                                                         if (confirmation) {
103                                                                                 for (var i in window.dirtyStore) {
104                                                                                         window.current_ou = window.dirtyStore[i];
105                                                                                         save_org(true);
106                                                                                 }
107                                                                         }
108                                                                 }
109
110                                                         });
111                                                 }
112                                         }).send();
113
114                     pCRUD.request({
115                         method : 'open-ils.permacrud.search.aout.atomic',
116                         timeout : 10,
117                         params : [ ses, { id : { "!=" : null } }, { order_by : { aout : 'depth' } } ],
118                         onerror : function (r) { status_update('Problem fetching types') },
119                         oncomplete : function (r) {
120                             window._ou_type_list = r.recv().content();
121                             window._ou_type_data = aout.toStoreData( window._ou_type_list );
122                             window.ou_type_store = new dojo.data.ItemFileReadStore({ data : window._ou_type_data });
123                         }
124                     }).send();
125
126                                         highlighter.ou_tree = {};
127                                         highlighter.editor_pane = {};
128                                         highlighter.hoo_pane = {};
129                                         highlighter.addresses_pane = {};
130
131                                         highlighter.ou_tree.green = dojox.fx.highlight( { color : '#B4FFB4', node : 'ou_tree', duration : 500 } );
132                                         highlighter.ou_tree.red = dojox.fx.highlight( { color : '#FF2018', node : 'ou_tree', duration : 500 } );
133
134                                         highlighter.editor_pane.green = dojox.fx.highlight( { color : '#B4FFB4', node : 'editor_pane', duration : 500 } );
135                                         highlighter.editor_pane.red = dojox.fx.highlight( { color : '#FF2018', node : 'editor_pane', duration : 500 } );
136
137                                         highlighter.hoo_pane.green = dojox.fx.highlight( { color : '#B4FFB4', node : 'hoo_pane', duration : 500 } );
138                                         highlighter.hoo_pane.red = dojox.fx.highlight( { color : '#FF2018', node : 'hoo_pane', duration : 500 } );
139
140                                         highlighter.addresses_pane.green = dojox.fx.highlight( { color : '#B4FFB4', node : 'addresses_pane', duration : 500 } );
141                                         highlighter.addresses_pane.red = dojox.fx.highlight( { color : '#FF2018', node : 'addresses_pane', duration : 500 } );
142                                 </script>
143                                 <div
144                                   id="ou_tree"
145                                   label="Organizational Units"
146                                   query="{'_top':'true'}"
147                                   dojoType="dijit.Tree"
148                                   store="ou_list_store"
149                                   minSize="200"
150                                   jsId="ou_tree"
151                                 >
152
153                                         <script type="dojo/method" event="onClick" args="item,node">
154
155                                                 right_pane_toggler.show();
156
157                                                 current_ou = item;
158
159                                                 highlighter.editor_pane.green.play();
160                                                 status_update( 'Now editing ' + this.store.getValue( item, 'name' ) );
161
162                                                 new_kid_button.disabled = false;
163                                                 save_ou_button.disabled = false;
164                                                 delete_ou_button.disabled = false;
165
166                                                 dojo.byId('current_ou_name').innerHTML = this.store.getValue( current_ou, 'name' );
167
168                                                 var main_settings_fields = [ 'name', 'shortname', 'email', 'phone', 'ou_type' ];
169                                                 for ( var i in main_settings_fields ) {
170                                                         var field = main_settings_fields[i];
171                                                         var value = this.store.getValue( current_ou, field );
172
173                                                         if (!value) {
174                                                                 window["editor_pane_" + field].setValue( '' ); // unset the value
175                                                                 window["editor_pane_" + field].setDisplayedValue( '' ); // unset the value
176                                                         } else window["editor_pane_" + field].setValue( value );
177                                                 }
178
179                                                 if ( this.store.getValue( current_ou, '_trueRoot' ) == 'true' ) {
180                                                         editor_pane_parent_ou.disabled = true;
181                                                         editor_pane_parent_ou.setValue(null);
182                                                         editor_pane_parent_ou.setDisplayedValue('');
183                                                         editor_pane_parent_ou.validate(false);
184                                                 } else {
185                                                         editor_pane_parent_ou.disabled = false;
186                                                         editor_pane_parent_ou.validate(true);
187                                                         editor_pane_parent_ou.setValue( this.store.getValue( current_ou, 'parent_ou' ) );
188                                                 }
189
190                                                 editor_pane_opac_visible.setChecked( this.store.getValue( current_ou, 'opac_visible' ) == 't' ? true : false );
191
192                                                 hoo_load();
193                                                 addr_load();
194
195                                         </script>
196
197                                         <script type="dojo/method" event="getLabel" args="item,pI">
198                                                 var label = this.store.getValue(item,'shortname') + ' : ' + this.store.getValue(item,'name');
199                                                 if (this.store.getValue(item,'ischanged') == 1) label = '* ' + label;
200                                                 return label;
201                                         </script>
202
203                                 </div>
204                         </div>
205
206                         <div jsId="right_pane" id="right_pane" dojoType="dijit.layout.ContentPane"  sizeShare="200">
207                                 <script type="dojo/method">
208                                         window.right_pane_toggler = new dojo.fx.Toggler({ node: 'right_pane'});
209                                         window.right_pane_toggler.hide();
210                                 </script>
211
212                                 <div id="right_tabpane" dojoType="dijit.layout.TabContainer">
213         
214                                         <div id="editor_pane" dojoType="dijit.layout.ContentPane" title="Main Settings">
215
216                                                 <table class="tundra" style="margin:10px;">
217                                                         <tr>
218                                                                 <th>Org Unit Name</th>
219                                                                 <td>
220                                                                         <span id="editor_pane_name" dojoType="dijit.form.ValidationTextBox" jsId="editor_pane_name" regExp=".+" required="true">
221                                                                                 <script type="dojo/connect" event="onChange">
222                                                                                         if (current_ou) ou_list_store.setValue( current_ou, "name", this.getValue() );
223                                                                                 </script>
224                                                                         </span>
225                                                                 </td>
226                                                         </tr>
227                                                         <tr>
228                                                                 <th>Org Unit Policy Code</th>
229                                                                 <td>
230                                                                         <span id="editor_pane_shortname" dojoType="dijit.form.ValidationTextBox" jsId="editor_pane_shortname" uppercase="true" regExp=".+" required="true">
231                                                                                 <script type="dojo/connect" event="onChange">
232                                                                                         if (current_ou) ou_list_store.setValue( current_ou, "shortname", this.getValue() );
233                                                                                 </script>
234                                                                         </span>
235                                                                 </td>
236                                                         </tr>
237                                                         <tr>
238                                                                 <th>Main Email Address</th>
239                                                                 <td>
240                                                                         <span id="editor_pane_email" dojoType="dijit.form.ValidationTextBox" jsId="editor_pane_email" regExp="^\w+\@\w+(?:\.\w+)+$">
241                                                                                 <script type="dojo/connect" event="onChange">
242                                                                                         if (current_ou) ou_list_store.setValue( current_ou, "email", this.getValue() );
243                                                                                 </script>
244                                                                         </span>
245                                                                 </td>
246                                                         </tr>
247                                                         <tr>
248                                                                 <th>Main Phone Number</th>
249                                                                 <td>
250                                                                         <span id="editor_pane_phone" dojoType="dijit.form.ValidationTextBox" jsId="editor_pane_phone" regExp="^(?:(?:\d{1}[ -\.])?\(?\d{3}\)?[ -\.]{1})?\d{3}[ -\.]{1}\d{4}(| \S+.*)$">
251                                                                                 <script type="dojo/connect" event="onChange">
252                                                                                         if (current_ou) ou_list_store.setValue( current_ou, "phone", this.getValue() );
253                                                                                 </script>
254                                                                         </span>
255                                                                 </td>
256                                                         </tr>
257                                                         <tr>
258                                                                 <th>Org Unit Type</th>
259                                                                 <td>
260                                                                         <div
261                                                                           id="editor_pane_ou_type"
262                                                                           dojoType="dijit.form.FilteringSelect"
263                                                                           jsId="editor_pane_ou_type"
264                                                                           store="ou_type_store"
265                                                                           searchAttr="name"
266                                                                           ignoreCase="true"
267                                                                           required="true"
268                                                                         >
269                                                                                 <script type="dojo/method" event="onChange">
270                                                                                         if (current_ou) ou_list_store.setValue( current_ou, "ou_type", this.getValue() );
271                                                                                 </script>
272                                                                         </div>
273                                                                 </td>
274                                                         </tr>
275                                                         <tr>
276                                                                 <th>Parent Org Unit</th>
277                                                                 <td>
278                                                                         <div
279                                                                           id="editor_pane_parent_ou"
280                                                                           dojoType="dijit.form.FilteringSelect"
281                                                                           jsId="editor_pane_parent_ou"
282                                                                           store="ou_list_store"
283                                                                           searchAttr="shortname"
284                                                                           ignoreCase="true"
285                                                                           required="true"
286                                                                         >
287                                                                                 <script type="dojo/method" event="onChange">
288                                                                                         if (current_ou && this.getValue()) this.store.setValue( current_ou, "parent_ou", this.getValue() );
289                                                                                         if ( this.store.getValue( current_ou, '_trueRoot' ) == 'true' ) this.required = false;
290                                                                                         else this.required = true;
291                                                                                 </script>
292                                                                         </div>
293                                                                 </td>
294                                                         </tr>
295                                                         <tr>
296                                                                 <th>OPAC Visible</th>
297                                                                 <td>
298                                                                         <input
299                                                                           id="editor_pane_opac_visible"
300                                                                           jsId="editor_pane_opac_visible"
301                                                                           type="checkbox"
302                                                                           dojoType="dijit.form.CheckBox"
303                                                                           onChange='if (current_ou) ou_list_store.setValue( current_ou, "opac_visible", this.checked ? "t" : "f" );'
304                                                                         />
305                                                                 </td>
306                                                         </tr>
307                                                 </table>
308         
309                                                 <div dojoType="dijit.layout.ContentPane" orientation="horizontal" style="margin-bottom: 20px;">
310         
311                                                         <button jsId="save_ou_button" dojoType="dijit.form.Button" label="Save" onClick="save_org()">
312                                                                 <script type="dojo/connect" event="startup">
313                                                                         this.disabled = true;
314                                                                 </script>
315                                                         </button>
316         
317                                                         <button jsId="delete_ou_button" dojoType="dijit.form.Button" label="Delete">
318                                                                 <script type="dojo/connect" event="startup">
319                                                                         this.disabled = true;
320                                                                 </script>
321                                                                 <script type="dojo/connect" event="onClick">
322         
323                                                                         var old_name = ou_list_store.getValue( current_ou, 'name' );
324
325                                                                         if (ou_list_store.getValue( current_ou, '_trueRoot' ) == 'true') {
326                                                                                 highlighter.editor_pane.red.play();
327                                                                                 status_update( 'Cannot delete' + ou_list_store.getValue( current_ou, 'name' ) + ', you need at least one.' );
328                                                                                 return false;
329                                                                         }
330
331                                                                         if ( current_ou.children ) {
332                                                                                 var kids = current_ou.children;
333                                                                                 if (!dojo.isArray(kids)) kids = [kids];
334         
335                                                                                 var existing_kids = dojo.filter(
336                                                                                         kids,
337                                                                                         function(kid){ return kid.isdeleted[0] != 1 }
338                                                                                 );
339                                                                                 if ( existing_kids.length > 0) {
340                                                                                         highlighter.editor_pane.red.play();
341                                                                                         status_update( 'Cannot delete' + ou_list_store.getValue( current_ou, 'name' ) + ', ' + existing_kids.length + ' subordinates still exist.' );
342                                                                                         return;
343                                                                                 }
344                                                                         }
345         
346                                                                         if ( confirm('Are you sure you want to delete ' + current_ou.name + '?')) {
347                                                                                 ou_list_store.setValue( current_ou, 'isdeleted', 1 );
348         
349                                                                                 var modified_ou = new aou().fromStoreItem( current_ou );
350                                                                                 modified_ou.isdeleted( 1 );
351         
352                                                                                 pCRUD.request({
353                                                                                         method : 'open-ils.permacrud.delete.aou',
354                                                                                         timeout : 10,
355                                                                                         params : [ ses, modified_ou ],
356                                                                                         onerror : function (r) {
357                                                                                                 highlighter.editor_pane.red.play();
358                                                                                                 status_update( 'Problem deleting ' + old_name );
359                                                                                         },
360                                                                                         oncomplete : function (r) {
361                                                                                                 var res = r.recv();
362                                                                                                 if ( res && res.content() ) {
363         
364                                                                                                         ou_list_store.fetch({
365                                                                                                                 query : { id : ou_list_store.getValue( current_ou, 'id' ) },
366                                                                                                                 queryOptions : { deep : true },
367                                                                                                                 onItem : function (item, req) { try { if (this.isItem( item )) this.deleteItem( item ); } catch (e) { /* meh */ } },
368                                                                                                                 scope : ou_list_store
369                                                                                                         });
370         
371                                                                                                         current_ou = null;
372         
373                                                                                                         new_kid_button.disabled = true;
374                                                                                                         save_ou_button.disabled = true;
375                                                                                                         delete_ou_button.disabled = true;
376                         
377                                                                                                         var main_settings_fields = [ 'name', 'shortname', 'email', 'phone', 'ou_type', 'parent_ou' ];
378                                                                                                         for ( var i in main_settings_fields ) {
379                                                                                                                 var field = main_settings_fields[i];
380                                                                                                                 window["editor_pane_" + field].setValue( '' ); // unset the value
381                                                                                                                 window["editor_pane_" + field].setDisplayedValue( '' ); // unset the value
382                                                                                                         }
383                         
384                                                                                                         highlighter.editor_pane.green.play();
385                                                                                                         status_update( old_name + ' deleted' );
386                                                                                                 } else {
387                                                                                                         highlighter.editor_pane.red.play();
388                                                                                                         status_update( 'Problem deleting ' + old_name );
389                                                                                                 }
390                                                                                         }
391                                                                                 }).send();
392         
393                                                                         }
394         
395                                                                 </script>
396                                                         </button>
397         
398                                                 </div>
399         
400                                                 <button jsId="new_kid_button" dojoType="dijit.form.Button" label="New Child">
401                                                         <script type="dojo/connect" event="startup">
402                                                                 this.disabled = true;
403                                                         </script>
404                                                         <script type="dojo/connect" event="onClick">
405         
406                                                                 var new_fm_obj = new aou().fromHash({
407                                                                         isnew                   : 1,
408                                                                         name                    : 'New Branch',
409                                                                         opac_visible    : 'f',
410                                                                         shortname               : ou_list_store.getValue( current_ou, 'shortname' ) + '-NEW' + virgin_ou_id--,
411                                                                         parent_ou               : ou_list_store.getValue( current_ou, 'id' ),
412                                                                         ou_type                 : ou_list_store.getValue( current_ou, 'ou_type' )
413                                                                 });
414         
415                                                                 var new_obj;
416         
417                                                                 pCRUD.request({
418                                                                         method : 'open-ils.permacrud.create.aou',
419                                                                         timeout : 10,
420                                                                         params : [ ses, new_fm_obj ],
421                                                                         onerror : function (r) {
422                                                                                 highlighter.editor_pane.red.play();
423                                                                                 status_update( 'Problem creating child Org Unit' );
424                                                                         },
425                                                                         oncomplete : function (r) {
426                                                                                 var res = r.recv();
427                                                                                 if ( res && res.content() ) {
428                                                                                         ou_list_store.newItem(
429                                                                                                 res.content().toHash(),
430                                                                                                 { parent : current_ou, attribute : 'children' }
431                                                                                         );
432                                                                                 } else {
433                                                                                         highlighter.editor_pane.red.play();
434                                                                                         status_update( 'Problem creating child Org Unit' );
435                                                                                 }
436                                                                         },
437                                                                 }).send();
438         
439                                                                 highlighter.editor_pane.green.play();
440                                                                 highlighter.ou_tree.green.play();
441                                                                 status_update( 'New child Organizational Unit created for ' + ou_list_store.getValue( current_ou, 'name' ) );
442         
443                                                         </script>
444                                                 </button>
445         
446                                         </div>
447
448                                         <div id="hoo_pane" dojoType="dijit.layout.ContentPane" title="Hours of Operation">
449                                                 <table class="tundra" style="margin:10px;">
450                                                         <tr><th/><th>Open time</th><th>Close time</th></tr>
451                                                         <tr><th>Monday</th>
452                                                                 <td><span dojoType="dijit.form.TimeTextBox" style="width:8em;" jsId="dow_0_open" onChange="current_ou_hoo.dow_0_open( this.getDisplayedValue() );"/></td>
453                                                                 <td><span dojoType="dijit.form.TimeTextBox" style="width:8em;" jsId="dow_0_close" onChange="current_ou_hoo.dow_0_close( this.getDisplayedValue() );"/></td>
454                                                                 <td><span dojoType="dijit.form.Button" label="Closed" onClick="dow_0_open.setValue( new Date('Tue Mar 25 2008 00:00:00') ); dow_0_close.setValue( new Date('Tue Mar 25 2008 00:00:00') );"/></td>
455                                                         </tr>
456                                                         <tr><th>Tuesday</th>
457                                                                 <td><span dojoType="dijit.form.TimeTextBox" style="width:8em;" jsId="dow_1_open" onChange="current_ou_hoo.dow_1_open( this.getDisplayedValue() );"/></td>
458                                                                 <td><span dojoType="dijit.form.TimeTextBox" style="width:8em;" jsId="dow_1_close" onChange="current_ou_hoo.dow_1_close( this.getDisplayedValue() );"/></td>
459                                                                 <td><span dojoType="dijit.form.Button" label="Closed" onClick="dow_1_open.setValue( new Date('Tue Mar 25 2008 00:00:00') ); dow_1_close.setValue( new Date('Tue Mar 25 2008 00:00:00') );"/></td>
460                                                         </tr>
461                                                         <tr><th>Wednesday</th>
462                                                                 <td><span dojoType="dijit.form.TimeTextBox" style="width:8em;" jsId="dow_2_open" onChange="current_ou_hoo.dow_2_open( this.getDisplayedValue() );"/></td>
463                                                                 <td><span dojoType="dijit.form.TimeTextBox" style="width:8em;" jsId="dow_2_close" onChange="current_ou_hoo.dow_2_close( this.getDisplayedValue() );"/></td>
464                                                                 <td><span dojoType="dijit.form.Button" label="Closed" onClick="dow_2_open.setValue( new Date('Tue Mar 25 2008 00:00:00') ); dow_2_close.setValue( new Date('Tue Mar 25 2008 00:00:00') );"/></td>
465                                                         </tr>
466                                                         <tr><th>Thursday</th>
467                                                                 <td><span dojoType="dijit.form.TimeTextBox" style="width:8em;" jsId="dow_3_open" onChange="current_ou_hoo.dow_3_open( this.getDisplayedValue() );"/></td>
468                                                                 <td><span dojoType="dijit.form.TimeTextBox" style="width:8em;" jsId="dow_3_close" onChange="current_ou_hoo.dow_3_close( this.getDisplayedValue() );"/></td>
469                                                                 <td><span dojoType="dijit.form.Button" label="Closed" onClick="dow_3_open.setValue( new Date('Tue Mar 25 2008 00:00:00') ); dow_3_close.setValue( new Date('Tue Mar 25 2008 00:00:00') );"/></td>
470                                                         </tr>
471                                                         <tr><th>Friday</th>
472                                                                 <td><span dojoType="dijit.form.TimeTextBox" style="width:8em;" jsId="dow_4_open" onChange="current_ou_hoo.dow_4_open( this.getDisplayedValue() );"/></td>
473                                                                 <td><span dojoType="dijit.form.TimeTextBox" style="width:8em;" jsId="dow_4_close" onChange="current_ou_hoo.dow_4_close( this.getDisplayedValue() );"/></td>
474                                                                 <td><span dojoType="dijit.form.Button" label="Closed" onClick="dow_4_open.setValue( new Date('Tue Mar 25 2008 00:00:00') ); dow_4_close.setValue( new Date('Tue Mar 25 2008 00:00:00') );"/></td>
475                                                         </tr>
476                                                         <tr><th>Saturday</th>
477                                                                 <td><span dojoType="dijit.form.TimeTextBox" style="width:8em;" jsId="dow_5_open" onChange="current_ou_hoo.dow_5_open( this.getDisplayedValue() );"/></td>
478                                                                 <td><span dojoType="dijit.form.TimeTextBox" style="width:8em;" jsId="dow_5_close" onChange="current_ou_hoo.dow_5_close( this.getDisplayedValue() );"/></td>
479                                                                 <td><span dojoType="dijit.form.Button" label="Closed" onClick="dow_5_open.setValue( new Date('Tue Mar 25 2008 00:00:00') ); dow_5_close.setValue( new Date('Tue Mar 25 2008 00:00:00') );"/></td>
480                                                         </tr>
481                                                         <tr><th>Sunday</th>
482                                                                 <td><span dojoType="dijit.form.TimeTextBox" style="width:8em;" jsId="dow_6_open" onChange="current_ou_hoo.dow_6_open( this.getDisplayedValue() );"/></td>
483                                                                 <td><span dojoType="dijit.form.TimeTextBox" style="width:8em;" jsId="dow_6_close" onChange="current_ou_hoo.dow_6_close( this.getDisplayedValue() );"/></td>
484                                                                 <td><span dojoType="dijit.form.Button" label="Closed" onClick="dow_6_open.setValue( new Date('Tue Mar 25 2008 00:00:00') ); dow_6_close.setValue( new Date('Tue Mar 25 2008 00:00:00') );"/></td>
485                                                         </tr>
486                                                 </table>
487         
488                                                 <button jsId="save_hoo_button" dojoType="dijit.form.Button" label="Save">
489                                                         <script type="dojo/connect" event="onClick">
490         
491                                                                 var method_name = 'open-ils.permacrud.update.aouhoo';
492                                                                 if (current_ou_hoo.isnew() == 1) method_name = 'open-ils.permacrud.create.aouhoo';
493         
494                                                                 pCRUD.request({
495                                                                         method : method_name,
496                                                                         params : [ ses, current_ou_hoo ],
497                                                                         onerror : function (r) {
498                                                                                 highlighter.editor_pane.red.play();
499                                                                                 status_update( 'Problem saving Hours of Operation data for ' + ou_list_store.getValue( current_ou, 'name' ));
500                                                                         },
501                                                                         oncomplete : function (r) {
502                                                                                 var res = r.recv();
503                                                                                 if ( res && res.content() ) {
504                                                                                         current_ou_hoo.isnew(0);
505                                                                                         highlighter.editor_pane.green.play();
506                                                                                         status_update( 'Hours of Operation updated for ' + ou_list_store.getValue( current_ou, 'name' ) );
507                                                                                 } else {
508                                                                                         highlighter.editor_pane.red.play();
509                                                                                         status_update( 'Problem saving Hours of Operation data for ' + ou_list_store.getValue( current_ou, 'name' ));
510                                                                                 }
511                                                                         },
512                                                                 }).send();
513         
514                                                         </script>
515                                                 </button>
516         
517                                         </div>
518         
519                                         <div id="addresses_pane" dojoType="dijit.layout.ContentPane" title="Addresses">
520                                                 
521                                                 <div id="billing_address_pane" dojoType="dijit.layout.TabContainer" style="margin-top:10px">
522         
523                                                         <script type="dojo/method">
524                                                                 window.current_billing_address = null;
525                                                                 window.current_mailing_address = null;
526                                                                 window.current_holds_address = null;
527                                                                 window.current_ill_address = null;
528                                                         </script>
529         
530                                                         <div id="billing_address" dojoType="dijit.layout.ContentPane" title="Physical Address">
531                                                                 <table class="tundra" style="margin:10px;">
532                                                                         <tr>
533                                                                                 <th>Type</th><td colspan="3"><span jsId="billing_addr_type" style="width:100%;" dojoType="dijit.form.TextBox" onChange="current_billing_address.address_type( this.getValue() )"/></td>
534                                                                                 <th>Valid</th><td>
535                                                                                         <input
536                                                                                           type="checkbox"
537                                                                                           jsId="billing_addr_valid"
538                                                                                           dojoType="dijit.form.CheckBox"
539                                                                                           value='t'
540                                                                                           onChange='if (current_billing_address) current_billing_address.valid( this.checked ? "t" : "f" );'
541                                                                                         />
542                                                                                 </td>
543                                                                         </tr>
544                                                                         <tr>
545                                                                                 <th>Street 1</th><td colspan="5"><span jsId="billing_addr_street1" style="width:100%;" dojoType="dijit.form.ValidationTextBox" onChange="current_billing_address.street1( this.getValue() )" required="true"/></td>
546                                                                         </tr>
547                                                                         <tr>
548                                                                                 <th>Street 2</th><td colspan="5"><span jsId="billing_addr_street2" style="width:100%;" dojoType="dijit.form.TextBox" onChange="current_billing_address.street2( this.getValue() )"/></td>
549                                                                         </tr>
550                                                                         <tr>
551                                                                                 <th>City</th><td><span jsId="billing_addr_city" style="width:100%;" dojoType="dijit.form.ValidationTextBox" onChange="current_billing_address.city( this.getValue() )" required="true"/></td>
552                                                                                 <th>State</th><td><span jsId="billing_addr_state" style="width:100%;" dojoType="dijit.form.ValidationTextBox" size="2" maxSize="2" uppercase="true" onChange="current_billing_address.state( this.getValue() )" required="true"/></td>
553                                                                                 <th>Zip</th><td><span jsId="billing_addr_post_code" style="width:100%;" dojoType="dijit.form.ValidationTextBox" size="10" maxSize="10" regExp="^\d{5}(?:-\d{4})?$" uppercase="true" onChange="current_billing_address.post_code( this.getValue() )" required="true"/></td>
554                                                                         </tr>
555                                                                         <tr>
556                                                                                 <th>Country</th><td colspan="2"><span jsId="billing_addr_country" style="width:100%;" dojoType="dijit.form.ValidationTextBox" onChange="current_billing_address.country( this.getValue() )" required="true"/></td>
557                                                                                 <th>County</th><td colspan="2"><span jsId="billing_addr_county" style="width:100%;" dojoType="dijit.form.ValidationTextBox" onChange="current_billing_address.county( this.getValue() )" required="true"/></td>
558                                                                         </tr>
559                                                                 </table>
560         
561                                                                 <button jsId="save_billing_address" dojoType="dijit.form.Button" label="Save">
562                                                                         <script type="dojo/connect" event="startup">
563                                                                                 this.disabled = true;
564                                                                         </script>
565                                                                         <script type="dojo/connect" event="onClick">
566         
567                                                                                 var method_name = 'open-ils.permacrud.update.aoa';
568                                                                                 if (current_billing_address.isnew() == 1) method_name = 'open-ils.permacrud.create.aoa';
569         
570                                                                                 pCRUD.request({
571                                                                                         method : method_name,
572                                                                                         params : [ ses, current_billing_address ],
573                                                                                         onerror : function (r) {
574                                                                                                 highlighter.addresses_pane.red.play();
575                                                                                                 status_update( 'Problem saving Physical Address data for ' + ou_list_store.getValue( current_ou, 'name' ) );
576                                                                                         },
577                                                                                         oncomplete : function (r) {
578                                                                                                 var res = r.recv();
579                                                                                                 if ( res && res.content() ) {
580                                                                                                         if (current_billing_address.isnew() == 1) {
581                                                                                                                 current_billing_address = res.content();
582                                                                                                                 ou_list_store.setValue( current_ou, 'billing_address', current_billing_address.id() );
583                                                                                                                 save_org();
584                                                                                                         }
585                                                                                                         current_billing_address.isnew(0);
586                                                                                                         highlighter.addresses_pane.green.play();
587                                                                                                         status_update( 'Changes to the Physical Address of ' + ou_list_store.getValue( current_ou, 'name' ) + ' saved' );
588                                                                                                 } else {
589                                                                                                         highlighter.addresses_pane.red.play();
590                                                                                                         status_update( 'Problem saving Physical Address data for ' + ou_list_store.getValue( current_ou, 'name' ) );
591                                                                                                 }
592                                                                                         },
593                                                                                 }).send();
594         
595                                                                         </script>
596                                                                 </button>
597                                                         </div>
598
599                                                         <div id="holds_address" dojoType="dijit.layout.ContentPane" title="Holds Address">
600                                                                 <table class="tundra" style="margin:10px;">
601                                                                         <tr>
602                                                                                 <th>Type</th><td colspan="3"><span jsId="holds_addr_type" style="width:100%;" dojoType="dijit.form.TextBox" onChange="current_holds_address.address_type( this.getValue() )"/></td>
603                                                                                 <th>Valid</th><td>
604                                                                                         <input
605                                                                                           type="checkbox"
606                                                                                           jsId="holds_addr_valid"
607                                                                                           dojoType="dijit.form.CheckBox"
608                                                                                           value='t'
609                                                                                           onChange='if (current_holds_address) current_holds_address.valid( this.checked ? "t" : "f" );'
610                                                                                         />
611                                                                                 </td>
612                                                                         </tr>
613                                                                         <tr>
614                                                                                 <th>Street 1</th><td colspan="5"><span jsId="holds_addr_street1" style="width:100%;" dojoType="dijit.form.ValidationTextBox" onChange="current_holds_address.street1( this.getValue() )" required="true"/></td>
615                                                                         </tr>
616                                                                         <tr>
617                                                                                 <th>Street 2</th><td colspan="5"><span jsId="holds_addr_street2" style="width:100%;" dojoType="dijit.form.TextBox" onChange="current_holds_address.street2( this.getValue() )"/></td>
618                                                                         </tr>
619                                                                         <tr>
620                                                                                 <th>City</th><td><span jsId="holds_addr_city" style="width:100%;" dojoType="dijit.form.ValidationTextBox" onChange="current_holds_address.city( this.getValue() )" required="true"/></td>
621                                                                                 <th>State</th><td><span jsId="holds_addr_state" style="width:100%;" dojoType="dijit.form.ValidationTextBox" size="2" maxSize="2" uppercase="true" onChange="current_holds_address.state( this.getValue() )" required="true"/></td>
622                                                                                 <th>Zip</th><td><span jsId="holds_addr_post_code" style="width:100%;" dojoType="dijit.form.ValidationTextBox" size="10" maxSize="10" regExp="^\d{5}(?:-\d{4})?$" uppercase="true" onChange="current_holds_address.post_code( this.getValue() )" required="true"/></td>
623                                                                         </tr>
624                                                                         <tr>
625                                                                                 <th>Country</th><td colspan="2"><span jsId="holds_addr_country" style="width:100%;" dojoType="dijit.form.ValidationTextBox" onChange="current_holds_address.country( this.getValue() )" required="true"/></td>
626                                                                                 <th>County</th><td colspan="2"><span jsId="holds_addr_county" style="width:100%;" dojoType="dijit.form.ValidationTextBox" onChange="current_holds_address.county( this.getValue() )" required="true"/></td>
627                                                                         </tr>
628                                                                 </table>
629         
630                                                                 <button jsId="save_holds_address" dojoType="dijit.form.Button" label="Save">
631                                                                         <script type="dojo/connect" event="startup">
632                                                                                 this.disabled = true;
633                                                                         </script>
634                                                                         <script type="dojo/connect" event="onClick">
635         
636                                                                                 var method_name = 'open-ils.permacrud.update.aoa';
637                                                                                 if (current_holds_address.isnew() == 1) method_name = 'open-ils.permacrud.create.aoa';
638         
639                                                                                 pCRUD.request({
640                                                                                         method : method_name,
641                                                                                         params : [ ses, current_holds_address ],
642                                                                                         onerror : function (r) {
643                                                                                                 highlighter.addresses_pane.red.play();
644                                                                                                 throw 'Problem saving Holds Address data for ' + ou_list_store.getValue( current_ou, 'name' );
645                                                                                         },
646                                                                                         oncomplete : function (r) {
647                                                                                                 var res = r.recv();
648                                                                                                 if ( res && res.content() ) {
649                                                                                                         if (current_holds_address.isnew() == 1) {
650                                                                                                                 current_holds_address = res.content();
651                                                                                                                 ou_list_store.setValue( current_ou, 'holds_address', current_holds_address.id() );
652                                                                                                                 save_org();
653                                                                                                         }
654                                                                                                         current_holds_address.isnew(0);
655                                                                                                         highlighter.addresses_pane.green.play();
656                                                                                                         status_update( 'Changes to the Holds Address of ' + ou_list_store.getValue( current_ou, 'name' ) + ' saved' );
657                                                                                                 } else {
658                                                                                                         highlighter.addresses_pane.red.play();
659                                                                                                         throw 'Problem saving Holds Address data for ' + ou_list_store.getValue( current_ou, 'name' );
660                                                                                                 }
661                                                                                         },
662                                                                                 }).send();
663         
664                                                                         </script>
665                                                                 </button>
666                                                         </div>
667
668                                                         <div id="mailing_address" dojoType="dijit.layout.ContentPane" title="Mailing Address">
669                                                                 <table class="tundra" style="margin:10px;">
670                                                                         <tr>
671                                                                                 <th>Type</th><td colspan="3"><span jsId="mailing_addr_type" style="width:100%;" dojoType="dijit.form.TextBox" onChange="current_mailing_address.address_type( this.getValue() )"/></td>
672                                                                                 <th>Valid</th><td>
673                                                                                         <input
674                                                                                           type="checkbox"
675                                                                                           jsId="mailing_addr_valid"
676                                                                                           dojoType="dijit.form.CheckBox"
677                                                                                           onChange='if (current_mailing_address) current_mailing_address.valid( this.checked ? "t" : "f" );'
678                                                                                         />
679                                                                                 </td>
680                                                                         </tr>
681                                                                         <tr>
682                                                                                 <th>Street 1</th><td colspan="5"><span jsId="mailing_addr_street1" style="width:100%;" dojoType="dijit.form.ValidationTextBox" onChange="current_mailing_address.street1( this.getValue() )" required="true"/></td>
683                                                                         </tr>
684                                                                         <tr>
685                                                                                 <th>Street 2</th><td colspan="5"><span jsId="mailing_addr_street2" style="width:100%;" dojoType="dijit.form.TextBox" onChange="current_mailing_address.street2( this.getValue() )"/></td>
686                                                                         </tr>
687                                                                         <tr>
688                                                                                 <th>City</th><td><span jsId="mailing_addr_city" style="width:100%;" dojoType="dijit.form.ValidationTextBox" onChange="current_mailing_address.city( this.getValue() )" required="true"/></td>
689                                                                                 <th>State</th><td><span jsId="mailing_addr_state" style="width:100%;" dojoType="dijit.form.ValidationTextBox" size="2" maxSize="2" uppercase="true" onChange="current_mailing_address.state( this.getValue() )" required="true"/></td>
690                                                                                 <th>Zip</th><td><span jsId="mailing_addr_post_code" style="width:100%;" dojoType="dijit.form.ValidationTextBox" size="10" maxSize="10" regExp="^\d{5}(?:-\d{4})?$" uppercase="true" onChange="current_mailing_address.post_code( this.getValue() )" required="true"/></td>
691                                                                         </tr>
692                                                                         <tr>
693                                                                                 <th>Country</th><td colspan="2"><span jsId="mailing_addr_country" style="width:100%;" dojoType="dijit.form.ValidationTextBox" onChange="current_mailing_address.country( this.getValue() )" required="true"/></td>
694                                                                                 <th>County</th><td colspan="2"><span jsId="mailing_addr_county" style="width:100%;" dojoType="dijit.form.ValidationTextBox" onChange="current_mailing_address.county( this.getValue() )" required="true"/></td>
695                                                                         </tr>
696                                                                 </table>
697         
698                                                                 <button jsId="save_mailing_address" dojoType="dijit.form.Button" label="Save">
699                                                                         <script type="dojo/connect" event="startup">
700                                                                                 this.disabled = true;
701                                                                         </script>
702                                                                         <script type="dojo/connect" event="onClick">
703         
704                                                                                 var method_name = 'open-ils.permacrud.update.aoa';
705                                                                                 if (current_mailing_address.isnew() == 1) method_name = 'open-ils.permacrud.create.aoa';
706         
707                                                                                 pCRUD.request({
708                                                                                         method : method_name,
709                                                                                         params : [ ses, current_mailing_address ],
710                                                                                         onerror : function (r) {
711                                                                                                 highlighter.addresses_pane.red.play();
712                                                                                                 throw 'Problem saving Mailing Address data for ' + ou_list_store.getValue( current_ou, 'name' );
713                                                                                         },
714                                                                                         oncomplete : function (r) {
715                                                                                                 var res = r.recv();
716                                                                                                 if ( res && res.content() ) {
717                                                                                                         if (current_mailing_address.isnew() == 1) {
718                                                                                                                 current_mailing_address = res.content();
719                                                                                                                 ou_list_store.setValue( current_ou, 'mailing_address', current_mailing_address.id() );
720                                                                                                                 save_org();
721                                                                                                         }
722                                                                                                         current_mailing_address.isnew(0);
723                                                                                                         highlighter.addresses_pane.green.play();
724                                                                                                         status_update( 'Changes to the Mailing Address of ' + ou_list_store.getValue( current_ou, 'name' ) + ' saved' );
725                                                                                                 } else {
726                                                                                                         highlighter.addresses_pane.red.play();
727                                                                                                         throw 'Problem saving Mailing Address data for ' + ou_list_store.getValue( current_ou, 'name' );
728                                                                                                 }
729                                                                                         },
730                                                                                 }).send();
731         
732                                                                         </script>
733                                                                 </button>
734                                                         </div>
735
736                                                         <div id="ill_address" dojoType="dijit.layout.ContentPane" title="ILL Address">
737                                                                 <table class="tundra" style="margin:10px;">
738                                                                         <tr>
739                                                                                 <th>Type</th><td colspan="3"><span jsId="ill_addr_type" style="width:100%;" dojoType="dijit.form.TextBox" onChange="current_ill_address.address_type( this.getValue() )"/></td>
740                                                                                 <th>Valid</th><td>
741                                                                                         <input
742                                                                                           type="checkbox"
743                                                                                           jsId="ill_addr_valid"
744                                                                                           dojoType="dijit.form.CheckBox"
745                                                                                           onChange='if (current_ill_address) current_ill_address.valid( this.checked ? "t" : "f" );'
746                                                                                         />
747                                                                                 </td>
748                                                                         </tr>
749                                                                         <tr>
750                                                                                 <th>Street 1</th><td colspan="5"><span jsId="ill_addr_street1" style="width:100%;" dojoType="dijit.form.ValidationTextBox" onChange="current_ill_address.street1( this.getValue() )" required="true"/></td>
751                                                                         </tr>
752                                                                         <tr>
753                                                                                 <th>Street 2</th><td colspan="5"><span jsId="ill_addr_street2" style="width:100%;" dojoType="dijit.form.TextBox" onChange="current_ill_address.street2( this.getValue() )"/></td>
754                                                                         </tr>
755                                                                         <tr>
756                                                                                 <th>City</th><td><span jsId="ill_addr_city" style="width:100%;" dojoType="dijit.form.ValidationTextBox" onChange="current_ill_address.city( this.getValue() )" required="true"/></td>
757                                                                                 <th>State</th><td><span jsId="ill_addr_state" style="width:100%;" dojoType="dijit.form.ValidationTextBox" size="2" maxSize="2" uppercase="true" onChange="current_ill_address.state( this.getValue() )" required="true"/></td>
758                                                                                 <th>Zip</th><td><span jsId="ill_addr_post_code" style="width:100%;" dojoType="dijit.form.ValidationTextBox" size="10" maxSize="10" regExp="^\d{5}(?:-\d{4})?$" uppercase="true" onChange="current_ill_address.post_code( this.getValue() )" required="true"/></td>
759                                                                         </tr>
760                                                                         <tr>
761                                                                                 <th>Country</th><td colspan="2"><span jsId="ill_addr_country" style="width:100%;" dojoType="dijit.form.ValidationTextBox" onChange="current_ill_address.country( this.getValue() )" required="true"/></td>
762                                                                                 <th>County</th><td colspan="2"><span jsId="ill_addr_county" style="width:100%;" dojoType="dijit.form.ValidationTextBox" onChange="current_ill_address.county( this.getValue() )" required="true"/></td>
763                                                                         </tr>
764                                                                 </table>
765         
766                                                                 <button jsId="save_ill_address" dojoType="dijit.form.Button" label="Save">
767                                                                         <script type="dojo/connect" event="startup">
768                                                                                 this.disabled = true;
769                                                                         </script>
770                                                                         <script type="dojo/connect" event="onClick">
771         
772                                                                                 var method_name = 'open-ils.permacrud.update.aoa';
773                                                                                 if (current_ill_address.isnew() == 1) method_name = 'open-ils.permacrud.create.aoa';
774         
775                                                                                 pCRUD.request({
776                                                                                         method : method_name,
777                                                                                         params : [ ses, current_ill_address ],
778                                                                                         onerror : function (r) {
779                                                                                                 highlighter.addresses_pane.red.play();
780                                                                                                 throw 'Problem saving Physical Address data for ' + ou_list_store.getValue( current_ou, 'name' );
781                                                                                         },
782                                                                                         oncomplete : function (r) {
783                                                                                                 var res = r.recv();
784                                                                                                 if ( res && res.content() ) {
785                                                                                                         if (current_ill_address.isnew() == 1) {
786                                                                                                                 current_ill_address = res.content();
787                                                                                                                 ou_list_store.setValue( current_ou, 'ill_address', current_ill_address.id() );
788                                                                                                                 save_org();
789                                                                                                         }
790                                                                                                         current_ill_address.isnew(0);
791                                                                                                         highlighter.addresses_pane.green.play();
792                                                                                                         status_update( 'Changes to the ILL Address of ' + ou_list_store.getValue( current_ou, 'name' ) + ' saved' );
793                                                                                                 } else {
794                                                                                                         highlighter.addresses_pane.red.play();
795                                                                                                         throw 'Problem saving Physical Address data for ' + ou_list_store.getValue( current_ou, 'name' );
796                                                                                                 }
797                                                                                         },
798                                                                                 }).send();
799         
800                                                                         </script>
801                                                                 </button>
802                                                         </div>
803                                                 </div>
804                                         </div>
805                                 </div>
806                         </div>
807                 </div>
808
809                 <div id="status_bar"><span style="font-weight: bold; margin: 5px; margin-right: 10px;">Now editing:</span><span id="current_ou_name"></span></div>
810         </body>
811 </html>