Пример #1
0
 def save(self,**args):
     
     ce=CheckExact.objects.filter(UserID=self.UserID,CHECKTIME=self.CHECKTIME)
     if ce and ce[0].id!=self.id:
                raise Exception(_(u'补签记录输入重复'))
     if self.pk!=None:
         ce=CheckExact.objects.get(pk=self.pk)
     old=""
     if ce:
         old=Transaction.objects.filter(UserID=self.UserID,TTime=ce.CHECKTIME)
    
     super(CheckExact,self).save(**args)
     if old:
         t=old[0]
     else:            
         t=Transaction()
     t.UserID=self.UserID
     t.TTime=self.CHECKTIME
     t.State=self.CHECKTYPE
     t.Verify=5
     t.save()    #---添加到签卡原始数据表
     from mysite.att.models.__init__ import get_autocalculate_time as gct
     from model_waitforprocessdata import WaitForProcessData as wfpd
     import datetime
     gct_time=gct()
     if self.CHECKTIME<gct_time:
         wtmp=wfpd()                
         st=datetime.datetime(self.CHECKTIME.year,self.CHECKTIME.month,self.CHECKTIME.day,0,0,0)
         et=datetime.datetime(self.CHECKTIME.year,self.CHECKTIME.month,self.CHECKTIME.day,23,59,59)
         wtmp.UserID=self.UserID
         wtmp.starttime=st
         wtmp.endtime=et
         #wtmp.customer=self.customer
         wtmp.save() #---添加考勤计算任务计划
Пример #2
0
    def save(self, *args, **kwargs):
        if self.start >= self.end:
            raise Exception(_(u'结束时间不能小于开始时间'))

        tt = EmpSpecDay.objects.filter(emp=self.emp,
                                       start__lte=self.end,
                                       end__gte=self.start)
        if tt and tt[0].id != self.id:
            raise Exception(_(u'请假时间重复'))
#        tmp=EmpSpecDay.objects.filter(Q(emp=self.emp,start__lte=self.start,end__gte=self.end)| Q(emp=self.emp,start__gte=self.start,end__lte=self.end)).exclude(pk=1)
#        if tmp and tmp[0].pk !=self.pk :
#            raise Exception(_(u'已存在相同请假记录!'))

        super(EmpSpecDay, self).save()
        from mysite.att.models.__init__ import get_autocalculate_time as gct
        from model_waitforprocessdata import WaitForProcessData as wfpd
        import datetime
        gct_time = gct()
        if self.start < gct_time or self.end <= gct_time:
            wtmp = wfpd()
            st = self.start
            et = self.end
            wtmp.UserID = self.emp
            wtmp.starttime = st
            wtmp.endtime = et
            #wtmp.customer=self.customer
            wtmp.save()
Пример #3
0
    def save(self, *args, **kwargs):
        if self.start>=self.end:
            raise Exception(_(u'结束时间不能小于开始时间'))
        
        tt=EmpSpecDay.objects.filter(emp=self.emp,start__lte=self.end,end__gte=self.start)
        if tt and tt[0].id !=self.id:
            raise Exception(_(u'请假时间重复'))
#        tmp=EmpSpecDay.objects.filter(Q(emp=self.emp,start__lte=self.start,end__gte=self.end)| Q(emp=self.emp,start__gte=self.start,end__lte=self.end)).exclude(pk=1)
#        if tmp and tmp[0].pk !=self.pk :
#            raise Exception(_(u'已存在相同请假记录!'))
        
        super(EmpSpecDay,self).save()
        from mysite.att.models.__init__ import get_autocalculate_time as gct
        from model_waitforprocessdata import WaitForProcessData as wfpd
        import datetime
        gct_time=gct()
        if self.start<gct_time or self.end<=gct_time:
            wtmp=wfpd()                
            st=self.start
            et=self.end
            wtmp.UserID=self.emp
            wtmp.starttime=st
            wtmp.endtime=et
            #wtmp.customer=self.customer
            wtmp.save()
