Initial commit

This commit is contained in:
Abdulaziz Axmadaliyev
2026-02-17 19:05:54 +05:00
parent 493cb58222
commit 3691e2d068
56 changed files with 3546 additions and 893 deletions

View File

@@ -1,33 +1,58 @@
{% extends "base.html" %}
{% block title %}{{ title|default:"Yaratish" }}{% endblock %}
{% block title %}{{ title|default:"Aparat Yaratish" }}{% endblock %}
{% block content %}
<div class="form-container">
<h2>{{ title|default:"Yaratish" }}</h2>
<h2>{{ title|default:"Aparat Yaratish" }}</h2>
<a href="{% url 'dashboard' %}" class="back-btn">
<svg xmlns="http://www.w3.org/2000/svg" class="icon" viewBox="0 0 24 24" fill="none" stroke="currentColor"
stroke-width="2">
<path stroke-linecap="round" stroke-linejoin="round" d="M15 18l-6-6 6-6"/>
<a href="{% url 'device_list' %}" class="back-btn">
<svg xmlns="http://www.w3.org/2000/svg" class="icon" viewBox="0 0 24 24"
fill="none" stroke="currentColor" stroke-width="2">
<path stroke-linecap="round" stroke-linejoin="round"
d="M15 18l-6-6 6-6"/>
</svg>
Orqaga
</a>
<form method="post" novalidate>
{% csrf_token %}
{% for field in form %}
<!-- Address -->
<div class="form-group">
<label for="{{ field.id_for_label }}">{{ field.label }}</label>
{{ field }}
{% if field.help_text %}
<small class="help-text">{{ field.help_text }}</small>
{% endif %}
{% for error in field.errors %}
<div class="error">{{ error }}</div>
<label for="{{ form.address.id_for_label }}">Manzil</label>
{{ form.address }}
{% for error in form.address.errors %}
<div class="error">{{ error }}</div>
{% endfor %}
</div>
<!-- District -->
<div class="form-group">
<label for="{{ form.district.id_for_label }}">Tuman</label>
{{ form.district }}
{% for error in form.district.errors %}
<div class="error">{{ error }}</div>
{% endfor %}
</div>
<!-- Amount -->
<div class="form-group">
<label for="{{ form.amount.id_for_label }}">Summa</label>
{{ form.amount }}
{% for error in form.amount.errors %}
<div class="error">{{ error }}</div>
{% endfor %}
</div>
<!-- Due Date -->
<div class="form-group">
<label for="{{ form.due_date.id_for_label }}">To'lov muddati</label>
{{ form.due_date }}
{% for error in form.due_date.errors %}
<div class="error">{{ error }}</div>
{% endfor %}
</div>
{% endfor %}
<button type="submit" class="submit-btn">Saqlash</button>
</form>
@@ -36,7 +61,7 @@
<style>
.form-container {
max-width: 480px;
margin: 0 auto;
margin: 40px auto;
background: #fff;
padding: 24px 28px;
border-radius: 12px;
@@ -44,7 +69,7 @@
}
.form-container h2 {
margin-bottom: 16px;
margin-bottom: 20px;
font-size: 22px;
color: #111827;
text-align: center;
@@ -70,7 +95,6 @@
background: #4f46e5;
color: #fff;
transform: translateY(-2px);
box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}
.back-btn .icon {
@@ -79,10 +103,9 @@
}
.form-group {
margin-bottom: 16px;
margin-bottom: 18px;
display: flex;
flex-direction: column;
transition: all 0.2s ease;
}
.form-group label {
@@ -107,12 +130,6 @@
box-shadow: 0 0 0 2px rgba(79,70,229,0.2);
}
.help-text {
font-size: 12px;
color: #6b7280;
margin-top: 4px;
}
.error {
font-size: 12px;
color: #ef4444;
@@ -121,7 +138,7 @@
.submit-btn {
width: 100%;
padding: 10px 0;
padding: 12px 0;
background: #4f46e5;
color: #fff;
font-weight: 600;
@@ -137,11 +154,10 @@
transform: translateY(-1px);
}
/* Mobile adjustments */
@media (max-width: 480px) {
.form-container {
padding: 20px 16px;
}
}
</style>
{% endblock %}
{% endblock %}

View File

@@ -6,7 +6,7 @@
<div class="form-container">
<h2>{{ title|default:"Yaratish" }}</h2>
<a href="{% url 'dashboard' %}" class="back-btn">
<a href="{% url 'expense_list' %}" class="back-btn">
<svg xmlns="http://www.w3.org/2000/svg" class="icon" viewBox="0 0 24 24" fill="none" stroke="currentColor"
stroke-width="2">
<path stroke-linecap="round" stroke-linejoin="round" d="M15 18l-6-6 6-6"/>
@@ -41,25 +41,42 @@ document.addEventListener("DOMContentLoaded", function() {
const typeSelect = document.getElementById("id_expense_type");
const employeeGroup = document.getElementById("group-employee");
const deviceGroup = document.getElementById("group-device");
const commentGroup = document.getElementById("group-comment");
function hideAllConditional() {
if (employeeGroup) employeeGroup.style.display = "none";
if (deviceGroup) deviceGroup.style.display = "none";
if (commentGroup) commentGroup.style.display = "none";
}
function toggleFields() {
if (!typeSelect) return;
const value = typeSelect.value;
// Hide both initially
if (employeeGroup) employeeGroup.style.display = "none";
if (deviceGroup) deviceGroup.style.display = "none";
// Hide all conditional fields first
hideAllConditional();
// Show relevant fields based on expense type
if (value === "salary") {
if (employeeGroup) employeeGroup.style.display = "flex";
} else if (value === "rent" || value === "maintenance") {
if (deviceGroup) deviceGroup.style.display = "flex";
} else if (value === "other") {
if (commentGroup) commentGroup.style.display = "flex";
}
}
// Initialize: hide all conditional fields on page load
hideAllConditional();
// Then show appropriate fields based on current selection
toggleFields();
if (typeSelect) typeSelect.addEventListener("change", toggleFields);
// Listen for changes
if (typeSelect) {
typeSelect.addEventListener("change", toggleFields);
}
});
</script>
@@ -114,7 +131,8 @@ document.addEventListener("DOMContentLoaded", function() {
color: #374151;
}
.form-group input,
.form-group select {
.form-group select,
.form-group textarea {
padding: 10px 14px;
border: 1px solid #d1d5db;
border-radius: 8px;
@@ -123,7 +141,8 @@ document.addEventListener("DOMContentLoaded", function() {
transition: border-color 0.2s, box-shadow 0.2s;
}
.form-group input:focus,
.form-group select:focus {
.form-group select:focus,
.form-group textarea:focus {
border-color: #4f46e5;
box-shadow: 0 0 0 2px rgba(79,70,229,0.2);
}
@@ -162,4 +181,4 @@ document.addEventListener("DOMContentLoaded", function() {
.form-container { padding: 20px 16px; }
}
</style>
{% endblock %}
{% endblock %}

View File

@@ -6,7 +6,7 @@
<div class="form-container">
<h2>{{ title|default:"Yaratish" }}</h2>
<a href="{% url 'dashboard' %}" class="back-btn">
<a href="{% url 'income_list' %}" class="back-btn">
<svg xmlns="http://www.w3.org/2000/svg" class="icon" viewBox="0 0 24 24" fill="none" stroke="currentColor"
stroke-width="2">
<path stroke-linecap="round" stroke-linejoin="round" d="M15 18l-6-6 6-6"/>

View File

@@ -0,0 +1,148 @@
{% extends "base.html" %}
{% block title %}{{ title|default:"Arenda Yaratish" }}{% endblock %}
{% block content %}
<div class="form-container">
<h2>{{ title|default:"Arenda Yaratish" }}</h2>
<a href="{% url 'dashboard' %}" class="back-btn">
<svg xmlns="http://www.w3.org/2000/svg" class="icon" viewBox="0 0 24 24" fill="none" stroke="currentColor"
stroke-width="2">
<path stroke-linecap="round" stroke-linejoin="round" d="M15 18l-6-6 6-6"/>
</svg>
Orqaga
</a>
<form method="post" novalidate>
{% csrf_token %}
{% for field in form %}
<div class="form-group">
<label for="{{ field.id_for_label }}">{{ field.label }}</label>
{{ field }}
{% if field.help_text %}
<small class="help-text">{{ field.help_text }}</small>
{% endif %}
{% for error in field.errors %}
<div class="error">{{ error }}</div>
{% endfor %}
</div>
{% endfor %}
<button type="submit" class="submit-btn">Saqlash</button>
</form>
</div>
<style>
.form-container {
max-width: 480px;
margin: 0 auto;
background: #fff;
padding: 24px 28px;
border-radius: 12px;
box-shadow: 0 6px 18px rgba(0,0,0,0.06);
}
.form-container h2 {
margin-bottom: 16px;
font-size: 22px;
color: #111827;
text-align: center;
}
.back-btn {
display: inline-flex;
align-items: center;
gap: 6px;
margin-bottom: 20px;
padding: 8px 16px;
background: #f3f4f6;
color: #4f46e5;
text-decoration: none;
font-weight: 500;
font-size: 14px;
border-radius: 9999px;
box-shadow: 0 2px 6px rgba(0,0,0,0.08);
transition: all 0.2s ease;
}
.back-btn:hover {
background: #4f46e5;
color: #fff;
transform: translateY(-2px);
box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}
.back-btn .icon {
width: 16px;
height: 16px;
}
.form-group {
margin-bottom: 16px;
display: flex;
flex-direction: column;
transition: all 0.2s ease;
}
.form-group label {
margin-bottom: 6px;
font-weight: 600;
color: #374151;
}
.form-group input,
.form-group select {
padding: 10px 14px;
border: 1px solid #d1d5db;
border-radius: 8px;
font-size: 14px;
outline: none;
transition: border-color 0.2s, box-shadow 0.2s;
}
.form-group input:focus,
.form-group select:focus {
border-color: #4f46e5;
box-shadow: 0 0 0 2px rgba(79,70,229,0.2);
}
.help-text {
font-size: 12px;
color: #6b7280;
margin-top: 4px;
}
.error {
font-size: 12px;
color: #ef4444;
margin-top: 4px;
}
.submit-btn {
width: 100%;
padding: 10px 0;
background: #4f46e5;
color: #fff;
font-weight: 600;
font-size: 15px;
border: none;
border-radius: 10px;
cursor: pointer;
transition: background 0.2s, transform 0.2s;
}
.submit-btn:hover {
background: #4338ca;
transform: translateY(-1px);
}
/* Responsive adjustments */
@media (max-width: 480px) {
.form-container {
padding: 20px 16px;
}
}
</style>
{% endblock %}

View File

@@ -0,0 +1,284 @@
{% extends "base.html" %}
{% block title %}Yakuniy Hisobot{% endblock %}
{% block content %}
<div class="form-container">
<div class="form-header">
<h2>Yakuniy Hisobot</h2>
<p class="subtitle">Kunni yakunlash uchun qurilma va oxirgi ko'rsatkichni tanlang</p>
</div>
{% if form.non_field_errors %}
<div class="alert alert-error">
{% for error in form.non_field_errors %}
<p>⚠️ {{ error }}</p>
{% endfor %}
</div>
{% endif %}
<form method="post" id="reportForm" novalidate>
{% csrf_token %}
<!-- Device Field -->
<div class="form-group">
<label for="{{ form.device.id_for_label }}">{{ form.device.label }} <span class="required">*</span></label>
<div class="input-wrapper">
{{ form.device }}
{% if form.device.help_text %}
<small class="help-text">{{ form.device.help_text }}</small>
{% endif %}
{% if form.device.errors %}
<div class="field-error">
{% for error in form.device.errors %}
<p>{{ error }}</p>
{% endfor %}
</div>
{% endif %}
</div>
</div>
<!-- Quantity Field -->
<div class="form-group">
<label for="{{ form.quantity.id_for_label }}">{{ form.quantity.label }} <span class="required">*</span></label>
<div class="input-wrapper">
{{ form.quantity }}
{% if form.quantity.errors %}
<div class="field-error">
{% for error in form.quantity.errors %}
<p>{{ error }}</p>
{% endfor %}
</div>
{% endif %}
</div>
</div>
<!-- Submit Button -->
<button type="submit" class="submit-btn">Yakunlash</button>
<!-- Back Link -->
<a href="{% url 'employee_dashboard' %}" class="back-link">Orqaga qaytish</a>
</form>
</div>
<script>
document.getElementById("reportForm").addEventListener("submit", function(e){
const device = document.getElementById("id_device").value;
const quantity = document.getElementById("id_quantity").value;
// Validate before showing confirmation
if (!device) {
e.preventDefault();
alert("Qurilmani tanlang");
return;
}
if (!quantity || quantity < 1) {
e.preventDefault();
alert("Miqdorni to'g'ri kiriting");
return;
}
// Show confirmation dialog
const deviceText = document.getElementById("id_device").options[
document.getElementById("id_device").selectedIndex
].text;
if (!confirm(`Siz kunni yakunlamoqchimisiz?\n\nQurilma: ${deviceText}\nMiqdor: ${quantity}`)) {
e.preventDefault();
}
});
</script>
<style>
.form-container {
max-width: 450px;
margin: 40px auto;
padding: 32px;
background: #fff;
border-radius: 14px;
box-shadow: 0 6px 20px rgba(0,0,0,0.08);
}
.form-header {
text-align: center;
margin-bottom: 28px;
}
.form-header h2 {
margin: 0 0 8px 0;
font-size: 24px;
color: #111827;
font-weight: 700;
}
.subtitle {
margin: 0;
font-size: 14px;
color: #6b7280;
line-height: 1.5;
}
/* Alerts */
.alert {
padding: 12px 14px;
border-radius: 8px;
margin-bottom: 20px;
font-size: 14px;
line-height: 1.5;
}
.alert-error {
background: #fee2e2;
border: 1px solid #fecaca;
color: #dc2626;
}
.alert-error p {
margin: 0;
}
/* Form Group */
.form-group {
margin-bottom: 20px;
display: flex;
flex-direction: column;
}
.form-group label {
margin-bottom: 8px;
font-weight: 600;
color: #374151;
font-size: 14px;
}
.required {
color: #ef4444;
}
.input-wrapper {
display: flex;
flex-direction: column;
}
#id_device,
#id_quantity {
padding: 11px 13px;
border: 1.5px solid #d1d5db;
border-radius: 9px;
font-size: 14px;
font-family: inherit;
outline: none;
transition: all 0.25s ease;
background: #fff;
}
#id_device:focus,
#id_quantity:focus {
border-color: #4f46e5;
box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.15);
background: #f8f7ff;
}
#id_device:disabled {
background: #f3f4f6;
color: #9ca3af;
cursor: not-allowed;
}
#id_quantity::placeholder {
color: #9ca3af;
}
/* Help Text */
.help-text {
font-size: 13px;
color: #f59e0b;
margin-top: 6px;
padding: 8px 10px;
background: #fef3c7;
border-left: 3px solid #f59e0b;
border-radius: 4px;
}
/* Field Errors */
.field-error {
margin-top: 6px;
padding: 8px 10px;
background: #fee2e2;
border-left: 3px solid #ef4444;
border-radius: 4px;
}
.field-error p {
margin: 0;
color: #dc2626;
font-size: 13px;
font-weight: 500;
line-height: 1.4;
}
.field-error p:not(:last-child) {
margin-bottom: 4px;
}
/* Buttons */
.submit-btn {
width: 100%;
padding: 12px 0;
background: linear-gradient(135deg, #16a34a 0%, #15803d 100%);
color: #fff;
font-weight: 600;
font-size: 15px;
border: none;
border-radius: 10px;
cursor: pointer;
transition: all 0.25s ease;
margin-bottom: 12px;
}
.submit-btn:hover {
background: linear-gradient(135deg, #15803d 0%, #166534 100%);
transform: translateY(-2px);
box-shadow: 0 6px 16px rgba(22, 163, 74, 0.3);
}
.submit-btn:active {
transform: translateY(0);
}
.back-link {
display: block;
text-align: center;
padding: 10px 0;
color: #4f46e5;
text-decoration: none;
font-size: 14px;
font-weight: 500;
transition: all 0.2s ease;
border-radius: 8px;
}
.back-link:hover {
background: #f3f4f6;
color: #4338ca;
}
/* Responsive */
@media (max-width: 480px) {
.form-container {
padding: 24px 16px;
margin: 20px 10px;
}
.form-header h2 {
font-size: 20px;
}
.subtitle {
font-size: 13px;
}
}
</style>
{% endblock %}

View File

@@ -4,31 +4,93 @@
{% block content %}
<div class="form-container">
<h2>{{ title|default:"Yaratish" }}</h2>
<h2>{{ title|default:"O'yinchoq harakati yaratish" }}</h2>
<a href="{% url 'dashboard' %}" class="back-btn">
<svg xmlns="http://www.w3.org/2000/svg" class="icon" viewBox="0 0 24 24" fill="none" stroke="currentColor"
stroke-width="2">
<a href="{% url 'toy_movement_list' %}" class="back-btn">
<svg xmlns="http://www.w3.org/2000/svg" class="icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<path stroke-linecap="round" stroke-linejoin="round" d="M15 18l-6-6 6-6"/>
</svg>
Orqaga
</a>
{% if form.non_field_errors %}
<div class="alert alert-error" style="margin-bottom: 16px;">
{% for error in form.non_field_errors %}
<p>⚠️ {{ error }}</p>
{% endfor %}
</div>
{% endif %}
<form method="post" novalidate>
{% csrf_token %}
{% for field in form %}
<div class="form-group">
<label for="{{ field.id_for_label }}">{{ field.label }}</label>
{{ field }}
{% if field.help_text %}
<small class="help-text">{{ field.help_text }}</small>
{% endif %}
{% for error in field.errors %}
<div class="error">{{ error }}</div>
{% endfor %}
</div>
{% endfor %}
<!-- EMPLOYEE FORM (Device + Quantity only) -->
{% if request.user.role == "employee" %}
<!-- Device Field -->
<div class="form-group">
<label for="{{ form.device.id_for_label }}">{{ form.device.label }}</label>
{{ form.device }}
{% if form.device.errors %}
<div class="error">{{ form.device.errors.0 }}</div>
{% endif %}
</div>
<!-- Quantity Field -->
<div class="form-group">
<label for="{{ form.quantity.id_for_label }}">{{ form.quantity.label }}</label>
{{ form.quantity }}
{% if form.quantity.errors %}
<div class="error">{{ form.quantity.errors.0 }}</div>
{% endif %}
</div>
<!-- MANAGER/BUSINESSMAN FORM (Full form) -->
{% else %}
<!-- Movement Type Field -->
<div class="form-group">
<label for="{{ form.movement_type.id_for_label }}">{{ form.movement_type.label }}</label>
{{ form.movement_type }}
{% if form.movement_type.errors %}
<div class="error">{{ form.movement_type.errors.0 }}</div>
{% endif %}
</div>
<!-- From Warehouse Field -->
<div class="form-group">
<label for="{{ form.from_warehouse.id_for_label }}">{{ form.from_warehouse.label }}</label>
{{ form.from_warehouse }}
{% if form.from_warehouse.errors %}
<div class="error">{{ form.from_warehouse.errors.0 }}</div>
{% endif %}
</div>
<!-- To Warehouse Field (hidden by default) -->
<div class="form-group" id="to-warehouse-group" style="display: none;">
<label for="{{ form.to_warehouse.id_for_label }}">{{ form.to_warehouse.label }}</label>
{{ form.to_warehouse }}
{% if form.to_warehouse.errors %}
<div class="error">{{ form.to_warehouse.errors.0 }}</div>
{% endif %}
</div>
<!-- Device Field (hidden by default) -->
<div class="form-group" id="device-group" style="display: none;">
<label for="{{ form.device.id_for_label }}">{{ form.device.label }}</label>
{{ form.device }}
{% if form.device.errors %}
<div class="error">{{ form.device.errors.0 }}</div>
{% endif %}
</div>
<!-- Quantity Field -->
<div class="form-group">
<label for="{{ form.quantity.id_for_label }}">{{ form.quantity.label }}</label>
{{ form.quantity }}
{% if form.quantity.errors %}
<div class="error">{{ form.quantity.errors.0 }}</div>
{% endif %}
</div>
{% endif %}
<button type="submit" class="submit-btn">Saqlash</button>
</form>
@@ -79,10 +141,29 @@
height: 16px;
}
.alert {
padding: 12px 14px;
border-radius: 8px;
margin-bottom: 20px;
font-size: 14px;
line-height: 1.5;
}
.alert-error {
background: #fee2e2;
border: 1px solid #fecaca;
color: #dc2626;
}
.alert-error p {
margin: 0;
}
.form-group {
margin-bottom: 16px;
display: flex;
flex-direction: column;
width: 100%;
}
.form-group label {
@@ -94,11 +175,14 @@
.form-group input,
.form-group select {
padding: 10px 14px;
border: 1px solid #d1d5db;
border: 1.5px solid #d1d5db;
border-radius: 8px;
font-size: 14px;
outline: none;
transition: border-color 0.2s, box-shadow 0.2s;
font-family: inherit;
width: 100%;
box-sizing: border-box;
}
.form-group input:focus,
@@ -117,6 +201,10 @@
font-size: 12px;
color: #ef4444;
margin-top: 4px;
padding: 6px 8px;
background: #fee2e2;
border-left: 3px solid #ef4444;
border-radius: 4px;
}
.submit-btn {
@@ -146,49 +234,37 @@
<script>
document.addEventListener("DOMContentLoaded", function() {
const movementType = document.getElementById("id_movement_type");
const toWarehouse = document.getElementById("id_to_warehouse");
const device = document.getElementById("id_device");
const userRole = "{{ request.user.role }}";
function toggleFields() {
const value = movementType.value;
// Only show field toggling for manager/businessman
if (userRole !== "employee") {
const movementTypeSelect = document.getElementById("id_movement_type");
const toWarehouseGroup = document.getElementById("to-warehouse-group");
const deviceGroup = document.getElementById("device-group");
if (value === "from_warehouse") { // Ombordan -> Aparatga
toWarehouse.parentElement.style.display = "none";
device.parentElement.style.display = "";
} else if (value === "between_warehouses") { // Ombordan -> Omborga
device.parentElement.style.display = "none";
toWarehouse.parentElement.style.display = "";
} else {
toWarehouse.parentElement.style.display = "";
device.parentElement.style.display = "";
function toggleFields() {
const value = movementTypeSelect.value;
// Reset all to hidden
toWarehouseGroup.style.display = "none";
deviceGroup.style.display = "none";
// Show relevant fields based on movement type
if (value === "from_warehouse") {
// Ombordan -> Aparatga
deviceGroup.style.display = "block";
} else if (value === "between_warehouses") {
// Ombordan -> Omborga
toWarehouseGroup.style.display = "block";
}
}
}
// Update movement_type when to_warehouse is selected
if (toWarehouse) {
toWarehouse.addEventListener("change", function() {
if (toWarehouse.value) {
movementType.value = "between_warehouses";
toggleFields();
}
});
}
// Update movement_type when device is selected
if (device) {
device.addEventListener("change", function() {
if (device.value) {
movementType.value = "from_warehouse";
toggleFields();
}
});
}
// Run on page load
if (movementType) {
toggleFields();
movementType.addEventListener("change", toggleFields);
// Listen for changes
if (movementTypeSelect) {
movementTypeSelect.addEventListener("change", toggleFields);
// Initial toggle on page load
toggleFields();
}
}
});
</script>

View File

@@ -6,7 +6,7 @@
<div class="form-container">
<h2>{{ title|default:"Yaratish" }}</h2>
<a href="{% url 'dashboard' %}" class="back-btn">
<a href="{% url 'user_list' %}" class="back-btn">
<svg xmlns="http://www.w3.org/2000/svg" class="icon" viewBox="0 0 24 24" fill="none" stroke="currentColor"
stroke-width="2">
<path stroke-linecap="round" stroke-linejoin="round" d="M15 18l-6-6 6-6"/>
@@ -22,10 +22,10 @@
<label for="{{ field.id_for_label }}">{{ field.label }}</label>
{{ field }}
{% if field.help_text %}
<small class="help-text">{{ field.help_text }}</small>
<p class="help-text">{{ field.help_text }}</p>
{% endif %}
{% for error in field.errors %}
<div class="error">{{ error }}</div>
<div class="error">{{ error }}</div>
{% endfor %}
</div>
{% endfor %}
@@ -35,120 +35,121 @@
</div>
<style>
.form-container {
max-width: 480px;
margin: 40px auto;
background: #fff;
padding: 24px 28px;
border-radius: 12px;
box-shadow: 0 6px 18px rgba(0,0,0,0.06);
}
.form-container h2 {
margin-bottom: 16px;
font-size: 22px;
color: #111827;
text-align: center;
}
.back-btn {
display: inline-flex;
align-items: center;
gap: 6px;
margin-bottom: 20px;
padding: 8px 16px;
background: #f3f4f6;
color: #4f46e5;
text-decoration: none;
font-weight: 500;
font-size: 14px;
border-radius: 9999px;
box-shadow: 0 2px 6px rgba(0,0,0,0.08);
transition: all 0.2s ease;
}
.back-btn:hover {
background: #4f46e5;
color: #fff;
transform: translateY(-2px);
box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}
.back-btn .icon {
width: 16px;
height: 16px;
}
.form-group {
margin-bottom: 16px;
display: flex;
flex-direction: column !important;
}
.form-group label {
margin-bottom: 6px;
font-weight: 600;
color: #374151;
}
.form-group input,
.form-group select,
.form-group textarea {
padding: 10px 14px;
border: 1px solid #d1d5db;
border-radius: 8px;
font-size: 14px;
outline: none;
transition: border-color 0.2s, box-shadow 0.2s;
font-family: inherit;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
border-color: #4f46e5;
box-shadow: 0 0 0 2px rgba(79,70,229,0.2);
}
.help-text {
font-size: 12px;
color: #6b7280;
margin-top: 4px;
}
.error {
font-size: 12px;
color: #ef4444;
margin-top: 4px;
}
.submit-btn {
width: 100%;
padding: 10px 0;
background: #4f46e5;
color: #fff;
font-weight: 600;
font-size: 15px;
border: none;
border-radius: 10px;
cursor: pointer;
transition: background 0.2s, transform 0.2s;
}
.submit-btn:hover {
background: #4338ca;
transform: translateY(-1px);
}
@media (max-width: 480px) {
.form-container {
max-width: 480px;
margin: 0 auto;
background: #fff;
padding: 24px 28px;
border-radius: 12px;
box-shadow: 0 6px 18px rgba(0,0,0,0.06);
}
.form-container h2 {
margin-bottom: 16px;
font-size: 22px;
color: #111827;
text-align: center;
}
.back-btn {
display: inline-flex;
align-items: center;
gap: 6px;
margin-bottom: 20px;
padding: 8px 16px;
background: #f3f4f6;
color: #4f46e5;
text-decoration: none;
font-weight: 500;
font-size: 14px;
border-radius: 9999px; /* pill shape */
box-shadow: 0 2px 6px rgba(0,0,0,0.08);
transition: all 0.2s ease;
}
.back-btn:hover {
background: #4f46e5;
color: #fff;
transform: translateY(-2px);
box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}
.back-btn .icon {
width: 16px;
height: 16px;
}
.form-group {
margin-bottom: 16px;
display: flex;
flex-direction: column;
transition:all 0.2s ease;
}
.form-group label {
margin-bottom: 6px;
font-weight: 600;
color: #374151;
}
.form-group input,
.form-group select {
padding: 10px 14px;
border: 1px solid #d1d5db;
border-radius: 8px;
font-size: 14px;
outline: none;
transition: border-color 0.2s, box-shadow 0.2s;
}
.form-group input:focus,
.form-group select:focus {
border-color: #4f46e5;
box-shadow: 0 0 0 2px rgba(79,70,229,0.2);
}
.help-text {
font-size: 12px;
color: #6b7280;
margin-top: 4px;
}
.error {
font-size: 12px;
color: #ef4444;
margin-top: 4px;
}
.submit-btn {
width: 100%;
padding: 10px 0;
background: #4f46e5;
color: #fff;
font-weight: 600;
font-size: 15px;
border: none;
border-radius: 10px;
cursor: pointer;
transition: background 0.2s, transform 0.2s;
}
.submit-btn:hover {
background: #4338ca;
transform: translateY(-1px);
}
/* Responsive adjustments */
@media (max-width: 480px) {
.form-container {
padding: 20px 16px;
}
padding: 20px 16px;
}
}
</style>
<script>
document.addEventListener("DOMContentLoaded", function () {
const roleField = document.getElementById("id_role");
const regionGroup = document.getElementById("id_region")?.closest(".form-group");
const warehouseGroup = document.getElementById("id_warehouse")?.closest(".form-group");
@@ -158,15 +159,23 @@ document.addEventListener("DOMContentLoaded", function () {
const role = roleField.value;
// Manager
// Hide everything first
if (regionGroup) regionGroup.style.display = "none";
if (warehouseGroup) warehouseGroup.style.display = "none";
// Manager - shows region
// Employee - shows warehouse only
if (role === "manager") {
if (regionGroup) regionGroup.style.display = "block";
if (warehouseGroup) warehouseGroup.style.display = "none";
if (regionGroup) regionGroup.style.display = "flex";
}
// Employee
if (role === "employee") {
if (regionGroup) regionGroup.style.display = "none";
if (warehouseGroup) warehouseGroup.style.display = "flex";
}
// Businessman - shows both region and warehouse
if (role === "businessman") {
if (regionGroup) regionGroup.style.display = "block";
if (warehouseGroup) warehouseGroup.style.display = "block";
}
}
@@ -179,6 +188,4 @@ document.addEventListener("DOMContentLoaded", function () {
});
</script>
{% endblock %}
{% endblock %}

View File

@@ -1,10 +1,120 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
{% extends "base.html" %}
</body>
</html>
{% block title %}{{ title }}{% endblock %}
{% block content %}
<div class="page">
<div class="card">
<a href="{% url 'warehouse_list' %}" class="back">
← Orqaga
</a>
<h1>{{ title }}</h1>
<form method="post">
{% csrf_token %}
<div class="field">
<label for="{{ form.name.id_for_label }}">Nomi</label>
{{ form.name }}
{{ form.name.errors }}
</div>
<div class="field">
<label for="{{ form.region.id_for_label }}">Hudud</label>
{{ form.region }}
{{ form.region.errors }}
</div>
<div class="field">
<label for="{{ form.toys_count.id_for_label }}">O'yinchoqlar Soni</label>
{{ form.toys_count }}
{{ form.toys_count.errors }}
</div>
<button type="submit" class="submit-btn">Saqlash</button>
</form>
</div>
</div>
<style>
body, html {
overflow: hidden;
margin: 0;
padding: 0;
height: 100vh;
}
.page {
height: 100vh;
width: 100vw;
background: #f6f7fb;
display: flex;
justify-content: center;
align-items: flex-start;
padding: 40px 20px;
overflow: hidden;
box-sizing: border-box;
}
.card {
width: 100%;
max-width: 480px;
background: white;
padding: 32px;
border-radius: 16px;
box-shadow: 0 10px 30px rgba(0,0,0,.08);
}
.card h1 {
text-align: center;
margin-bottom: 24px;
margin-top: 0;
}
.back {
display: inline-block;
margin-bottom: 20px;
text-decoration: none;
color: #4f46e5;
font-weight: 500;
}
.field {
margin-bottom: 18px;
}
.field label {
display: block;
margin-bottom: 6px;
font-weight: 600;
}
.field input,
.field select {
width: 100%;
padding: 12px;
border-radius: 10px;
border: 1px solid #d1d5db;
box-sizing: border-box;
}
.submit-btn {
width: 100%;
padding: 14px;
background: #4f46e5;
color: white;
border: none;
border-radius: 12px;
font-size: 16px;
font-weight: 600;
cursor: pointer;
}
.submit-btn:hover {
background: #4338ca;
}
</style>
{% endblock %}