コード例 #1
0
ファイル: timecard_wdg.py プロジェクト: 0-T-0/TACTIC
    def add_unregistered_hours(my, main_div):
        '''draw the unregistered hours'''
        row_div = FloatDivWdg()
        row_div.add_style("margin-bottom: 4px")
        main_div.add(row_div)
        process_div =  _get_div(my.process_len)
        process_div.add("unregistered hours")
        #process_div.add_style('color: #999')
        row_div.add(process_div)
        
        for i in TimecardWdg.WEEK_CALENDAR:
            unreg_hours = 0.0
            div = _get_div(50)
            row_div.add(div)
            div.add_class('center_content')
            span = SpanWdg()
            div.add(span)
            span.add_style('padding: 0 6px 0 6px')

            max_hours = Project.get_reg_hours()
            if not max_hours:
                max_hours = TimecardWdg.MAX_REG_HOURS
            max_hours = float(max_hours)

            # get all the timecards for the week and hours 
            reg_hours = Timecard.get_registered_hours(None, my.week, i, my.year)
                    
            unreg_hours = max_hours-reg_hours
            if unreg_hours <= 0:
                my.overtime_dict[i] = abs(unreg_hours)
                unreg_hours = IconWdg(icon=IconWdg.GOOD)
            else:
                my.overtime_dict[i] = ''
                unreg_hours = str(unreg_hours)
            span.add(unreg_hours)
コード例 #2
0
    def add_unregistered_hours(my, main_div):
        '''draw the unregistered hours'''
        row_div = FloatDivWdg()
        row_div.add_style("margin-bottom: 4px")
        main_div.add(row_div)
        process_div =  _get_div(my.process_len)
        process_div.add("unregistered hours")
        #process_div.add_style('color: #999')
        row_div.add(process_div)
        
        for i in TimecardWdg.WEEK_CALENDAR:
            unreg_hours = 0.0
            div = _get_div(50)
            row_div.add(div)
            div.add_class('center_content')
            span = SpanWdg()
            div.add(span)
            span.add_style('padding: 0 6px 0 6px')

            max_hours = Project.get_reg_hours()
            if not max_hours:
                max_hours = TimecardWdg.MAX_REG_HOURS
            max_hours = float(max_hours)

            # get all the timecards for the week and hours 
            reg_hours = Timecard.get_registered_hours(None, my.week, i, my.year)
                    
            unreg_hours = max_hours-reg_hours
            if unreg_hours <= 0:
                my.overtime_dict[i] = abs(unreg_hours)
                unreg_hours = IconWdg(icon=IconWdg.GOOD)
            else:
                my.overtime_dict[i] = ''
                unreg_hours = str(unreg_hours)
            span.add(unreg_hours)
コード例 #3
0
ファイル: timecard_wdg.py プロジェクト: 0-T-0/TACTIC
    def execute(my):
        cards = Timecard.get(None, week=my.week, year=my.year, \
            desc=my.desc, project=my.project_code)
        if not cards:
            # this has been set in the EditCmd
            timecard = my.sobject
            timecard.set_value('login', Environment.get_user_name())
            timecard.set_value('project_code', my.project_code)
            timecard.set_value("year", my.year)
            timecard.set_value("week", my.week)
            timecard.set_value("description", my.desc)
            timecard.commit()

        else:
            raise UserException('This time card already exists. '\
                    'Please edit the existing one instead.')
コード例 #4
0
    def execute(my):
        cards = Timecard.get(None, week=my.week, year=my.year, \
            desc=my.desc, project=my.project_code)
        if not cards:
            # this has been set in the EditCmd
            timecard = my.sobject
            timecard.set_value('login', Environment.get_user_name())
            timecard.set_value('project_code', my.project_code)
            timecard.set_value("year", my.year)
            timecard.set_value("week", my.week)
            timecard.set_value("description", my.desc)
            timecard.commit()

        else:
            raise UserException('This time card already exists. '\
                    'Please edit the existing one instead.')