Пример #4
0
        def action(self, UserID, StartDate, EndDate):
            #            from mysite.personnel.models.model_emp import Employee
            #            deptIDs=self.request.POST.getlist('deptIDs')
            #            UserIDs=self.request.POST.getlist('UserID')
            #            dept_all=self.request.POST.get('dept_all','')
            #            if len(UserIDs)>0:
            #                users=Employee.objects.filter(id__in=UserIDs)
            #            else:
            #                if dept_all:
            #                   users=Employee.objects.filter(DeptID__in=deptIDs)
            #                else:
            #                    users=[]
            users = UserID
            #            print users
            if not users:
                raise Exception(_(u'请选择人员'))
            if len(users) > 1000:
                raise Exception(_(u'人员选择过多,最大支持1000人同时新增记录!'))
            sAssigned_shifts = self.request.POST.get('sAssigned_shifts', '')
            #print "sAssigned_shifts:%s"%sAssigned_shifts
            if not sAssigned_shifts:
                raise Exception(_(u'请选择班次'))
            if StartDate > EndDate:
                raise Exception(_(u'结束日期不能小于开始日期!'))

            sAssigned_shifts = eval(sAssigned_shifts)
            print sAssigned_shifts[0]
            num_run = NUM_RUN.objects.get(pk=int(sAssigned_shifts[0]['SchId']))
            for u in users:
                USER_OF_RUN.objects.filter(UserID=u,
                                           StartDate=StartDate,
                                           EndDate=EndDate,
                                           NUM_OF_RUN_ID=num_run).delete()
                t = USER_OF_RUN()
                t.UserID = u
                t.StartDate = StartDate
                t.EndDate = EndDate
                t.NUM_OF_RUN_ID = num_run
                t.save()
                from mysite.att.models.__init__ import get_autocalculate_time as gct
                from model_waitforprocessdata import WaitForProcessData as wfpd
                import datetime
                gct_time = gct()
                gct_date = datetime.date(gct_time.year, gct_time.month,
                                         gct_time.day)

                if StartDate < gct_date or EndDate <= gct_date:
                    wtmp = wfpd()
                    st = datetime.datetime(StartDate.year, StartDate.month,
                                           StartDate.day, 0, 0, 0)
                    et = datetime.datetime(EndDate.year, EndDate.month,
                                           EndDate.day, 23, 59, 59)
                    wtmp.UserID = u
                    wtmp.starttime = st
                    wtmp.endtime = et
                    #wtmp.customer=self.customer
                    wtmp.save()
Пример #5
0
 def save(self):
     super(USER_TEMP_SCH,self).save()
     from mysite.att.models.__init__ import get_autocalculate_time as gct
     from model_waitforprocessdata import WaitForProcessData as wfpd
     import datetime
     gct_time=gct()
     if self.ComeTime<gct_time or self.LeaveTime<=gct_time:
         wtmp=wfpd()                
         st=self.ComeTime
         et=self.LeaveTime
         wtmp.UserID=self.UserID
         wtmp.starttime=st
         wtmp.endtime=et
         #wtmp.customer=self.customer
         wtmp.save()
Пример #6
0
        def action(self, UserID, StartDate, EndDate):
            deptIDs = self.request.POST.getlist('deptIDs')
            UserIDs = self.request.POST.getlist('UserID')
            dept_all = self.request.POST.get('dept_all', '')
            if len(UserIDs) > 0:
                users = Employee.objects.filter(id__in=UserIDs)
            else:
                if dept_all:
                    users = Employee.objects.filter(DeptID__in=deptIDs)
                else:
                    users = []
            if not users:
                raise Exception(_(u'请选择人员'))
            sAssigned_shifts = self.request.POST.get('sAssigned_shifts', '')
            if not sAssigned_shifts:
                raise Exception(_(u'请选择班次'))
            sAssigned_shifts = eval(sAssigned_shifts)
            print sAssigned_shifts[0]
            num_run = NUM_RUN.objects.get(pk=int(sAssigned_shifts[0]['SchId']))
            for u in users:
                USER_OF_RUN.objects.filter(UserID=u,
                                           StartDate=StartDate,
                                           EndDate=EndDate,
                                           NUM_OF_RUN_ID=num_run).delete()
                t = USER_OF_RUN()
                t.UserID = u
                t.StartDate = StartDate
                t.EndDate = EndDate
                t.NUM_OF_RUN_ID = num_run
                t.save()
                from mysite.att.models.__init__ import get_autocalculate_time as gct
                from model_waitforprocessdata import WaitForProcessData as wfpd
                import datetime
                gct_time = gct()
                gct_date = datetime.date(gct_time.year, gct_time.month,
                                         gct_time.day)

                if StartDate < gct_date or EndDate <= gct_date:
                    wtmp = wfpd()
                    st = datetime.datetime(StartDate.year, StartDate.month,
                                           StartDate.day, 0, 0, 0)
                    et = datetime.datetime(EndDate.year, EndDate.month,
                                           EndDate.day, 23, 59, 59)
                    wtmp.UserID = u
                    wtmp.starttime = st
                    wtmp.endtime = et
                    wtmp.save()
