load fmall.js via dojo in fieldmapper.Fieldmapper
[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                 <!-- Dojo goodness -->
51                 <script type="text/javascript" src="../admin.js"></script>
52
53                 <script type="text/javascript" src="/js/dojo/dojo/dojo.js"></script>
54                 <script type="text/javascript" src="/js/dojo/dijit/dijit.js"></script>
55
56                 <script type="text/javascript" src="org_unit.js"></script>
57
58         </head>
59
60         <body class="tundra" id='pagebody'>
61
62                 <div dojoType="dijit.layout.SplitContainer" orientation="horizontal" style="height: 100%">
63
64                         <div dojoType="dijit.layout.ContentPane" sizeShare="100">
65                                 <script type="dojo/method">
66
67                                         var ou_list_data = { label : 'shortname', identifier : 'id' };
68                                         window.dirtyStore = [];
69                 
70                                         pCRUD.request({
71                                                 method : 'open-ils.permacrud.search.aou.atomic',
72                                                 timeout : 15,
73                                                 params : [ ses, { id : { "!=" : null } }, { order_by : { aou : 'shortname' } } ],
74                                                 onerror : function (r) { throw 'Problem fetching org units';},
75                                                 oncomplete : function (r) {
76                                                         window._ou_list = r.recv().content();
77                                                         window._ou_data = aou.toStoreData( window._ou_list );
78                                                         window.ou_list_store = new dojo.data.ItemFileWriteStore({ data : window._ou_data });
79
80                                                         window.ou_list_store.onSet = function (item, attr, o, n) {
81                                                                 if (attr == 'ischanged') return;
82                                                                 if (n == o) return;
83                                                                 this.setValue( item, 'ischanged', 1);
84                                                         };
85
86                                                         dojo.addOnUnload( function (event) {
87
88                                                                 ou_list_store.fetch({
89                                                                         query : { ischanged : 1 },
90                                                                         queryOptions : { deep : true },
91                                                                         onItem : function (item, req) { try { if (this.isItem( item )) window.dirtyStore.push( item ); } catch (e) { /* meh */ } },
92                                                                         scope : ou_list_store
93                                                                 });
94
95                                                                 if (dirtyStore.length > 0) {
96                                                                         var confirmation = confirm(
97                                                                                 'There are unsaved modified Organizational Units!  '+
98                                                                                 'OK to save these changes, Cancel to abandon them.'
99                                                                         );
100
101                                                                         if (confirmation) {
102                                                                                 for (var i in window.dirtyStore) {
103                                                                                         window.current_ou = window.dirtyStore[i];
104                                                                                         save_org(true);
105                                                                                 }
106                                                                         }
107                                                                 }
108
109                                                         });
110                                                 }
111                                         }).send();
112
113                     pCRUD.request({
114                         method : 'open-ils.permacrud.search.aout.atomic',
115                         timeout : 10,
116                         params : [ ses, { id : { "!=" : null } }, { order_by : { aout : 'depth' } } ],
117                         onerror : function (r) { status_update('Problem fetching types') },
118                         oncomplete : function (r) {
119                             window._ou_type_list = r.recv().content();
120                             window._ou_type_data = aout.toStoreData( window._ou_type_list );
121                             window.ou_type_store = new dojo.data.ItemFileReadStore({ data : window._ou_type_data });
122                         }
123                     }).send();
124
125                                         highlighter.ou_tree = {};
126                                         highlighter.editor_pane = {};
127                                         highlighter.hoo_pane = {};
128                                         highlighter.addresses_pane = {};
129
130                                         highlighter.ou_tree.green = dojox.fx.highlight( { color : '#B4FFB4', node : 'ou_tree', duration : 500 } );
131                                         highlighter.ou_tree.red = dojox.fx.highlight( { color : '#FF2018', node : 'ou_tree', duration : 500 } );
132
133                                         highlighter.editor_pane.green = dojox.fx.highlight( { color : '#B4FFB4', node : 'editor_pane', duration : 500 } );
134                                         highlighter.editor_pane.red = dojox.fx.highlight( { color : '#FF2018', node : 'editor_pane', duration : 500 } );
135
136                                         highlighter.hoo_pane.green = dojox.fx.highlight( { color : '#B4FFB4', node : 'hoo_pane', duration : 500 } );
137                                         highlighter.hoo_pane.red = dojox.fx.highlight( { color : '#FF2018', node : 'hoo_pane', duration : 500 } );
138
139                                         highlighter.addresses_pane.green = dojox.fx.highlight( { color : '#B4FFB4', node : 'addresses_pane', duration : 500 } );
140                                         highlighter.addresses_pane.red = dojox.fx.highlight( { color : '#FF2018', node : 'addresses_pane', duration : 500 } );
141                                 </script>
142                                 <div
143                                   id="ou_tree"
144                                   label="Organizational Units"
145                                   query="{'_top':'true'}"
146                                   dojoType="dijit.Tree"
147                                   store="ou_list_store"
148                                   minSize="200"
149                                   jsId="ou_tree"
150                                 >
151
152                                         <script type="dojo/method" event="onClick" args="item,node">
153
154                                                 right_pane_toggler.show();
155
156                                                 current_ou = item;
157                                                 window.current_fm_ou = new aou().fromStoreItem(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                                                                         <span dojoType="openils.I18N.translationWidget" targetObject="current_fm_ou" field="name"></span>
226                                                                 </td>
227                                                         </tr>
228                                                         <tr>
229                                                                 <th>Org Unit Policy Code</th>
230                                                                 <td>
231                                                                         <span id="editor_pane_shortname" dojoType="dijit.form.ValidationTextBox" jsId="editor_pane_shortname" uppercase="true" regExp=".+" required="true">
232                                                                                 <script type="dojo/connect" event="onChange">
233                                                                                         if (current_ou) ou_list_store.setValue( current_ou, "shortname", this.getValue() );
234                                                                                 </script>
235                                                                         </span>
236                                                                 </td>
237                                                         </tr>
238                                                         <tr>
239                                                                 <th>Main Email Address</th>
240                                                                 <td>
241                                                                         <span id="editor_pane_email" dojoType="dijit.form.ValidationTextBox" jsId="editor_pane_email" regExp="^\w+\@\w+(?:\.\w+)+$">
242                                                                                 <script type="dojo/connect" event="onChange">
243                                                                                         if (current_ou) ou_list_store.setValue( current_ou, "email", this.getValue() );
244                                                                                 </script>
245                                                                         </span>
246                                                                 </td>
247                                                         </tr>
248                                                         <tr>
249                                                                 <th>Main Phone Number</th>
250                                                                 <td>
251                                                                         <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+.*)$">
252                                                                                 <script type="dojo/connect" event="onChange">
253                                                                                         if (current_ou) ou_list_store.setValue( current_ou, "phone", this.getValue() );
254                                                                                 </script>
255                                                                         </span>
256                                                                 </td>
257                                                         </tr>
258                                                         <tr>
259                                                                 <th>Org Unit Type</th>
260                                                                 <td>
261                                                                         <div
262                                                                           id="editor_pane_ou_type"
263                                                                           dojoType="dijit.form.FilteringSelect"
264                                                                           jsId="editor_pane_ou_type"
265                                                                           store="ou_type_store"
266                                                                           searchAttr="name"
267                                                                           ignoreCase="true"
268                                                                           required="true"
269                                                                         >
270                                                                                 <script type="dojo/method" event="onChange">
271                                                                                         if (current_ou) ou_list_store.setValue( current_ou, "ou_type", this.getValue() );
272                                                                                 </script>
273                                                                         </div>
274                                                                 </td>
275                                                         </tr>
276                                                         <tr>
277                                                                 <th>Parent Org Unit</th>
278                                                                 <td>
279                                                                         <div
280                                                                           id="editor_pane_parent_ou"
281                                                                           dojoType="dijit.form.FilteringSelect"
282                                                                           jsId="editor_pane_parent_ou"
283                                                                           store="ou_list_store"
284                                                                           searchAttr="shortname"
285                                                                           ignoreCase="true"
286                                                                           required="true"
287                                                                         >
288                                                                                 <script type="dojo/method" event="onChange">
289                                                                                         if (current_ou && this.getValue()) this.store.setValue( current_ou, "parent_ou", this.getValue() );
290                                                                                         if ( this.store.getValue( current_ou, '_trueRoot' ) == 'true' ) this.required = false;
291                                                                                         else this.required = true;
292                                                                                 </script>
293                                                                         </div>
294                                                                 </td>
295                                                         </tr>
296                                                         <tr>
297                                                                 <th>OPAC Visible</th>
298                                                                 <td>
299                                                                         <input
300                                                                           id="editor_pane_opac_visible"
301                                                                           jsId="editor_pane_opac_visible"
302                                                                           type="checkbox"
303                                                                           dojoType="dijit.form.CheckBox"
304                                                                           onChange='if (current_ou) ou_list_store.setValue( current_ou, "opac_visible", this.checked ? "t" : "f" );'
305                                                                         />
306                                                                 </td>
307                                                         </tr>
308                                                 </table>
309         
310                                                 <div dojoType="dijit.layout.ContentPane" orientation="horizontal" style="margin-bottom: 20px;">
311         
312                                                         <button jsId="save_ou_button" dojoType="dijit.form.Button" label="Save" onClick="save_org()">
313                                                                 <script type="dojo/connect" event="startup">
314                                                                         this.disabled = true;
315                                                                 </script>
316                                                         </button>
317         
318                                                         <button jsId="delete_ou_button" dojoType="dijit.form.Button" label="Delete">
319                                                                 <script type="dojo/connect" event="startup">
320                                                                         this.disabled = true;
321                                                                 </script>
322                                                                 <script type="dojo/connect" event="onClick">
323         
324                                                                         var old_name = ou_list_store.getValue( current_ou, 'name' );
325
326                                                                         if (ou_list_store.getValue( current_ou, '_trueRoot' ) == 'true') {
327                                                                                 highlighter.editor_pane.red.play();
328                                                                                 status_update( 'Cannot delete' + ou_list_store.getValue( current_ou, 'name' ) + ', you need at least one.' );
329                                                                                 return false;
330                                                                         }
331
332                                                                         if ( current_ou.children ) {
333                                                                                 var kids = current_ou.children;
334                                                                                 if (!dojo.isArray(kids)) kids = [kids];
335         
336                                                                                 var existing_kids = dojo.filter(
337                                                                                         kids,
338                                                                                         function(kid){ return kid.isdeleted[0] != 1 }
339                                                                                 );
340                                                                                 if ( existing_kids.length > 0) {
341                                                                                         highlighter.editor_pane.red.play();
342                                                                                         status_update( 'Cannot delete' + ou_list_store.getValue( current_ou, 'name' ) + ', ' + existing_kids.length + ' subordinates still exist.' );
343                                                                                         return;
344                                                                                 }
345                                                                         }
346         
347                                                                         if ( confirm('Are you sure you want to delete ' + current_ou.name + '?')) {
348                                                                                 ou_list_store.setValue( current_ou, 'isdeleted', 1 );
349         
350                                                                                 var modified_ou = new aou().fromStoreItem( current_ou );
351                                                                                 modified_ou.isdeleted( 1 );
352         
353                                                                                 pCRUD.request({
354                                                                                         method : 'open-ils.permacrud.delete.aou',
355                                                                                         timeout : 10,
356                                                                                         params : [ ses, modified_ou ],
357                                                                                         onerror : function (r) {
358                                                                                                 highlighter.editor_pane.red.play();
359                                                                                                 status_update( 'Problem deleting ' + old_name );
360                                                                                         },
361                                                                                         oncomplete : function (r) {
362                                                                                                 var res = r.recv();
363                                                                                                 if ( res && res.content() ) {
364         
365                                                                                                         ou_list_store.fetch({
366                                                                                                                 query : { id : ou_list_store.getValue( current_ou, 'id' ) },
367                                                                                                                 queryOptions : { deep : true },
368                                                                                                                 onItem : function (item, req) { try { if (this.isItem( item )) this.deleteItem( item ); } catch (e) { /* meh */ } },
369                                                                                                                 scope : ou_list_store
370                                                                                                         });
371         
372                                                                                                         current_ou = null;
373         
374                                                                                                         new_kid_button.disabled = true;
375                                                                                                         save_ou_button.disabled = true;
376                                                                                                         delete_ou_button.disabled = true;
377                         
378                                                                                                         var main_settings_fields = [ 'name', 'shortname', 'email', 'phone', 'ou_type', 'parent_ou' ];
379                                                                                                         for ( var i in main_settings_fields ) {
380                                                                                                                 var field = main_settings_fields[i];
381                                                                                                                 window["editor_pane_" + field].setValue( '' ); // unset the value
382                                                                                                                 window["editor_pane_" + field].setDisplayedValue( '' ); // unset the value
383                                                                                                         }
384                         
385                                                                                                         highlighter.editor_pane.green.play();
386                                                                                                         status_update( old_name + ' deleted' );
387                                                                                                 } else {
388                                                                                                         highlighter.editor_pane.red.play();
389                                                                                                         status_update( 'Problem deleting ' + old_name );
390                                                                                                 }
391                                                                                         }
392                                                                                 }).send();
393         
394                                                                         }
395         
396                                                                 </script>
397                                                         </button>
398         
399                                                 </div>
400         
401                                                 <button jsId="new_kid_button" dojoType="dijit.form.Button" label="New Child">
402                                                         <script type="dojo/connect" event="startup">
403                                                                 this.disabled = true;
404                                                         </script>
405                                                         <script type="dojo/connect" event="onClick">
406         
407                                                                 var new_fm_obj = new aou().fromHash({
408                                                                         isnew                   : 1,
409                                                                         name                    : 'New Branch',
410                                                                         opac_visible    : 'f',
411                                                                         shortname               : ou_list_store.getValue( current_ou, 'shortname' ) + '-NEW' + virgin_ou_id--,
412                                                                         parent_ou               : ou_list_store.getValue( current_ou, 'id' ),
413                                                                         ou_type                 : ou_list_store.getValue( current_ou, 'ou_type' )
414                                                                 });
415         
416                                                                 var new_obj;
417         
418                                                                 pCRUD.request({
419                                                                         method : 'open-ils.permacrud.create.aou',
420                                                                         timeout : 10,
421                                                                         params : [ ses, new_fm_obj ],
422                                                                         onerror : function (r) {
423                                                                                 highlighter.editor_pane.red.play();
424                                                                                 status_update( 'Problem creating child Org Unit' );
425                                                                         },
426                                                                         oncomplete : function (r) {
427                                                                                 var res = r.recv();
428                                                                                 if ( res && res.content() ) {
429                                                                                         ou_list_store.newItem(
430                                                                                                 res.content().toHash(),
431                                                                                                 { parent : current_ou, attribute : 'children' }
432                                                                                         );
433                                                                                 } else {
434                                                                                         highlighter.editor_pane.red.play();
435                                                                                         status_update( 'Problem creating child Org Unit' );
436                                                                                 }
437                                                                         },
438                                                                 }).send();
439         
440                                                                 highlighter.editor_pane.green.play();
441                                                                 highlighter.ou_tree.green.play();
442                                                                 status_update( 'New child Organizational Unit created for ' + ou_list_store.getValue( current_ou, 'name' ) );
443         
444                                                         </script>
445                                                 </button>
446         
447                                         </div>
448
449                                         <div id="hoo_pane" dojoType="dijit.layout.ContentPane" title="Hours of Operation">
450                                                 <table class="tundra" style="margin:10px;">
451                                                         <tr><th/><th>Open time</th><th>Close time</th></tr>
452                                                         <tr><th>Monday</th>
453                                                                 <td><span dojoType="dijit.form.TimeTextBox" style="width:8em;" jsId="dow_0_open" onChange="current_ou_hoo.dow_0_open( this.getDisplayedValue() );"/></td>
454                                                                 <td><span dojoType="dijit.form.TimeTextBox" style="width:8em;" jsId="dow_0_close" onChange="current_ou_hoo.dow_0_close( this.getDisplayedValue() );"/></td>
455                                                                 <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>
456                                                         </tr>
457                                                         <tr><th>Tuesday</th>
458                                                                 <td><span dojoType="dijit.form.TimeTextBox" style="width:8em;" jsId="dow_1_open" onChange="current_ou_hoo.dow_1_open( this.getDisplayedValue() );"/></td>
459                                                                 <td><span dojoType="dijit.form.TimeTextBox" style="width:8em;" jsId="dow_1_close" onChange="current_ou_hoo.dow_1_close( this.getDisplayedValue() );"/></td>
460                                                                 <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>
461                                                         </tr>
462                                                         <tr><th>Wednesday</th>
463                                                                 <td><span dojoType="dijit.form.TimeTextBox" style="width:8em;" jsId="dow_2_open" onChange="current_ou_hoo.dow_2_open( this.getDisplayedValue() );"/></td>
464                                                                 <td><span dojoType="dijit.form.TimeTextBox" style="width:8em;" jsId="dow_2_close" onChange="current_ou_hoo.dow_2_close( this.getDisplayedValue() );"/></td>
465                                                                 <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>
466                                                         </tr>
467                                                         <tr><th>Thursday</th>
468                                                                 <td><span dojoType="dijit.form.TimeTextBox" style="width:8em;" jsId="dow_3_open" onChange="current_ou_hoo.dow_3_open( this.getDisplayedValue() );"/></td>
469                                                                 <td><span dojoType="dijit.form.TimeTextBox" style="width:8em;" jsId="dow_3_close" onChange="current_ou_hoo.dow_3_close( this.getDisplayedValue() );"/></td>
470                                                                 <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>
471                                                         </tr>
472                                                         <tr><th>Friday</th>
473                                                                 <td><span dojoType="dijit.form.TimeTextBox" style="width:8em;" jsId="dow_4_open" onChange="current_ou_hoo.dow_4_open( this.getDisplayedValue() );"/></td>
474                                                                 <td><span dojoType="dijit.form.TimeTextBox" style="width:8em;" jsId="dow_4_close" onChange="current_ou_hoo.dow_4_close( this.getDisplayedValue() );"/></td>
475                                                                 <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>
476                                                         </tr>
477                                                         <tr><th>Saturday</th>
478                                                                 <td><span dojoType="dijit.form.TimeTextBox" style="width:8em;" jsId="dow_5_open" onChange="current_ou_hoo.dow_5_open( this.getDisplayedValue() );"/></td>
479                                                                 <td><span dojoType="dijit.form.TimeTextBox" style="width:8em;" jsId="dow_5_close" onChange="current_ou_hoo.dow_5_close( this.getDisplayedValue() );"/></td>
480                                                                 <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>
481                                                         </tr>
482                                                         <tr><th>Sunday</th>
483                                                                 <td><span dojoType="dijit.form.TimeTextBox" style="width:8em;" jsId="dow_6_open" onChange="current_ou_hoo.dow_6_open( this.getDisplayedValue() );"/></td>
484                                                                 <td><span dojoType="dijit.form.TimeTextBox" style="width:8em;" jsId="dow_6_close" onChange="current_ou_hoo.dow_6_close( this.getDisplayedValue() );"/></td>
485                                                                 <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>
486                                                         </tr>
487                                                 </table>
488         
489                                                 <button jsId="save_hoo_button" dojoType="dijit.form.Button" label="Save">
490                                                         <script type="dojo/connect" event="onClick">
491         
492                                                                 var method_name = 'open-ils.permacrud.update.aouhoo';
493                                                                 if (current_ou_hoo.isnew() == 1) method_name = 'open-ils.permacrud.create.aouhoo';
494         
495                                                                 pCRUD.request({
496                                                                         method : method_name,
497                                                                         params : [ ses, current_ou_hoo ],
498                                                                         onerror : function (r) {
499                                                                                 highlighter.editor_pane.red.play();
500                                                                                 status_update( 'Problem saving Hours of Operation data for ' + ou_list_store.getValue( current_ou, 'name' ));
501                                                                         },
502                                                                         oncomplete : function (r) {
503                                                                                 var res = r.recv();
504                                                                                 if ( res && res.content() ) {
505                                                                                         current_ou_hoo.isnew(0);
506                                                                                         highlighter.editor_pane.green.play();
507                                                                                         status_update( 'Hours of Operation updated for ' + ou_list_store.getValue( current_ou, 'name' ) );
508                                                                                 } else {
509                                                                                         highlighter.editor_pane.red.play();
510                                                                                         status_update( 'Problem saving Hours of Operation data for ' + ou_list_store.getValue( current_ou, 'name' ));
511                                                                                 }
512                                                                         },
513                                                                 }).send();
514         
515                                                         </script>
516                                                 </button>
517         
518                                         </div>
519         
520                                         <div id="addresses_pane" dojoType="dijit.layout.ContentPane" title="Addresses">
521                                                 
522                                                 <div id="billing_address_pane" dojoType="dijit.layout.TabContainer" style="margin-top:10px">
523         
524                                                         <script type="dojo/method">
525                                                                 window.current_billing_address = null;
526                                                                 window.current_mailing_address = null;
527                                                                 window.current_holds_address = null;
528                                                                 window.current_ill_address = null;
529                                                         </script>
530         
531                                                         <div id="billing_address" dojoType="dijit.layout.ContentPane" title="Physical Address">
532                                                                 <table class="tundra" style="margin:10px;">
533                                                                         <tr>
534                                                                                 <th>Type</th>
535                                                                                 <td colspan="3">
536                                                                                         <span jsId="billing_addr_type" style="width:100%;" dojoType="dijit.form.TextBox" onChange="current_billing_address.address_type( this.getValue() )"/>
537                                                                                 </td>
538                                                                                 <th>Valid</th><td>
539                                                                                         <input
540                                                                                           type="checkbox"
541                                                                                           jsId="billing_addr_valid"
542                                                                                           dojoType="dijit.form.CheckBox"
543                                                                                           value='t'
544                                                                                           onChange='if (current_billing_address) current_billing_address.valid( this.checked ? "t" : "f" );'
545                                                                                         />
546                                                                                 </td>
547                                                                         </tr>
548                                                                         <tr>
549                                                                                 <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>
550                                                                         </tr>
551                                                                         <tr>
552                                                                                 <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>
553                                                                         </tr>
554                                                                         <tr>
555                                                                                 <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>
556                                                                                 <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>
557                                                                                 <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>
558                                                                         </tr>
559                                                                         <tr>
560                                                                                 <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>
561                                                                                 <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>
562                                                                         </tr>
563                                                                 </table>
564         
565                                                                 <button jsId="save_billing_address" dojoType="dijit.form.Button" label="Save">
566                                                                         <script type="dojo/connect" event="startup">
567                                                                                 this.disabled = true;
568                                                                         </script>
569                                                                         <script type="dojo/connect" event="onClick">
570         
571                                                                                 var method_name = 'open-ils.permacrud.update.aoa';
572                                                                                 if (current_billing_address.isnew() == 1) method_name = 'open-ils.permacrud.create.aoa';
573         
574                                                                                 pCRUD.request({
575                                                                                         method : method_name,
576                                                                                         params : [ ses, current_billing_address ],
577                                                                                         onerror : function (r) {
578                                                                                                 highlighter.addresses_pane.red.play();
579                                                                                                 status_update( 'Problem saving Physical Address data for ' + ou_list_store.getValue( current_ou, 'name' ) );
580                                                                                         },
581                                                                                         oncomplete : function (r) {
582                                                                                                 var res = r.recv();
583                                                                                                 if ( res && res.content() ) {
584                                                                                                         if (current_billing_address.isnew() == 1) {
585                                                                                                                 current_billing_address = res.content();
586                                                                                                                 ou_list_store.setValue( current_ou, 'billing_address', current_billing_address.id() );
587                                                                                                                 save_org();
588                                                                                                         }
589                                                                                                         current_billing_address.isnew(0);
590                                                                                                         highlighter.addresses_pane.green.play();
591                                                                                                         status_update( 'Changes to the Physical Address of ' + ou_list_store.getValue( current_ou, 'name' ) + ' saved' );
592                                                                                                 } else {
593                                                                                                         highlighter.addresses_pane.red.play();
594                                                                                                         status_update( 'Problem saving Physical Address data for ' + ou_list_store.getValue( current_ou, 'name' ) );
595                                                                                                 }
596                                                                                         },
597                                                                                 }).send();
598         
599                                                                         </script>
600                                                                 </button>
601                                                         </div>
602
603                                                         <div id="holds_address" dojoType="dijit.layout.ContentPane" title="Holds Address">
604                                                                 <table class="tundra" style="margin:10px;">
605                                                                         <tr>
606                                                                                 <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>
607                                                                                 <th>Valid</th><td>
608                                                                                         <input
609                                                                                           type="checkbox"
610                                                                                           jsId="holds_addr_valid"
611                                                                                           dojoType="dijit.form.CheckBox"
612                                                                                           value='t'
613                                                                                           onChange='if (current_holds_address) current_holds_address.valid( this.checked ? "t" : "f" );'
614                                                                                         />
615                                                                                 </td>
616                                                                         </tr>
617                                                                         <tr>
618                                                                                 <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>
619                                                                         </tr>
620                                                                         <tr>
621                                                                                 <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>
622                                                                         </tr>
623                                                                         <tr>
624                                                                                 <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>
625                                                                                 <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>
626                                                                                 <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>
627                                                                         </tr>
628                                                                         <tr>
629                                                                                 <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>
630                                                                                 <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>
631                                                                         </tr>
632                                                                 </table>
633         
634                                                                 <button jsId="save_holds_address" dojoType="dijit.form.Button" label="Save">
635                                                                         <script type="dojo/connect" event="startup">
636                                                                                 this.disabled = true;
637                                                                         </script>
638                                                                         <script type="dojo/connect" event="onClick">
639         
640                                                                                 var method_name = 'open-ils.permacrud.update.aoa';
641                                                                                 if (current_holds_address.isnew() == 1) method_name = 'open-ils.permacrud.create.aoa';
642         
643                                                                                 pCRUD.request({
644                                                                                         method : method_name,
645                                                                                         params : [ ses, current_holds_address ],
646                                                                                         onerror : function (r) {
647                                                                                                 highlighter.addresses_pane.red.play();
648                                                                                                 throw 'Problem saving Holds Address data for ' + ou_list_store.getValue( current_ou, 'name' );
649                                                                                         },
650                                                                                         oncomplete : function (r) {
651                                                                                                 var res = r.recv();
652                                                                                                 if ( res && res.content() ) {
653                                                                                                         if (current_holds_address.isnew() == 1) {
654                                                                                                                 current_holds_address = res.content();
655                                                                                                                 ou_list_store.setValue( current_ou, 'holds_address', current_holds_address.id() );
656                                                                                                                 save_org();
657                                                                                                         }
658                                                                                                         current_holds_address.isnew(0);
659                                                                                                         highlighter.addresses_pane.green.play();
660                                                                                                         status_update( 'Changes to the Holds Address of ' + ou_list_store.getValue( current_ou, 'name' ) + ' saved' );
661                                                                                                 } else {
662                                                                                                         highlighter.addresses_pane.red.play();
663                                                                                                         throw 'Problem saving Holds Address data for ' + ou_list_store.getValue( current_ou, 'name' );
664                                                                                                 }
665                                                                                         },
666                                                                                 }).send();
667         
668                                                                         </script>
669                                                                 </button>
670                                                         </div>
671
672                                                         <div id="mailing_address" dojoType="dijit.layout.ContentPane" title="Mailing Address">
673                                                                 <table class="tundra" style="margin:10px;">
674                                                                         <tr>
675                                                                                 <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>
676                                                                                 <th>Valid</th><td>
677                                                                                         <input
678                                                                                           type="checkbox"
679                                                                                           jsId="mailing_addr_valid"
680                                                                                           dojoType="dijit.form.CheckBox"
681                                                                                           onChange='if (current_mailing_address) current_mailing_address.valid( this.checked ? "t" : "f" );'
682                                                                                         />
683                                                                                 </td>
684                                                                         </tr>
685                                                                         <tr>
686                                                                                 <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>
687                                                                         </tr>
688                                                                         <tr>
689                                                                                 <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>
690                                                                         </tr>
691                                                                         <tr>
692                                                                                 <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>
693                                                                                 <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>
694                                                                                 <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>
695                                                                         </tr>
696                                                                         <tr>
697                                                                                 <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>
698                                                                                 <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>
699                                                                         </tr>
700                                                                 </table>
701         
702                                                                 <button jsId="save_mailing_address" dojoType="dijit.form.Button" label="Save">
703                                                                         <script type="dojo/connect" event="startup">
704                                                                                 this.disabled = true;
705                                                                         </script>
706                                                                         <script type="dojo/connect" event="onClick">
707         
708                                                                                 var method_name = 'open-ils.permacrud.update.aoa';
709                                                                                 if (current_mailing_address.isnew() == 1) method_name = 'open-ils.permacrud.create.aoa';
710         
711                                                                                 pCRUD.request({
712                                                                                         method : method_name,
713                                                                                         params : [ ses, current_mailing_address ],
714                                                                                         onerror : function (r) {
715                                                                                                 highlighter.addresses_pane.red.play();
716                                                                                                 throw 'Problem saving Mailing Address data for ' + ou_list_store.getValue( current_ou, 'name' );
717                                                                                         },
718                                                                                         oncomplete : function (r) {
719                                                                                                 var res = r.recv();
720                                                                                                 if ( res && res.content() ) {
721                                                                                                         if (current_mailing_address.isnew() == 1) {
722                                                                                                                 current_mailing_address = res.content();
723                                                                                                                 ou_list_store.setValue( current_ou, 'mailing_address', current_mailing_address.id() );
724                                                                                                                 save_org();
725                                                                                                         }
726                                                                                                         current_mailing_address.isnew(0);
727                                                                                                         highlighter.addresses_pane.green.play();
728                                                                                                         status_update( 'Changes to the Mailing Address of ' + ou_list_store.getValue( current_ou, 'name' ) + ' saved' );
729                                                                                                 } else {
730                                                                                                         highlighter.addresses_pane.red.play();
731                                                                                                         throw 'Problem saving Mailing Address data for ' + ou_list_store.getValue( current_ou, 'name' );
732                                                                                                 }
733                                                                                         },
734                                                                                 }).send();
735         
736                                                                         </script>
737                                                                 </button>
738                                                         </div>
739
740                                                         <div id="ill_address" dojoType="dijit.layout.ContentPane" title="ILL Address">
741                                                                 <table class="tundra" style="margin:10px;">
742                                                                         <tr>
743                                                                                 <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>
744                                                                                 <th>Valid</th><td>
745                                                                                         <input
746                                                                                           type="checkbox"
747                                                                                           jsId="ill_addr_valid"
748                                                                                           dojoType="dijit.form.CheckBox"
749                                                                                           onChange='if (current_ill_address) current_ill_address.valid( this.checked ? "t" : "f" );'
750                                                                                         />
751                                                                                 </td>
752                                                                         </tr>
753                                                                         <tr>
754                                                                                 <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>
755                                                                         </tr>
756                                                                         <tr>
757                                                                                 <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>
758                                                                         </tr>
759                                                                         <tr>
760                                                                                 <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>
761                                                                                 <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>
762                                                                                 <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>
763                                                                         </tr>
764                                                                         <tr>
765                                                                                 <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>
766                                                                                 <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>
767                                                                         </tr>
768                                                                 </table>
769         
770                                                                 <button jsId="save_ill_address" dojoType="dijit.form.Button" label="Save">
771                                                                         <script type="dojo/connect" event="startup">
772                                                                                 this.disabled = true;
773                                                                         </script>
774                                                                         <script type="dojo/connect" event="onClick">
775         
776                                                                                 var method_name = 'open-ils.permacrud.update.aoa';
777                                                                                 if (current_ill_address.isnew() == 1) method_name = 'open-ils.permacrud.create.aoa';
778         
779                                                                                 pCRUD.request({
780                                                                                         method : method_name,
781                                                                                         params : [ ses, current_ill_address ],
782                                                                                         onerror : function (r) {
783                                                                                                 highlighter.addresses_pane.red.play();
784                                                                                                 throw 'Problem saving Physical Address data for ' + ou_list_store.getValue( current_ou, 'name' );
785                                                                                         },
786                                                                                         oncomplete : function (r) {
787                                                                                                 var res = r.recv();
788                                                                                                 if ( res && res.content() ) {
789                                                                                                         if (current_ill_address.isnew() == 1) {
790                                                                                                                 current_ill_address = res.content();
791                                                                                                                 ou_list_store.setValue( current_ou, 'ill_address', current_ill_address.id() );
792                                                                                                                 save_org();
793                                                                                                         }
794                                                                                                         current_ill_address.isnew(0);
795                                                                                                         highlighter.addresses_pane.green.play();
796                                                                                                         status_update( 'Changes to the ILL Address of ' + ou_list_store.getValue( current_ou, 'name' ) + ' saved' );
797                                                                                                 } else {
798                                                                                                         highlighter.addresses_pane.red.play();
799                                                                                                         throw 'Problem saving Physical Address data for ' + ou_list_store.getValue( current_ou, 'name' );
800                                                                                                 }
801                                                                                         },
802                                                                                 }).send();
803         
804                                                                         </script>
805                                                                 </button>
806                                                         </div>
807                                                 </div>
808                                         </div>
809                                 </div>
810                         </div>
811                 </div>
812
813                 <div id="status_bar"><span style="font-weight: bold; margin: 5px; margin-right: 10px;">Now editing:</span><span id="current_ou_name"></span></div>
814         </body>
815 </html>