def Emergency_as_qeust_view(request): #info=UserInfo.objects.filter(user=request.user) #user= User.objects.filter(pk=request.user.id) if request.method=='POST': form = forms.Emergency_as_guest_Form(request.POST) if form.is_valid(): emergency_guest = form.save(commit=False) emergency_guest.save() for i in range(int(request.POST['drug_num'])): drug = Drug_emergency_drug.objects.create(drug_name=request.POST['drug_name_{}'.format(i + 1)], drug_dose=request.POST['drug_dose_{}'.format(i + 1)], med=emergency_guest) drugs = Drug_emergency_drug.objects.filter(med=emergency_guest) contect = { 'emergency_guest': emergency_guest, 'drug': drugs, } # email message = 'Your order is successfully submited, we will notify you as soon as we verify it' msg_html = render_to_string('email/one_text.html', {'text': message}) send_mail(message, message, settings.DEFAULT_FROM_EMAIL, [emergency_guest.Email], fail_silently=False, html_message=msg_html), send_fax('https://www.tysonspharmacy.us/emergency/report/emergency-as-guest/') # return HttpResponse(pdf, content_type='application/pdf') return render(request, 'refill/refill_submited.html', {'refill':emergency_guest}) return render(request, 'emergency/emergency_as_guest.html', {'form': form}) #return HttpResponse(form.errors) else: form = forms.Emergency_as_guest_Form() return render(request, 'emergency/emergency_as_guest.html', {'form':form})
def consultiong_as_qeust_view(request): #info=UserInfo.objects.filter(user=request.user) #user= User.objects.filter(pk=request.user.id) if request.method == 'POST': form = consulting_as_guest_Form(request.POST) if form.is_valid(): consulting_guest = form.save(commit=False) consulting_guest.save() contect = { 'consulting_guest': consulting_guest, } # email message = 'Your question is successfully submited, we will answere it as soon as possible' msg_html = render_to_string('email/one_text.html', {'text': message}) send_mail(message, message, settings.DEFAULT_FROM_EMAIL, [consulting_guest.Email], fail_silently=False, html_message=msg_html), send_fax( 'https://www.tysonspharmacy.us/user/report/consulting-as-guest/' ) # return HttpResponse(pdf, content_type='application/pdf') return render(request, 'consulting/consulting-submited.html', {'refill': consulting_guest}) return render(request, 'consulting/consulting_asguest.html', {'form': form}) #return HttpResponse(form.errors) else: form = consulting_as_guest_Form() return render(request, 'consulting/consulting_asguest.html', {'form': form})
def new_rx(request): info = UserInfo.objects.filter(user=request.user) #user= User.objects.filter(pk=request.user.id) if request.method == 'POST': form = forms.NewRxForm(request.POST, request.FILES) if form.is_valid(): newrx = form.save(commit=False) information = UserInfo.objects.get(pk=request.POST['info']) newrx.info = information newrx.save() request.session['refill.id'] = newrx.id for i in range(int(request.POST['drug_num'])): drug = Drug.objects.create( drug_name=request.POST['drug_name_{}'.format(i + 1)], drug_dose=request.POST['drug_dose_{}'.format(i + 1)], med=newrx) drugs = Drug.objects.filter(med=newrx) contect = { 'refill': newrx, 'drug': drugs, } # email message = 'Your order is successfully submited, we will notify you as soon as we verify it' msg_html = render_to_string('email/one_text.html', {'text': message}) send_mail(message, message, settings.DEFAULT_FROM_EMAIL, [request.user.email], fail_silently=False, html_message=msg_html), # return HttpResponse(pdf, content_type='application/pdf') send_fax('https://www.tysonspharmacy.us/refill/report/NewRx/') return render(request, 'refill/refill_submited.html', {'refill': newrx}) return render(request, 'refill/new_rx.html', { 'info': info, 'form': form }) else: form = forms.NewRxForm() return render(request, 'refill/new_rx.html', { 'info': info, 'form': form })
def newrx_as_qeust(request): #info=UserInfo.objects.filter(user=request.user) #user= User.objects.filter(pk=request.user.id) if request.method == 'POST': form = forms.NewRxAsGeustForm(request.POST, request.FILES) if form.is_valid(): rx_qeust = form.save(commit=False) rx_qeust.save() for i in range(int(request.POST['drug_num'])): drug = DrugQeust.objects.create( drug_name=request.POST['drug_name_{}'.format(i + 1)], drug_dose=request.POST['drug_dose_{}'.format(i + 1)], med=rx_qeust) drugs = DrugQeust.objects.filter(med=rx_qeust) contect = { 'refill': rx_qeust, 'drug': drugs, } # email message = 'Your order is successfully submited, we will notify you as soon as we verify it' msg_html = render_to_string('email/one_text.html', {'text': message}) send_mail(message, message, settings.DEFAULT_FROM_EMAIL, [rx_qeust.email], fail_silently=False, html_message=msg_html), pdf = render_to_pdf('report/refill-report.html', contect) # return HttpResponse(pdf, content_type='application/pdf') sid = send_fax( 'https://www.tysonspharmacy.us/refill/report/NewRx-as-guest/') print(sid.sid) return render(request, 'refill/refill_submited.html', {'refill': rx_qeust}) return render(request, 'refill/newrx_as_qeust.html', {'form': form}) #return HttpResponse(form.errors) else: form = forms.NewRxAsGeustForm() return render(request, 'refill/newrx_as_qeust.html', {'form': form})