initial print templates config UI
authorBill Erickson <berick@esilibrary.com>
Thu, 29 May 2014 17:00:42 +0000 (13:00 -0400)
committerBill Erickson <berick@esilibrary.com>
Thu, 29 May 2014 17:00:42 +0000 (13:00 -0400)
Signed-off-by: Bill Erickson <berick@esilibrary.com>
Open-ILS/src/templates/staff/admin/workstation/t_print_config.tt2 [new file with mode: 0644]
Open-ILS/src/templates/staff/admin/workstation/t_print_templates.tt2 [new file with mode: 0644]
Open-ILS/src/templates/staff/admin/workstation/t_printing.tt2 [deleted file]
Open-ILS/src/templates/staff/admin/workstation/t_splash.tt2
Open-ILS/src/templates/staff/share/print_templates/index.tt2 [new file with mode: 0644]
Open-ILS/src/templates/staff/share/print_templates/t_bills_current.tt2 [new file with mode: 0644]
Open-ILS/web/js/ui/default/staff/admin/workstation/app.js
Open-ILS/web/js/ui/default/staff/services/hatch.js
Open-ILS/web/js/ui/default/staff/services/print_templates.js [new file with mode: 0644]

diff --git a/Open-ILS/src/templates/staff/admin/workstation/t_print_config.tt2 b/Open-ILS/src/templates/staff/admin/workstation/t_print_config.tt2
new file mode 100644 (file)
index 0000000..f90fc01
--- /dev/null
@@ -0,0 +1,176 @@
+<div class="container" id="admin-workstation-printing">
+
+  <style>
+    /* TODO: more context and move me */
+    textarea {
+      height: 400px;
+      width: 100%;
+    }
+    .tab-pane .row {
+      padding-top: 20px;
+    }
+    h2 { margin-bottom: 15px }
+      
+  </style>
+
+  <div class="row"> 
+    <div class="col-md-12">
+      <h2>[% l('Printer Settings for Remote Printing') %]</h2>
+    </div>
+  </div>
+
+  <div class="row"> 
+    <div class="col-md-12">
+      <ul class="nav nav-tabs">
+        <li ng-class="{active : context == 'default'}">
+          <a href='' ng-click="setContext('default')">[% l('Default') %]</a>
+        </li>
+        <li ng-class="{active : context == 'receipt'}">
+          <a href='' ng-click="setContext('receipt')">[% l('Receipt') %]</a>
+        </li>
+        <li ng-class="{active : context == 'label'}">
+          <a href='' ng-click="setContext('label')">[% l('Label') %]</a>
+        </li>
+        <li ng-class="{active : context == 'mail'}">
+          <a href='' ng-click="setContext('mail')">[% l('Mail') %]</a>
+        </li>
+        <li ng-class="{active : context == 'offline'}">
+          <a href='' ng-click="setContext('offline')">[% l('Offline') %]</a>
+        </li>
+        <li ng-class="{active : isTestView}" class="pull-right">
+          <a href='' ng-click="isTestView=true">[% l('Test Printing') %]</a>
+        </li>
+      </ul>
+      <div class="tab-content">
+        <div class="tab-pane active">
+
+          <!-- printer config UI -->
+          <div class="row" ng-hide="isTestView">
+            <div class="col-md-6">
+              <div class="input-group">
+                <div class="input-group-btn" dropdown>
+                  <button type="button" class="btn btn-default dropdown-toggle">
+                    [% l('Select Printer') %]
+                    <span class="caret"></span></button>
+                  <ul class="dropdown-menu">
+                    <li ng-repeat="printer in printers">
+                      <a href='' ng-click="setPrinter(printer.name)">
+                        {{printer.name}}
+                      </a>
+                    </li>
+                  </ul>
+                </div><!-- /btn-group -->
+                <input ng-if="!printers[0]" type="text" 
+                  class="form-control" disabled="disabled"
+                  value="[% l('No Printers Found') %]">
+                <input ng-if="printers[0] && !printConfig[context]" type="text" 
+                  class="form-control" disabled="disabled"
+                  value="[% l('No Printer Selected') %]">
+                <input ng-if="printConfig[context].printer" type="text" 
+                  class="form-control" disabled="disabled"
+                  value="{{printConfig[context].printer}}">
+              </div><!-- /input-group -->
+            </div><!-- col -->
+            <div class="col-md-6">
+              <div class="input-group">
+                <div class="input-group-btn">
+                  <button type="button" 
+                    ng-click="configurePrinter()"
+                    ng-class="{disabled : actionPending || !printers[0]}"
+                    class="btn btn-default btn-success">
+                      [% l('Configure Printer') %]
+                  </button>
+                  <button type="button" 
+                    ng-click="resetConfig()"
+                    ng-class="{disabled : actionPending}"
+                    class="btn btn-default btn-warning">
+                      [% l('Reset Configuration') %]
+                  </button>
+                </div>
+              </div>
+            </div>
+          </div><!-- row -->
+          <div class="row" ng-hide="isTestView"> 
+            <div class="col-md-12">
+              <h2>[% l('Compiled Printer Settings') %]</h2>
+              <pre>{{printerConfString()}}</pre>
+            </div><!-- col -->
+          </div><!-- row -->
+
+          <!-- printer test UI -->
+          <div class="row" ng-show="isTestView"> 
+            <div class="col-md-10">
+              <div class="btn-group">
+                <button type="button" 
+                  class="btn btn-default btn-lg" 
+                  ng-class="{active : contentType=='text/plain'}"
+                  ng-click="setContentType('text/plain')">[% l('Plain Text') %]</button>
+                <button type="button" 
+                  class="btn btn-default btn-lg" 
+                  ng-class="{active : contentType=='text/html'}"
+                  ng-click="setContentType('text/html')">[% l('HTML') %]</button>
+              </div>
+            </div>
+            <div class="col-md-2">
+              <div class="input-group pull-right">
+                <div class="input-group-btn">
+                  <button type="button" 
+                    ng-click="testPrint()"
+                    class="btn btn-default btn-success">
+                      [% l('Print') %]</button>
+                  <button type="button" 
+                    ng-click="testPrint(true)"
+                    class="btn btn-default btn-info">
+                      [% l('Print with Dialog') %]</button>
+                </div>
+              </div>
+            </div>
+          </div>
+
+          <div class="row" ng-show="isTestView"> 
+            <div class="col-md-12">
+              <div ng-show="contentType=='text/plain'"
+ng-init="textPrintContent='
+[% l('Test Print') %]
+
+1234567890
+
+12345678901234567890
+
+123456789012345678901234567890
+
+1234567890123456789012345678901234567890
+
+12345678901234567890123456789012345678901234567890
+
+12345678901234567890123456789012345678901234567890123456790
+
+[% l('Test Print') %]
+'">
+        <pre><textarea>{{textPrintContent}}</textarea></pre>
+      </div>
+
+      <div ng-show="contentType=='text/html'">
+        <textarea ng-model="htmlPrintContent" 
+ng-init="htmlPrintContent='
+<div>
+  <style>p { color: blue }</style>
+  <h2>[% l('Test HTML Print') %]</h2>
+  <br/>
+  <img src=\'http://[% ctx.hostname %]/opac/images/main_logo.png\' width=\'140\' height=\'24\'/>
+  <p>[% l('Welcome, Stranger!') %]</p>
+  <p>{{value1}}</p>
+  <p>{{value2}}</p>
+  <p>{{date_value | date}}</p>
+</div>
+'">
+                </textarea>
+              </div><!-- html content -->
+            </div><!-- col -->
+          </div><!-- row -->
+        </div><!-- tab pane -->
+      </div><!-- tab content -->
+    </div><!-- col -->
+  </div><!-- row -->
+</div><!-- container -->
+
diff --git a/Open-ILS/src/templates/staff/admin/workstation/t_print_templates.tt2 b/Open-ILS/src/templates/staff/admin/workstation/t_print_templates.tt2
new file mode 100644 (file)
index 0000000..cda10b2
--- /dev/null
@@ -0,0 +1,43 @@
+<style>
+  /* TODO: move me */
+  .print-template-text {
+    height: 36em;
+    width: 100%;
+  }
+</style>
+
+<h2>[% l('Print Templates') %]</h2>
+
+<div class="row">
+  <div class="col-md-2">[% l('Template Name') %]</div>
+  <div class="col-md-3">
+    <select class="form-control" ng-model="print.template_name" ng-change="template_changed()">
+      <option value="bills_current">[% l('Bills, Current') %]</option>
+      <option value="bills_historical">[% l('Bills, Historical') %]</option>
+    </select>
+  </div>
+  <div class="col-md-7">
+    <div class="pull-right">
+      <button class="btn btn-default" ng-click="update_preview()">[% l('Preview') %]</button>
+      <button class="btn btn-default" ng-click="save_locally()">[% l('Save Locally') %]</button>
+    </div>
+  </div>
+  <!-- other stuff -->
+</div>
+
+<hr/>
+
+<div class="row">
+  <div class="col-md-5">
+    <h3>[% l('Preview') %]</h3>
+    <div eg-print-template-output content="print.template_content"></div>
+  </div>
+  <div class="col-md-7">
+    <h3>[% l('Template') %]</h3>
+    <div>
+      <textarea ng-model="print.template_content" class="print-template-text">
+      </textarea>
+    </div>
+  </div> <!-- col -->
+</div>
diff --git a/Open-ILS/src/templates/staff/admin/workstation/t_printing.tt2 b/Open-ILS/src/templates/staff/admin/workstation/t_printing.tt2
deleted file mode 100644 (file)
index f90fc01..0000000
+++ /dev/null
@@ -1,176 +0,0 @@
-<div class="container" id="admin-workstation-printing">
-
-  <style>
-    /* TODO: more context and move me */
-    textarea {
-      height: 400px;
-      width: 100%;
-    }
-    .tab-pane .row {
-      padding-top: 20px;
-    }
-    h2 { margin-bottom: 15px }
-      
-  </style>
-
-  <div class="row"> 
-    <div class="col-md-12">
-      <h2>[% l('Printer Settings for Remote Printing') %]</h2>
-    </div>
-  </div>
-
-  <div class="row"> 
-    <div class="col-md-12">
-      <ul class="nav nav-tabs">
-        <li ng-class="{active : context == 'default'}">
-          <a href='' ng-click="setContext('default')">[% l('Default') %]</a>
-        </li>
-        <li ng-class="{active : context == 'receipt'}">
-          <a href='' ng-click="setContext('receipt')">[% l('Receipt') %]</a>
-        </li>
-        <li ng-class="{active : context == 'label'}">
-          <a href='' ng-click="setContext('label')">[% l('Label') %]</a>
-        </li>
-        <li ng-class="{active : context == 'mail'}">
-          <a href='' ng-click="setContext('mail')">[% l('Mail') %]</a>
-        </li>
-        <li ng-class="{active : context == 'offline'}">
-          <a href='' ng-click="setContext('offline')">[% l('Offline') %]</a>
-        </li>
-        <li ng-class="{active : isTestView}" class="pull-right">
-          <a href='' ng-click="isTestView=true">[% l('Test Printing') %]</a>
-        </li>
-      </ul>
-      <div class="tab-content">
-        <div class="tab-pane active">
-
-          <!-- printer config UI -->
-          <div class="row" ng-hide="isTestView">
-            <div class="col-md-6">
-              <div class="input-group">
-                <div class="input-group-btn" dropdown>
-                  <button type="button" class="btn btn-default dropdown-toggle">
-                    [% l('Select Printer') %]
-                    <span class="caret"></span></button>
-                  <ul class="dropdown-menu">
-                    <li ng-repeat="printer in printers">
-                      <a href='' ng-click="setPrinter(printer.name)">
-                        {{printer.name}}
-                      </a>
-                    </li>
-                  </ul>
-                </div><!-- /btn-group -->
-                <input ng-if="!printers[0]" type="text" 
-                  class="form-control" disabled="disabled"
-                  value="[% l('No Printers Found') %]">
-                <input ng-if="printers[0] && !printConfig[context]" type="text" 
-                  class="form-control" disabled="disabled"
-                  value="[% l('No Printer Selected') %]">
-                <input ng-if="printConfig[context].printer" type="text" 
-                  class="form-control" disabled="disabled"
-                  value="{{printConfig[context].printer}}">
-              </div><!-- /input-group -->
-            </div><!-- col -->
-            <div class="col-md-6">
-              <div class="input-group">
-                <div class="input-group-btn">
-                  <button type="button" 
-                    ng-click="configurePrinter()"
-                    ng-class="{disabled : actionPending || !printers[0]}"
-                    class="btn btn-default btn-success">
-                      [% l('Configure Printer') %]
-                  </button>
-                  <button type="button" 
-                    ng-click="resetConfig()"
-                    ng-class="{disabled : actionPending}"
-                    class="btn btn-default btn-warning">
-                      [% l('Reset Configuration') %]
-                  </button>
-                </div>
-              </div>
-            </div>
-          </div><!-- row -->
-          <div class="row" ng-hide="isTestView"> 
-            <div class="col-md-12">
-              <h2>[% l('Compiled Printer Settings') %]</h2>
-              <pre>{{printerConfString()}}</pre>
-            </div><!-- col -->
-          </div><!-- row -->
-
-          <!-- printer test UI -->
-          <div class="row" ng-show="isTestView"> 
-            <div class="col-md-10">
-              <div class="btn-group">
-                <button type="button" 
-                  class="btn btn-default btn-lg" 
-                  ng-class="{active : contentType=='text/plain'}"
-                  ng-click="setContentType('text/plain')">[% l('Plain Text') %]</button>
-                <button type="button" 
-                  class="btn btn-default btn-lg" 
-                  ng-class="{active : contentType=='text/html'}"
-                  ng-click="setContentType('text/html')">[% l('HTML') %]</button>
-              </div>
-            </div>
-            <div class="col-md-2">
-              <div class="input-group pull-right">
-                <div class="input-group-btn">
-                  <button type="button" 
-                    ng-click="testPrint()"
-                    class="btn btn-default btn-success">
-                      [% l('Print') %]</button>
-                  <button type="button" 
-                    ng-click="testPrint(true)"
-                    class="btn btn-default btn-info">
-                      [% l('Print with Dialog') %]</button>
-                </div>
-              </div>
-            </div>
-          </div>
-
-          <div class="row" ng-show="isTestView"> 
-            <div class="col-md-12">
-              <div ng-show="contentType=='text/plain'"
-ng-init="textPrintContent='
-[% l('Test Print') %]
-
-1234567890
-
-12345678901234567890
-
-123456789012345678901234567890
-
-1234567890123456789012345678901234567890
-
-12345678901234567890123456789012345678901234567890
-
-12345678901234567890123456789012345678901234567890123456790
-
-[% l('Test Print') %]
-'">
-        <pre><textarea>{{textPrintContent}}</textarea></pre>
-      </div>
-
-      <div ng-show="contentType=='text/html'">
-        <textarea ng-model="htmlPrintContent" 
-ng-init="htmlPrintContent='
-<div>
-  <style>p { color: blue }</style>
-  <h2>[% l('Test HTML Print') %]</h2>
-  <br/>
-  <img src=\'http://[% ctx.hostname %]/opac/images/main_logo.png\' width=\'140\' height=\'24\'/>
-  <p>[% l('Welcome, Stranger!') %]</p>
-  <p>{{value1}}</p>
-  <p>{{value2}}</p>
-  <p>{{date_value | date}}</p>
-</div>
-'">
-                </textarea>
-              </div><!-- html content -->
-            </div><!-- col -->
-          </div><!-- row -->
-        </div><!-- tab pane -->
-      </div><!-- tab content -->
-    </div><!-- col -->
-  </div><!-- row -->
-</div><!-- container -->
-
index 40287c5..3a14bbe 100644 (file)
@@ -93,7 +93,7 @@
   <div class="row new-entry">
     <div class="col-md-6">
       <span class="glyphicon glyphicon-print"></span>