コード例 #5
0
ファイル: timecard_wdg.py プロジェクト: 0-T-0/TACTIC
 def execute(my):
     if my.search_key: 
         search_type, search_id = my.search_key.split('|')
     
     timecard = Timecard.get(my.search_key, my.week, my.year)
     if not timecard:
         timecard = my._create_timecard(search_type, search_id)
     else:
         timecard = timecard[0]
    
     timecard.set_value(my.attr_name, my.value)
     # set week
     timecard.set_value('week', my.week)
     # set year
     timecard.set_value('year', my.year)
     
     timecard.commit()
         
     sobj = Search.get_by_search_key(my.search_key)
         
     my.description = "Set timecard %shr for [%s]"%(my.value, sobj.get_code())
コード例 #6
0
 def execute(my):
     if my.search_key: 
         search_type, search_id = my.search_key.split('|')
     
     timecard = Timecard.get(my.search_key, my.week, my.year)
     if not timecard:
         timecard = my._create_timecard(search_type, search_id)
     else:
         timecard = timecard[0]
    
     timecard.set_value(my.attr_name, my.value)
     # set week
     timecard.set_value('week', my.week)
     # set year
     timecard.set_value('year', my.year)
     
     timecard.commit()
         
     sobj = Search.get_by_search_key(my.search_key)
         
     my.description = "Set timecard %shr for [%s]"%(my.value, sobj.get_code())
コード例 #7
0
ファイル: timecard_wdg.py プロジェクト: 0-T-0/TACTIC
    def add_control(my, main_div):
        ''' add the control for adjusting time card hours'''
        weekday_list = Calendar.get_monthday_time(my.year, my.week)
        month_list = []
        for item in weekday_list:  
             month, day, time = item
             if month not in month_list:
                 month_list.append(month)
       
        today = Date()
        current_week = int(today.get_week())
        current_year = int(today.get_year())

        today_div = _get_div(TimecardWdg.PROCESS_WIDTH)
        today_div.add(my._get_this_week_link(current_week, current_year))
        main_div.add(today_div)
        title_div = _get_div(270)
        #title_div.add_style('color: #6869a3')
        title_div.add_class('right_content')
        
        main_div.add(title_div)
        
        # show the year and month
        month = ' / '.join(month_list)
        year = my.year
        title_div.add(SpanWdg(month, css='small'))
        title_div.add('&middot;')
        title_div.add(SpanWdg(year, css='small'))
        
        if not my.task or not my.week:
            main_div.add('Invalid task info or undetermined week found!')
            return main_div

        main_div.add(HtmlElement.br(2))

        process_div = _get_div(my.process_len)
        process_div.add('&nbsp;')
        main_div.add(process_div)
        
        for idx, weekday in enumerate(TimecardWdg.WEEK_CALENDAR):
            div = _get_div(50)
            div.add(weekday.capitalize()[0:1])
            month, day, time = weekday_list[idx]
            div.add(SpanWdg(day, css='med'))
            main_div.add(div)
            
        main_div.add(HtmlElement.br())
        process_div_container = _get_div(my.process_len)
        
        process = 'general'
        if isinstance(my.task, Task):
            process = my.task.get_process()
        process_div = FloatDivWdg(process, css='timecard_process')
        process_div.add_style("padding-right: 6px")
        process_div_container.add(process_div)
       
        main_div.add(process_div_container)
       
        
        # register cmd 
        my.cmd.register_cmd("TimecardHourCmd")

        # query the db values
        timecard = Timecard.get(my.task.get_search_key(), my.week, my.year,\
            login=Environment.get_user_name())
        if timecard:
            timecard = timecard[0]
        
       
        # add the progress icon
        progress = my.cmd.generate_div()
        progress.add("&nbsp;")
        progress.add_style('width: 20px')
        progress.add_style('float: left')
       
        progress.set_post_ajax_script(my.get_refresh_script(show_progress=False))
        process_div_container.add(progress)

        today_time = Date().get_struct_time()
        for idx, weekday in enumerate(TimecardWdg.WEEK_CALENDAR):
            div = _get_div(50)
            month, day, time = weekday_list[idx]
            
            select = ActionSelectWdg(weekday)
            select.add_empty_option()

            # disable setting time cards in the future
            if time > today_time:
                select.set_attr('disabled','')
            else:    
                # using the MAX_HOUR
                hours = ['%0.1f'%x for x in xrange(0, TimecardWdg.MAX_HOUR  + 1)]
                select.set_option('values', hours)
                if timecard:
                    select.set_value( timecard.get_value(weekday))
                my.cmd.set_option('search_key', my.task.get_search_key())
                my.cmd.set_option('attr_name',  weekday)
                my.cmd.set_option('project_code', Project.get_project_code())
                
                select.add_event("onchange", my.cmd.get_on_script() )
            div.add(select)
            main_div.add(div)
