码迷,mamicode.com
首页 > 其他好文 > 详细

Django项目:CRM(客户关系管理系统)--62--52PerfectCRM实现CRM客户报名流程学生合同审核

时间:2018-04-21 19:46:06      阅读:175      评论:0      收藏:0      [点我收藏+]

标签:name   orm   def   图片   lse   ble   turn   label   关系   

技术分享图片

 

技术分享图片
 1 # sales_urls.py
 2 # ————————47PerfectCRM实现CRM客户报名流程————————
 3 from django.conf.urls import url
 4 from bpm.sales import sales_views
 5 
 6 urlpatterns = [
 7     url(r^customer/(\d+)/enrollment/$, sales_views.enrollment, name="enrollment"),#客户招生#报名流程一 下一步
 8 
 9     # ————————48PerfectCRM实现CRM客户报名流程学生合同————————
10     # url(r‘^customer/registration/(\d+)/$‘, sales_views.stu_registration, name="stu_registration"),  # 报名流程二 学员签同合
11     # ————————50PerfectCRM实现CRM客户报名流程学生合同URL随机码————————
12     url(r^customer/registration/(\d+)/(\w+)/$, sales_views.stu_registration, name="stu_registration"),#报名流程二 学员签同合
13     # ————————50PerfectCRM实现CRM客户报名流程学生合同URL随机码————————
14     # ————————48PerfectCRM实现CRM客户报名流程学生合同————————
15 
16     # ————————52PerfectCRM实现CRM客户报名流程学生合同审核————————
17     url(r^contract_prompt/$, sales_views.contract_prompt, name="contract_prompt"),  # 报名流程二 提示学员
18     url(r^not_audit/$, sales_views.not_audit),  # 报名流程二  未审核 查询
19     url(r^contract_review/(\d+)/$, sales_views.contract_review, name="contract_review"),  # 报名流程三  审核
20     url(r^enrollment_rejection/(\d+)/$, sales_views.enrollment_rejection, name="enrollment_rejection"),  # 报名流程三 驳回
21     # ————————52PerfectCRM实现CRM客户报名流程学生合同审核————————
22 
23 ]
24 # ————————47PerfectCRM实现CRM客户报名流程————————
# sales_urls.py

 

技术分享图片

 

技术分享图片

 