-      <a target="_self" href="./admin/workstation/printing">
+      <a target="_self" href="./admin/workstation/print/config">
         [% l('Printer Settings') %]
       </a>
     </div>
 
   <div class="row new-entry">
     <div class="col-md-6">
+      <span class="glyphicon glyphicon-film"></span>
+      <a target="_self" href="./admin/workstation/print/templates">
+        [% l('Print Templates') %]
+      </a>
+    </div>
+  </div>
+
+  <div class="row new-entry">
+    <div class="col-md-6">
       <span class="glyphicon glyphicon-info-sign"></span>
       <a target="_self" href="./admin/workstation/stored_prefs">
         [% l('Stored Preferences') %]
diff --git a/Open-ILS/src/templates/staff/share/print_templates/index.tt2 b/Open-ILS/src/templates/staff/share/print_templates/index.tt2
new file mode 100644 (file)
index 0000000..0bcedf0
--- /dev/null
@@ -0,0 +1,2 @@
+[% USE CGI %]
+[% l('Print Template Not Found: [_1]', CGI.url("-path",1,"-relative",1)) %]
diff --git a/Open-ILS/src/templates/staff/share/print_templates/t_bills_current.tt2 b/Open-ILS/src/templates/staff/share/print_templates/t_bills_current.tt2
new file mode 100644 (file)
index 0000000..71e6bf2
--- /dev/null
@@ -0,0 +1,52 @@
+Welcome to {{current_location.name}}!<br/>
+You have the following bills:
+<hr/>
+
+<b ng-repeat="xact in transactions">{{xact.id}}</b>
+<dl>
+
+  <div ng-repeat="xact in transactions">
+    <dt><b>Bill #{{xact.id}}</b></dt>
+    <dd>
+    <table> 
+      <tr valign="top">
+        <td>[% l('Date:') %]</td>
+        <td>{{xact.xact_start | date:'short'}}</td>
+      </tr> 
+      <tr valign="top">
+        <td>[% l('Type') %]:</td>
+        <td>{{xact.summary.xact_type}}</td>
+      </tr> 
+      <tr valign="top">
+        <td>[% l('Last Billing') %]:</td>
+        <td>{{xact.summary.last_billing_type}}<br/>
+            {{xact.summary.last_billing_note}}
+        </td>
+      </tr> 
+      <tr valign="top">
+        <td>[% l('Total Billed') %]:</td>
+        <td>{{xact.summary.total_owed | currency}}</td>
+      </tr> 
+      <tr valign="top">
+        <td>[% l('Last Payment') %]:</td>
+        <td>{{xact.summary.last_payment_type}}<br/>
+            {{xact.summary.last_payment_note}}
+        </td>
+      </tr> 
+      <tr valign="top">
+        <td>[% l('Total Paid') %]:</td>
+        <td>{{xact.summary.total_paid | currency}}</td>
+      </tr> 
+      <tr valign="top">
+        <td><b>[% l('Balance') %]:</b></td>
+        <td><b>{{xact.summary.balance_owed | currency}}</b></td>
+      </tr> 
+    </table>
+    </dd>
+    <br/>
+  </div><!-- ng-repeat -->
+</dl>
+<hr/>
+{{current_location.shortname}} {{today | date:'short'}}
+<br/><br/>
+
index b0ec9aa..9e3a104 100644 (file)
@@ -14,9 +14,15 @@ angular.module('egWorkstationAdmin',
     $compileProvider.aHrefSanitizationWhitelist(/^\s*(https?|blob):/); 
     var resolver = {delay : function(egStartup) {return egStartup.go()}};
 
-    $routeProvider.when('/admin/workstation/printing', {
-        templateUrl: './admin/workstation/t_printing',
-        controller: 'PrintingCtrl',
+    $routeProvider.when('/admin/workstation/print/config', {
+        templateUrl: './admin/workstation/t_print_config',
+        controller: 'PrintConfigCtrl',
+        resolve : resolver
+    });
+
+    $routeProvider.when('/admin/workstation/print/templates', {
+        templateUrl: './admin/workstation/t_print_templates',
+        controller: 'PrintTemplatesCtrl',
         resolve : resolver
     });
 
@@ -146,10 +152,10 @@ function($scope , $window , $location , egCore) {
     }
 }])
 
