def fundBudgetViewWork(request,pid,is_submited,redirect=False): fundbudget = ProjectFundBudget.objects.get(project_id = pid) project = ProjectSingle.objects.get(project_id = pid) # if fundbudget.finance_staff:finance_staff=fundbudget.finance_staff # else:finance_staff="未填写" # if fundbudget.finance_checktime:finance_checktime=fundbudget.finance_checktime # else:finance_checktime="未填写" if request.method == "POST": fundbudget_form = ProFundBudgetForm(request.POST, instance=fundbudget) fundbudgetremarkment_form = ProFundBudgetRemarkmentForm(request.POST,instance=fundbudget) if fundbudget_form.is_valid() and fundbudgetremarkment_form.is_valid(): fundbudgetremarkment_form.save() fundbudget_form.save() # redirect = True status_confirm(request,project) loginfo(p=project.project_status,label="status") else: logger.info("ProFundBudgetForm Valid Failed"+"**"*10) logger.info(fundbudget_form.errors) logger.info(fundbudgetremarkment_form.errors) else: fundbudget_form = ProFundBudgetForm(instance=fundbudget) fundbudgetremarkment_form=ProFundBudgetRemarkmentForm(instance=fundbudget) context = { 'redirect':redirect, 'fundbudget_form':fundbudget_form, 'fundbudgetremarkment_form':fundbudgetremarkment_form, 'pid':pid, 'is_submited':is_submited, 'projectbudget':project.project_budget_max, 'project':project, 'fundbudget':fundbudget, 'showseal':project.project_status.status>=PROJECT_STATUS_TASK_FINANCE_OVER, } return context
def submitProgress(request, pid): project = ProjectSingle.objects.get(project_id = pid) is_redirect = (request.session.get('auth_role') == TEACHER_USER) current_year = datetime.datetime.today().year if not ProgressReport.objects.filter(Q(project_id = pid) & Q(year = current_year)).count(): return simplejson.dumps({"message": "empty report"}) status_confirm(request,project) return simplejson.dumps({"message": "ok", "is_redirect": is_redirect, "pid": pid})
def fundBudget(request, form, remarkmentform,pid,max_budget,projectcode,is_submited = False): profundbudget = ProjectFundBudget.objects.get(project_id = pid) profundbudgetform = ProFundBudgetForm(deserialize_form(form),instance = profundbudget) profundbudgetremarkmentform = ProFundBudgetRemarkmentForm(deserialize_form(remarkmentform),instance = profundbudget) project = ProjectSingle.objects.get(project_id = pid ) flag = False identity = request.session.get('auth_role', "") accessList = [ADMINSTAFF_USER,SCHOOL_USER,FINANCE_USER] if not check_input(max_budget) or not check_input(projectcode): message = "" if not check_input(max_budget): message += u"项目最大预算不能为空 " if not check_input(projectcode): message += u"项目编号不能为空 " #if not check_input(finance_account): # message += u"项目财务编号不能为空 " ret = {'message':message,'flag':flag,} return simplejson.dumps(ret) if identity in accessList: project.project_budget_max = max_budget project.project_code = projectcode #project.finance_account = finance_account project.save() if profundbudgetform.is_valid(): total_budget = float(profundbudgetform.cleaned_data["total_budget"]) if total_budget < 0: message = u"数据未填写完整或数据格式不对,保存失败" else: laborcosts_budget = float(profundbudgetform.cleaned_data["laborcosts_budget"]) if laborcosts_budget <= total_budget * 0.3: if total_budget <= project.project_budget_max: profundbudgetform.save() copyBudgetToFundsummary(pid) if is_submited: if profundbudgetremarkmentform.is_valid(): profundbudgetremarkmentform.save() flag = True message=u"保存成功" status_confirm(request,project) else: message="预算说明为必填项" else: message=u"保存成功" else: message = u"经费预算表总结额应低于项目最大预算金额,请仔细核实" else: message = u"劳务费应低于总结额的30%,请仔细核实" else: loginfo(p=profundbudgetform.errors,label='profundbudgetform.errors') message = u"数据未填写完整或数据格式不对,保存失败" # table = refresh_fundsummary_table(request,profundsummaryform,pid) ret = {'message':message,'flag':flag,'project_code':project.project_code,'project_budget_max':project.project_budget_max,} return simplejson.dumps(ret)
def submitProgress(request, pid): project = ProjectSingle.objects.get(project_id=pid) is_redirect = (request.session.get('auth_role') == TEACHER_USER) current_year = datetime.datetime.today().year if not ProgressReport.objects.filter( Q(project_id=pid) & Q(year=current_year)).count(): return simplejson.dumps({"message": "empty report"}) status_confirm(request, project) return simplejson.dumps({ "message": "ok", "is_redirect": is_redirect, "pid": pid })
def handleFileUpload(request, pid, entrance): f = request.FILES[entrance] ftype = getType(f.name) ftype = FileList[entrance] # if(ftype != FileList[entrance]): # return 0 obj = UploadFile() if ftype != FileList['file_other']: if f.name.count('.') == 0: return 0 if not AcceptedExtension.count(f.name.split('.')[1]): return 0 obj = UploadFile.objects.filter(project__project_id=pid, file_type=ftype) else: obj = UploadFile.objects.filter(project__project_id=pid, name=f.name) if entrance == "file_application" or \ entrance == "file_task" or \ entrance == "file_summary": for i in obj: path = i.file_obj.path i.delete() default_storage.delete(path) project = ProjectSingle.objects.get(project_id=pid) obj = UploadFile() obj.name = f.name obj.project = project obj.file_obj = f obj.upload_time = time.strftime('%Y-%m-%d %X', time.localtime(time.time())) obj.file_type = ftype obj.file_size = f.size obj.save() timenow = time.strftime('%Y-%m-%d', time.localtime(time.time())) if entrance == 'file_application': project.file_application = True project.submit_date = timenow if project.project_status.status == PROJECT_STATUS_APPLICATION_WEB_OVER: status_confirm(request, project) elif entrance == 'file_task': project.file_task = True project.submit_date = timenow if project.project_status.status == PROJECT_STATUS_TASK_FINANCE_OVER: status_confirm(request, project) elif entrance == 'file_interimchecklist': project.file_interimchecklist = True project.submit_date = timenow if project.project_status.status == PROJECT_STATUS_PROGRESS_WEB_OVER: status_confirm(request, project) elif entrance == 'file_summary': project.file_summary = True project.submit_date = timenow if project.project_status.status == PROJECT_STATUS_FINAL_WEB_OVER: status_confirm(request, project) project.save() return 1
def handleFileUpload(request, pid, entrance): f = request.FILES[entrance] ftype = getType(f.name) ftype = FileList[entrance] # if(ftype != FileList[entrance]): # return 0 obj = UploadFile() if ftype != FileList['file_other']: if f.name.count('.') == 0: return 0 if not AcceptedExtension.count(f.name.split('.')[1]): return 0 obj = UploadFile.objects.filter(project__project_id = pid, file_type = ftype) else: obj = UploadFile.objects.filter(project__project_id = pid, name = f.name) if entrance == "file_application" or \ entrance == "file_task" or \ entrance == "file_summary": for i in obj: path = i.file_obj.path i.delete() default_storage.delete(path) project = ProjectSingle.objects.get(project_id = pid) obj = UploadFile() obj.name = f.name obj.project = project obj.file_obj = f obj.upload_time = time.strftime('%Y-%m-%d %X', time.localtime(time.time())) obj.file_type = ftype obj.file_size = f.size obj.save() timenow = time.strftime('%Y-%m-%d',time.localtime(time.time())) if entrance == 'file_application': project.file_application = True project.submit_date=timenow if project.project_status.status == PROJECT_STATUS_APPLICATION_WEB_OVER: status_confirm(request,project) elif entrance == 'file_task': project.file_task = True project.submit_date=timenow if project.project_status.status == PROJECT_STATUS_TASK_FINANCE_OVER: status_confirm(request,project) elif entrance == 'file_interimchecklist': project.file_interimchecklist = True project.submit_date=timenow if project.project_status.status == PROJECT_STATUS_PROGRESS_WEB_OVER: status_confirm(request,project) elif entrance == 'file_summary': project.file_summary = True project.submit_date=timenow if project.project_status.status == PROJECT_STATUS_FINAL_WEB_OVER: status_confirm(request,project) project.save() return 1
def fundSummary(request, form, remarkmentform, pid, finance_account, is_submited): profundsummary = ProjectFundSummary.objects.get(project_id=pid) profundsummaryform = ProFundSummaryForm(deserialize_form(form), instance=profundsummary) profundsummaryremarkmentform = ProFundSummaryRemarkmentForm( deserialize_form(remarkmentform), instance=profundsummary) project = ProjectSingle.objects.get(project_id=pid) flag = False if profundsummaryform.is_valid() and finance_account: total_budget = float(profundsummaryform.cleaned_data["total_budget"]) total_expenditure = float( profundsummaryform.cleaned_data["total_expenditure"]) if total_budget < 0 or total_expenditure < 0: message = u"数据未填写完整或数据格式不对,保存失败" else: laborcosts_budget = float( profundsummaryform.cleaned_data["laborcosts_budget"]) if laborcosts_budget <= total_budget * 0.3: if total_budget <= project.project_budget_max: profundsummaryform.save() #copyFundsummaryToBudget(pid) project.finance_account = finance_account project.save() if is_submited: if profundsummaryremarkmentform.is_valid(): profundsummaryremarkmentform.save() message = u"保存成功" flag = True status_confirm(request, project) else: message = u"决算说明为必填项" else: message = u"保存成功" else: message = u"经费决算表总结额应低于项目最大预算金额,请仔细核实" else: message = u"劳务费应低于总结额的30%,请仔细核实" else: loginfo(p=profundsummaryform.errors, label='profundsummaryform.errors') message = u"数据未填写完整或数据格式不对,保存失败" # table = refresh_fundsummary_table(request,profundsummaryform,pid) ret = {'message': message, 'flag': flag} return simplejson.dumps(ret)
def checkValid(request, pid): project = ProjectSingle.objects.get(project_id = pid) context = { 'status': 1, 'error':"", } error = "" if not project.title : context['status'] = 0 error += u"您的‘项目信息‘页面下有未填写字段" # print '0' elif not project.science_type : context['status'] = 0 error += u"您的‘项目信息‘页面下有未填写字段" # print '1' elif not project.trade_code : context['status'] = 0 error += u"您的‘项目信息‘页面下有未填写字段" # print '2' elif not project.subject : context['status'] = 0 error += u"您的‘项目信息‘页面下有未填写字段" # print '3' elif not project.start_time : context['status'] = 0 error += u"您的‘项目信息‘页面下有未填写字段" # print '5' elif not project.end_time : context['status'] = 0 error += u"您的‘项目信息‘页面下有未填写字段" basis_content = BasisContent.objects.get(project__project_id = pid) if not basis_content.basis: print "SBSB ^^^^" context['status'] = 0 error = u"您的‘ 立项依据与研究内容‘页面下有未填写字段" if context['status']: loginfo("mdoify success") status_confirm(request,project) context['error'] = error return simplejson.dumps(context)
def checkValid(request, pid): project = ProjectSingle.objects.get(project_id=pid) context = { 'status': 1, 'error': "", } error = "" if not project.title: context['status'] = 0 error += u"您的‘项目信息‘页面下有未填写字段" # print '0' elif not project.science_type: context['status'] = 0 error += u"您的‘项目信息‘页面下有未填写字段" # print '1' elif not project.trade_code: context['status'] = 0 error += u"您的‘项目信息‘页面下有未填写字段" # print '2' elif not project.subject: context['status'] = 0 error += u"您的‘项目信息‘页面下有未填写字段" # print '3' elif not project.start_time: context['status'] = 0 error += u"您的‘项目信息‘页面下有未填写字段" # print '5' elif not project.end_time: context['status'] = 0 error += u"您的‘项目信息‘页面下有未填写字段" basis_content = BasisContent.objects.get(project__project_id=pid) if not basis_content.basis: print "SBSB ^^^^" context['status'] = 0 error = u"您的‘ 立项依据与研究内容‘页面下有未填写字段" if context['status']: loginfo("mdoify success") status_confirm(request, project) context['error'] = error return simplejson.dumps(context)
def finalReportFinish(request,pid): project = ProjectSingle.objects.get(project_id = pid) finalsubmit = project.finalsubmit fundsummary = project.projectfundsummary loginfo(p=finalsubmit.project_summary,label="finalsubmit") loginfo(p=fundsummary.total_budget,label="fundbudget") if finalsubmit.project_summary: if fundsummary.total_budget != '0': status_confirm(request,project) status = '1' message = u"项目状态变为结题书网上提交" else: status = '0' message = u"请完善经费决算表内容" else: status = '0' message = u"请完善报告正文内容" ret = {'message':message,'pid':pid,'status':status,} return simplejson.dumps(ret)
def fundSummary(request, form,remarkmentform,pid,finance_account,is_submited): profundsummary = ProjectFundSummary.objects.get(project_id = pid) profundsummaryform = ProFundSummaryForm(deserialize_form(form),instance = profundsummary) profundsummaryremarkmentform=ProFundSummaryRemarkmentForm(deserialize_form(remarkmentform),instance = profundsummary ) project = ProjectSingle.objects.get(project_id = pid) flag = False if profundsummaryform.is_valid() and finance_account: total_budget = float(profundsummaryform.cleaned_data["total_budget"]) total_expenditure = float(profundsummaryform.cleaned_data["total_expenditure"]) if total_budget < 0 or total_expenditure < 0: message = u"数据未填写完整或数据格式不对,保存失败" else: laborcosts_budget = float(profundsummaryform.cleaned_data["laborcosts_budget"]) if laborcosts_budget <= total_budget * 0.3: if total_budget <= project.project_budget_max: profundsummaryform.save() #copyFundsummaryToBudget(pid) project.finance_account=finance_account project.save() if is_submited: if profundsummaryremarkmentform.is_valid(): profundsummaryremarkmentform.save() message=u"保存成功" flag = True status_confirm(request,project) else: message=u"决算说明为必填项" else: message=u"保存成功" else: message = u"经费决算表总结额应低于项目最大预算金额,请仔细核实" else: message = u"劳务费应低于总结额的30%,请仔细核实" else: loginfo(p=profundsummaryform.errors,label='profundsummaryform.errors') message = u"数据未填写完整或数据格式不对,保存失败" # table = refresh_fundsummary_table(request,profundsummaryform,pid) ret = {'message':message,'flag':flag} return simplejson.dumps(ret)
def finalReportFinish(request, pid): project = ProjectSingle.objects.get(project_id=pid) finalsubmit = project.finalsubmit fundsummary = project.projectfundsummary loginfo(p=finalsubmit.project_summary, label="finalsubmit") loginfo(p=fundsummary.total_budget, label="fundbudget") if finalsubmit.project_summary: if fundsummary.total_budget != '0': status_confirm(request, project) status = '1' message = u"项目状态变为结题书网上提交" else: status = '0' message = u"请完善经费决算表内容" else: status = '0' message = u"请完善报告正文内容" ret = { 'message': message, 'pid': pid, 'status': status, } return simplejson.dumps(ret)
def fundBudget(request, form, remarkmentform, pid, max_budget, projectcode, is_submited=False): profundbudget = ProjectFundBudget.objects.get(project_id=pid) profundbudgetform = ProFundBudgetForm(deserialize_form(form), instance=profundbudget) profundbudgetremarkmentform = ProFundBudgetRemarkmentForm( deserialize_form(remarkmentform), instance=profundbudget) project = ProjectSingle.objects.get(project_id=pid) flag = False identity = request.session.get('auth_role', "") accessList = [ADMINSTAFF_USER, SCHOOL_USER, FINANCE_USER] if not check_input(max_budget) or not check_input(projectcode): message = "" if not check_input(max_budget): message += u"项目最大预算不能为空 " if not check_input(projectcode): message += u"项目编号不能为空 " #if not check_input(finance_account): # message += u"项目财务编号不能为空 " ret = { 'message': message, 'flag': flag, } return simplejson.dumps(ret) if identity in accessList: project.project_budget_max = max_budget project.project_code = projectcode #project.finance_account = finance_account project.save() if profundbudgetform.is_valid(): total_budget = float(profundbudgetform.cleaned_data["total_budget"]) if total_budget < 0: message = u"数据未填写完整或数据格式不对,保存失败" else: laborcosts_budget = float( profundbudgetform.cleaned_data["laborcosts_budget"]) if laborcosts_budget <= total_budget * 0.3: if total_budget <= project.project_budget_max: profundbudgetform.save() copyBudgetToFundsummary(pid) if is_submited: if profundbudgetremarkmentform.is_valid(): profundbudgetremarkmentform.save() flag = True message = u"保存成功" status_confirm(request, project) else: message = "预算说明为必填项" else: message = u"保存成功" else: message = u"经费预算表总结额应低于项目最大预算金额,请仔细核实" else: message = u"劳务费应低于总结额的30%,请仔细核实" else: loginfo(p=profundbudgetform.errors, label='profundbudgetform.errors') message = u"数据未填写完整或数据格式不对,保存失败" # table = refresh_fundsummary_table(request,profundsummaryform,pid) ret = { 'message': message, 'flag': flag, 'project_code': project.project_code, 'project_budget_max': project.project_budget_max, } return simplejson.dumps(ret)
def LookThroughResult(request, judgeid, userrole, userstatus, page, page2, search, look_through_form, searchForm, skip_judge=False): project = ProjectSingle.objects.get(pk=judgeid) form = deserialize_form(look_through_form) if userrole == FINANCE_USER and (not (form.get("finance_staff") and form.get("finance_checktime"))): return simplejson.dumps({"message": "请填写审核人和审核时间"}) loginfo(form["judgeresult"]) if form["judgeresult"] == "1": project.comment = '' project.save() status_confirm(request, project) #request,pprint project.statusroject if skip_judge: status_confirm(request, project) if userstatus == "application": if form.get("max_budget"): project.project_budget_max = int(form.get("max_budget")) project.save() loginfo(project.project_budget_max) identity = request.session.get("auth_role", "") import time, string currentYear = time.strftime("%Y") if userstatus == "budget" and identity == FINANCE_USER: finance_budget = ProjectFundBudget.objects.get(project_id=project) finance_budget.finance_comment = form.get("reason") finance_budget.finance_staff = form.get("finance_staff") finance_budget.finance_checktime = form.get("finance_checktime") if not finance_budget.serial_number: lastest = ProjectFundBudget.objects.filter( Q(serial_number__startswith=currentYear)).order_by( 'serial_number') if lastest: finance_budget.serial_number = str( string.atoi(lastest[len(lastest) - 1].serial_number) + 1) else: finance_budget.serial_number = currentYear + "0000" finance_budget.save() if userstatus == "final" and identity == FINANCE_USER: finance_summary = ProjectFundSummary.objects.get( project_id=project) finance_summary.finance_comment = form.get("reason") finance_summary.finance_staff = form.get("finance_staff") finance_summary.finance_checktime = form.get("finance_checktime") lastest = ProjectFundSummary.objects.filter( Q(serial_number__startswith=currentYear)).order_by( 'serial_number') if not finance_summary.serial_number: if lastest: finance_summary.serial_number = str( string.atoi(lastest[len(lastest) - 1].serial_number) + 1) else: finance_summary.serial_number = currentYear + "0000" finance_summary.save() else: identity = request.session.get("auth_role", "") if identity == SCHOOL_USER: school = SchoolProfile.objects.get(userid=request.user) comment = school.department + u"管理员" + school.userid.first_name + u":" elif identity == COLLEGE_USER: comment = u"学院管理员" + request.user.first_name + u":" elif identity == FINANCE_USER: comment = u"财务管理员" + request.user.first_name + u":" else: comment = u"" for item in form.getlist('application'): comment += item + u"" for item in form.getlist("final"): comment += item + u"、" if form["reason"] == '': comment += u"请根据项目下一步操作进行相应修改。" + u" 未给出评审意见" else: comment += u"请根据项目下一步操作进行相应修改" + form["reason"] loginfo(comment) project.comment = comment project.save() choices_noPassReason = form.getlist('noPassReason') if identity == FINANCE_USER or len(choices_noPassReason) != 1: statusRollBack(request, project, 3) print "11" elif u"网上申请不合格" in choices_noPassReason or u"网上提交不合格" in choices_noPassReason: statusRollBack(request, project, 2) #10,request,project print "10" else: print "01" statusRollBack(request, project, 1) #01,request,project context = schedule_form_data(request, { "role": userrole, "status": userstatus }, searchForm, page, page2, search) loginfo(userstatus) if userstatus == "application": table_html = render_to_string("widgets/project_info.html", context) else: table_html = render_to_string("widgets/research_concluding_table.html", context) return simplejson.dumps({"table_html": table_html, "message": ""})
def LookThroughResult(request,judgeid,userrole,userstatus,page,page2,search,look_through_form,searchForm,skip_judge=False): print skip_judge project=ProjectSingle.objects.get(pk=judgeid) form=deserialize_form(look_through_form) if userrole == FINANCE_USER and (not (form.get("finance_staff") and form.get("finance_checktime"))): return simplejson.dumps({"message":"请填写审核人和审核时间"}) loginfo(form["judgeresult"]) if form["judgeresult"]=="1": project.comment='' project.save() status_confirm(request,project)#request,project if skip_judge: status_confirm(request,project) if userstatus=="application": if form.get("max_budget"): project.project_budget_max=int(form.get("max_budget")) project.save() loginfo(project.project_budget_max) identity = request.session.get("auth_role","") import time,string currentYear=time.strftime("%Y") if userstatus=="budget" and identity == FINANCE_USER: finance_budget=ProjectFundBudget.objects.get(project_id=project) finance_budget.finance_comment=form.get("reason") finance_budget.finance_staff=form.get("finance_staff") finance_budget.finance_checktime=form.get("finance_checktime") if not finance_budget.serial_number: lastest=ProjectFundBudget.objects.filter(Q(serial_number__startswith=currentYear)).order_by('serial_number') if lastest: finance_budget.serial_number=str(string.atoi(lastest[len(lastest)-1].serial_number)+1) else: finance_budget.serial_number=currentYear+"0000" finance_budget.save() if userstatus=="final" and identity == FINANCE_USER: finance_summary=ProjectFundSummary.objects.get(project_id=project) finance_summary.finance_comment=form.get("reason") finance_summary.finance_staff=form.get("finance_staff") finance_summary.finance_checktime=form.get("finance_checktime") lastest=ProjectFundSummary.objects.filter(Q(serial_number__startswith=currentYear)).order_by('serial_number') if not finance_summary.serial_number: if lastest: finance_summary.serial_number=str(string.atoi(lastest[len(lastest)-1].serial_number)+1) else: finance_summary.serial_number=currentYear+"0000" print "qqqqqqqq"+finance_summary.serial_number+"qqqqqqqqqqqqqqqqqqqqqqq" finance_summary.save() else: identity = request.session.get("auth_role","") if identity == SCHOOL_USER: school = SchoolProfile.objects.get(userid = request.user) comment= school.department+u"管理员"+school.userid.first_name+u":" elif identity == COLLEGE_USER: comment= u"学院管理员"+request.user.first_name+u":" elif identity == FINANCE_USER: comment= u"财务管理员"+request.user.first_name+u":" else: comment = u"" for item in form.getlist('application'): comment+=item+u"" for item in form.getlist("final"): comment+=item+u"、" comment+=u",原因"+form["reason"] loginfo(comment) project.comment=comment project.save() choices_application=form.getlist('application') choices_final=form.getlist('final') if identity == FINANCE_USER or len(choices_application)!=1 or len(choices_final)!=1 : statusRollBack(request,project,3) print "11" elif u"网上申请不合格" in choices_application or u"网上提交不合格" in choices_final: statusRollBack(request,project,2)#10,request,project print "10" else: print "01" statusRollBack(request,project,1)#01,request,project context=schedule_form_data(request,{ "role":userrole, "status":userstatus },searchForm,page,page2,search) loginfo(userstatus) if userstatus=="application": table_html=render_to_string("widgets/project_info.html",context) else: table_html=render_to_string("widgets/research_concluding_table.html",context) return simplejson.dumps({"table_html":table_html,"message":""})