技术分享图片
  1 # sales_views.py
  2 # ————————47PerfectCRM实现CRM客户报名流程————————
  3 from django.db import IntegrityError  #主动捕捉错误信息
  4 from django.shortcuts import render  #页面返回
  5 from crm import models    #数据库
  6 from bpm.bpm_auxiliary import bpm_forms   #自定制 forms
  7 
  8 # ————————50PerfectCRM实现CRM客户报名流程学生合同URL随机码————————
  9 import random #随机
 10 import string #字母 数字
 11 from django.core.cache import cache  #缓存
 12 # ————————50PerfectCRM实现CRM客户报名流程学生合同URL随机码————————
 13 
 14 #报名填写 销售
 15 def enrollment(request,customer_id):
 16     msgs={} #错误信息
 17     customer_obj=models.Customer.objects.get(id=customer_id)#取到客户信息记录 #返回到页面
 18 
 19     if request.method=="POST":
 20         enroll_form= bpm_forms.EnrollmentForm(request.POST)#获取数据
 21         if enroll_form.is_valid():#表单验证
 22 
 23             # ————————50PerfectCRM实现CRM客户报名流程学生合同URL随机码————————
 24             # msg = ‘‘‘请将此链接发给客户进行填写:
 25             #        http://127.0.0.1:8000/bpm/customer/registration/{enroll_obj_id}/
 26             #     ‘‘‘
 27             msg = ‘‘‘请将此链接发给客户进行填写:
 28                    http://127.0.0.1:8000/bpm/customer/registration/{enroll_obj_id}/{random_str}/ 
 29                 ‘‘‘
 30             random_str=‘‘.join(random.sample(string.ascii_lowercase+string.digits,8))#生成8位随机字符串 #URL使用
 31             url_str=‘‘‘customer/registration/{enroll_obj_id}/{random_str}/‘‘‘#报名链接
 32             # ————————50PerfectCRM实现CRM客户报名流程学生合同URL随机码————————
 33             try:
 34                 print(enroll_form.cleaned_data,cleaned)
 35                 enroll_form.cleaned_data[customer]=customer_obj#添加学员对象 记录
 36                 enroll_obj=models.Enrollment.objects.create(**enroll_form.cleaned_data)#创建记录
 37 
 38                 # ————————50PerfectCRM实现CRM客户报名流程学生合同URL随机码————————
 39                 # msgs[‘msg‘]=msg.format(enroll_obj_id=enroll_obj.id)#报名记录对应的id,随机字符串,报名链接
 40                 sort_url=enroll_obj.id#获取报名表对应的ID
 41                 cache.set(enroll_obj.id,random_str,61000)#加入过期时间   #URL使用    # cache缓存
 42                 msgs[msg]=msg.format(enroll_obj_id=enroll_obj.id,random_str=random_str)#报名记录对应的id,随机字符串,报名链接
 43                 url_str=url_str.format(enroll_obj_id=enroll_obj.id,random_str=random_str)#报名链接
 44                 print(url_str)
 45                 # ————————50PerfectCRM实现CRM客户报名流程学生合同URL随机码————————
 46 
 47             except IntegrityError as e:
 48                 #取到这条记录
 49                 enroll_obj=models.Enrollment.objects.get(customer_id=customer_obj.id,
 50                                                          enrolled_class_id=enroll_form.cleaned_data[enrolled_class].id)
 51 
 52                 # ————————52PerfectCRM实现CRM客户报名流程学生合同审核————————
 53                 if enroll_obj.contract_agreed:#学员同意
 54                     #return redirect(‘/crm/contract_review/%s/‘%enroll_obj.id)#跳转到审核页面
 55                     return render(request,bpm_sales/contract_prompt.html,locals())#跳转提示页面
 56                 # ————————52PerfectCRM实现CRM客户报名流程学生合同审核————————
 57 #
 58                 enroll_form.add_error(__all__,记录已经存在,不能重复创建!)
 59                 # ————————50PerfectCRM实现CRM客户报名流程学生合同URL随机码————————
 60                 # msgs[‘msg‘]=msg.format(enroll_obj_id=enroll_obj.id)#报名记录对应的id
 61                 cache.set(enroll_obj.id,random_str,61000)#加入过期时间  #URL使用    # cache缓存
 62                 msgs[msg]=msg.format(enroll_obj_id=enroll_obj.id,random_str=random_str)#报名记录对应的id
 63                 url_str=url_str.format(enroll_obj_id=enroll_obj.id,random_str=random_str)#报名链接
 64 
 65                 # ————————50PerfectCRM实现CRM客户报名流程学生合同URL随机码————————
 66     else:
 67         enroll_form= bpm_forms.EnrollmentForm()#modelform表单
 68     return render(request, bpm_sales/enrollment.html, locals())
 69 
 70 # ————————47PerfectCRM实现CRM客户报名流程————————
 71 
 72 
 73 
 74 # ————————51PerfectCRM实现CRM客户报名流程学生合同上传照片————————
 75 import os
 76 from PerfectCRM import settings
 77 import json
 78 # ————————51PerfectCRM实现CRM客户报名流程学生合同上传照片————————
 79 # ————————48PerfectCRM实现CRM客户报名流程学生合同————————
 80 #学员合同签定
 81 # ————————50PerfectCRM实现CRM客户报名流程学生合同URL随机码————————
 82 from django.shortcuts import HttpResponse #页面返回
 83 # def stu_registration(request,enroll_id):
 84 #     enroll_obj=models.Enrollment.objects.get(id=enroll_id)#获取报名记录
 85 def stu_registration(request,enroll_id,random_str):
 86     if cache.get(enroll_id) == random_str:  # 判断链接失效了没有
 87         enroll_obj = models.Enrollment.objects.get(id=enroll_id)  # 报名记录
 88 # ————————50PerfectCRM实现CRM客户报名流程学生合同URL随机码————————
 89         # ————————51PerfectCRM实现CRM客户报名流程学生合同上传照片————————
 90         enrolled_path=%s/%s/%(settings.ENROLLED_DATA,enroll_id)#证件上传路径
 91         img_file_len=0  #文件
 92         if os.path.exists(enrolled_path):#判断目录是否存在
 93             img_file_list=os.listdir(enrolled_path)#取目录 下的文件
 94             img_file_len=len(img_file_list)
 95         if request.method=="POST":
 96             ret=False
 97             data=request.POST.get(data)
 98             if data:#如果有删除动作
 99                 del_img_path="%s/%s/%s"%(settings.ENROLLED_DATA,enroll_id,data)#路径
