an rel="diff-f2e0a141432fb2310bd3503010bc7a2e67f72c89L16">16 16
     </div>
17 17
     <div class="flex items-center gap-2 mb-4">
18 18
       <label for="lot-number" class="text-gray-700 font-medium">Lot No. :</label>
19
-      <input id="lot-number" type="text" class="border border-gray-300 rounded px-4 py-2 focus:outline-blue-500" placeholder="Enter Lot No." name='lot_no'>
19
+      <input id="lot-number" type="text" class="border border-gray-300 rounded px-4 py-2 focus:outline-blue-500" placeholder="Enter Lot No." name='lot_no' required>
20 20
       <button class="bg-blue-500 text-white px-4 py-2 rounded hover:bg-blue-600" type="submit" name="search_lot">
21 21
         🔍
22 22
       </button>
@@ -64,5 +64,69 @@
64 64
       </button>
65 65
     </div>
66 66
   </form>
67
+  {{ result }}
68
+  
69
+  <div class="bg-white shadow-md rounded-md p-4">
70
+
71
+                <table class="w-full text-left border-collapse border border-gray-300">
72
+                    <tbody>
73
+                        <tr class="bg-blue-100">
74
+                            <td class="border border-gray-300 px-4 py-2 font-medium text-gray-700">Product Code :</td>
75
+                            <td class="border border-gray-300 px-4 py-2 text-gray-700">{{ result.PRO1 }}</td>
76
+                        </tr>
77
+                        <tr>
78
+                            <td class="border border-gray-300 px-4 py-2 font-medium text-gray-700">Lot No. :</td>
79
+                            <td class="border border-gray-300 px-4 py-2 text-gray-700">{{ result.PRO2 }}</td>
80
+                        </tr>
81
+                        <tr class="bg-blue-100">
82
+                            <td class="border border-gray-300 px-4 py-2 font-medium text-gray-700">Customer :</td>
83
+                            <td class="border border-gray-300 px-4 py-2 text-gray-700">{{ result.PRO1C }}</td>
84
+                        </tr>
85
+                        <tr>
86
+                            <td class="border border-gray-300 px-4 py-2 font-medium text-gray-700">Pcs. :</td>
87
+                            <td class="border border-gray-300 px-4 py-2 text-gray-700">{{ pcs }}</td>
88
+                        </tr>
89
+                        <tr class="bg-blue-100">
90
+                            <td class="border border-gray-300 px-4 py-2 font-medium text-gray-700">Shape | Size :</td>
91
+                            <td class="border border-gray-300 px-4 py-2 text-gray-700">{{ size_str }}</td>
92
+                        </tr>
93
+                        <tr>
94
+                            <td class="border border-gray-300 px-4 py-2 font-medium text-gray-700">Specification :</td>
95
+                            <td class="border border-gray-300 px-4 py-2 text-gray-700">{{ spec }}</td>
96
+                        </tr>
97
+                        <tr class="bg-blue-100">
98
+                            <td class="border border-gray-300 px-4 py-2 font-medium text-gray-700">Inspection Date :</td>
99
+                            <td class="border border-gray-300 px-4 py-2 text-gray-700">22/06/2024</td>
100
+                        </tr>
101
+                        <tr>
102
+                            <td class="border border-gray-300 px-4 py-2 font-medium text-gray-700">Inspection Indicate1 :</td>
103
+                            <td class="border border-gray-300 px-4 py-2 text-gray-700"></td>
104
+                        </tr>
105
+                        <tr class="bg-blue-100">
106
+                            <td class="border border-gray-300 px-4 py-2 font-medium text-gray-700">Inspection Indicate2 :</td>
107
+                            <td class="border border-gray-300 px-4 py-2 text-gray-700"></td>
108
+                        </tr>
109
+                    </tbody>
110
+                </table>
111
+                    </div>
67 112
 </div>
