From 6a0e10784287403b9e170a5c9c8f0c0925c68d21 Mon Sep 17 00:00:00 2001 From: erickson Date: Wed, 27 May 2009 03:45:04 +0000 Subject: [PATCH] add pcrud controller for ccmcmtm and ccmcmt git-svn-id: svn://svn.open-ils.org/ILS/trunk@13245 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- Open-ILS/examples/fm_IDL.xml | 4 +- .../src/support-scripts/test-scripts/print_po.pl | 23 ++++++-- .../conify/global/config/circ_matrix_matchpoint.js | 62 ++++++++++++++++++++-- .../global/config/circ_matrix_matchpoint.tt2 | 2 + .../server/patron/summary_overlay_horiz.xul | 2 +- 5 files changed, 83 insertions(+), 10 deletions(-) diff --git a/Open-ILS/examples/fm_IDL.xml b/Open-ILS/examples/fm_IDL.xml index d2a191c9b..994639854 100644 --- a/Open-ILS/examples/fm_IDL.xml +++ b/Open-ILS/examples/fm_IDL.xml @@ -921,7 +921,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - + @@ -946,7 +946,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - + diff --git a/Open-ILS/src/support-scripts/test-scripts/print_po.pl b/Open-ILS/src/support-scripts/test-scripts/print_po.pl index db8ec6a57..3fd959082 100755 --- a/Open-ILS/src/support-scripts/test-scripts/print_po.pl +++ b/Open-ILS/src/support-scripts/test-scripts/print_po.pl @@ -18,14 +18,27 @@ osrf_connect($config); oils_login($username, $password); my $e = OpenILS::Utils::CStoreEditor->new; +use OpenILS::Utils::Fieldmapper; +$e->xact_begin; +my $bt = $e->retrieve_acq_currency_type('USD'); +$bt->label('vvvv'); +my $resp = $e->update_acq_currency_type($bt); +print Dumper($resp); +$e->xact_rollback; + + my $po = $e->retrieve_acq_purchase_order($po_id) or oils_event_die($e->event); my $orgs = $apputils->get_org_ancestors($po->ordering_agency); -my $defs = $e->search_action_trigger_event_definition({hook => $hook, owner => $orgs}); -$defs = [sort { $a->id cmp $b->id } @$defs ]; # this is a brittle hack, but.. meh -my $def = pop @$defs; -print "using def " . $def->id . " at org_unit " . $def->owner . "\n"; +$orgs = $e->search_actor_org_unit([{id => $orgs}, {flesh => 1, flesh_fields => {aou => ['ou_type']}}]); +$orgs = [ sort { $a->ou_type->depth cmp $b->ou_type->depth } @$orgs ]; +my $def; +for my $org (reverse @$orgs) { + $def = $e->search_action_trigger_event_definition({hook => $hook, owner => $org->id})->[0]; + last if $def; +} die "No event_definition found with hook $hook\n" unless $def; +print "using def " . $def->id . " at org_unit " . $def->owner . "\n"; my $event_id = $apputils->simplereq( 'open-ils.trigger', @@ -47,6 +60,8 @@ my $event = $e->retrieve_action_trigger_event( ] ); +print "$event\n"; + if($event->template_output) { print $event->template_output->data . "\n"; } diff --git a/Open-ILS/web/js/ui/default/conify/global/config/circ_matrix_matchpoint.js b/Open-ILS/web/js/ui/default/conify/global/config/circ_matrix_matchpoint.js index 6e24496dd..1bc6ff864 100644 --- a/Open-ILS/web/js/ui/default/conify/global/config/circ_matrix_matchpoint.js +++ b/Open-ILS/web/js/ui/default/conify/global/config/circ_matrix_matchpoint.js @@ -3,9 +3,13 @@ dojo.require('dijit.form.Button'); dojo.require('openils.widget.AutoGrid'); dojo.require('openils.widget.AutoFieldWidget'); dojo.require('openils.PermaCrud'); +dojo.require('openils.widget.ProgressDialog'); var circModEditor = null; var circModGroupTables = []; +var circModGroupCache = {}; +var circModEntryCache = {}; +var matchPoint; function load(){ cmGrid.loadAll({order_by:{ccmm:'circ_modifier'}}); @@ -21,14 +25,15 @@ function buildEditPaneAdditions(editPane) { var node = circModEditor.cloneNode(true); var tableTmpl = node.removeChild(byName('circ-mod-group-table', node)); circModGroupTables = []; + matchPoint = editPane.fmObject.id(); byName('add-circ-mod-group', node).onclick = function() { addCircModGroup(node, tableTmpl) } - var group = null; if(editPane.mode == 'update') { - //group = + var groups = new openils.PermaCrud().search('ccmcmt', {matchpoint: editPane.fmObject.id()}); + dojo.forEach(groups, function(g) { addCircModGroup(node, tableTmpl, g); } ); } editPane.domNode.appendChild(node); @@ -41,7 +46,14 @@ function addCircModGroup(node, tableTmpl, group) { var circModRowTmpl = byName('circ-mod-entry-tbody', table).removeChild(byName('circ-mod-entry-row', table)); circModGroupTables.push(table); + var entries = []; + if(group) { + entries = new openils.PermaCrud().search('ccmcmtm', {circ_mod_test : group.id()}); + table.setAttribute('group', group.id()); + } + function addMod(code, name) { + name = name || code; // XXX var row = circModRowTmpl.cloneNode(true); byName('circ-mod', row).innerHTML = name; byName('circ-mod', row).setAttribute('code', code); @@ -51,6 +63,8 @@ function addCircModGroup(node, tableTmpl, group) { } } + dojo.forEach(entries, function(e) { addMod(e.circ_mod()); }); + byName('circ-mod-count', table).value = (group) ? group.items_out() : 0; var selector = new openils.widget.AutoFieldWidget({ @@ -69,17 +83,59 @@ function addCircModGroup(node, tableTmpl, group) { } function applyCircModChanges() { + var pcrud = new openils.PermaCrud(); + progressDialog.show(true); for(var idx in circModGroupTables) { var table = circModGroupTables[idx]; + var gp = table.getAttribute('group'); var count = byName('circ-mod-count', table).value; var mods = []; + var entries = []; + dojo.forEach(dojo.query('[name=circ-mod]', table), function(td) { mods.push(td.getAttribute('code')); }); - alert(count + ' : ' + mods); + var group = circModGroupCache[gp]; + + if(!group) { + + group = new fieldmapper.ccmcmt(); + group.isnew(true); + dojo.forEach(mods, function(mod) { + var entry = new fieldmapper.ccmcmtm(); + entry.isnew(true); + entry.circ_mod(mod); + entries.push(entry); + }); + + + } else { + } + + group.items_out(count); + group.matchpoint(matchPoint); + + if(group.isnew()) { + + pcrud.create(group, { + oncomplete : function(r) { + var group = openils.Util.readResponse(r); + dojo.forEach(entries, function(e) { e.circ_mod_test(group.id()) } ); + pcrud.create(entries, { + oncomplete : function() { + progressDialog.hide(); + } + }); + } + }); + + } else { + + } + } } diff --git a/Open-ILS/web/templates/default/conify/global/config/circ_matrix_matchpoint.tt2 b/Open-ILS/web/templates/default/conify/global/config/circ_matrix_matchpoint.tt2 index cd6fece66..86c811e10 100644 --- a/Open-ILS/web/templates/default/conify/global/config/circ_matrix_matchpoint.tt2 +++ b/Open-ILS/web/templates/default/conify/global/config/circ_matrix_matchpoint.tt2 @@ -50,5 +50,7 @@ +