crm审核合同、学员缴费
1、审核合同
#审核合同 url(r'^customer/(\d+)/contract_review/$', views.contract_review, name="contract_review"),
#contract_review.html {% extends 'base.html'%} {% load crm_tags %} {% block body %} <div class="container form-horizontal"> <div class="panel panel-success"> <div class="panel-heading"> <h3>Panel title</h3> </div> <div class="panel-body"> <span style="color: red">{{customer_form.errors}}</span> {%for field in customer_form%} <div class="form-group"> <label class="col-sm-2 control-label">{{field.label}}</label> <div class="col-sm-9"> {{field}} </div> </div> {% endfor %} <hr/> <div class="form-group"> <label class="col-sm-2 control-label">所报课程</label> <div class="col-sm-8"> {{enroll_obj.enrolled_class.course}} </div> </div> <div class="form-group"> <label class="col-sm-2 control-label">课程学费</label> <div class="col-sm-8"> {{enroll_obj.enrolled_class.course.price}} </div> </div> <div class="form-group"> <label class="col-sm-2 control-label">课程开始时间</label> <div class="col-sm-8"> {{enroll_obj.enrolled_class.start_date}} </div> </div> <a class="btn btn-danger" href="{% url 'enrollment' enroll_obj.id %}">审核拒绝</a> <a class="btn btn-success pull-right" href="{% url 'payment' enroll_obj.id %}">审核成功</a> </div> </div> </div> {% endblock%} {% block bottom-js %} <script> $(document).ready(function () { Dropzone.options.filedropzone ={ url:"{{request.path}}", paramName:"file",//The name that will be used to transfer the file maxFilesize:1,//MB addRemoveLinks:true, maxFiles:5, uploadMultiple:true, accept:function (file,done) { if(file.name == "justinbieber.jpg"){ done("Naha,you don't."); }else{done();} }}; myDropzone.on("success",function (file,response) { /*Maybe display some more file information on your page*/ console.log('filex upload done....',response); }) }); function RegisterFormCheck() { if(myDropzone.files.length<2){ alert("必须至少上传2张图片!") return false; } if($("form :checkbox").prop("checked")){ $("form").find("[disabled]").removeAttr("disabled"); return true; }else{ alert("必须同意该协议"); return false; } } Dropzone.autoDiscover = false; myDropzone = new Dropzone("#filedropzone"); myDropzone.on("addedfile", function(file) { /* Maybe display some more file information on your page */ console.log("-------",file) }); console.log(myDropzone.files) </script> {% endblock %}
#views.py def contract_review(request,enroll_id): """销售审核合同""" enroll_obj = models.Enrollment.objects.get(id=enroll_id) customer_form = CustomerForm(instance=enroll_obj.customer) return render(request,"sales/contract_review.html",{"enroll_obj":enroll_obj, "customer_form":customer_form})
2、学员缴费
#缴费 url(r'^customer/(\d+)/payment/$', views.payment, name="payment"),
#payment.html {% extends 'base.html'%} {% load crm_tags %} {% block body %} <div class="container"> <div class="panel panel-success"> <div class="panel-heading"> <h3>Panel title</h3> </div> <form class="form-horizontal" method="post" >{% csrf_token %} <div class="panel-body"> <ul> {% for error in errors%} <li style="color: red">{{error}}</li> {% endfor %} </ul> <div class="form-group"> <label class="col-sm-2 control-label">客户</label> <div class="col-sm-8"> {{enroll_obj.customer}} </div> </div> <div class="form-group"> <label class="col-sm-2 control-label">课程费用</label> <input type="text" name="amount" placeholder="至少500元" value=""> </div> <div class="form-group"> <label class="col-sm-2 control-label">所报课程</label> <div class="col-sm-8"> {{enroll_obj.enrolled_class}} </div> </div> <div class="form-group"> <label class="col-sm-2 control-label">课程顾问</label> <div class="col-sm-8"> {{enroll_obj.consultant}} </div> </div> <div class="form-group"> <label class="col-sm-2 control-label">课程开始时间</label> <div class="col-sm-8"> {{enroll_obj.enrolled_class.start_date}} </div> </div> </div> <button class="btn btn-success col-lg-offset-2" type="submit">提交</button> </form> </div> </div> {% endblock%}
#views.py def payment(request,enroll_id): """学员缴费""" enroll_obj = models.Enrollment.objects.get(id=enroll_id) customer_form = CustomerForm(instance=enroll_obj.customer) errors =[] if request.method == "POST": amount = request.POST.get("amount") print("amount",type(amount)) if amount: try: amount = int(amount) except ValueError as e: errors.append("费用必须是数字") else: if amount >= 500: payment_obj = models.Payment.objects.create(customer=enroll_obj.customer, course=enroll_obj.enrolled_class.course, amount=amount, consultant=enroll_obj.consultant) #更新合同的状态 enroll_obj.contract_approved = True enroll_obj.save() #更新报名的状态 enroll_obj.customer.status = 0 enroll_obj.customer.save() return redirect("/kind_admin/crm/customer/") else: errors.append("费用不能小于500元") else: errors.append("费用不能为空") return render(request,"sales/payment.html",{"enroll_obj":enroll_obj, "customer_form":customer_form, "errors":errors })