Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

66 lines
1.3 KiB
Python
Raw Normal View History

# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
# License: GNU General Public License v3. See license.txt
2013-05-06 18:37:57 +05:30
2014-02-14 15:47:51 +05:30
import frappe
2014-09-11 16:15:27 +08:00
from frappe import _
2013-05-06 18:37:57 +05:30
def execute(filters=None):
if not filters:
filters = {}
2014-07-02 17:35:00 +05:30
2013-05-06 18:37:57 +05:30
columns = get_columns()
data = get_employees(filters)
2014-07-02 17:35:00 +05:30
2013-05-06 18:37:57 +05:30
return columns, data
2014-07-02 17:35:00 +05:30
2022-03-28 18:52:46 +05:30
2013-05-06 18:37:57 +05:30
def get_columns():
return [
2014-09-11 16:15:27 +08:00
_("Employee") + ":Link/Employee:120",
_("Name") + ":Data:200",
_("Date of Birth") + ":Date:100",
_("Branch") + ":Link/Branch:120",
_("Department") + ":Link/Department:120",
_("Designation") + ":Link/Designation:120",
_("Gender") + "::60",
_("Company") + ":Link/Company:120",
2013-05-06 18:37:57 +05:30
]
2014-07-02 17:35:00 +05:30
2022-03-28 18:52:46 +05:30
2013-05-06 18:37:57 +05:30
def get_employees(filters):
conditions = get_conditions(filters)
return frappe.db.sql(
"""select name, employee_name, date_of_birth,
branch, department, designation,
2013-05-06 18:37:57 +05:30
gender, company from tabEmployee where status = 'Active' %s"""
% conditions,
as_list=1,
)
2022-03-28 18:52:46 +05:30
2014-07-02 17:35:00 +05:30
2013-05-06 18:37:57 +05:30
def get_conditions(filters):
conditions = ""
if filters.get("month"):
2014-07-02 17:35:00 +05:30
month = [
"Jan",
"Feb",
"Mar",
"Apr",
"May",
"Jun",
"Jul",
"Aug",
"Sep",
"Oct",
"Nov",
2013-05-06 18:37:57 +05:30
"Dec",
].index(filters["month"]) + 1
conditions += " and month(date_of_birth) = '%s'" % month
2014-07-02 17:35:00 +05:30
2014-03-03 15:51:13 +05:30
if filters.get("company"):
conditions += " and company = '%s'" % filters["company"].replace("'", "\\'")
2014-07-02 17:35:00 +05:30
return conditions