示例#1
0
def technical(request, pk):
    check_user_login(request)
    employee = Employee.objects.get(position=Position.objects.get(
        initials="CACC"))
    employee_2 = Employee.objects.get(position=Position.objects.get(
        initials="ME1"))
    client = Client.objects.get(id=pk)
    message = "Dear {} {},You have been requested to generate barcodes for [ {} ],GS1 Kenya,({})"
    msg = message.format(employee.user.first_name, employee.user.last_name,
                         client.company_name, datetime.now())
    message_1 = "Dear {} {},You have been requested to generate reciepts & invoice for [ {} ],GS1 Kenya,({})"
    msg_1 = message.format(employee_2.user.first_name,
                           employee_2.user.last_name, client.company_name,
                           datetime.now())
    tm = client.is_tm = 1
    if tm:
        client.save()
        SMS().send(employee.phone, msg_1)
        SMS().send(employee_2.phone, msg)
        print("TM -Approved")
        current_user = Employee.objects.get(user=User.objects.get(
            username=request.session['username']).id)
        RecordApprove(member_id=client.id,
                      current_user_id=current_user.id).save()
        messages.success(request,
                         "Technical Executive. Successfully! Approved member")
        return HttpResponseRedirect(reverse('CRM:list_client'))
示例#2
0
def assign_member_details(request, pk):
    form = EditClient(request.POST or None,
                      instance=get_object_or_404(Client, pk=pk))
    client = Client.objects.get(id=pk)
    phone = client.company_phone
    company_name = client.company_name
    employee = Employee.objects.get(user=User.objects.get(
        username=request.session['username']).id)
    if request.method == "POST":
        if form.is_valid():
            member_number = form.cleaned_data['member_number']
            member_prefix = form.cleaned_data['member_prefix']
            message = "Dear {} you have been assigned {} as member and {} as prefix number.GS1 KENYA"
            form.save()
            current_user = Employee.objects.get(user=User.objects.get(
                username=request.session['username']).id)
            RecordApprove(member_id=client.id,
                          current_user_id=current_user.id).save()
            SMS().send(
                phone,
                message.format(company_name, member_number, member_prefix))
            return HttpResponseRedirect(reverse('CRM:list_client'))
    return render(request, 'client/member_form.html', {
        'form': form,
        'employee': employee
    })
def membership_2(request, pk):
    check_user_login(request)
    client = Client.objects.get(id = pk)
    client.is_me2 = 1
    client.save()
    current_user = Employee.objects.get(user = User.objects.get(username = request.session['username']).id)
    RecordApprove(member_id = client.id, current_user_id = current_user.id).save()
    messages.success(request, "Member Executive. Successfully! Approved member")
    print("ME2 -Approved")
    return HttpResponseRedirect(reverse('CRM:list_client'))
def accounts_ex(request, pk):
    check_user_login(request)
    employee = Employee.objects.get(position = Position.objects.get(initials = "TM"))
    client = Client.objects.get(id = pk)
    client.is_cacc_x = 1
    client.save()
    current_user = Employee.objects.get(user = User.objects.get(username = request.session['username']).id)
    RecordApprove(member_id = client.id, current_user_id = current_user.id).save()
    print("CACC_ex -Approved")
    notify(employee.phone , employee.user.first_name, employee.user.last_name, client.company_name, datetime.now().date())
    return HttpResponseRedirect(reverse('CRM:list_client'))
def membership(request, pk):
    check_user_login(request)
    employee = Employee.objects.get(position = Position.objects.get(initials = "CCM"))
    current_user = Employee.objects.get(user = User.objects.get(username = request.session['username']).id)
    RecordApprove(member_id = client.id, current_user_id = current_user.id).save()
    client = Client.objects.get(id = pk)
    client.is_me1 = 1
    client.save()
    messages.success(request, "Member Executive. Successfully! Approved member")
    print("ME1 -Approved")
    notify(employee.phone , employee.user.first_name, employee.user.last_name, client.company_name, datetime.now().date())
    return HttpResponseRedirect(reverse('CRM:list_client'))
def general_manager(request, pk):
    check_user_login(request)
    client = Client.objects.get(id = pk)
    client.is_gm = 1
    client.status = 1
    client.save()
    current_user = Employee.objects.get(user = User.objects.get(username = request.session['username']).id)
    RecordApprove(member_id = client.id, current_user_id = current_user.id).save()
    message = "Dear {} your membership has been approved with member number  [{}] by GS1 KENYA"
    SMS().send(client.company_phone, message.format(client.company_name, client.member_number))
    messages.success(request, "General Manager. Successfully! Approved member")
    print("GM -Approved")
    return HttpResponseRedirect(reverse('CRM:list_client'))
def communication(request, pk):
    check_user_login(request)
    employee = Employee.objects.get(position = Position.objects.get(initials = "ACCM"))
    client = Client.objects.get(id = pk)
    message  = "Dear {} {},You have been requested to generate profoma invoice for [ {} ],GS1 Kenya,({})"
    msg = message.format(employee.user.first_name, employee.user.last_name, client.company_name, datetime.now())
    client.is_ccm = 1
    client.save()
    current_user = Employee.objects.get(user = User.objects.get(username = request.session['username']).id)
    RecordApprove(member_id = client.id, current_user_id = current_user.id).save()
    print("CCM -Approved")
    SMS().send(employee.phone, msg)
    messages.success(request, "Corporate Communication. Successfully! Approved member")
    return HttpResponseRedirect(reverse('CRM:list_client'))