def updateMembership(request): res = checksession(request=request) if True != res: return res vipid = request.POST['vipid'] vipname = request.POST['vipname'] phonenumber = request.POST['phonenumber'] #vipno = request.POST['vipno'] vipno = phonenumber discountrateId = request.POST['discountrate'] discountrate = 0 discountrate2 = 0 try : discount = ServiceRate.objects.get(id = discountrateId) discountrate = discount.rate discountrate2 = discount.morningdiscount except : discountrate = 1 discountrate2 = 1 membership = Membership.objects.get(id = vipid, deleteFlag = '0') membership.vipname = vipname membership.vipno = vipno membership.discounttype = discountrateId membership.phonenumber = phonenumber membership.discountrate = discountrate membership.discountrate2 = discountrate2 membership.save()
def goPaymentTypeSelect(request): res = checksession(request=request) if True != res: return res outDic = createResponseDic(request=request) outDic['hightlight'] = '5' isMembership = True try: transactionIds = '' for key in request.GET.keys(): if key[0:13] == 'transactionId': transactionId = request.GET[key] transactionIds = transactionIds + transactionId + ',' transaction = Transaction.objects.get(id=transactionId) if transaction.membershipId == '': isMembership = False outDic['transactionIds'] = transactionIds except: outDic['messages'] = 'ERROR' paymentTypeList = PaymentType.objects.all() if not isMembership: paymentTypeList = paymentTypeList.exclude(paymenttype='02') outDic['paymentTypeList'] = paymentTypeList usedTemplate = get_template('admin/paymenttypeselect.html') html = usedTemplate.render(outDic) return HttpResponse(html)
def addMembership(request): res = checksession(request=request) if True != res: return res #vipno = request.GET['vipno'] vipname = request.POST['vipname'] #vipnameid = request.GET['vipnameid'] vipnameid = '' phonenumber = request.POST['phonenumber'] password = '******' amount = 0 '''if request.GET['amount'].strip() : amount = float(request.GET['amount'])''' lastamount = 0 vipno = '' discountrateId = request.POST['discountrate'] discounttype = discountrateId discountrate = 0 discountrate2 = 0 try : discount = ServiceRate.objects.get(id = discountrateId) discountrate = discount.rate discountrate2 = discount.morningdiscount vipno = discount.nextCardNo except : discountrate = 1 discountrate2 = 1 vipno = phonenumber webchatid = '' isMember = False tmpMembership = Membership.objects.filter(vipno = vipno).filter(deleteFlag = '0') if tmpMembership : isMember = True else : membership = Membership() membership.vipno = vipno membership.vipname = vipname membership.vipnameid = vipnameid membership.phonenumber = phonenumber membership.password = password membership.amount = amount membership.lastamount = lastamount membership.discountrate = discountrate membership.discountrate2 = discountrate2 membership.discounttype = discounttype membership.webchatid = webchatid membership.webchatid2 = webchatid membership.startDate = getToday().strftime('%Y/%m/%d') membership.deleteFlag = '0' membership.endDate = '9999/12/31' membership.save() #update the next membership id discount.nextCardNo = int(vipno) + 1 discount.save() return isMember
def goPrePayment(request): res = checksession(request=request) if True != res: return res outDic = createResponseDic(request=request) outDic['hightlight'] = '5' doctorList = DoctorInfo.objects.all() outDic['doctorList'] = doctorList servicetypeList = ServiceType.objects.all() outDic['servicetypeList'] = servicetypeList productList = Product.objects.all() outDic['productList'] = productList #serviceRateList = ServiceRate.objects.all() #outDic['serviceRateList'] = serviceRateList try: bookingId = request.GET['id'] bookingInfo = BookingInfo.objects.get(id=bookingId) outDic['bookingInfo'] = bookingInfo doctor = DoctorInfo.objects.get(id=bookingInfo.bookeddoctor) outDic['doctorname'] = doctor.doctorname service = ServiceType.objects.get(id=bookingInfo.bookeditem) outDic['servicename'] = service.servicename except: print '--------there is no booking pay ' usedTemplate = get_template('admin/prepayment.html') html = usedTemplate.render(outDic) return HttpResponse(html)
def doMembership(request): res = checksession(request=request) if True != res: return res try : flag = request.POST['operation'] try : redirectUrl = '../' + request.POST['redirectUrl'] + '/' except : redirectUrl = '../membershiplist/' if flag == 'A' : if addMembership(request=request) : outDic = createResponseDic(request=request) outDic['hightlight'] = '4' outDic['isMessages'] = 'OK' usedTemplate = get_template('admin/membership.html') html = usedTemplate.render(outDic) return HttpResponse(html) elif flag == 'U' : updateMembership(request=request) elif flag == 'M' : updateMembershipAmount(request=request) else : addMembership(request=request) except : print finally : return HttpResponseRedirect(redirectUrl)
def cancelPayment(request): res = checksession(request=request) if True != res: return res id = request.GET['id'] try: transaction = Transaction.objects.get(id=id) successFlag = transaction.successFlag with dbTransaction.atomic(): if successFlag == '1': transaction.successFlag = '8' transaction.save() membershipId = transaction.membershipId if membershipId != '': amount = transaction.amount membership = Membership.objects.get(id=membershipId, deleteFlag='0') membership.amount = membership.amount + amount membership.save() bookingId = transaction.bookingId if bookingId != '': bookingInfo = BookingInfo.objects.get(id=bookingId) bookingInfo.status = '1' bookingInfo.save() except: print '-------------there is no transaction id = ' + id finally: return HttpResponseRedirect('../gopaymentlist/')
def goUpdateDoctorInfo(request): res = checksession(request=request) if True != res: return res doctorid = request.GET['id'] try : doctor = DoctorInfo.objects.get(id=doctorid) except : print '------there is no doctor id = ' + doctorid + '----------' finally: outDic = createResponseDic(request=request) outDic['hightlight'] = '2' outDic['doctorinfo'] = doctor doctorserviceIds = doctor.service serviceList = [] dbServiceList = ServiceType.objects.all() for service in dbServiceList : service.checkFlag = checkServiceCan(doctorserviceIds=doctorserviceIds, serviceId=service.id) serviceList.append(service) outDic['serviceList'] = serviceList usedTemplate = get_template('admin/doctor.html') html = usedTemplate.render(outDic) return HttpResponse(html)
def goMembershipDetail(request): res = checksession(request=request) if True != res: return res outDic = createResponseDic(request=request) outDic['hightlight'] = '4' temId = request.GET['id'] #membership = Membership.objects.get(id = temId, deleteFlag = '0') membership = Membership.objects.get(id = temId) serviceRate = ServiceRate.objects.get(id = membership.discounttype) membership.ratename = serviceRate.ratename outDic['membership'] = membership membershipAmountLogList = MembershipAmountLog.objects.all() membershipAmountLogList = membershipAmountLogList.filter(membershipId = temId).order_by('-transactionDate') outDic['membershipAmountLogList'] = membershipAmountLogList transactionList = Transaction.objects.all() transactionList = transactionList.filter(membershipId = temId, successFlag = '1').order_by('-transactionDate') paymentList = [] for transaction in transactionList : payment = createPayment(transaction = transaction) paymentList.append(payment) outDic['paymentList'] = paymentList usedTemplate = get_template('admin/membershipinfo.html') html = usedTemplate.render(outDic) return HttpResponse(html)
def doAdminVacatinApplication(request): res = checksession(request=request) if True != res: return res outDic = createResponseDic(request=request) outDic['hightlight'] = '10' doctorId = request.POST['doctorId'] vacationDate = request.POST['vacationDate'] starttime = request.POST['starttime'] endtime = request.POST['endtime'] doctor = DoctorInfo.objects.get(id = doctorId) doctorName = doctor.doctorname flag = '1' comments = '' vacation = Vacation() vacation.doctorId = doctorId vacation.doctorName = doctorName vacation.vacationDate = vacationDate vacation.starttime = starttime vacation.endtime = endtime vacation.flag = flag vacation.comments = comments vacation.save() return HttpResponseRedirect('../govacationlist/')
def doServiceType(request): res = checksession(request=request) if True != res: return res try : serviceid = request.GET['serviceid'] except : serviceid = '' servicename = request.GET['servicename'] servicerate = request.GET['servicerate'] serviceperiod = request.GET['serviceperiod'] try : if serviceid.strip() == '' : serviceType = ServiceType() else : serviceType = ServiceType.objects.get(id=serviceid) serviceType.servicename = servicename serviceType.servicerate = servicerate serviceType.serviceperiod = serviceperiod serviceType.save() except : print '------there is no service type id=' + serviceid + '--------' finally: return goServiceTypeList(request=request)
def searchPaymentSummaryList(request): res = checksession(request=request) if True != res: return res outDic = createResponseDic(request=request) outDic['hightlight'] = '6' #query form show yearList = [] year = getToday().strftime('%Y') for i in range(0, 5): yearList.append(int(year) - i) outDic['yearList'] = yearList doctrList = DoctorInfo.objects.all() outDic['doctrList'] = doctrList #query form show queryyear = request.GET['queryyear'] querymonth = request.GET['querymonth'] doctorId = request.GET['doctorid'] paymentList = getPaymentList(queryyear=queryyear, querymonth=querymonth, doctorId=doctorId) outDic['paymentList'] = paymentList usedTemplate = get_template('admin/paymentsummarylist.html') html = usedTemplate.render(outDic) return HttpResponse(html)
def doDeleteUnpayed(request): res = checksession(request=request) if True != res: return res outDic = createResponseDic(request=request) outDic['hightlight'] = '5' transactionId = request.GET['transactionId'] try: transaction = Transaction.objects.get(id=transactionId) transaction.delete() except: print '----------------the transaction that you want to delete is not exist. Tansaction ID : ' + transactionId transactionList = Transaction.objects.filter(successFlag='0') paymentList = [] for transaction in transactionList: payment = createPayment(transaction=transaction) paymentList.append(payment) outDic['paymentList'] = paymentList usedTemplate = get_template('admin/unpayedlist.html') html = usedTemplate.render(outDic) return HttpResponse(html)
def goUnpayedCopy(request): res = checksession(request=request) if True != res: return res #unpayed copy start 20170217 paymenttype = '00' try: transactionId = request.GET['transactionId'] transaction = Transaction.objects.get(id=transactionId) try: newTransaction = Transaction() newTransaction.membershipId = transaction.membershipId newTransaction.bookingId = transaction.bookingId newTransaction.doctorId = transaction.doctorId newTransaction.servicetypeId = transaction.servicetypeId newTransaction.amount = transaction.amount newTransaction.productamount = transaction.productamount newTransaction.serviceamount = transaction.serviceamount newTransaction.productIds = transaction.productIds newTransaction.discount = transaction.discount newTransaction.paymentType = paymenttype newTransaction.successFlag = '0' newTransaction.transactionDate = getToday() newTransaction.save() except: print 'copy failt transactionId: ' + transactionId except: print 'there is no transaction record transactionId :' + transactionId #unpayed copy end 20170217 return HttpResponseRedirect("../gounpayedlist/")
def goUpdateDoctorInfo(request): res = checksession(request=request) if True != res: return res doctorid = request.GET['id'] try : doctor = DoctorInfo.objects.get(id=doctorid) except : print '------there is no doctor id = ' + doctorid + '----------' finally: outDic = createResponseDic(request=request) outDic['hightlight'] = '2' outDic['doctorinfo'] = doctor doctorserviceIds = doctor.service serviceList = [] dbServiceList = ServiceType.objects.all() for service in dbServiceList : checkFlag = checkServiceCan(doctorserviceIds=doctorserviceIds, serviceId=service.id) # print(checkFlag) service.checkFlag = checkFlag serviceList.append(service) outDic['serviceList'] = serviceList usedTemplate = get_template('admin/doctor.html') html = usedTemplate.render(outDic) return HttpResponse(html)
def doProduct(request): res = checksession(request=request) if True != res: return res usedTemplate = get_template('admin/productlist.html') try : try : productid = request.POST['productid'] except : productid = '' productName = request.POST['productname'] productPrice = request.POST['productprice'] if productid.strip() == '': product = Product() print('------------new product added----------') else: product = Product.objects.get(id=productid) product.productname = productName product.productprice = productPrice product.save() except BaseException as e: print '-----------worry--------------' print(e) outDic = createResponseDic(request=request) outDic['hightlight'] = '8' productList = Product.objects.all() outDic['productList'] = productList html = usedTemplate.render(outDic) return HttpResponse(html)
def doProduct(request): res = checksession(request=request) if True != res: return res usedTemplate = get_template('admin/productlist.html') try : id = request.POST['productid'] productName = request.POST['productname'] productPrice = request.POST['productprice'] if id == '' : product = Product() else : product = Product.objects.get(id = id) product.productname = productName product.productprice = productPrice product.save() except : print '-----------worry--------------' outDic = createResponseDic(request=request) outDic['hightlight'] = '8' productList = Product.objects.all() outDic['productList'] = productList html = usedTemplate.render(outDic) return HttpResponse(html)
def searchPaymentList(request): res = checksession(request=request) if True != res: return res outDic = createResponseDic(request=request) outDic['hightlight'] = '6' #query form show dayList = [] tempday = getToday() for i in range(0, 8): dayList.append((tempday + timedelta(days=-i)).strftime('%Y-%m-%d')) outDic['dayList'] = dayList doctrList = DoctorInfo.objects.all() outDic['doctrList'] = doctrList #query form show querydate = request.GET['querydate'] doctorId = request.GET['doctorid'] paymentList = getPaymentList(querydate=querydate, doctorId=doctorId) outDic['paymentList'] = paymentList usedTemplate = get_template('admin/paymentlist.html') html = usedTemplate.render(outDic) return HttpResponse(html)
def goPaymentSummaryList(request): res = checksession(request=request) if True != res: return res outDic = createResponseDic(request=request) outDic['hightlight'] = '6' #query form show today = getToday() yearList = [] year = datetime.strftime(today, '%Y') month = datetime.strftime(today, '%m') for i in range(0, 5): yearList.append(int(year) - i) outDic['yearList'] = yearList doctrList = DoctorInfo.objects.all() outDic['doctrList'] = doctrList #query form show #today = str(date.today()) paymentList = getPaymentList(queryyear=year, querymonth=month) outDic['paymentList'] = paymentList usedTemplate = get_template('admin/paymentsummarylist.html') html = usedTemplate.render(outDic) return HttpResponse(html)
def goAddMessage(request): res = checksession(request=request) if True != res: return res outDic = createResponseDic(request=request) outDic['hightlight'] = '13' usedTemplate = get_template('admin/message.html') html = usedTemplate.render(outDic) return HttpResponse(html)
def goPaymentType(request): res = checksession(request=request) if True != res: return res usedTemplate = get_template('admin/paymenttype.html') outDic = createResponseDic(request=request) outDic['hightlight'] = '9' html = usedTemplate.render(outDic) return HttpResponse(html)
def goDiscountRate(request): res = checksession(request=request) if True != res: return res usedTemplate = get_template('admin/discount.html') outDic = createResponseDic(request=request) outDic['hightlight'] = '7' html = usedTemplate.render(outDic) return HttpResponse(html)
def goChangePassword(request): res = checksession(request=request) if True != res: return res outDic = createResponseDic(request=request) outDic['hightlight'] = '11' usedTemplate = get_template('admin/changepassword.html') html = usedTemplate.render(outDic) return HttpResponse(html)
def goDiscountRateList(request): res = checksession(request=request) if True != res: return res usedTemplate = get_template('admin/discountlist.html') outDic = createResponseDic(request=request) serviceRateList = ServiceRate.objects.all() outDic['serviceRateList'] = serviceRateList outDic['hightlight'] = '7' html = usedTemplate.render(outDic) return HttpResponse(html)
def goProductList(request): res = checksession(request=request) if True != res: return res usedTemplate = get_template('admin/productlist.html') productList = Product.objects.all() outDic = createResponseDic(request=request) outDic['hightlight'] = '8' outDic['productList'] = productList html = usedTemplate.render(outDic) return HttpResponse(html)
def checkServiceCan(doctorserviceIds, serviceId): res = checksession(request=request) if True != res: return res serviceCan = 'False' doctorserviceIdList = doctorserviceIds.split(',') for tmpId in doctorserviceIdList : if str(serviceId) == tmpId : serviceCan = 'True' break return serviceCan
def goMessageList(request): res = checksession(request=request) if True != res: return res outDic = createResponseDic(request=request) outDic['hightlight'] = '13' messageList = Messages.objects.all() outDic['messageList'] = messageList usedTemplate = get_template('admin/messagelist.html') html = usedTemplate.render(outDic) return HttpResponse(html)
def goDoctorInfoList(request): res = checksession(request=request) if True != res: return res usedTemplate = get_template('admin/doctorlist.html') doctorlist = DoctorInfo.objects.all() outDic = createResponseDic(request=request) outDic['hightlight'] = '2' outDic['doctorList'] = doctorlist html = usedTemplate.render(outDic) return HttpResponse(html)
def goDoctorInfo(request): res = checksession(request=request) if True != res: return res usedTemplate = get_template('admin/doctor.html') outDic = createResponseDic(request=request) outDic['hightlight'] = '2' serviceList = ServiceType.objects.all() outDic['serviceList'] = serviceList html = usedTemplate.render(outDic) return HttpResponse(html)
def goMembershipMonthlyList(request): res = checksession(request=request) if True != res: return res outDic = createResponseDic(request=request) outDic['hightlight'] = '4' yearList = [] year = getToday().strftime('%Y') for i in range(0, 3) : yearList.append(int(year) - i) outDic['yearList'] = yearList monthList = ['01', '02', '03', '04', '05', '06', '07', '08', '09', '10', '11', '12'] outDic['monthList'] = monthList currentMonth = getToday().strftime('%m') outDic['currentMonth'] = currentMonth try : queryYear = request.POST['queryyear'] queryMonth = request.POST['querymonth'] monthlyDay01 = queryYear + '/' + queryMonth + '/01' monthlyDay31 = queryYear + '/' + queryMonth + '/31' except : monthlyDay01 = getToday().strftime('%Y/%m') + '/01' monthlyDay31 = getToday().strftime('%Y/%m') + '/31' newMembershipList = Membership.objects.all() newMembershipList = newMembershipList.filter(startDate__gte = monthlyDay01) newMembershipList = newMembershipList.filter(startDate__lte = monthlyDay31) newMembershipList = newMembershipList.filter(deleteFlag = '0') for membership in newMembershipList : discoutType = ServiceRate.objects.get(id = membership.discounttype) membership.discounttype = discoutType.ratename outDic['newMembershipList'] = newMembershipList endMembershipList = Membership.objects.all() endMembershipList = endMembershipList.filter(endDate__gte = monthlyDay01) endMembershipList = endMembershipList.filter(endDate__lte = monthlyDay31) endMembershipList = endMembershipList.filter(deleteFlag = '1') for membership in endMembershipList : discoutType = ServiceRate.objects.get(id = membership.discounttype) membership.discounttype = discoutType.ratename outDic['endMembershipList'] = endMembershipList usedTemplate = get_template('admin/membershipmonthlylist.html') html = usedTemplate.render(outDic) return HttpResponse(html)
def goUpdateDiscountRate(request): res = checksession(request=request) if True != res: return res usedTemplate = get_template('admin/discount.html') discountId = request.GET['id'] discout = ServiceRate.objects.get(id=discountId) outDic = createResponseDic(request=request) outDic['serviceRate'] = discout outDic['hightlight'] = '7' html = usedTemplate.render(outDic) return HttpResponse(html)
def deleteServiceType(request): res = checksession(request=request) if True != res: return res serviceId = request.GET['id'] try : service = ServiceType.objects.get(id=serviceId) service.delete() except : print '------there is no service type id = ' + serviceId + '----------' finally: return goServiceTypeList(request=request)
def goMembershipDelete(request): res = checksession(request=request) if True != res: return res temId = request.GET['id'] try : membership = Membership.objects.get(id = temId) membership.delete() except : print '---------there is no membership id = ' + temId + '----------' finally: return HttpResponseRedirect("../membershiplist/")
def bookingList(request): res = checksession(request=request) if True != res: return res usedTemplate = get_template('admin/bookinglist.html') #usedTemplate = get_template('admin/admintest.html') bookingList = getBookingList() outDic = createResponseDic(request=request) outDic['bookingList'] = bookingList outDic['hightlight'] = '1' html = usedTemplate.render(outDic) return HttpResponse(html)
def sendMessage(request): res = checksession(request=request) if True != res: return res outDic = createResponseDic(request=request) outDic['hightlight'] = '12' try : message = request.POST['message'] sendMessageToAll(message) return HttpResponse('Success!') except : return HttpResponse('Failt!')
def goDoctorInfoList(request): res = checksession(request=request) if True != res: return res usedTemplate = get_template('admin/doctorlist.html') doctorlist = DoctorInfo.objects.all() doctorlist = doctorlist.order_by('rank') outDic = createResponseDic(request=request) outDic['hightlight'] = '2' outDic['doctorList'] = doctorlist html = usedTemplate.render(outDic) return HttpResponse(html)
def sendMessage(request): res = checksession(request=request) if True != res: return res outDic = createResponseDic(request=request) outDic['hightlight'] = '12' try: message = request.POST['message'] sendMessageToAll(message) return HttpResponse('Success!') except: return HttpResponse('Failt!')
def deleteDoctorInfo(request): res = checksession(request=request) if True != res: return res doctorid = request.GET['id'] try : doctor = DoctorInfo.objects.get(id=doctorid) doctor.delete() except : print '------there is no doctor id = ' + doctorid + '----------' finally: return goDoctorInfoList(request=request)
def goMembership(request): res = checksession(request=request) if True != res: return res usedTemplate = get_template('admin/membership.html') outDic = createResponseDic(request=request) serviceRateList = ServiceRate.objects.all() outDic['serviceRateList'] = serviceRateList outDic['hightlight'] = '4' outDic['flag'] = 'A' html = usedTemplate.render(outDic) return HttpResponse(html)
def doPaymentType(request): res = checksession(request=request) if True != res: return res paymentType = PaymentType() paymentType.paymenttype = request.POST['paymenttype'] paymentType.paymenttypename = request.POST['paymenttypename'] paymentType.save() usedTemplate = get_template('admin/paymenttypelist.html') outDic = createResponseDic(request=request) outDic['hightlight'] = '9' html = usedTemplate.render(outDic) return HttpResponse(html)
def goMembershipUnbind(request): res = checksession(request=request) if True != res: return res temId = request.GET['id'] try : membership = Membership.objects.get(id = temId, deleteFlag = '0') membership.webchatid = '' membership.webchatid2 = '' membership.save() except : print '---------there is no membership id = ' + temId + '----------' finally: return HttpResponseRedirect("../membershiplist/")
def goVacatinList(request): res = checksession(request=request) if True != res: return res outDic = createResponseDic(request=request) outDic['hightlight'] = '10' today = (datetime.now() + timedelta(hours=timeBJ)).strftime('%Y/%m/%d') vacationList = Vacation.objects.filter(flag='1') vacationList = vacationList.filter(vacationDate__gte = today) outDic['vacationList'] = vacationList usedTemplate = get_template('admin/vacationlist.html') html = usedTemplate.render(outDic) return HttpResponse(html)
def goServiceTypeUpdate(request): res = checksession(request=request) if True != res: return res serviceid = request.GET['id'] outDic = createResponseDic(request=request) outDic['hightlight'] = '3' try : service = ServiceType.objects.get(id=serviceid) outDic['service'] = service except : print '------------there is no service type id = ' + serviceid + ' ----------' finally: usedTemplate = get_template('admin/servicetype.html') html = usedTemplate.render(outDic) return HttpResponse(html)
def goAdminVacatinApplication(request): res = checksession(request=request) if True != res: return res outDic = createResponseDic(request=request) outDic['hightlight'] = '10' dayList = getDaysList(bookingDays + 7) outDic['dayList'] = dayList doctorInfoList = DoctorInfo.objects.all() outDic['doctorInfoList'] = doctorInfoList usedTemplate = get_template('admin/vacationapplication.html') html = usedTemplate.render(outDic) return HttpResponse(html)