blob: b4ce38af17b90209ab3fc9c1085985f61f34f906 [file] [log] [blame]
Rushabh Mehta3966f1d2012-02-23 12:35:32 +05301# ERPNext - web based ERP (http://erpnext.com)
2# Copyright (C) 2012 Web Notes Technologies Pvt Ltd
3#
4# This program is free software: you can redistribute it and/or modify
5# it under the terms of the GNU General Public License as published by
6# the Free Software Foundation, either version 3 of the License, or
7# (at your option) any later version.
8#
9# This program is distributed in the hope that it will be useful,
10# but WITHOUT ANY WARRANTY; without even the implied warranty of
11# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12# GNU General Public License for more details.
13#
14# You should have received a copy of the GNU General Public License
15# along with this program. If not, see <http://www.gnu.org/licenses/>.
16
Anand Doshi486f9df2012-07-19 13:40:31 +053017from __future__ import unicode_literals
Rushabh Mehtad0251332012-02-21 17:26:50 +053018import webnotes
Anand Doshicdba51c2012-10-04 18:11:29 +053019from webnotes.utils import cint
Rushabh Mehtad0251332012-02-21 17:26:50 +053020
21@webnotes.whitelist()
Rushabh Mehta16aea342012-05-29 10:53:37 +053022def get_sc_list(arg=None):
Anand Doshicdba51c2012-10-04 18:11:29 +053023 """return list of reports for the given module module"""
24 limit_start = webnotes.form_dict.get("limit_start")
25 limit_page_length = webnotes.form_dict.get("limit_page_length")
26 module = webnotes.form_dict.get("module")
27
28 webnotes.response['values'] = webnotes.conn.sql("""
29 select distinct criteria_name, doc_type, parent_doc_type
Rushabh Mehtad0251332012-02-21 17:26:50 +053030 from `tabSearch Criteria`
Anand Doshicdba51c2012-10-04 18:11:29 +053031 where module=%s
32 and docstatus in (0, NULL)
33 and ifnull(disabled, 0) = 0
34 order by criteria_name
35 limit %s, %s""" % \
36 ("%s", cint(limit_start), cint(limit_page_length)), (module,), as_dict=True)
Rushabh Mehta16aea342012-05-29 10:53:37 +053037
38@webnotes.whitelist()
39def get_report_list():
40 """return list on new style reports for modules"""
Anand Doshicdba51c2012-10-04 18:11:29 +053041 limit_start = webnotes.form_dict.get("limit_start")
42 limit_page_length = webnotes.form_dict.get("limit_page_length")
43 module = webnotes.form_dict.get("module")
44
45 webnotes.response['values'] = webnotes.conn.sql("""
46 select distinct tabReport.name, tabReport.ref_doctype,
47 if(ifnull(tabReport.query, '')!='', 1, 0) as is_query_report
Rushabh Mehta16aea342012-05-29 10:53:37 +053048 from `tabReport`, `tabDocType`
Anand Doshicdba51c2012-10-04 18:11:29 +053049 where tabDocType.module=%s
50 and tabDocType.name = tabReport.ref_doctype
51 and tabReport.docstatus in (0, NULL)
52 order by tabReport.name
53 limit %s, %s""" % \
54 ("%s", cint(limit_start), cint(limit_page_length)), (module,), as_dict=True)