Skip to content
Snippets Groups Projects
Commit 3ea413bd authored by wactbprot's avatar wactbprot
Browse files

neues KD mit _show/new

parent cf0adf1b
No related branches found
No related tags found
No related merge requests found
javascript
\ No newline at end of file
...@@ -92,8 +92,8 @@ var pad0 = function(n){ ...@@ -92,8 +92,8 @@ var pad0 = function(n){
}; };
exports.pad0 = pad0; exports.pad0 = pad0;
var vlDateString = function(){ var vlDateString = function(d){
var dt = new Date(), var dt = d || new Date(),
Y = dt.getFullYear(), Y = dt.getFullYear(),
M = pad0(dt.getMonth()+1), M = pad0(dt.getMonth()+1),
D = pad0(dt.getDate()), D = pad0(dt.getDate()),
......
function (doc, req) { function (doc, req) {
// example url:
// example url: // http://localhost:5984/vaclab_db/_design/e-share/_show/dup/73eda2bf9694bb4f78edaecba90cdc49
// http://localhost:5984/vaclab_db/_design/e-share/_show/dup/73eda2bf9694bb4f78edaecba90cdc49 //
var
dc = doc.Calibration,
ds = dc.Sign,
ss = ds.split(/[-_]+/),
nd = new Date(),
s0 = ss[0], // main sign
s1 = ss[1], // sub sign
ns1 = ""; // new sub sign
var share = require("lib/share"),
dc = doc.Calibration;
if(doc &&
dc &&
typeof dc == "object"){
var
ds = dc.Sign,
dcm = dc.Measurement,
dcp = dc.Presettings;
if(dcm &&
typeof dcm == "object" &&
dcp &&
typeof dcp == "object"){
var
dcmco = dcm.CalibrationObject,
dcpt = dcp.Todo,
dcpc = dcp.Customer;
if(dcmco &&
typeof dcmco == "object"){
var
dcmco0 = dcmco[0],
ss = ds.split(/[-_]+/),
nd = new Date(),
s0 = ss[0], // main sign
s1 = ss[1], // sub sign
ns1 = ""; // new sub sign
var tn1 = "" + (parseInt("1" + s1, 10) + 1);
tn1 = tn1.substr(1,tn1.length-1);
if(doc && // code is data!
dc &&
typeof dc == "object" && var dupd = {
ds){ Calibration:{
var tn1 = "" + (parseInt("1" + s1, 10) + 1); Sign: s0 + "_" + tn1,
tn1 = tn1.substr(1,tn1.length-1); Type: req.query.type || dc.Type,
var dupd = { Year: "" + nd.getFullYear(),
Calibration:{ Standard: req.query.standard || dc.Standard,
Sign: s0 + "_" + tn1, Presettings:{
Type: req.query.type || dc.Type, Date: [
Year: "" + nd.getFullYear(), {Value: share.vlDateString(nd),
Standard: req.query.standard || dc.Standard, Type: "duplicated"
Presettings:{ }
]
},
Measurement:{
CalibrationObject:[dcmco0]
}
}
};
if(dcpt){
dupd.Calibration.Presettings.ToDo = dcpt;
} }
} if(dcpc){
}; dupd.Calibration.Presettings.Customer = dcpc;
}
}
}else{
var dupd = {error: "Doc contains no measurement block"};
}
}else{ }else{
var dupd = {error: "Doc seems to be no calibration"}; var dupd = {error: "Doc seems to be no calibration"};
} }
return toJSON(dupd); return {
"headers" : {"Content-Type" : "application/json"},
"body" : toJSON(dupd)
};
}; };
function (doc, req) {
// example url:
// http://localhost:5984/vaclab_db/_design/e-share/_show/new
//
var share = require("lib/share"),
nd = new Date(),
ndoc = {
Calibration:{
Sign: req.query.sign || "99999_0001",
Type: req.query.type || "NN",
Year: "" + nd.getFullYear(),
Standard: req.query.standard || "",
Presettings:{
Maintainer:req.query.maintainer || "",
Date: [
{Value: share.vlDateString(nd),
Type: "generated"
}
]
},
Measurement:{
CalibrationObject:[{
Type: "",
Sign: "",
Name: ""
}]
}
}
};
return {
"headers" : {"Content-Type" : "application/json"},
"body" : toJSON(ndoc)
};
};
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment