// Copyright (c) 2012 Web Notes Technologies Pvt Ltd (http://erpnext.com) // // MIT License (MIT) // // Permission is hereby granted, free of charge, to any person obtaining a // copy of this software and associated documentation files (the "Software"), // to deal in the Software without restriction, including without limitation // the rights to use, copy, modify, merge, publish, distribute, sublicense, // and/or sell copies of the Software, and to permit persons to whom the // Software is furnished to do so, subject to the following conditions: // // The above copyright notice and this permission notice shall be included in // all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, // INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A // PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF // CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE // OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // var export_dialog; function export_query(query, callback) { if(!export_dialog) { var d = new Dialog(400, 300, "Export..."); d.make_body([ ['Data', 'Max rows', 'Blank to export all rows'], ['Button', 'Go'], ]); d.widgets['Go'].onclick = function() { export_dialog.hide(); n = export_dialog.widgets['Max rows'].value; if(cint(n)) export_dialog.query += ' LIMIT 0,' + cint(n); callback(export_dialog.query); } d.onshow = function() { this.widgets['Max rows'].value = '500'; } export_dialog = d; } export_dialog.query = query; export_dialog.show(); } function export_csv(q, report_name, sc_id, is_simple, filter_values, colnames) { var args = {} args.cmd = 'webnotes.widgets.query_builder.runquery_csv'; if(is_simple) args.simple_query = q; else args.query = q; args.sc_id = sc_id ? sc_id : ''; args.filter_values = filter_values ? filter_values: ''; if(colnames) args.colnames = colnames.join(','); args.report_name = report_name ? report_name : ''; open_url_post(webnotes.request.url, args); }