messages fixed

This commit is contained in:
bcomsugi 2023-12-31 03:42:00 +07:00
parent 67ab69750d
commit abc64aa7a0
5 changed files with 32 additions and 34 deletions

View File

@ -4,18 +4,7 @@
{% block title %}Invoice{% endblock title %}
{% block body %}
{% comment %} {% if messages %}
<div class="alert alert-success" role="alert">
{{message}}
</div>
{% endif %} {% endcomment %}
{% if messages %}
<ul class="messages">
{% for message in messages %}
<li{% if message.tags %} class="alert alert-{{ message.tags }}"{% endif %}>{{ message }}</li>
{% endfor %}
</ul>
{% endif %}
<div class="container-fluid">
<form action="" method="POST" class="card border-info-subtle p-3 mt-2" autocomplete="off" id="form">
@ -23,7 +12,7 @@
<div class="row">
</div>
<!-- <input name="customer_fullname" type='text' list='itemname' onchange='changeitem(event)' value='{{customer_name}}' class='textinput form-control'> -->
<input name="customerreffullname" type='text' list='itemname' value='{{customer_name}}' id='id_CustomerRefFullName' class='textinput form-control' autofocus>
<input name="customerreffullname" type='text' list='itemname' value='{{customer_name}}' id='id_CustomerRefFullName' class='textinput form-control' placeholder="Choose Customer" autofocus>
<button type="submit" class="btn btn-primary mt-2 me-2 ms-2" id="id_btnsave" onclick="checksubmit(event)">Save</button>
<!-- <button type="submit" class="btn btn-primary mt-2 me-2 ms-2" id="id_btnsave" >Save</button> -->

View File

@ -5,11 +5,13 @@
<form method="POST" action="{% url 'Invoice:save_inv' %}" class="modal-content">
{% csrf_token %}
<div class="modal-header">
<h1>Choose Items</h1>
<!-- <h1>Choose Items</h1> -->
<h2>{{ customer_fullname }}</h2>
</div>
<div class="modal-body">
<div class="mb-3 mt-3">
<input type="hidden" name="customer_fullname" value="{{ customer_fullname }}">
<!-- <input name="customerreffullname" type='text' list='itemname' value='{{customer_name}}' id='id_CustomerRefFullName' class='textinput form-control' autofocus> -->
<table class="table table-striped">
<thead>

View File

@ -5,7 +5,7 @@
<form method="POST" action="{% url 'Invoice:choose_inv' %}" class="modal-content">
{% csrf_token %}
<div class="modal-header">
<h1>Choose SO</h1>
<h2>Select SO Customer: {{ customer_fullname }}</h2>
</div>
<div class="modal-body">
<div class="mb-3 mt-3">

View File

@ -59,7 +59,7 @@ def show_customer(request):
if request.method =="POST":
customer_name = request.POST.get("customerreffullname")
print(f'customer_name: {customer_name}')
context['objects'] = [['abc', 'def', 'ghi', 'jkl']]
# context['objects'] = [['abc', 'def', 'ghi', 'jkl']]
context['objects'] = []
if customer_name:
@ -73,8 +73,11 @@ def show_customer(request):
open_sales_orders = ini.get_open_so()
print(f'open sales orders:{open_sales_orders}')
ini=None
if open_sales_orders:
context['objects'] = open_sales_orders
if not open_sales_orders:
messages.info(request, f"There is No open SO for {customer_name}")
return redirect("Invoice:show_customer")
# if open_sales_orders:
context['objects'] = open_sales_orders
context['customer_fullname'] = customer_name
@ -331,9 +334,11 @@ def save_inv(request):
print(result)
if result and ini.status_ok(result):
pass
messages.success(request, 'Invoice Has Been SAVED')
# context['messages']=[{"alert":"info", "message": "invoice Is Good"}]
messages.success(request, f"Invoice No: Has Been SAVED with link SO No. : {unique(df['RefNumber'].to_list())}")
# messages.info(request, 'Invoice Has Been SAVED2')
return redirect('Invoice:show_customer')
return render(request, "Invoice/show-customers.html", context)
return render(request, "Invoice/so_details_form.html", context)
else:
return HttpResponse(f"You cannot Save, because There Is No Open Sales Order for Customer: {customer_fullname}")

View File

@ -8,8 +8,8 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-KK94CHFLLe+nY2dmCWGMq91rCGa5gtU4mk92HdvYe+M/SXH301p5ILy+dN9+nJOZ" crossorigin="anonymous">
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha3/dist/js/bootstrap.bundle.min.js" integrity="sha384-ENjdO4Dr2bkBIFxQpeoTz1HIcje39Wm4jDKdf19U8gI4ddQ3GYNS7NTKfAdVQSZe" crossorigin="anonymous"></script>
<link href= {% static 'bootstrap.min.css' %} rel="stylesheet" crossorigin="anonymous">
<script src= {% static 'bootstrap.bundle.min.js' %} ></script>
<!-- <link href= {% static 'bootstrap.min.css' %} rel="stylesheet" crossorigin="anonymous">
<script src= {% static 'bootstrap.bundle.min.js' %} ></script> -->
<script src="https://unpkg.com/htmx.org@1.9.6"></script>
<style type="text/css">
@ -47,9 +47,9 @@
{% block head %}{% endblock %}
</head>
<body>
<nav class="navbar navbar-expand-lg bg-light">
<nav class="navbar navbar-expand-lg border-bottom bg-body-tertiary" data-bs-theme='light' >
<div class="container-fluid">
<a class="navbar-brand" href="#">DBW</a>
<a class="navbar-brand" href="{% url 'Invoice:show_customer' %}">DBW</a>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarScroll" aria-controls="navbarScroll" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
@ -78,24 +78,26 @@
<a class="nav-link disabled">Link</a>
</li>
</ul>
<div>{% block search_nav %}{% endblock search_nav %}
<div>{% block search_nav %}<form class="d-flex" role="search">
<input class="form-control me-2" type="search" placeholder="Search" aria-label="Search">
<button class="btn btn-outline-success" type="submit">Search</button>
</form>
{% endblock search_nav %}
</div>
</div>
</div>
</nav>
{% if messages %}
{% for message in messages %}
<div class="alert alert-{{ message.tags }} alert-dismissible fade show" role="alert">
{{ message | safe }}
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
{% for message in messages %}
<div class="alert alert-{{ message.tags }} alert-dismissible fade show" role="alert">
<strong>{{message | safe}}</strong>
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
</div>
{% endfor %}
{% endfor %}
{% endif %}
<div>
{% block body %}{% endblock body %}
</div>
<!-- Modal -->