[% WRAPPER base.tt2 %]
[% ctx.page_title = 'Providers' %]
-<div class="hidden">
- <select dojoType="dijit.form.FilteringSelect" jsId="nameSelect">
- <option value='owning_lib'>Owning Library</option>
- <option value='quantity'>Quantity</option>
- <option value='call_number'>Call Number</option>
- <option value='fund_code'>Fund Code</option>
- <option value='local_note'>Local Note</option>
- <option value='price'>Price</option>
- <option value='circ_modifier'>Circulation Modifier</option>
- <option value='copy_location'>Copy Location</option>
- <option value='collection_code'>Collection Code</option>
- </select>
-</div>
-
-<div id='provider-list-div'>
- <div dojoType="dijit.layout.ContentPane" layoutAlign='top'>
+<div dojoType="dijit.layout.ContentPane" layoutAlign='client'>
+ <div id='provider-list-div'>
<div dojoType="dijit.layout.ContentPane" layoutAlign="top" class='oils-header-panel'>
<div>Provider</div>
<div>
<button dojoType='dijit.form.Button' onClick='pListGrid.deleteSelected()'>Delete Selected</button>
</div>
</div>
- </div>
- <div dojoType="dijit.layout.ContentPane" layoutAlign="client">
- <span>Context Org Unit</span>
- <select dojoType="openils.widget.OrgUnitFilteringSelect"
- jsId='contextOrgSelector'
- searchAttr='shortname'
- labelAttr='shortname'>
- </select>
- </div>
- <div dojoType="dijit.layout.ContentPane" layoutAlign="client">
- <table jsId="pListGrid"
- dojoType="openils.widget.AutoGrid"
- fieldOrder="['id', 'name', 'code', 'owner', 'currency_type']"
- query="{id: '*'}"
- defaultCellWidth='"auto"'
- fmClass='acqpro'
- showPaginator='true'
- editOnEnter='true'>
- <thead>
- <tr><th field='name' get='getProviderName' formatter='formatName'/></tr>
- </thead>
- </table>
- </div>
-</div>
-
-<div id='provider-summary-pane'></div>
-<div id='provider-details-div' style='height:600px'>
-<div dojoType="dijit.layout.TabContainer" style='height:100%' jsId='providerTabs'>
-
- <div dojoType="dijit.layout.ContentPane" title='Provider Address' select='true' id='provider-address'>
- <div dojoType="dijit.layout.ContentPane" layoutAlign="top" class='oils-header-panel'>
- <div>Provider Address</div>
- <div>
- <button dojoType='dijit.form.Button' onClick='paListGrid.showCreateDialog()'>New Provider Address</button>
- <button dojoType='dijit.form.Button' onClick='paListGrid.deleteSelected()'>Delete Selected</button>
- </div>
+ <div dojoType="dijit.layout.ContentPane" layoutAlign="client">
+ <span>Context Org Unit</span>
+ <select dojoType="openils.widget.OrgUnitFilteringSelect"
+ jsId='contextOrgSelector'
+ searchAttr='shortname'
+ labelAttr='shortname'>
+ </select>
</div>
- <div dojoType="dijit.layout.ContentPane" layoutAlign="client" style='height:100px'>
- <table jsId="paListGrid"
+ <div dojoType="dijit.layout.ContentPane" layoutAlign="client">
+ <table jsId="pListGrid"
dojoType="openils.widget.AutoGrid"
- fieldOrder="['id', 'address_type', 'provider', 'street1', 'street2', 'city', 'county', 'state', 'country', 'post_code']"
- requiredFields="['street1', 'city', 'state', 'country', 'post_code']"
+ fieldOrder="['id', 'name', 'code', 'owner', 'currency_type']"
query="{id: '*'}"
- fmClass='acqpa'
- defaultCellWidth='"auto"'
+ defaultCellWidth='"auto"'
+ fmClass='acqpro'
+ showLoadFilter='true'
editOnEnter='true'>
+ <thead>
+ <tr><th field='name' get='getProviderName' formatter='formatName'/></tr>
+ </thead>
</table>
</div>
</div>
- <div dojoType="dijit.layout.ContentPane" title='Provider Contact' id='tab-pro-contact'>
- <div dojoType="dijit.layout.ContentPane" layoutAlign="top" class='oils-header-panel'>
- <div>Provider Contact</div>
- <div>
- <button dojoType='dijit.form.Button' onClick='pcListGrid.showCreateDialog()'>New Contact</button>
- <button dojoType='dijit.form.Button' onClick='pcListGrid.deleteSelected()'>Delete Selected</button>
+ <div id='provider-summary-pane'></div>
+ <div id='provider-details-div' style='height:600px'>
+ <div dojoType="dijit.layout.TabContainer" style='height:100%' jsId='providerTabs'>
+
+ <div dojoType="dijit.layout.ContentPane" title='Provider Address' select='true' id='provider-address'>
+ <div dojoType="dijit.layout.ContentPane" layoutAlign="top" class='oils-header-panel'>
+ <div>Provider Address</div>
+ <div>
+ <button dojoType='dijit.form.Button' onClick='paListGrid.showCreateDialog()'>New Provider Address</button>
+ <button dojoType='dijit.form.Button' onClick='paListGrid.deleteSelected()'>Delete Selected</button>
+ </div>
</div>
- </div>
- <div dojoType="dijit.layout.ContentPane" layoutAlign="client" style='height:200px'>
- <table jsId="pcListGrid"
- dojoType="openils.widget.AutoGrid"
- fieldOrder="['id', 'name', 'provider', 'role', 'email']"
- requiredFields="['name']"
- defaultCellWidth='"auto"'
- query="{id: '*'}"
- fmClass='acqpc'
- editOnEnter='true'>
- </table>
- </div>
-
- <div dojoType="dijit.layout.ContentPane" layoutAlign="top" class='oils-header-panel'>
- <div>Contact Address</div>
- <div>
- <button dojoType='dijit.form.Button' onClick='pcaListGrid.showCreateDialog()'>New Contact Address</button>
- <button dojoType='dijit.form.Button' onClick='pcaListGrid.deleteSelected()'>Delete Selected</button>
+ <div dojoType="dijit.layout.ContentPane" layoutAlign="client" style='height:100px'>
+ <table jsId="paListGrid"
+ dojoType="openils.widget.AutoGrid"
+ fieldOrder="['id', 'address_type', 'provider', 'street1', 'street2', 'city', 'county', 'state', 'country', 'post_code']"
+ requiredFields="['street1', 'city', 'state', 'country', 'post_code']"
+ query="{id: '*'}"
+ fmClass='acqpa'
+ defaultCellWidth='"auto"'
+ editOnEnter='true'>
+ </table>
</div>
</div>
- <div dojoType="dijit.layout.ContentPane" layoutAlign="client" style='height:200px'>
- <table jsId="pcaListGrid"
- dojoType="openils.widget.AutoGrid"
- fieldOrder="['id', 'address_type', 'contact', 'street1', 'street2', 'city', 'county', 'state', 'country', 'post_code']"
- requiredFields="['street1', 'city', 'state', 'country', 'post_code']"
- query="{id: '*'}"
- fmClass='acqpca'
- defaultCellWidth='"auto"'
- editOnEnter='true'>
- </table>
- </div>
-
- </div>
- <div dojoType="dijit.layout.ContentPane" title='Attribute Definitions' id='tab-attr'>
- <div dojoType="dijit.layout.ContentPane" layoutAlign="top" class='oils-header-panel'>
- <div> Attribute Definitions</div>
- <div>
- <button dojoType='dijit.form.Button' onClick='padListGrid.showCreateDialog()'>New Attribute Definition</button>
- <button dojoType='dijit.form.Button' onClick='padListGrid.deleteSelected()'>Delete Selected</button>
+
+ <div dojoType="dijit.layout.ContentPane" title='Provider Contact' id='tab-pro-contact'>
+ <div dojoType="dijit.layout.ContentPane" layoutAlign="top" class='oils-header-panel'>
+ <div>Provider Contact</div>
+ <div>
+ <button dojoType='dijit.form.Button' onClick='pcListGrid.showCreateDialog()'>New Contact</button>
+ <button dojoType='dijit.form.Button' onClick='pcListGrid.deleteSelected()'>Delete Selected</button>
+ </div>
+ </div>
+ <div dojoType="dijit.layout.ContentPane" layoutAlign="client" style='height:200px'>
+ <table jsId="pcListGrid"
+ dojoType="openils.widget.AutoGrid"
+ fieldOrder="['id', 'name', 'provider', 'role', 'email']"
+ requiredFields="['name']"
+ defaultCellWidth='"auto"'
+ query="{id: '*'}"
+ fmClass='acqpc'
+ editOnEnter='true'>
+ </table>
+ </div>
+
+ <div dojoType="dijit.layout.ContentPane" layoutAlign="top" class='oils-header-panel'>
+ <div>Contact Address</div>
+ <div>
+ <button dojoType='dijit.form.Button' onClick='pcaListGrid.showCreateDialog()'>New Contact Address</button>
+ <button dojoType='dijit.form.Button' onClick='pcaListGrid.deleteSelected()'>Delete Selected</button>
+ </div>
</div>
+ <div dojoType="dijit.layout.ContentPane" layoutAlign="client" style='height:200px'>
+ <table jsId="pcaListGrid"
+ dojoType="openils.widget.AutoGrid"
+ fieldOrder="['id', 'address_type', 'contact', 'street1', 'street2', 'city', 'county', 'state', 'country', 'post_code']"
+ requiredFields="['street1', 'city', 'state', 'country', 'post_code']"
+ query="{id: '*'}"
+ fmClass='acqpca'
+ defaultCellWidth='"auto"'
+ editOnEnter='true'>
+ </table>
+ </div>
+
</div>
- <div dojoType="dijit.layout.ContentPane" layoutAlign="client" style='height:200px'>
- <table jsId="padListGrid"
- dojoType="openils.widget.AutoGrid"
- fieldOrder="['id', 'provider', 'code', 'description', 'provider', 'ident', 'remove', 'tag', 'subfield', 'xpath']"
- requiredFields="['code', 'description', 'xpath']"
- query="{id: '*'}"
- fmClass='acqlipad'
- editOnEnter='true'>
- <thead>
- <tr>
- <th field="xpath" width='auto'/>
- <th field="tag" name="Tag" get='getParsedTag'/>
- <th field="subfield" name="Subfield" get='getParsedSubf'/>
- </tr>
- </thead>
- </table>
+ <div dojoType="dijit.layout.ContentPane" title='Attribute Definitions' id='tab-attr'>
+ <div dojoType="dijit.layout.ContentPane" layoutAlign="top" class='oils-header-panel'>
+ <div> Attribute Definitions</div>
+ <div>
+ <button dojoType='dijit.form.Button' onClick='padListGrid.showCreateDialog()'>New Attribute Definition</button>
+ <button dojoType='dijit.form.Button' onClick='padListGrid.deleteSelected()'>Delete Selected</button>
+ </div>
+ </div>
+ <div dojoType="dijit.layout.ContentPane" layoutAlign="client" style='height:200px'>
+ <table jsId="padListGrid"
+ dojoType="openils.widget.AutoGrid"
+ fieldOrder="['id', 'provider', 'code', 'description', 'provider', 'ident', 'remove', 'tag', 'subfield', 'xpath']"
+ requiredFields="['code', 'description', 'xpath']"
+ query="{id: '*'}"
+ fmClass='acqlipad'
+ editOnEnter='true'>
+ <thead>
+ <tr>
+ <th field="xpath" width='auto'/>
+ <th field="tag" name="Tag" get='getParsedTag'/>
+ <th field="subfield" name="Subfield" get='getParsedSubf'/>
+ </tr>
+ </thead>
+ </table>
+ </div>
</div>
- </div>
- <div dojoType="dijit.layout.ContentPane" title='Holding Subfield' id='tab-hold'>
- <div dojoType="dijit.layout.ContentPane" layoutAlign="top" class='oils-header-panel'>
- <div>Holding Subfield</div>
- <div>
- <button dojoType='dijit.form.Button' onClick='phsListGrid.showCreateDialog()'>New Holding Subfield</button>
- <button dojoType='dijit.form.Button' onClick='phsListGrid.deleteSelected()'>Delete Selected</button>
+ <div dojoType="dijit.layout.ContentPane" title='Holding Subfield' id='tab-hold'>
+ <div dojoType="dijit.layout.ContentPane" layoutAlign="top" class='oils-header-panel'>
+ <div>Holding Subfield</div>
+ <div>
+ <button dojoType='dijit.form.Button' onClick='phsListGrid.showCreateDialog()'>New Holding Subfield</button>
+ <button dojoType='dijit.form.Button' onClick='phsListGrid.deleteSelected()'>Delete Selected</button>
+ </div>
+ </div>
+ <div dojoType="dijit.layout.ContentPane" layoutAlign="client" style='height:400px'>
+ <table jsId="phsListGrid"
+ dojoType="openils.widget.AutoGrid"
+ fieldOrder="['id', 'provider', 'name', 'subfield']"
+ requiredFields="['name', 'subfield']"
+ query="{id: '*'}"
+ fmClass='acqphsm'
+ editOnEnter='true'>
+ </table>
</div>
</div>
- <div dojoType="dijit.layout.ContentPane" layoutAlign="client" style='height:400px'>
- <table jsId="phsListGrid"
+
+ <div dojoType="dijit.layout.ContentPane" title="Invoices" id="tab-invoice">
+ <big class="oils-acq-basic-roomy"><strong>Invoices</strong></big>
+ <div dojoType="dijit.layout.ContentPane" layoutAlign="client" style="height:400px">
+ <table jsId="invListGrid"
dojoType="openils.widget.AutoGrid"
- fieldOrder="['id', 'provider', 'name', 'subfield']"
- requiredFields="['name', 'subfield']"
+ fieldOrder="['inv_ident', 'receiver', 'shipper']"
+ suppressFields="['id', 'provider']"
query="{id: '*'}"
- fmClass='acqphsm'
- editOnEnter='true'>
- </table>
+ showPaginator='true'
+ fmClass="acqinv">
+ <thead>
+ <tr>
+ <th field="inv_ident" get="getInvIdent" formatter="formatInvIdent" />
+ </tr>
+ </thead>
+ </table>
+ </div>
</div>
</div>
-
- <div dojoType="dijit.layout.ContentPane" title="Invoices" id="tab-invoice">
- <big class="oils-acq-basic-roomy"><strong>Invoices</strong></big>
- <div dojoType="dijit.layout.ContentPane" layoutAlign="client" style="height:400px">
- <table jsId="invListGrid"
- dojoType="openils.widget.AutoGrid"
- fieldOrder="['inv_ident', 'receiver', 'shipper']"
- suppressFields="['id', 'provider']"
- query="{id: '*'}"
- showPaginator='true'
- fmClass="acqinv">
- <thead>
- <tr>
- <th field="inv_ident" get="getInvIdent" formatter="formatInvIdent" />
- </tr>
- </thead>
- </table>
- </div>
</div>
+
+ <div class="hidden">
+ <select dojoType="dijit.form.FilteringSelect" jsId="nameSelect">
+ <option value='owning_lib'>Owning Library</option>
+ <option value='quantity'>Quantity</option>
+ <option value='call_number'>Call Number</option>
+ <option value='fund_code'>Fund Code</option>
+ <option value='local_note'>Local Note</option>
+ <option value='price'>Price</option>
+ <option value='circ_modifier'>Circulation Modifier</option>
+ <option value='copy_location'>Copy Location</option>
+ <option value='collection_code'>Collection Code</option>
+ </select>
+ </div>
</div>
-</div>
+
<script type="text/javascript" src='[% ctx.media_prefix %]/js/ui/default/conify/global/acq/provider.js'> </script>
var provider;
var xpathParser = new openils.MarcXPathParser();
var subFields= [];
+var adminPermOrgs = [];
+var viewPermOrgs = [];
+var user;
+var viewPerms = [
+ 'ADMIN_PROVIDER',
+ 'MANAGE_PROVIDER',
+ 'VIEW_PROVIDER'
+];
+
function draw() {
- var org_id = openils.User.user.ws_ou();
- var list = fieldmapper.aou.findOrgUnit(org_id).orgNodeTrail().map(
- function (i) {return i.id() }
- );
- new openils.User().buildPermOrgSelector(
- 'VIEW_PROVIDER', contextOrgSelector, null,
+ user = new openils.User();
+
+ if(providerId) {
+ drawOneProvider();
+ return;
+ }
+
+ openils.Util.hide('provider-details-div');
+
+ // after a provider is created, load the provider page
+ pListGrid.onPostCreate = function(fmObject) {
+ location.href = location.href + '/' + fmObject.id();
+ }
+
+ user.buildPermOrgSelector(
+ viewPerms,
+ contextOrgSelector, null,
+
function() {
- dojo.connect(contextOrgSelector, 'onChange', filterGrid);
+ if (!contextOrgSelector.attr('value')) return
+
+ dojo.connect(contextOrgSelector, 'onChange', drawProviderGrid);
+
+ // fetch the admin org units
+ user.getPermOrgList(
+ 'ADMIN_PROVIDER',
+
+ function(list) {
+ adminPermOrgs = list;
+
+ // fetch the view org units
+ user.getPermOrgList(
+ viewPerms,
+ function(list2) {
+ viewPermOrgs = list2
+ drawProviderGrid();
+ },
+ true, true
+ );
+ },
+ true, true
+ );
}
);
+}
- if(providerId) {
- openils.Util.addCSSClass(dojo.byId('provider-list-div'), 'hidden');
-
- console.log('in draw');
- var pcrud = new openils.PermaCrud();
- pcrud.retrieve('acqpro', providerId, {
- oncomplete : function(r) {
- provider = openils.Util.readResponse(r);
- console.log('provider is' + js2JSON(provider));
- var pane = new openils.widget.EditPane({fmObject:provider, paneStackCount:2}, dojo.byId('provider-summary-pane'));
- pane.startup();
- console.log("pane started");
- dojo.connect(providerTabs, 'selectChild', drawProviderSummary);
- }
-
- });
-
- drawProviderSummary();
- } else {
- openils.Util.addCSSClass(dojo.byId('provider-details-div'), 'hidden');
- console.log('in else block');
- pListGrid.loadAll({order_by:{acqpro : 'name'}},{'owner':list});
- pListGrid.onPostCreate = function(fmObject) {
- location.href = location.href + '/' + fmObject.id();
- }
-
- }
+function drawOneProvider() {
+ openils.Util.hide('provider-list-div');
+ var pcrud = new openils.PermaCrud();
+ pcrud.retrieve('acqpro', providerId, {
+ oncomplete : function(r) {
+ provider = openils.Util.readResponse(r);
+ console.log('provider is' + js2JSON(provider));
+ var pane = new openils.widget.EditPane({fmObject:provider, paneStackCount:2}, dojo.byId('provider-summary-pane'));
+ pane.startup();
+ console.log("pane started");
+ dojo.connect(providerTabs, 'selectChild', drawProviderSummary);
+ }
+ });
+
+ drawProviderSummary();
+}
+
+
+function drawProviderGrid() {
+ pListGrid.resetStore();
+
+ // view providers for here plus children
+ var list = fieldmapper.aou.descendantNodeList(
+ contextOrgSelector.attr('value'), true, true);
+
+ pListGrid.loadAll(
+ {order_by : [ // sort providers I can edit to the front
+ { 'class' : 'acqpro',
+ field : 'owner',
+ compare : {'in' : adminPermOrgs},
+ direction : 'desc'
+ },
+ { 'class' : 'acqpro',
+ field : 'name'
+ }
+ ]},
+ {'owner' : list}
+ );
}
+
function drawProviderSummary(child) {
var loadedTabs = {'provider-address' : true};
if(child){
pcListGrid.overrideEditWidgets.provider = new
dijit.form.TextBox({disabled: 'true', value: providerId});
pcListGrid.resetStore();
- pcListGrid.loadAll( {oncomplete:function(r){
- var count = 0;
- pcListGrid.store.fetch( {onComplete:function(list) {
+ pcListGrid.loadAll({
+ oncomplete:function(r) {
+ var count = 0;
+ pcListGrid.store.fetch( {
+ onComplete:function(list) {
count = list.length
- if(count>=1){
- var contactIds = []; dojo.forEach(list, function(item) {
- contactIds.push(pcListGrid.store.getValue(item, 'id')); }
- );
-
+ if (count>=1) {
+ var contactIds = [];
+ dojo.forEach(list, function(item) {
+ contactIds.push(pcListGrid.store.getValue(item, 'id'));
+ });
+
pcaListGrid.overrideEditWidgets.contact = new
dijit.form.FilteringSelect({store: pcListGrid.store});
pcaListGrid.resetStore();
pcaListGrid.loadAll({order_by:{acqpca : 'contact'}}, {contact: contactIds});
- }else{
+
+ } else {
return;
}
- }
- }
- );
- }
- }, {provider : providerId});
+ }
+ });
+ }
+ }, {provider : providerId});
break;
+
case 'tab-attr':
padListGrid.overrideEditWidgets.provider = new
dijit.form.TextBox({disabled: 'true', value: providerId});
padListGrid.resetStore();
padListGrid.loadAll({order_by:{acqlipad : 'code'}}, {provider : providerId});
break;
+
case 'tab-hold':
phsListGrid.overrideEditWidgets.provider = new
dijit.form.TextBox({disabled: 'true', value: providerId});
phsListGrid.resetStore();
phsListGrid.loadAll({order_by:{acqphsm : 'name'}}, {provider : providerId});
break;
+
case "tab-invoice":
invListGrid.resetStore();
invListGrid.loadAll(
{"provider": providerId}
);
break;
+
default:
paListGrid.overrideEditWidgets.provider = new
dijit.form.TextBox({disabled: 'true', value: providerId});
function getParsedSubf(rowIndex, item) {
-
if(item) {
var subfields = xpathParser.parse(padListGrid.store.getValue(item, 'xpath')).subfields;
return subfields.join(',');
return'';
}
-function filterGrid() {
- pListGrid.resetStore();
- var unit = contextOrgSelector.getValue();
- var list = fieldmapper.aou.findOrgUnit(unit).orgNodeTrail().map( function (i) {return i.id() } );
- if(unit){
- pListGrid.loadAll({order_by:{acqpro : 'name'}}, { 'owner' : list });
- } else {
- pListGrid.loadAll({order_by:{acqpro : 'name'}});
- }
-}
openils.Util.addOnLoad(draw);