113
+{% include "report/_hardnessout.html" %}
114
+<div class="border-t border-gray-300 my-4"></div>
115
+{% include "report/_hardness_outin.html" %}
116
+<div class="border-t border-gray-300 my-4"></div>
117
+{% include "report/_hardnessboth.html" %}
118
+<div class="border-t border-gray-300 my-4"></div>
119
+{% include "report/_dimen.html" %}
120
+<div class="border-t border-gray-300 my-4"></div>
121
+{% include "report/_dimen_app.html" %}
122
+<div class="border-t border-gray-300 my-4"></div>
123
+{% include "report/_dimen_bal.html" %}
124
+<div class="border-t border-gray-300 my-4"></div>
125
+{% include "report/_dim_bl_app_hard.html" %}
126
+<div class="border-t border-gray-300 my-4"></div>
127
+{% include "report/_dim_bal_app_rot_hard.html" %}
128
+<div class="border-t border-gray-300 my-4"></div>
129
+{% include "report/_t8p.html" %}
130
+<div class="border-t border-gray-300 my-4"></div>
131
+{% include "report/_cen.html" %}
68 132
 {% endblock %}

+ 18 - 1
app/report/views.py

@@ -3,11 +3,12 @@ from django.core.paginator import Paginator
3 3
 from django.contrib import messages
4 4
 from core.models import Report
5 5
 from core.forms import ReportForm
6
-from core.utils import ConfigurableCRUDView
6
+from core.utils import ConfigurableCRUDView, queryFromMaster
7 7
 from .filters import ReportFilter
8 8
 from .forms import ExportOptionsForm
9 9
 from pprint import pprint
10 10
 
11
+
11 12
 def index(request):
12 13
     reports = Report.objects.all()
13 14
     report_filter = ReportFilter(request.GET, queryset=reports)
@@ -60,6 +61,22 @@ class ReportCRUDView(ConfigurableCRUDView):
60 61
 def coi_view(request):
61 62
     pprint(f"xxxx method = xxx {request.method}")
62 63
     if request.method == "POST":
64
+        if 'search_lot' in request.POST:
65
+            lot_no = request.POST.get('lot_no', None)
66
+            if lot_no:
67
+                results = queryFromMaster(lot_no)
68
+                first_result = results[0] if results else None
69
+                try:
70
+                    pcs = int(first_result.PRO5) - int(first_result.PRO27)
71
+                except:
72
+                    pcs = 0
73
+                size_str = f"{first_result.PRO10}x{first_result.PRO11}x{first_result.PRO12}";
74
+                spec = f"{first_result.PRO13} {first_result.PRO14} {first_result.PRO15} {first_result.PRO16} {first_result.PRO17} {first_result.PRO18}"
75
+                return render(request, 'report/coi.html', {'result': first_result, 
76
+                                                           'pcs':pcs, 
77
+                                                           'size_str': size_str,
78
+                                                           'spec': spec})
79
+
63 80
         exports = request.POST.getlist("exports")  # Retrieve the list of selected values
64 81
         pprint(f"Selected Export Options: {exports}")
65 82
         messages.success(request, "Request Sent")

tum/ecoloop - Gogs: Simplico Git Service

Geen omschrijving

signals.py 1.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. from __future__ import annotations
  2. from django.db.models.signals import post_save
  3. from django.dispatch import receiver
  4. from django.contrib.auth.models import Group
  5. from .models import UserProfile
  6. ROLE_GROUP_MAP = {
  7. UserProfile.ROLE_OWNER: "owner",
  8. UserProfile.ROLE_MANAGER: "manager",
  9. UserProfile.ROLE_DRIVER: "driver",
  10. UserProfile.ROLE_CUSTOMER: "customer",
  11. UserProfile.ROLE_AUDITOR: "auditor",
  12. }
  13. MANAGED_GROUPS = set(ROLE_GROUP_MAP.values())
  14. @receiver(post_save, sender=UserProfile)
  15. def sync_profile_role_to_groups(sender, instance: UserProfile, created: bool, **kwargs):
  16. """Keep Django Group membership in sync with the profile role.
  17. - Removes the user from managed role groups (owner/manager/driver/customer/auditor)
  18. - Adds the user to the group mapped from the current role
  19. - Lazily creates the Group if missing
  20. """
  21. user = instance.user
  22. if user is None or not getattr(user, "pk", None):
  23. return
  24. # Remove from managed groups first (do not touch other unrelated groups)
  25. current_managed = user.groups.filter(name__in=MANAGED_GROUPS)
  26. if current_managed.exists():
  27. user.groups.remove(*current_managed)
  28. # Add target group for role
  29. group_name = ROLE_GROUP_MAP.get(instance.role)
  30. if not group_name:
  31. return
  32. group, _ = Group.objects.get_or_create(name=group_name)
  33. user.groups.add(group)