-.controller('PrintingCtrl',
+.controller('PrintConfigCtrl',
        ['$scope','egCore',
 function($scope , egCore) {
-    console.log('PrintingCtrl');
+    console.log('PrintConfigCtrl');
 
     $scope.actionPending = false;
     $scope.isTestView = false;
@@ -286,6 +292,90 @@ function($scope , egCore) {
 
 }])
 
+.controller('PrintTemplatesCtrl',
+       ['$scope','$q','egCore',
+function($scope , $q , egCore) {
+
+    $scope.print = {
+        template_name : 'bills_current',
+        template_output : ''
+    };
+
+    // print preview scope data
+    // TODO: consider moving the template-specific bits directly
+    // into the templates or storing template- specific script files
+    // alongside the templates
+    $scope.preview_scope = {
+        current_location : egCore.idl.toHash(
+            egCore.org.get(egCore.auth.user().ws_ou())),
+        today : new Date(),
+
+        //bills
+        transactions : [
+            {
+                id : 1,
+                xact_start : new Date().toISOString(),
+                summary : {
+                    xact_type : 'circulation',
+                    last_billing_type : 'Overdue materials',
+                    total_owed : 1.50,
+                    last_payment_note : 'Test Note 1',
+                    total_paid : 0.50,
+                    balance_owed : 1.00
+                }
+            }, {
+                id : 2,
+                xact_start : new Date().toISOString(),
+                summary : {
+                    xact_type : 'circulation',
+                    last_billing_type : 'Overdue materials',
+                    total_owed : 2.50,
+                    last_payment_note : 'Test Note 2',
+                    total_paid : 0.50,
+                    balance_owed : 2.00
+                }
+            }
+        ]
+    }
+
+    $scope.template_changed = function() {
+        egCore.hatch.getPrintTemplate($scope.print.template_name)
+        .then(function(html) { 
+            $scope.print.template_content = html;
+        });
+    }
+
+    $scope.save_locally = function() {
+        egCore.hatch.storePrintTemplate(
+            $scope.print.template_name,
+            $scope.print.template_content
+        );
+    }
+
+    $scope.template_changed(); // load the default
+}])
+
+// TODO: move compilation into egHatch!
+.directive('egPrintTemplateOutput', ['$compile',function($compile) {
+    return function(scope, element, attrs) {
+        scope.$watch(
+            function(scope) {
+                return scope.$eval(attrs.content);
+            },
+            function(value) {
+                var result = element.html(value);
+                var print_scope = scope.$new(true);
+                // copy only the print preview scope data 
+                // into the isolate scope for compilation
+                angular.forEach(scope.preview_scope, function(val, key) {
+                    print_scope[key] = val;
+                })
+                $compile(element.contents())(print_scope);
+            }
+        );
+    };
+}])
+
 .controller('StoredPrefsCtrl',
        ['$scope','$q','egCore','egConfirmDialog',
 function($scope , $q , egCore , egConfirmDialog) {
index 547cdf9..edd6907 100644 (file)
@@ -28,8 +28,8 @@
 angular.module('egCoreMod')
 
 .factory('egHatch',
-           ['$q','$window','$timeout','$interpolate','$rootScope',
-    function($q , $window , $timeout , $interpolate , $rootScope) {
+           ['$q','$window','$timeout','$interpolate','$rootScope','$http',
+    function($q , $window , $timeout , $interpolate , $rootScope , $http) {
 
     var service = {};
     service.msgId = 0;
@@ -40,6 +40,8 @@ angular.module('egCoreMod')
     service.defaultHatchURL = 'wss://localhost:8443/hatch'; 
     service.hatchRequired = false;
 
+    service.printTemplateBase = 'share/print_templates/t_';
+
     // write a message to the Hatch websocket
     service.sendToHatch = function(msg) {
         var msg2 = {};
@@ -259,14 +261,14 @@ angular.module('egCoreMod')
         if (service.printConfig) 
             return $q.when(service.printConfig);
 
-        return service.getRemoteItem('eg.printing.config')
+        return service.getRemoteItem('eg.print.config')
         .then(function(conf) { 
             return (service.printConfig = conf || {}) 
         });
     }
     service.setPrintConfig = function(conf) {
         service.printConfig = conf;
-        return service.setRemoteItem('eg.printing.config', conf);
+        return service.setRemoteItem('eg.print.config', conf);
     }
     // -----------
 
@@ -302,7 +304,7 @@ angular.module('egCoreMod')
 
         // store the newly linked settings
         .then(function() {
-            service.setItem('eg.printing.config', service.printConfig);
+            service.setItem('eg.print.config', service.printConfig);
         })
 
         // return the final settings to the caller
@@ -457,6 +459,39 @@ angular.module('egCoreMod')
         return keys;
     }
 
+    // loads an HTML print template by name from the server
+    // If no template is available in local/hatch storage, 
+    // fetch the template as an HTML file from the server.
+    service.getPrintTemplate = function(name) {
+        var deferred = $q.defer();
+
+        service.getItem('eg.print.template.' + name)
+        .then(function(html) {
+
+            if (html) {
+                // we have a locally stored template
+                deferred.resolve(html);
+                return;
+            }
+
+            var path = service.printTemplateBase + name;
+            console.debug('fetching template ' + path);
+
+            $http.get(path)
+            .success(function(data) { deferred.resolve(data) })
+            .error(function() {
+                console.error('unable to locate print template: ' + name);
+                deferred.reject();
+            });
+        });
+
+        return deferred.promise;
+    }
+
+    service.storePrintTemplate = function(name, html) {
+        return service.setItem('eg.print.template.' + name, html);
+    }
+
     return service;
 }])
 
diff --git a/Open-ILS/web/js/ui/default/staff/services/print_templates.js b/Open-ILS/web/js/ui/default/staff/services/print_templates.js
new file mode 100644 (file)
index 0000000..e69de29