100                 print(del_img_path,=-=-=-=-=-=)
101                 os.remove(del_img_path)
102                 ret=True
103                 return HttpResponse(json.dumps(ret))
104             if request.is_ajax():#ajax上传图片 #异步提交
105                 print(ajax上传图片 #异步提交中。。。 ,request.FILES)
106                 enroll_data_dir="%s/%s"%(settings.ENROLLED_DATA,enroll_id)#路径  #重要信息不能放在静态文件中
107                 if not os.path.exists(enroll_data_dir):#如果不存目录
108                     os.makedirs(enroll_data_dir,exist_ok=True)#创建目录
109                 for k,file_obj in request.FILES.items():   #循环字典 #上传的文件
110                     with open("%s/%s"%(enroll_data_dir,file_obj.name),wb) as f: #打开一个文件#路径#获取文件名
111                         for chunk in file_obj.chunks():#循环写入文件 # chunks块
112                             f.write(chunk)  #保存文件
113                 return HttpResponse(上传完成!)
114         # ————————51PerfectCRM实现CRM客户报名流程学生合同上传照片————————
115         # ————————50PerfectCRM实现CRM客户报名流程学生合同URL随机码————————
116     # ————————49PerfectCRM实现CRM客户报名流程学生合同表单验证————————
117 # ————————51PerfectCRM实现CRM客户报名流程学生合同上传照片————————
118     #     if request.method == "POST":
119 # ————————51PerfectCRM实现CRM客户报名流程学生合同上传照片————————
120             customer_form = bpm_forms.CustomerForm(request.POST, instance=enroll_obj.customer)  # 生成表单验证
121             if customer_form.is_valid():  # 表单验证通过
122                 customer_form.save()  # 保存
123                 enroll_obj.contract_agreed = True  # 同意协议
124                 enroll_obj.save()  # 保存
125                 status = 1  # 修改报名状态 # 1 已经报名
126                 return render(request, bpm_sales/stu_registration.html, locals())
127 
128         else:
129             if enroll_obj.contract_agreed == True:  # 如果协议已经签订
130                 status = 1  # 修改报名状态 # 1 已经报名
131             else:
132                 status = 0
133             customer_form = bpm_forms.CustomerForm(instance=enroll_obj.customer)  # 生成表单
134     # customer_form = bpm_forms.CustomerForm(instance=enroll_obj.customer)  # 生成表单
135     # ————————49PerfectCRM实现CRM客户报名流程学生合同表单验证————————
136 
137         return render(request,bpm_sales/stu_registration.html,locals())
138 # ————————48PerfectCRM实现CRM客户报名流程学生合同————————
139     else:
140         return HttpResponse(链接失效,非法链接,请自重!)
141 
142         # ————————50PerfectCRM实现CRM客户报名流程学生合同URL随机码————————
143 
144 
145 # ————————52PerfectCRM实现CRM客户报名流程学生合同审核————————
146 from django.shortcuts import redirect
147 #查询流程提示页面
148 def contract_prompt(request,enroll_id):
149     enroll_obj=models.Enrollment.objects.get(id=enroll_id)#取对象
150     enroll_form= bpm_forms.EnrollmentForm(instance=enroll_obj)#报名表对象
151     customers_form= bpm_forms.CustomerForm(instance=enroll_obj.customer)#学员的信息
152     return render(request,bpm_sales/contract_prompt.html,locals())
153 
154 # #待审核
155 def not_audit(request):
156     sign=models.Enrollment.objects.all()#所有的报名表
157     print(sign,sign----->)
158     return render(request, bpm_sales/not_audit.html, locals())#
159 
160 #审核合同
161 def contract_review(request,enroll_id):
162     enroll_obj=models.Enrollment.objects.get(id=enroll_id)#取对象
163     #payment_form=forms.PaymentForm()#生成表单
164     enroll_form= bpm_forms.EnrollmentForm(instance=enroll_obj)#报名表对象
165     customer_form= bpm_forms.CustomerForm(instance=enroll_obj.customer)#学员的信息
166     enrolled_path=%s/%s/%(settings.ENROLLED_DATA,enroll_id)#证件上传路径
167     if os.path.exists(enrolled_path):#判断目录是否存在
168         file_list=os.listdir(enrolled_path)#取目录 下的文件
169         imgs_one=file_list[0]
170         imgs_two=file_list[1]
171     return render(request, bpm_sales/contract_review.html, locals())#
172 
173 #驳回合同
174 def enrollment_rejection(request,enroll_id):
175     enroll_obj=models.Enrollment.objects.get(id=enroll_id)#报名表的对象
176     enroll_obj.contract_agreed=False#修改学员已经同意核同
177     enroll_obj.save()
178     return redirect(/bpm/customer/%s/enrollment/%enroll_obj.customer.id)#跳转到enrollment_rejection
179 # ————————52PerfectCRM实现CRM客户报名流程学生合同审核————————
# sales_views.py

 

技术分享图片

 

技术分享图片
 1 {#contract_prompt.html#}
 2 {## # ————————52PerfectCRM实现CRM客户报名流程学生合同审核————————#}
 3 {% extends ‘bpm_master/bpm_sample.html‘ %}
 4 {% block right-container-content %} {#自定义内容开始 右边页面内容#}
 5     <div class="panel-default">
 6         <div class="panel-body">
 7             <table class="table table-striped table-responsive">
 8                 <thead>
 9                 <tr>
10                     <th>客户</th>
11                     <th>课程名称</th>
12                 </tr>
13                 </thead>
14                 <tbody>
15                 <tr>
16                     <td>{{ enroll_obj.customer }}</td>
17                     <td>{{ enroll_obj.enrolled_class }}</td>
18                 </tr>
19                 </tbody>
20             </table>
21             <p class="errors" style="color:#ff0004 "> 该学员所报的课程已经进入合同审核</p>
22             <a href="{{ request.path }}"><input type="submit" class="btn btn-info pull-left" value="返回,查询其他课程"> </a>
23             <a href="/bpm/not_audit/"><input type="submit" class="btn btn-info pull-right" value="审核合同"> </a>
24         </div>
25     </div>
26 {% endblock %}
27 
28 {## # ————————52PerfectCRM实现CRM客户报名流程学生合同审核————————#}
{#contract_prompt.html#}

 

 

技术分享图片

技术分享图片

 

技术分享图片
 1 {#contract_review.html#}
 2 {## # ————————52PerfectCRM实现CRM客户报名流程学生合同审核————————#}
 3 {% extends ‘bpm_master/bpm_sample.html‘ %}
 4 {% load bpm_tags %}
 5 {% block right-container-content %} {#自定义内容开始 右边页面内容#}
 6     <div class="container col-lg-7 col-md-offset-2">
 7         <div class="panel panel-warning">
 8             <div class=" panel-heading">
 9                 <h3 class="panel-title container">报名入学|学员信息审核</h3>
10             </div>
11             <div class="panel-body "><!--返回提交函数-->
12                 <div class="form-horizontal">
13                     {% for foo in customer_form %}
14                         <div class="form-group">
15                             <label for="inputEmail3" class="col-sm-2 control-label">{{ foo.label }}</label>
16                             <div class="col-sm-8"> {{ foo }}</div>
17                         </div>
18                     {% endfor %}
19 
20                     {% for foo in enroll_form %}
21                         <div class="form-group">
22                             <label for="inputEmail3" class="col-sm-2 control-label">{{ foo.label }}</label>
23                             <div class="col-sm-8">{{ foo }} </div>
24                         </div>
25                     {% endfor %}
26 
27                     <div class="form-group">
28                         <label for="inputEmail3" class="col-sm-2 control-label">课程费用</label>
29                         <div class="col-sm-8">
30                             {{ enroll_obj.enrolled_class.course.price }}
31                         </div>
32                     </div>
33                     <div class="form-group">
34                         <label for="inputEmail3" class="col-sm-2 control-label">开课日期</label>
35                         <div class="col-sm-8">
36                             {{ enroll_obj.enrolled_class.start_date }}
37                         </div>
38                     </div>
39                 </div>
40 
41                 <div class="panel panel-warning">
42                     <div class=" panel-heading">
43                         <h3 class="panel-title container">学员证件|身份证</h3>
44                     </div>
45                 </div>
46                 <div class="rest_left cad" style="width: 200px;height: 200px;  float: left">
47                     <a href="#">
48                         <img src="/static/enrolled_data/{{ enroll_id }}/{{ imgs_one }}" alt=""
49                              style="width: 320px;height: 200px;">
50                     </a>
51                 </div>
52                 <div class="rest_left cad" style="width: 200px;height: 200px;  float: right">
53                     <a href="#">
54                         <img src="/static/enrolled_data/{{ enroll_id }}/{{ imgs_two }}" alt=""
55                              style="width: 320px;height: 200px;">
56                     </a>
57                 </div>
58                 <div style="clear: both"></div>
59                 <div class="panel panel-warning">
60                     <div class=" panel-heading">
61                         <h3 class="panel-title container">请认真审核后,通知相关人员!!!</h3>
62                     </div>
63                 </div>
64 
65                 <form action="" class="form-horizontal col-lg-5" role="form" method="post">{% csrf_token %}
66 
67 
68                     <a class="btn btn-danger" href="{% url ‘enrollment_rejection‘ enroll_obj.id %}">驳回合同</a>
69                     {#        <a class="btn btn-info pull-right" href="{% url ‘payment‘ enroll_obj.id %}">审核通过</a>#}
70                 </form>
71             </div>
72         </div>
73     </div>
74 {% endblock %}
75 {## # ————————52PerfectCRM实现CRM客户报名流程学生合同审核————————#}
{#contract_review.html#}

 

 

技术分享图片

 

技术分享图片
 1 {#not_audit.html#}
 2 {## # ————————52PerfectCRM实现CRM客户报名流程学生合同审核————————#}
 3 {% extends ‘bpm_master/bpm_sample.html‘ %}
 4 {% block right-container-content %} {#自定义内容开始 右边页面内容#}
 5     <div class="panel-default">
 6         <div class="panel-body">
 7             <h3>待审核的合同</h3>
 8             <table class="table table-striped table-responsive">
 9                 <thead>
10                 <tr>
11                     <th>客户</th>
12                     <th>所报班级</th>
13                     <th>课程顾问</th>
14                     <th>合同审核</th>
15                     <th>日期时间</th>
16                 </tr>
17                 </thead>
18                 <tbody>
19                 {% for foo in sign %}
20 {#                    {% if foo.contract_agreed and foo.contract_approved == false %}#}
21                     {% if foo.contract_agreed and not foo.contract_approved %}
22                     <tr>
23                         <td><a href="{% url ‘contract_review‘ foo.id %}">{{ foo.customer }}</a></td>
24                         <td>{{ foo.enrolled_class }}</td>
25                         <td>{{ foo.consultant }}</td>
26                         <td>{{ foo.contract_approved }}</td>
27                         <td>{{ foo.date }}</td>
28                     </tr>
29                     {% endif %}
30                 {% endfor %}
31                 </tbody>
32             </table>
33         </div>
34     </div>
35 {% endblock %}
36 
37 {## # ————————52PerfectCRM实现CRM客户报名流程学生合同审核————————#}
{#not_audit.html#}

技术分享图片

 

技术分享图片技术分享图片技术分享图片技术分享图片技术分享图片

Django项目:CRM(客户关系管理系统)--62--52PerfectCRM实现CRM客户报名流程学生合同审核

标签:name   orm   def   图片   lse   ble   turn   label   关系   

原文地址:https://www.cnblogs.com/ujq3/p/8902546.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!