Ejemplo n.º 1
0
    def alter_search(self, search):

        user = Environment.get_user_name()
        from pyasm.security import Login
        user = Login.get_by_login(user)
        search.add_filter("login", user.get_value("login"))

        import datetime
        from dateutil import parser
        filter_data = FilterData.get()
        values = filter_data.get_values_by_index("week", 0)
        date_string = values.get("calendar")
        if date_string:
            date = parser.parse(date_string)
        else:
            date = datetime.datetime.now()

        from tactic.ui.report import MMSUtility
        #start_wday, end_wday = self.get_week_range(date_string)
        start_wday, end_wday = MMSUtility.get_week_range(date)

        one_day = datetime.timedelta(days=1)

        column = "work_performed_date"

        # KEEP it simple for now
        search.add_op("begin")
        search.add_filter(column, start_wday, op='>=')
        search.add_filter(column, end_wday, op='<=')
        search.add_op("and")
        '''
        search.add_op("begin")
        search.add_filter(column, start_wday + one_day, op='>=')
        search.add_filter(column, end_wday - one_day, op='<=')
        search.add_op("and")

        search.add_op("begin")
        search.add_filter(column, start_wday, op='>=')
        search.add_filter(column, start_wday+one_day, op='<=')
        search.add_filter("shift", "pm", op='=')
        search.add_op("and")

        # FIXME: have to add this extra "or" because we don't support multiple
        # begins??
        search.add_op("or")
 
        search.add_op("begin")
        search.add_filter(column, end_wday, op='>=')
        search.add_filter(column, end_wday+one_day, op='<=')
        search.add_filter("shift", "am", op='=')
        search.add_op("and")
 
        search.add_op("or")
        '''

        search.add_order_by(column)
        search.add_order_by("work_start_time")
        search.add_order_by("shift")
Ejemplo n.º 2
0
    def alter_search(self, search):

        user = Environment.get_user_name()
        from pyasm.security import Login
        user = Login.get_by_login(user)
        search.add_filter("login", user.get_value("login"))


        import datetime
        from dateutil import parser
        filter_data = FilterData.get()
        values = filter_data.get_values_by_index("week", 0)
        date_string = values.get("calendar")
        if date_string:
            date = parser.parse(date_string)
        else:
            date = datetime.datetime.now()

        from tactic.ui.report import MMSUtility
        #start_wday, end_wday = self.get_week_range(date_string)
        start_wday, end_wday = MMSUtility.get_week_range(date)

        one_day = datetime.timedelta(days=1)

        column = "work_performed_date"

        # KEEP it simple for now
        search.add_op("begin")
        search.add_filter(column, start_wday, op='>=')
        search.add_filter(column, end_wday, op='<=')
        search.add_op("and")

        '''
        search.add_op("begin")
        search.add_filter(column, start_wday + one_day, op='>=')
        search.add_filter(column, end_wday - one_day, op='<=')
        search.add_op("and")

        search.add_op("begin")
        search.add_filter(column, start_wday, op='>=')
        search.add_filter(column, start_wday+one_day, op='<=')
        search.add_filter("shift", "pm", op='=')
        search.add_op("and")

        # FIXME: have to add this extra "or" because we don't support multiple
        # begins??
        search.add_op("or")
 
        search.add_op("begin")
        search.add_filter(column, end_wday, op='>=')
        search.add_filter(column, end_wday+one_day, op='<=')
        search.add_filter("shift", "am", op='=')
        search.add_op("and")
 
        search.add_op("or")
        '''


        search.add_order_by(column)
        search.add_order_by("work_start_time")
        search.add_order_by("shift")
