print: function() {
if (this.printSettingsFormDijit.isValid()) { //"advanced" form
//get entered values
var form = this.printSettingsFormDijit.get('value');
lang.mixin(form, this.layoutMetadataDijit.get('value')); //cte array of custom text layout elements
lang.mixin(form, this.labelsFormDijit.get('value'));
this.preserve = this.preserveFormDijit.get('value');
lang.mixin(form, this.preserve);
this.layoutForm = this.layoutFormDijit.get('value');
var mapQualityForm = this.mapQualityFormDijit.get('value');
var mapOnlyForm = this.mapOnlyFormDijit.get('value');
lang.mixin(mapOnlyForm, mapQualityForm);
//get custom text elements, loop, query and tag related parcels - as entered by user
var elementsObj = this.customTextElementsDijit.get('value'); //get elements
var cteArray = [], cte = {}, hasDate = false, locale = dojoConfig.locale || 'en';
for (var p in elementsObj) {
//console.log(elementsObj) Subject Parcel: 1231321 <<< returns
//console.log(p) Subject Parcel: <<<returns 32132132
//query for parcel address
var query = new esriQuery();
query.where = "PARCEL = '0136400001'";
query.returnGeometry = false;
query.outFields = ["ADDRESS"];
queryTask.execute(query, resFunction);
function resFunction(results){ //results is FeatureSet.features returns graphic[] array
console.log(results.features);
for (var i = 0; i < results.features.length; i++){ //graphic[] .length full graphics array "features"
var attsObject = results.features.attributes; //graphic[0].attributes individual graphic atts "features[0]", atts=Object (of field/val pairs)
console.log(attsObject);
}
};
if (p === 'Date') { // is date
cte
= new Date().toLocaleString(locale); // create date hasDate = true;
}
else { // not date
cte
= "T1 " + elementsObj
+ " AddressHere"; }
cteArray.push(cte); //add cte to Array
}
//if date never found add it now to array
if(!hasDate) {
cteArray.push({ Date: new Date().toLocaleString(locale) });
}
//setup print template
var templateInfo = this._currentTemplateInfo;
var hasAuthorText = lang.getObject('layoutOptions.hasAuthorText', false, templateInfo);
var hasCopyrightText = lang.getObject('layoutOptions.hasCopyrightText', false, templateInfo);
var hasTitleText = lang.getObject('layoutOptions.hasTitleText', false, templateInfo);
var template = new PrintTemplate();
template.format = form.format; //pdf
template.layout = form.layout; //layout selected
template.preserveScale = (form.preserveScale === 'true' || form.preserveScale === 'force');
template.label = form.title;
template.exportOptions = mapOnlyForm;
template.showLabels = form.showLabels && form.showLabels[0];
template.layoutOptions = {
authorText: hasAuthorText ? form.author : "",
copyrightText: hasCopyrightText ? (form.copyright || this._getMapAttribution()) : "",
legendLayers: this._getLegendLayers(),
titleText: hasTitleText ? form.title : "",
customTextElements: cteArray
};
//execute print task
this.printparams.template = template;
this.printparams.extraParameters = {
printFlag: true
};
var fileHandel = this.printTask.execute(this.printparams);
var result = new printResultDijit({
count: this.count.toString(),
icon: (form.format === "PDF") ? this.pdfIcon : this.imageIcon,
docName: form.title,
title: form.format + ', ' + form.layout,
fileHandle: fileHandel,
nls: this.nls
}).placeAt(this.printResultsNode, 'last');
result.startup();
domStyle.set(this.clearActionBarNode, 'display', 'block');
this.count++;
} // end of advanced form is valid
// if advanced form is not valid
else {
this.printSettingsFormDijit.validate();
}
}, //end of print function