You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

преди 11 години
преди 13 години
преди 13 години
преди 13 години
преди 12 години
преди 12 години
преди 12 години
преди 12 години
12345678910111213141516171819202122232425262728293031323334
  1. # Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
  2. # MIT License. See license.txt
  3. # Event
  4. # -------------
  5. from __future__ import unicode_literals
  6. import webnotes
  7. @webnotes.whitelist()
  8. def get_cal_events(m_st, m_end):
  9. import webnotes.model.doc
  10. # load owned events
  11. res1 = webnotes.conn.sql("select name from `tabEvent` WHERE ifnull(event_date,'2000-01-01') between '%s' and '%s' and owner = '%s' and event_type != 'Public' and event_type != 'Cancel'" % (m_st, m_end, webnotes.user.name))
  12. # load individual events
  13. res2 = webnotes.conn.sql("select t1.name from `tabEvent` t1, `tabEvent User` t2 where ifnull(t1.event_date,'2000-01-01') between '%s' and '%s' and t2.person = '%s' and t1.name = t2.parent and t1.event_type != 'Cancel'" % (m_st, m_end, webnotes.user.name))
  14. # load role events
  15. roles = webnotes.user.get_roles()
  16. myroles = ['t2.role = "%s"' % r for r in roles]
  17. myroles = '(' + (' OR '.join(myroles)) + ')'
  18. res3 = webnotes.conn.sql("select t1.name from `tabEvent` t1, `tabEvent Role` t2 where ifnull(t1.event_date,'2000-01-01') between '%s' and '%s' and t1.name = t2.parent and t1.event_type != 'Cancel' and %s" % (m_st, m_end, myroles))
  19. # load public events
  20. res4 = webnotes.conn.sql("select name from `tabEvent` where ifnull(event_date,'2000-01-01') between '%s' and '%s' and event_type='Public'" % (m_st, m_end))
  21. doclist, rl = [], []
  22. for r in res1 + res2 + res3 + res4:
  23. if not r in rl:
  24. doclist += webnotes.model.doc.get('Event', r[0])
  25. rl.append(r)
  26. return doclist