Ejemplo n.º 3
0
    def get_display(self):


        from tactic.ui.report import MMSUtility
        import datetime
        date = datetime.datetime.now()
        start_wday, end_wday =  MMSUtility.get_week_range(date)

        self.prefix = 'week'
        top = DivWdg()
        top.add_class("spt_table_search")
        self.set_as_panel(top)

        from tactic.ui.container import RoundedCornerDivWdg
        inner = RoundedCornerDivWdg(corner_size=10, hex_color_code='949494')
        inner.set_dimensions(width_str="95%", content_height_str='95%', height_str="100%")
        inner.add_style("margin: 20px")
        top.add(inner)


        hidden = HiddenWdg("prefix", self.prefix)
        top.add(hidden)



        filter_data = FilterData.get()
        values = filter_data.get_values_by_index("week", 0)
        date_string = values.get("calendar")
        if not date_string:
            date_string = WebContainer.get_web().get_form_value("calendar")

        if date_string:
            date = parser.parse(date_string)
        else:
            date = datetime.datetime.now()

        week = 1


        table = Table()
        table.add_style("color: black")
        table.add_style("width: 600px")
        table.add_row()
        inner.add(table)


        #inner.add("Range: %s - %s<br/><br/>" % (start_wday, end_wday))


        table.add_cell("Week Of Date: <br/>")
        calendar = CalendarInputWdg('calendar')

        day_cbk = '''
        var top = spt.get_parent(bvr.src_el, '.spt_table_search');
        var week_el = top.getElement('.spt_calendar_week');
        var input_el = top.getElement('.spt_calendar_input');
        var value = input_el.value;
        var week = spt.date_util.ymd.get_week( value )
        week_el.innerHTML = week + '';
        '''
        calendar.add_day_cbk(day_cbk)


        #calendar.set_option("first_day_of_week", 4)
        calendar.set_value(date.strftime("%Y-%m-%d"))
        # TODO: set default
        table.add_cell( calendar )

        week = int(date.strftime("%W")) + 1

        table.add_cell("Week: ")
        #select = SelectWdg("week")
        #select.add_class("action inputfield")
        #select.set_option("values", range(1,53) )
        #select.set_value(week)
        #select.set_option( "size", "2" )
        text = DivWdg()
        text.add_class("spt_calendar_week")
        text.add_style("width", "25px")
        text.add(week)
        table.add_cell(text)

        table.add_cell( self.get_search_wdg() )

        return top
Ejemplo n.º 4
0
    def get_display(self):

        from tactic.ui.report import MMSUtility
        import datetime
        date = datetime.datetime.now()
        start_wday, end_wday = MMSUtility.get_week_range(date)

        self.prefix = 'week'
        top = DivWdg()
        top.add_class("spt_table_search")
        self.set_as_panel(top)

        from tactic.ui.container import RoundedCornerDivWdg
        inner = RoundedCornerDivWdg(corner_size=10, hex_color_code='949494')
        inner.set_dimensions(width_str="95%",
                             content_height_str='95%',
                             height_str="100%")
        inner.add_style("margin: 20px")
        top.add(inner)

        hidden = HiddenWdg("prefix", self.prefix)
        top.add(hidden)

        filter_data = FilterData.get()
        values = filter_data.get_values_by_index("week", 0)
        date_string = values.get("calendar")
        if not date_string:
            date_string = WebContainer.get_web().get_form_value("calendar")

        if date_string:
            date = parser.parse(date_string)
        else:
            date = datetime.datetime.now()

        week = 1

        table = Table()
        table.add_style("color: black")
        table.add_style("width: 600px")
        table.add_row()
        inner.add(table)

        #inner.add("Range: %s - %s<br/><br/>" % (start_wday, end_wday))

        table.add_cell("Week Of Date: <br/>")
        calendar = CalendarInputWdg('calendar')

        day_cbk = '''
        var top = spt.get_parent(bvr.src_el, '.spt_table_search');
        var week_el = top.getElement('.spt_calendar_week');
        var input_el = top.getElement('.spt_calendar_input');
        var value = input_el.value;
        var week = spt.date_util.ymd.get_week( value )
        week_el.innerHTML = week + '';
        '''
        calendar.add_day_cbk(day_cbk)

        #calendar.set_option("first_day_of_week", 4)
        calendar.set_value(date.strftime("%Y-%m-%d"))
        # TODO: set default
        table.add_cell(calendar)

        week = int(date.strftime("%W")) + 1

        table.add_cell("Week: ")
        #select = SelectWdg("week")
        #select.add_class("action inputfield")
        #select.set_option("values", range(1,53) )
        #select.set_value(week)
        #select.set_option( "size", "2" )
        text = DivWdg()
        text.add_class("spt_calendar_week")
        text.add_style("width", "25px")
        text.add(week)
        table.add_cell(text)

        table.add_cell(self.get_search_wdg())

        return top