issue #22461 working for now from invoice->gear>print
authorGreg Pazo <gpazo@xtuple.com>
Tue, 25 Feb 2014 19:24:06 +0000 (14:24 -0500)
committerGreg Pazo <gpazo@xtuple.com>
Tue, 25 Feb 2014 19:24:06 +0000 (14:24 -0500)
node-datasource/main.js
node-datasource/routes/generate_report.js
node-datasource/sample_config.js
package.json

index ee43607..83010b0 100755 (executable)
@@ -609,7 +609,7 @@ io.of('/clientsock').authorization(function (handshakeData, callback) {
           debugging: X.options.datasource.debugging,
           biAvailable: _.isObject(X.options.biServer) && !_.isEmpty(X.options.biServer),
           emailAvailable: _.isString(X.options.datasource.smtpHost) && X.options.datasource.smtpHost !== "",
-          printAvailable: false,
+          printAvailable: _.isString(X.options.datasource.printer) && X.options.datasource.printer !== "",
           version: X.version
         });
       callback(callbackObj);
index b2ae63a..a6da7fe 100644 (file)
@@ -13,6 +13,7 @@ regexp:true, undef:true, strict:true, trailing:true, white:true */
     async = require("async"),
     fs = require("fs"),
     path = require("path"),
+    ipp = require("ipp"),
     Report = require('fluentreports').Report,
     queryForData = require("./report").queryForData;
 
@@ -25,7 +26,7 @@ regexp:true, undef:true, strict:true, trailing:true, white:true */
     @property req.query.action
 
     Sample URL:
-    https://localhost:8543/qatest/generate-report?nameSpace=XM&type=Invoice&id=60000
+    https://localhost:8443/dev/generate-report?nameSpace=XM&type=Invoice&id=60000&action=print
 
    */
   var generateReport = function (req, res) {
@@ -279,8 +280,25 @@ regexp:true, undef:true, strict:true, trailing:true, white:true */
       Silent-print to a printer registered in the node-datasource.
      */
     var responsePrint = function (res, data, done) {
-      // TODO
+
+    var printer = ipp.Printer(X.options.datasource.printer);
+    var msg = {
+      "operation-attributes-tag": {
+      "job-name": "Silent Print",
+      "document-format": "application/pdf"
+    },
+    data: data
+    };
+    printer.execute("Print-Job", msg, function(error, result){
+     if (error) {
+      X.log("Print error", error);
+      res.send({isError: true, message: "Error printing"});
       done();
+      } else {
+      res.send({message: "Print Success"});
+      done();
+      }
+      }); 
     };
 
     // Convenience hash to avoid log if-else
index 57be4ae..5b5a7f5 100644 (file)
@@ -41,6 +41,7 @@ newcap:true, noarg:true, regexp:true, undef:true, strict:true, trailing:true, wh
       smtpPort: 587,
       smtpUser: "",
       smtpPassword: "",
+      printer: "",
 
       // these properties are dynamically registered with the
       // node discovery service
index bc10bcc..d114caa 100644 (file)
@@ -19,6 +19,7 @@
     "ejs": "0.8.x",
     "express": "3.1.x",
     "fluentreports": "git://github.com/xtuple/fluentreports.git",
+    "ipp": "0.0.5",
     "json-patch": "git://github.com/xtuple/JSON-Patch.git",
     "less": "1.5.0",
     "moment": "2.4.x",