Пример #7
0
    def delete(self):
        u"删除加班单"
        req = get_current_request()
        if req.session.has_key("employee"):
            if self.audit_status == AUDIT_SUCCESS:
                raise Exception(_(u'审核通过的记录不能被删除'))
        if self.audit_status == AUDIT_SUCCESS:
            from model_waitforprocessdata import WaitForProcessData as wfpd
            wtmp = wfpd()
            st = datetime.datetime(self.starttime.year, self.starttime.month,
                                   self.starttime.day, 0, 0, 0)
            et = datetime.datetime(self.endtime.year, self.endtime.month,
                                   self.endtime.day, 23, 59, 59)
            wtmp.UserID = self.emp
            wtmp.starttime = st
            wtmp.endtime = et
            wtmp.save()

        super(OverTime, self).delete()
Пример #8
0
    def save(self, *args, **kwargs):
        if not self.emp:
            raise Exception(_(u'必须选择人员'))
        if self.start >= self.end:
            raise Exception(_(u'结束时间不能小于或等于开始时间'))
        tt = EmpSpecDay.objects.filter(emp=self.emp,
                                       start__lte=self.end,
                                       end__gte=self.start)
        if tt and tt[0].id != self.id:
            raise Exception(_(u'请假时间重复'))
#        if tt and int(tt[0].audit_status)== AUDIT_SUCCESS:
        if self.id and tt and tt[0].audit_status == AUDIT_SUCCESS:
            raise Exception(_(u'审核通过的请假记录不能修改'))
#        tmp=EmpSpecDay.objects.filter(Q(emp=self.emp,start__lte=self.start,end__gte=self.end)| Q(emp=self.emp,start__gte=self.start,end__lte=self.end)).exclude(pk=1)
#        if tmp and tmp[0].pk !=self.pk :
#            raise Exception(_(u'已存在相同请假记录!'))

        req = get_current_request()
        if self.pk:
            tx = EmpSpecDay.objects.get(pk=self.pk)
            if req.session.has_key("employee"):
                if int(tx.audit_status) == AUDIT_SUCCESS:
                    raise Exception(_(u'该记录已审核'))
                if int(tx.state) == REFUSE:
                    self.audit_status = APPLICATION_AGAIN
        elif (not req.session.has_key("employee")):
            self.audit_status = AUDIT_SUCCESS

        super(EmpSpecDay, self).save()
        from mysite.att.models.__init__ import get_autocalculate_time as gct
        from model_waitforprocessdata import WaitForProcessData as wfpd
        import datetime
        gct_time = gct()
        if self.start < gct_time or self.end <= gct_time:
            wtmp = wfpd()
            st = self.start
            et = self.end
            wtmp.UserID = self.emp
            wtmp.starttime = st
            wtmp.endtime = et
            #wtmp.customer=self.customer
            wtmp.save()