コード例 #8
0
    def add_control(my, main_div):
        ''' add the control for adjusting time card hours'''
        weekday_list = Calendar.get_monthday_time(my.year, my.week)
        month_list = []
        for item in weekday_list:
            month, day, time = item
            if month not in month_list:
                month_list.append(month)

        today = Date()
        current_week = int(today.get_week())
        current_year = int(today.get_year())

        today_div = _get_div(TimecardWdg.PROCESS_WIDTH)
        today_div.add(my._get_this_week_link(current_week, current_year))
        main_div.add(today_div)
        title_div = _get_div(270)
        #title_div.add_style('color: #6869a3')
        title_div.add_class('right_content')

        main_div.add(title_div)

        # show the year and month
        month = ' / '.join(month_list)
        year = my.year
        title_div.add(SpanWdg(month, css='small'))
        title_div.add('&middot;')
        title_div.add(SpanWdg(year, css='small'))

        if not my.task or not my.week:
            main_div.add('Invalid task info or undetermined week found!')
            return main_div

        main_div.add(HtmlElement.br(2))

        process_div = _get_div(my.process_len)
        process_div.add('&nbsp;')
        main_div.add(process_div)

        for idx, weekday in enumerate(TimecardWdg.WEEK_CALENDAR):
            div = _get_div(50)
            div.add(weekday.capitalize()[0:1])
            month, day, time = weekday_list[idx]
            div.add(SpanWdg(day, css='med'))
            main_div.add(div)

        main_div.add(HtmlElement.br())
        process_div_container = _get_div(my.process_len)

        process = 'general'
        if isinstance(my.task, Task):
            process = my.task.get_process()
        process_div = FloatDivWdg(process, css='timecard_process')
        process_div.add_style("padding-right: 6px")
        process_div_container.add(process_div)

        main_div.add(process_div_container)

        # register cmd
        my.cmd.register_cmd("TimecardHourCmd")

        # query the db values
        timecard = Timecard.get(my.task.get_search_key(), my.week, my.year,\
            login=Environment.get_user_name())
        if timecard:
            timecard = timecard[0]

        # add the progress icon
        progress = my.cmd.generate_div()
        progress.add("&nbsp;")
        progress.add_style('width: 20px')
        progress.add_style('float: left')

        progress.set_post_ajax_script(
            my.get_refresh_script(show_progress=False))
        process_div_container.add(progress)

        today_time = Date().get_struct_time()
        for idx, weekday in enumerate(TimecardWdg.WEEK_CALENDAR):
            div = _get_div(50)
            month, day, time = weekday_list[idx]

            select = ActionSelectWdg(weekday)
            select.add_empty_option()

            # disable setting time cards in the future
            if time > today_time:
                select.set_attr('disabled', '')
            else:
                # using the MAX_HOUR
                hours = [
                    '%0.1f' % x for x in xrange(0, TimecardWdg.MAX_HOUR + 1)
                ]
                select.set_option('values', hours)
                if timecard:
                    select.set_value(timecard.get_value(weekday))
                my.cmd.set_option('search_key', my.task.get_search_key())
                my.cmd.set_option('attr_name', weekday)
                my.cmd.set_option('project_code', Project.get_project_code())

                select.add_event("onchange", my.cmd.get_on_script())
            div.add(select)
            main_div.add(div)