</permacrud>
</class>
- <class id="ccmcmt" controller="open-ils.cstore" oils_obj:fieldmapper="config::circ_matrix_circ_mod_test" oils_persist:tablename="config.circ_matrix_circ_mod_test" reporter:label="Circulation Matrix Circulation Modifier Subtest">
+ <class id="ccmcmt" controller="open-ils.cstore open-ils.pcrud" oils_obj:fieldmapper="config::circ_matrix_circ_mod_test" oils_persist:tablename="config.circ_matrix_circ_mod_test" reporter:label="Circulation Matrix Circulation Modifier Subtest">
<fields oils_persist:primary="id" oils_persist:sequence="config.circ_matrix_circ_mod_test_id_seq">
<field reporter:label="Test ID" name="id" reporter:datatype="id"/>
<field reporter:label="Matchpoint ID" name="matchpoint" reporter:datatype="link"/>
</permacrud>
</class>
- <class id="ccmcmtm" controller="open-ils.cstore" oils_obj:fieldmapper="config::circ_matrix_circ_mod_test_map" oils_persist:tablename="config.circ_matrix_circ_mod_test_map" reporter:label="Circulation Matrix Circulation Modifier Subtest Circulation Modifier Set">
+ <class id="ccmcmtm" controller="open-ils.cstore open-ils.pcrud" oils_obj:fieldmapper="config::circ_matrix_circ_mod_test_map" oils_persist:tablename="config.circ_matrix_circ_mod_test_map" reporter:label="Circulation Matrix Circulation Modifier Subtest Circulation Modifier Set">
<fields oils_persist:primary="id" oils_persist:sequence="config.circ_matrix_circ_mod_test_map_id_seq">
<field reporter:label="Entry ID" name="id" reporter:datatype="id"/>
<field reporter:label="Circulation Modifier Subtest ID" name="circ_mod_test" reporter:datatype="link"/>
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',
]
);
+print "$event\n";
+
if($event->template_output) {
print $event->template_output->data . "\n";
}
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'}});
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);
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);
}
}
+ 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({
}
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 {
+
+ }
+
}
}