Пример #9
0
    def save(self):
        #验证
        obj_tmp = OverTime.objects.filter(emp=self.emp,
                                          starttime__lte=self.endtime,
                                          endtime__gte=self.starttime)
        if obj_tmp and obj_tmp[0].pk != self.pk:
            raise Exception(_(u'加班记录重复'))
        if self.endtime <= self.starttime:
            raise Exception(_(u'结束时间不能小于等于开始时间'))

        req = get_current_request()
        if self.pk:  #编辑
            tmp = OverTime.objects.get(pk=self.pk)
            if req.session.has_key("employee"):  #员工自助用户申请或者重新申请
                if tmp.audit_status == REFUSE:
                    self.audit_status = APPLICATION_AGAIN
                if tmp.audit_status == AUDIT_SUCCESS:
                    raise Exception(_(u'该记录已审核'))
        elif (not req.session.has_key("employee")):  #管理员,新增,默认就是审核通过
            self.audit_status = AUDIT_SUCCESS

        super(OverTime, self).save()
        #        from mysite.att.calculate.global_cache import JBD_DATA
        #        if JBD_DATA.has_key(self.emp.id):
        #            del JBD_DATA[self.emp.id]
        if self.audit_status == AUDIT_SUCCESS:
            from mysite.att.models.__init__ import get_autocalculate_time as gct
            from model_waitforprocessdata import WaitForProcessData as wfpd

            gct_time = gct()
            if self.starttime < gct_time or self.endtime <= gct_time:
                wtmp = wfpd()
                st = datetime.datetime(self.starttime.year,
                                       self.starttime.month,
                                       self.starttime.day, 0, 0, 0)
                et = datetime.datetime(self.endtime.year, self.endtime.month,
                                       self.endtime.day, 23, 59, 59)
                wtmp.UserID = self.emp
                wtmp.starttime = st
                wtmp.endtime = et
                wtmp.save()
Пример #10
0
 def action(self,UserID,StartDate,EndDate):
     deptIDs=self.request.POST.getlist('deptIDs')
     UserIDs=self.request.POST.getlist('UserID')
     dept_all=self.request.POST.get('dept_all','')
     if len(UserIDs)>0:
         users=Employee.objects.filter(id__in=UserIDs)
     else:
         if dept_all:
            users=Employee.objects.filter(DeptID__in=deptIDs)
         else:
             users=[]
     if not users:
         raise Exception(_(u'请选择人员'))
     sAssigned_shifts=self.request.POST.get('sAssigned_shifts','')
     if not sAssigned_shifts:
         raise Exception(_(u'请选择班次'))
     sAssigned_shifts=eval(sAssigned_shifts)
     print sAssigned_shifts[0]
     num_run=NUM_RUN.objects.get(pk=int(sAssigned_shifts[0]['SchId']))
     for u in  users:
         USER_OF_RUN.objects.filter(UserID=u,StartDate=StartDate,EndDate=EndDate,NUM_OF_RUN_ID=num_run).delete()
         t=USER_OF_RUN()
         t.UserID=u
         t.StartDate=StartDate
         t.EndDate=EndDate
         t.NUM_OF_RUN_ID=num_run
         t.save()
         from mysite.att.models.__init__ import get_autocalculate_time as gct
         from model_waitforprocessdata import WaitForProcessData as wfpd
         import datetime
         gct_time=gct()
         gct_date=datetime.date(gct_time.year,gct_time.month,gct_time.day)
         
         if StartDate<gct_date or EndDate<=gct_date:                    
                 wtmp=wfpd()                
                 st=datetime.datetime(StartDate.year,StartDate.month,StartDate.day,0,0,0)
                 et=datetime.datetime(EndDate.year,EndDate.month,EndDate.day,23,59,59)
                 wtmp.UserID=u
                 wtmp.starttime=st
                 wtmp.endtime=et
                 wtmp.save()
Пример #11
0
 def save(self,**args):
     if self.UserID=="" or self.UserID==None:
         raise Exception(_(u'请选择人员!'))
     if self.endtime<=self.starttime:
         raise Exception(_(u'结束时间不能小于或等于开始时间!'))
     sua=SetUserAtt.objects.filter(UserID=self.UserID,starttime__lte=self.endtime,endtime__gte=self.starttime)
     if sua and sua[0].pk!=self.pk:
         raise Exception(_(u'调休记录输入重复'))
         
     
     super(SetUserAtt,self).save(**args)  
     from mysite.att.models.__init__ import get_autocalculate_time as gct
     from model_waitforprocessdata import WaitForProcessData as wfpd
     import datetime
     gct_time=gct()
     if self.starttime<gct_time or self.endtime<=gct_time:
           wtmp=wfpd()                
           st=self.starttime
           et=self.endtime
           wtmp.UserID=self.UserID
           wtmp.starttime=st
           wtmp.endtime=et
           wtmp.save()