fix print and preview quote and add broker to req and complete company model.
This commit is contained in:
parent
5ce94214d5
commit
246a2c0759
19 changed files with 872 additions and 260 deletions
|
@ -33,9 +33,9 @@ class ProfileAdmin(admin.ModelAdmin):
|
|||
|
||||
@admin.register(Company)
|
||||
class CompanyAdmin(admin.ModelAdmin):
|
||||
list_display = ['name', 'logo', 'signature', 'address', 'phone']
|
||||
list_display = ['name', 'logo', 'signature', 'address', 'phone', 'broker']
|
||||
prepopulated_fields = {'slug': ('name',)}
|
||||
search_fields = ['name', 'address', 'phone']
|
||||
list_filter = ['is_active']
|
||||
list_filter = ['is_active', 'broker']
|
||||
date_hierarchy = 'created'
|
||||
ordering = ['-created']
|
20
accounts/migrations/0002_company_broker.py
Normal file
20
accounts/migrations/0002_company_broker.py
Normal file
|
@ -0,0 +1,20 @@
|
|||
# Generated by Django 5.2.4 on 2025-09-07 13:43
|
||||
|
||||
import django.db.models.deletion
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('accounts', '0001_initial'),
|
||||
('locations', '0003_remove_broker_company'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='company',
|
||||
name='broker',
|
||||
field=models.OneToOneField(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='company', to='locations.broker', verbose_name='کارگزار'),
|
||||
),
|
||||
]
|
|
@ -0,0 +1,34 @@
|
|||
# Generated by Django 5.2.4 on 2025-09-07 14:11
|
||||
|
||||
import django.core.validators
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('accounts', '0002_company_broker'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='company',
|
||||
name='account_number',
|
||||
field=models.CharField(blank=True, max_length=20, null=True, validators=[django.core.validators.RegexValidator(code='invalid_account_number', message='شماره حساب باید فقط شامل اعداد باشد.', regex='^\\d+$')], verbose_name='شماره حساب'),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='company',
|
||||
name='bank_name',
|
||||
field=models.CharField(blank=True, choices=[('mellat', 'بانک ملت'), ('saman', 'بانک سامان'), ('parsian', 'بانک پارسیان'), ('sina', 'بانک سینا'), ('tejarat', 'بانک تجارت'), ('tosee', 'بانک توسعه'), ('iran_zamin', 'بانک ایران زمین'), ('meli', 'بانک ملی'), ('saderat', 'بانک توسعه صادرات'), ('iran_zamin', 'بانک ایران زمین'), ('refah', 'بانک رفاه'), ('eghtesad_novin', 'بانک اقتصاد نوین'), ('pasargad', 'بانک پاسارگاد'), ('other', 'سایر')], max_length=255, null=True, verbose_name='نام بانک'),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='company',
|
||||
name='card_number',
|
||||
field=models.CharField(blank=True, max_length=16, null=True, validators=[django.core.validators.RegexValidator(code='invalid_card_number', message='شماره کارت باید فقط شامل اعداد باشد.', regex='^\\d+$')], verbose_name='شماره کارت'),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='company',
|
||||
name='sheba_number',
|
||||
field=models.CharField(blank=True, max_length=30, null=True, verbose_name='شماره شبا'),
|
||||
),
|
||||
]
|
18
accounts/migrations/0004_company_branch_name.py
Normal file
18
accounts/migrations/0004_company_branch_name.py
Normal file
|
@ -0,0 +1,18 @@
|
|||
# Generated by Django 5.2.4 on 2025-09-07 14:12
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('accounts', '0003_company_account_number_company_bank_name_and_more'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='company',
|
||||
name='branch_name',
|
||||
field=models.CharField(blank=True, max_length=255, null=True, verbose_name='شعبه بانک'),
|
||||
),
|
||||
]
|
|
@ -181,11 +181,82 @@ class Profile(BaseModel):
|
|||
|
||||
|
||||
class Company(NameSlugModel):
|
||||
logo = models.ImageField(upload_to='companies/logos', null=True, blank=True, verbose_name='لوگوی شرکت')
|
||||
signature = models.ImageField(upload_to='companies/signatures', null=True, blank=True, verbose_name='امضای شرکت')
|
||||
address = models.TextField(null=True, blank=True, verbose_name='آدرس')
|
||||
phone = models.CharField(max_length=11, null=True, blank=True, verbose_name='شماره تماس')
|
||||
|
||||
logo = models.ImageField(
|
||||
upload_to='companies/logos',
|
||||
null=True,
|
||||
blank=True,
|
||||
verbose_name='لوگوی شرکت'
|
||||
)
|
||||
signature = models.ImageField(
|
||||
upload_to='companies/signatures',
|
||||
null=True,
|
||||
blank=True,
|
||||
verbose_name='امضای شرکت'
|
||||
)
|
||||
address = models.TextField(
|
||||
null=True,
|
||||
blank=True,
|
||||
verbose_name='آدرس'
|
||||
)
|
||||
phone = models.CharField(
|
||||
max_length=11,
|
||||
null=True,
|
||||
blank=True,
|
||||
verbose_name='شماره تماس'
|
||||
)
|
||||
broker = models.OneToOneField(
|
||||
Broker,
|
||||
on_delete=models.SET_NULL,
|
||||
verbose_name="کارگزار",
|
||||
null=True,
|
||||
blank=True,
|
||||
related_name='company'
|
||||
)
|
||||
card_number = models.CharField(
|
||||
max_length=16,
|
||||
null=True,
|
||||
verbose_name="شماره کارت",
|
||||
blank=True,
|
||||
validators=[
|
||||
RegexValidator(
|
||||
regex=r'^\d+$',
|
||||
message='شماره کارت باید فقط شامل اعداد باشد.',
|
||||
code='invalid_card_number'
|
||||
)
|
||||
]
|
||||
)
|
||||
account_number = models.CharField(
|
||||
max_length=20,
|
||||
null=True,
|
||||
verbose_name="شماره حساب",
|
||||
blank=True,
|
||||
validators=[
|
||||
RegexValidator(
|
||||
regex=r'^\d+$',
|
||||
message='شماره حساب باید فقط شامل اعداد باشد.',
|
||||
code='invalid_account_number'
|
||||
)
|
||||
]
|
||||
)
|
||||
sheba_number = models.CharField(
|
||||
max_length=30,
|
||||
null=True,
|
||||
verbose_name="شماره شبا",
|
||||
blank=True,
|
||||
)
|
||||
bank_name = models.CharField(
|
||||
max_length=255,
|
||||
choices=BANK_CHOICES,
|
||||
null=True,
|
||||
verbose_name="نام بانک",
|
||||
blank=True
|
||||
)
|
||||
branch_name = models.CharField(
|
||||
max_length=255,
|
||||
null=True,
|
||||
verbose_name="شعبه بانک",
|
||||
blank=True
|
||||
)
|
||||
class Meta:
|
||||
verbose_name = 'شرکت'
|
||||
verbose_name_plural = 'شرکتها'
|
||||
|
|
BIN
db.sqlite3
BIN
db.sqlite3
Binary file not shown.
|
@ -24,6 +24,10 @@
|
|||
|
||||
{% block content %}
|
||||
{% include '_toasts.html' %}
|
||||
|
||||
<!-- Instance Info Modal -->
|
||||
{% instance_info_modal instance %}
|
||||
|
||||
{% csrf_token %}
|
||||
<div class="container-xxl flex-grow-1 container-p-y">
|
||||
<div class="row">
|
||||
|
@ -32,15 +36,17 @@
|
|||
<div>
|
||||
<h4 class="mb-1">{{ step.name }}: {{ instance.process.name }}</h4>
|
||||
<small class="text-muted d-block">
|
||||
اشتراک آب: {{ instance.well.water_subscription_number|default:"-" }}
|
||||
| نماینده: {{ instance.representative.profile.national_code|default:"-" }}
|
||||
{% instance_info instance %}
|
||||
</small>
|
||||
</div>
|
||||
<div class="d-flex gap-2">
|
||||
<a href="{% url 'invoices:quote_print' instance.id %}" target="_blank" class="btn btn-outline-secondary">
|
||||
<i class="bx bx-printer"></i> پرینت
|
||||
</a>
|
||||
<a href="{% url 'processes:request_list' %}" class="btn btn-outline-secondary">بازگشت</a>
|
||||
<a href="{% url 'processes:request_list' %}" class="btn btn-outline-secondary">
|
||||
<i class="bx bx-chevron-right bx-sm ms-sm-n2"></i>
|
||||
بازگشت
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
@ -50,100 +56,116 @@
|
|||
<!-- Invoice Preview Card -->
|
||||
<div class="card invoice-preview-card mt-4 border">
|
||||
<div class="card-body">
|
||||
<div class="d-flex justify-content-between flex-xl-row flex-md-column flex-sm-row flex-column p-sm-3 p-0">
|
||||
<div class="d-flex justify-content-between flex-xl-row flex-md-column flex-sm-row flex-column p-sm-3 p-0 align-items-center">
|
||||
<div class="mb-xl-0 mb-4">
|
||||
<div class="d-flex svg-illustration mb-3 gap-2">
|
||||
<span class="app-brand-logo demo">
|
||||
<svg width="25" viewBox="0 0 25 42" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
<defs>
|
||||
<path d="M13.7918663,0.358365126 L3.39788168,7.44174259 C0.566865006,9.69408886 -0.379795268,12.4788597 0.557900856,15.7960551 C0.68998853,16.2305145 1.09562888,17.7872135 3.12357076,19.2293357 C3.8146334,19.7207684 5.32369333,20.3834223 7.65075054,21.2172976 L7.59773219,21.2525164 L2.63468769,24.5493413 C0.445452254,26.3002124 0.0884951797,28.5083815 1.56381646,31.1738486 C2.83770406,32.8170431 5.20850219,33.2640127 7.09180128,32.5391577 C8.347334,32.0559211 11.4559176,30.0011079 16.4175519,26.3747182 C18.0338572,24.4997857 18.6973423,22.4544883 18.4080071,20.2388261 C17.963753,17.5346866 16.1776345,15.5799961 13.0496516,14.3747546 L10.9194936,13.4715819 L18.6192054,7.984237 L13.7918663,0.358365126 Z" id="path-1"></path>
|
||||
<path d="M5.47320593,6.00457225 C4.05321814,8.216144 4.36334763,10.0722806 6.40359441,11.5729822 C8.61520715,12.571656 10.0999176,13.2171421 10.8577257,13.5094407 L15.5088241,14.433041 L18.6192054,7.984237 C15.5364148,3.11535317 13.9273018,0.573395879 13.7918663,0.358365126 C13.5790555,0.511491653 10.8061687,2.3935607 5.47320593,6.00457225 Z" id="path-3"></path>
|
||||
<path d="M7.50063644,21.2294429 L12.3234468,23.3159332 C14.1688022,24.7579751 14.397098,26.4880487 13.008334,28.506154 C11.6195701,30.5242593 10.3099883,31.790241 9.07958868,32.3040991 C5.78142938,33.4346997 4.13234973,34 4.13234973,34 C4.13234973,34 2.75489982,33.0538207 2.37032616e-14,31.1614621 C-0.55822714,27.8186216 -0.55822714,26.0572515 -4.05231404e-15,25.8773518 C0.83734071,25.6075023 2.77988457,22.8248993 3.3049379,22.52991 C3.65497346,22.3332504 5.05353963,21.8997614 7.50063644,21.2294429 Z" id="path-4"></path>
|
||||
<path d="M20.6,7.13333333 L25.6,13.8 C26.2627417,14.6836556 26.0836556,15.9372583 25.2,16.6 C24.8538077,16.8596443 24.4327404,17 24,17 L14,17 C12.8954305,17 12,16.1045695 12,15 C12,14.5672596 12.1403557,14.1461923 12.4,13.8 L17.4,7.13333333 C18.0627417,6.24967773 19.3163444,6.07059163 20.2,6.73333333 C20.3516113,6.84704183 20.4862915,6.981722 20.6,7.13333333 Z" id="path-5"></path>
|
||||
</defs>
|
||||
<g id="g-app-brand" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
|
||||
<g id="Brand-Logo" transform="translate(-27.000000, -15.000000)">
|
||||
<g id="Icon" transform="translate(27.000000, 15.000000)">
|
||||
<g id="Mask" transform="translate(0.000000, 8.000000)">
|
||||
<mask id="mask-2" fill="white">
|
||||
<use xlink:href="#path-1"></use>
|
||||
</mask>
|
||||
<use fill="#696cff" xlink:href="#path-1"></use>
|
||||
<g id="Path-3" mask="url(#mask-2)">
|
||||
<use fill="#696cff" xlink:href="#path-3"></use>
|
||||
<use fill-opacity="0.2" fill="#FFFFFF" xlink:href="#path-3"></use>
|
||||
</g>
|
||||
<g id="Path-4" mask="url(#mask-2)">
|
||||
<use fill="#696cff" xlink:href="#path-4"></use>
|
||||
<use fill-opacity="0.2" fill="#FFFFFF" xlink:href="#path-4"></use>
|
||||
</g>
|
||||
</g>
|
||||
<g id="Triangle" transform="translate(19.000000, 11.000000) rotate(-300.000000) translate(-19.000000, -11.000000) ">
|
||||
<use fill="#696cff" xlink:href="#path-5"></use>
|
||||
<use fill-opacity="0.2" fill="#FFFFFF" xlink:href="#path-5"></use>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
</svg>
|
||||
</span>
|
||||
<span class="app-brand-text demo text-body fw-bold">شرکت آب منطقهای</span>
|
||||
<!-- Company Logo & Info -->
|
||||
<div class="d-flex align-items-center">
|
||||
<div class="avatar avatar-lg me-3">
|
||||
<span class="avatar-initial rounded bg-label-primary">
|
||||
{% if instance.broker.company %}
|
||||
<img src="{{ instance.broker.company.logo.url }}" alt="لوگوی شرکت" style="max-height:80px;">
|
||||
{% else %}
|
||||
<i class="bx bx-buildings bx-md"></i>
|
||||
{% endif %}
|
||||
</span>
|
||||
</div>
|
||||
<div>
|
||||
<h5 class="mb-1">
|
||||
{% if instance.broker.company %}
|
||||
{{ instance.broker.company.name }}
|
||||
{% else %}
|
||||
شرکت آب منطقهای
|
||||
{% endif %}
|
||||
</h5>
|
||||
{% if instance.broker.company %}
|
||||
<div class="text-muted small">
|
||||
{% if instance.broker.company.address %}
|
||||
<div><i class="bx bx-map me-1"></i>{{ instance.broker.company.address }}</div>
|
||||
{% endif %}
|
||||
{% if instance.broker.affairs.county.city.name %}
|
||||
<div><i class="bx bx-current-location me-1"></i>{{ instance.broker.affairs.county.city.name }}، ایران</div>
|
||||
{% endif %}
|
||||
{% if instance.broker.company.phone %}
|
||||
<div><i class="bx bx-phone me-1"></i>{{ instance.broker.company.phone }}</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
<p class="mb-1">دفتر مرکزی، خیابان اصلی</p>
|
||||
<p class="mb-1">تهران، ایران</p>
|
||||
<p class="mb-0">۰۲۱-۱۲۳۴۵۶۷۸</p>
|
||||
</div>
|
||||
<div>
|
||||
<h4>پیشفاکتور #{{ quote.name }}</h4>
|
||||
<div class="mb-2">
|
||||
<span class="me-1">تاریخ صدور:</span>
|
||||
<span class="fw-medium">{{ quote.jcreated }}</span>
|
||||
<!-- Invoice Details -->
|
||||
<div class="text-center">
|
||||
<div class="mb-3">
|
||||
<h5 class="text-body">#{{ quote.name }}</h5>
|
||||
</div>
|
||||
<div>
|
||||
<span class="me-1">معتبر تا:</span>
|
||||
<span class="fw-medium">{{ quote.valid_until|date:"Y/m/d" }}</span>
|
||||
<div class="invoice-details">
|
||||
<div class="d-flex justify-content-end align-items-center mb-2">
|
||||
<span class="text-muted me-2">تاریخ صدور:</span>
|
||||
<span class="fw-medium text-body">{{ quote.jcreated_date }}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<hr class="my-0">
|
||||
<div class="card-body">
|
||||
<div class="row p-sm-3 p-0">
|
||||
<div class="col-xl-6 col-md-12 col-sm-5 col-12 mb-xl-0 mb-md-4 mb-sm-0 mb-4">
|
||||
<h6 class="pb-2">صادر شده برای:</h6>
|
||||
<p class="mb-1">{{ quote.customer.get_full_name }}</p>
|
||||
{% if instance.representative.profile %}
|
||||
<p class="mb-1">کد ملی: {{ instance.representative.profile.national_code }}</p>
|
||||
<p class="mb-1">{{ instance.representative.profile.address|default:"آدرس نامشخص" }}</p>
|
||||
<p class="mb-1">{{ instance.representative.profile.phone_number_1|default:"" }}</p>
|
||||
{% endif %}
|
||||
<div class="card-body py-1">
|
||||
<div class="row">
|
||||
<div class="col-xl-6 col-md-12 col-sm-6 col-12 mb-3">
|
||||
<div class="">
|
||||
<div class="card-body p-3">
|
||||
<h6 class="card-title text-primary mb-2">
|
||||
<i class="bx bx-user me-1"></i>اطلاعات مشترک
|
||||
</h6>
|
||||
<div class="d-flex gap-2 mb-1">
|
||||
<span class="text-muted small">نام:</span>
|
||||
<span class="fw-medium small">{{ quote.customer.get_full_name }}</span>
|
||||
</div>
|
||||
{% if instance.representative.profile.national_code %}
|
||||
<div class="d-flex gap-2 mb-1">
|
||||
<span class="text-muted small">کد ملی:</span>
|
||||
<span class="fw-medium small">{{ instance.representative.profile.national_code }}</span>
|
||||
</div>
|
||||
{% endif %}
|
||||
{% if instance.representative.profile.phone_number_1 %}
|
||||
<div class="d-flex gap-2 mb-1">
|
||||
<span class="text-muted small">تلفن:</span>
|
||||
<span class="fw-medium small">{{ instance.representative.profile.phone_number_1 }}</span>
|
||||
</div>
|
||||
{% endif %}
|
||||
{% if instance.representative.profile.address %}
|
||||
<div class="d-flex gap-2">
|
||||
<span class="text-muted small">آدرس:</span>
|
||||
<span class="fw-medium small">{{ instance.representative.profile.address }}</span>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-xl-6 col-md-12 col-sm-7 col-12">
|
||||
<h6 class="pb-2">اطلاعات چاه:</h6>
|
||||
<table>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td class="pe-3">شماره اشتراک آب:</td>
|
||||
<td>{{ instance.well.water_subscription_number }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="pe-3">شماره اشتراک برق:</td>
|
||||
<td>{{ instance.well.electricity_subscription_number|default:"-" }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="pe-3">سریال کنتور:</td>
|
||||
<td>{{ instance.well.water_meter_serial_number|default:"-" }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="pe-3">قدرت چاه:</td>
|
||||
<td>{{ instance.well.well_power|default:"-" }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="pe-3">کد درخواست:</td>
|
||||
<td>{{ instance.code }}</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<div class="col-xl-6 col-md-12 col-sm-6 col-12 mb-3">
|
||||
<div class="border-0 bg-light">
|
||||
<div class="card-body p-3">
|
||||
<h6 class="card-title text-primary mb-2">
|
||||
<i class="bx bx-droplet me-1"></i>اطلاعات چاه
|
||||
</h6>
|
||||
<div class="d-flex gap-2 mb-1">
|
||||
<span class="text-muted small">شماره اشتراک آب:</span>
|
||||
<span class="fw-medium small">{{ instance.well.water_subscription_number }}</span>
|
||||
</div>
|
||||
<div class="d-flex gap-2 mb-1">
|
||||
<span class="text-muted small">شماره اشتراک برق:</span>
|
||||
<span class="fw-medium small">{{ instance.well.electricity_subscription_number|default:"-" }}</span>
|
||||
</div>
|
||||
<div class="d-flex gap-2 mb-1">
|
||||
<span class="text-muted small">سریال کنتور:</span>
|
||||
<span class="fw-medium small">{{ instance.well.water_meter_serial_number|default:"-" }}</span>
|
||||
</div>
|
||||
<div class="d-flex gap-2">
|
||||
<span class="text-muted small">قدرت چاه:</span>
|
||||
<span class="fw-medium small">{{ instance.well.well_power|default:"-" }}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -170,11 +192,6 @@
|
|||
{% endfor %}
|
||||
<tr>
|
||||
<td colspan="3" class="align-top px-4 py-5">
|
||||
<p class="mb-2">
|
||||
<span class="me-1 fw-medium">صادر کننده:</span>
|
||||
<span>{{ quote.created_by.get_full_name }}</span>
|
||||
</p>
|
||||
<span>با تشکر از انتخاب شما</span>
|
||||
</td>
|
||||
<td class="text-end px-4 py-5">
|
||||
<p class="mb-2">جمع کل:</p>
|
||||
|
@ -193,6 +210,72 @@
|
|||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<!-- Footer Information -->
|
||||
<div class="card-body border-top">
|
||||
<div class="row">
|
||||
<div class="col-md-8">
|
||||
<h6 class="mb-3">شرایط و ضوابط:</h6>
|
||||
<ul class="list-unstyled mb-0">
|
||||
<li class="mb-2">
|
||||
<i class="bx bx-time-five text-muted me-2"></i>
|
||||
اعتبار پیشفاکتور صادر شده ۴۸ ساعت پس از تاریخ صدور میباشد
|
||||
</li>
|
||||
<li class="mb-2">
|
||||
<i class="bx bx-money text-muted me-2"></i>
|
||||
مبلغ فوق به صورت علیالحساب دریافت میگردد
|
||||
</li>
|
||||
<li class="mb-0">
|
||||
<i class="bx bx-info-circle text-muted me-2"></i>
|
||||
این برگه صرفاً جهت اعلام قیمت بوده و ارزش قانونی دیگری ندارد
|
||||
</li>
|
||||
{% if instance.broker.company.signature %}
|
||||
<li class="mb-0 text-start mt-4 ms-5">
|
||||
<img src="{{ instance.broker.company.signature.url }}" alt="امضای شرکت" style="height: 200px;">
|
||||
</li>
|
||||
{% endif %}
|
||||
</ul>
|
||||
</div>
|
||||
{% if instance.broker.company %}
|
||||
<div class="col-md-4">
|
||||
<h6 class="mb-3">اطلاعات پرداخت:</h6>
|
||||
<div class="d-flex flex-column gap-2">
|
||||
{% if instance.broker.company.card_number %}
|
||||
<div>
|
||||
<small class="text-muted">شماره کارت:</small>
|
||||
<div class="fw-medium">{{ instance.broker.company.card_number }}</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
{% if instance.broker.company.account_number %}
|
||||
<div>
|
||||
<small class="text-muted">شماره حساب:</small>
|
||||
<div class="fw-medium">{{ instance.broker.company.account_number }}</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
{% if instance.broker.company.sheba_number %}
|
||||
<div>
|
||||
<small class="text-muted">شماره شبا:</small>
|
||||
<div class="fw-medium">{{ instance.broker.company.sheba_number }}</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
{% if instance.broker.company.bank_name %}
|
||||
<div>
|
||||
<small class="text-muted">بانک:</small>
|
||||
<div class="fw-medium">{{ instance.broker.company.get_bank_name_display }}</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
{% if instance.broker.company.branch_name %}
|
||||
<div>
|
||||
<small class="text-muted">شعبه:</small>
|
||||
<div class="fw-medium">{{ instance.broker.company.branch_name }}</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{% if quote.notes %}
|
||||
|
|
|
@ -5,8 +5,24 @@
|
|||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>پیشفاکتور {{ quote.name }} - {{ instance.code }}</title>
|
||||
|
||||
<!-- Bootstrap CSS -->
|
||||
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
|
||||
{% load static %}
|
||||
{% load humanize %}
|
||||
|
||||
<!-- Fonts (match base) -->
|
||||
<link rel="preconnect" href="https://fonts.googleapis.com">
|
||||
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
||||
<link href="https://fonts.googleapis.com/css2?family=Public+Sans:ital,wght@0,300;0,400;0,500;0,600;0,700;1,300;1,400;1,500;1,600;1,700&display=swap" rel="stylesheet">
|
||||
|
||||
<!-- Icons (optional) -->
|
||||
<link rel="stylesheet" href="{% static 'assets/vendor/fonts/boxicons.css' %}">
|
||||
<link rel="stylesheet" href="{% static 'assets/vendor/fonts/fontawesome.css' %}">
|
||||
<link rel="stylesheet" href="{% static 'assets/vendor/fonts/flag-icons.css' %}">
|
||||
|
||||
<!-- Core CSS (same as preview) -->
|
||||
<link rel="stylesheet" href="{% static 'assets/vendor/css/rtl/core.css' %}">
|
||||
<link rel="stylesheet" href="{% static 'assets/vendor/css/rtl/theme-default.css' %}">
|
||||
<link rel="stylesheet" href="{% static 'assets/css/demo.css' %}">
|
||||
<link rel="stylesheet" href="{% static 'assets/css/persian-fonts.css' %}">
|
||||
|
||||
<style>
|
||||
@page {
|
||||
|
@ -14,11 +30,7 @@
|
|||
margin: 1cm;
|
||||
}
|
||||
|
||||
body {
|
||||
font-family: 'Vazirmatn', sans-serif;
|
||||
font-size: 14px;
|
||||
line-height: 1.6;
|
||||
}
|
||||
/* Inherit project fonts and sizes from core.css/persian-fonts */
|
||||
|
||||
@media print {
|
||||
body { print-color-adjust: exact; }
|
||||
|
@ -27,7 +39,7 @@
|
|||
}
|
||||
|
||||
.invoice-header {
|
||||
border-bottom: 2px solid #696cff;
|
||||
border-bottom: 1px solid #dee2e6;
|
||||
padding-bottom: 20px;
|
||||
margin-bottom: 30px;
|
||||
}
|
||||
|
@ -89,195 +101,159 @@
|
|||
</head>
|
||||
<body>
|
||||
<div class="container-fluid">
|
||||
<!-- Print Button (hidden in print) -->
|
||||
<div class="no-print mb-3">
|
||||
<button onclick="window.print()" class="btn btn-primary">
|
||||
<i class="bi bi-printer"></i> پرینت
|
||||
</button>
|
||||
<button onclick="window.close()" class="btn btn-secondary">
|
||||
بستن
|
||||
</button>
|
||||
</div>
|
||||
<!-- Auto print: buttons removed -->
|
||||
|
||||
<!-- Invoice Header -->
|
||||
<!-- Invoice Header (compact, matches preview) -->
|
||||
<div class="invoice-header">
|
||||
<div class="row">
|
||||
<div class="col-6">
|
||||
<div class="company-logo mb-3">
|
||||
شرکت آب منطقهای
|
||||
<div class="row align-items-center">
|
||||
<div class="col-6 d-flex align-items-center">
|
||||
<div class="me-3" style="width:64px;height:64px;display:flex;align-items:center;justify-content:center;background:#eef2ff;border-radius:8px;">
|
||||
{% if instance.broker.company and instance.broker.company.logo %}
|
||||
<img src="{{ instance.broker.company.logo.url }}" alt="لوگو" style="max-height:58px;max-width:120px;">
|
||||
{% else %}
|
||||
<span class="company-logo">شرکت</span>
|
||||
{% endif %}
|
||||
</div>
|
||||
<div class="company-info">
|
||||
<p class="mb-1">دفتر مرکزی، خیابان اصلی</p>
|
||||
<p class="mb-1">تهران، ایران</p>
|
||||
<p class="mb-1">تلفن: ۰۲۱-۱۲۳۴۵۶۷۸</p>
|
||||
<p class="mb-0">ایمیل: info@watercompany.ir</p>
|
||||
<div>
|
||||
{% if instance.broker.company %}
|
||||
{{ instance.broker.company.name }}
|
||||
{% endif %}
|
||||
{% if instance.broker.company %}
|
||||
<div class="text-muted small">
|
||||
{% if instance.broker.company.address %}
|
||||
<div>{{ instance.broker.company.address }}</div>
|
||||
{% endif %}
|
||||
{% if instance.broker.affairs.county.city.name %}
|
||||
<div>{{ instance.broker.affairs.county.city.name }}، ایران</div>
|
||||
{% endif %}
|
||||
{% if instance.broker.company.phone %}
|
||||
<div>تلفن: {{ instance.broker.company.phone }}</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-6 text-end">
|
||||
<div class="invoice-title">پیشفاکتور</div>
|
||||
<div class="mt-3">
|
||||
<table class="info-table">
|
||||
<tr>
|
||||
<td><strong>شماره پیشفاکتور:</strong></td>
|
||||
<td>{{ quote.name }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>کد درخواست:</strong></td>
|
||||
<td>{{ instance.code }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>تاریخ صدور:</strong></td>
|
||||
<td>{{ quote.created|date:"Y/m/d" }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>معتبر تا:</strong></td>
|
||||
<td>{{ quote.valid_until|date:"Y/m/d" }}</td>
|
||||
</tr>
|
||||
</table>
|
||||
<div class="mt-2">
|
||||
<div><strong>#{{ quote.name }}</strong></div>
|
||||
<div class="text-muted small">تاریخ صدور: {{ quote.jcreated_date }}</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Customer & Well Info -->
|
||||
<div class="row mb-4">
|
||||
<!-- Customer & Well Info (compact to match preview) -->
|
||||
<div class="row mb-3">
|
||||
<div class="col-6">
|
||||
<h6 class="fw-bold mb-3">مشخصات مشترک:</h6>
|
||||
<table class="info-table">
|
||||
<tr>
|
||||
<td><strong>نام و نام خانوادگی:</strong></td>
|
||||
<td>{{ quote.customer.get_full_name }}</td>
|
||||
</tr>
|
||||
{% if instance.representative.profile %}
|
||||
<tr>
|
||||
<td><strong>کد ملی:</strong></td>
|
||||
<td>{{ instance.representative.profile.national_code }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>تلفن:</strong></td>
|
||||
<td>{{ instance.representative.profile.phone_number_1|default:"-" }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>آدرس:</strong></td>
|
||||
<td>{{ instance.representative.profile.address|default:"آدرس نامشخص" }}</td>
|
||||
</tr>
|
||||
{% endif %}
|
||||
</table>
|
||||
<h6 class="fw-bold mb-2">اطلاعات مشترک</h6>
|
||||
<div class="small mb-1"><span class="text-muted">نام:</span> {{ quote.customer.get_full_name }}</div>
|
||||
{% if instance.representative.profile and instance.representative.profile.national_code %}
|
||||
<div class="small mb-1"><span class="text-muted">کد ملی:</span> {{ instance.representative.profile.national_code }}</div>
|
||||
{% endif %}
|
||||
{% if instance.representative.profile and instance.representative.profile.phone_number_1 %}
|
||||
<div class="small mb-1"><span class="text-muted">تلفن:</span> {{ instance.representative.profile.phone_number_1 }}</div>
|
||||
{% endif %}
|
||||
{% if instance.representative.profile and instance.representative.profile.address %}
|
||||
<div class="small"><span class="text-muted">آدرس:</span> {{ instance.representative.profile.address }}</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
<div class="col-6">
|
||||
<h6 class="fw-bold mb-3">مشخصات چاه:</h6>
|
||||
<table class="info-table">
|
||||
<tr>
|
||||
<td><strong>شماره اشتراک آب:</strong></td>
|
||||
<td>{{ instance.well.water_subscription_number }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>شماره اشتراک برق:</strong></td>
|
||||
<td>{{ instance.well.electricity_subscription_number|default:"-" }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>سریال کنتور:</strong></td>
|
||||
<td>{{ instance.well.water_meter_serial_number|default:"-" }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>قدرت چاه:</strong></td>
|
||||
<td>{{ instance.well.well_power|default:"-" }}</td>
|
||||
</tr>
|
||||
</table>
|
||||
<h6 class="fw-bold mb-2">اطلاعات چاه</h6>
|
||||
<div class="small mb-1"><span class="text-muted">شماره اشتراک آب:</span> {{ instance.well.water_subscription_number }}</div>
|
||||
<div class="small mb-1"><span class="text-muted">شماره اشتراک برق:</span> {{ instance.well.electricity_subscription_number|default:"-" }}</div>
|
||||
<div class="small mb-1"><span class="text-muted">سریال کنتور:</span> {{ instance.well.water_meter_serial_number|default:"-" }}</div>
|
||||
<div class="small"><span class="text-muted">قدرت چاه:</span> {{ instance.well.well_power|default:"-" }}</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Items Table -->
|
||||
<div class="mb-4">
|
||||
<table class="table items-table">
|
||||
<table class="table border-top m-0">
|
||||
<thead>
|
||||
<tr>
|
||||
<th style="width: 5%">ردیف</th>
|
||||
<th style="width: 30%">شرح کالا/خدمات</th>
|
||||
<th style="width: 30%">توضیحات</th>
|
||||
<th style="width: 10%">تعداد</th>
|
||||
<th style="width: 12.5%">قیمت واحد (تومان)</th>
|
||||
<th style="width: 12.5%">قیمت کل (تومان)</th>
|
||||
<th style="width: 12.5%">قیمت واحد(تومان)</th>
|
||||
<th style="width: 12.5%">قیمت کل(تومان)</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for quote_item in quote.items.all %}
|
||||
<tr>
|
||||
<td>{{ forloop.counter }}</td>
|
||||
<td class="text-start">{{ quote_item.item.name }}</td>
|
||||
<td class="text-start">{{ quote_item.item.description|default:"-" }}</td>
|
||||
<td class="text-nowrap">{{ quote_item.item.name }}</td>
|
||||
<td class="text-nowrap">{{ quote_item.item.description|default:"-" }}</td>
|
||||
<td>{{ quote_item.quantity }}</td>
|
||||
<td>{{ quote_item.unit_price|floatformat:0 }}</td>
|
||||
<td>{{ quote_item.total_price|floatformat:0 }}</td>
|
||||
<td>{{ quote_item.unit_price|floatformat:0|intcomma:False }}</td>
|
||||
<td>{{ quote_item.total_price|floatformat:0|intcomma:False }}</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
<tfoot>
|
||||
<tr class="total-section">
|
||||
<td colspan="5" class="text-end"><strong>جمع کل:</strong></td>
|
||||
<td><strong>{{ quote.total_amount|floatformat:0 }} تومان</strong></td>
|
||||
<td colspan="5" class="text-end"><strong>جمع کل(تومان):</strong></td>
|
||||
<td><strong>{{ quote.total_amount|floatformat:0|intcomma:False }}</strong></td>
|
||||
</tr>
|
||||
{% if quote.discount_amount > 0 %}
|
||||
<tr class="total-section">
|
||||
<td colspan="5" class="text-end"><strong>تخفیف:</strong></td>
|
||||
<td><strong>{{ quote.discount_amount|floatformat:0 }} تومان</strong></td>
|
||||
<td colspan="5" class="text-end"><strong>تخفیف(تومان):</strong></td>
|
||||
<td><strong>{{ quote.discount_amount|floatformat:0|intcomma:False }}</strong></td>
|
||||
</tr>
|
||||
{% endif %}
|
||||
<tr class="total-section border-top border-2">
|
||||
<td colspan="5" class="text-end"><strong>مبلغ نهایی:</strong></td>
|
||||
<td><strong>{{ quote.final_amount|floatformat:0 }} تومان</strong></td>
|
||||
<td colspan="5" class="text-end"><strong>مبلغ نهایی(تومان):</strong></td>
|
||||
<td><strong>{{ quote.final_amount|floatformat:0|intcomma:False }}</strong></td>
|
||||
</tr>
|
||||
</tfoot>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<!-- Notes -->
|
||||
{% if quote.notes %}
|
||||
<div class="mb-4">
|
||||
<h6 class="fw-bold">یادداشت:</h6>
|
||||
<p>{{ quote.notes }}</p>
|
||||
<!-- Conditions & Payment (matches preview) -->
|
||||
<div class="row">
|
||||
<div class="col-8">
|
||||
<h6 class="fw-bold mb-2">شرایط و ضوابط</h6>
|
||||
<ul class="small mb-0">
|
||||
<li class="mb-1">اعتبار پیشفاکتور صادر شده ۴۸ ساعت پس از تاریخ صدور میباشد</li>
|
||||
<li class="mb-1">مبلغ فوق به صورت علیالحساب دریافت میگردد</li>
|
||||
<li class="mb-1">این برگه صرفاً جهت اعلام قیمت بوده و ارزش قانونی دیگری ندارد</li>
|
||||
{% if instance.broker.company and instance.broker.company.signature %}
|
||||
<li class="mt-3" style="list-style:none;"><img src="{{ instance.broker.company.signature.url }}" alt="امضا" style="height: 200px;"></li>
|
||||
{% endif %}
|
||||
</ul>
|
||||
</div>
|
||||
{% if instance.broker.company %}
|
||||
<div class="col-4">
|
||||
<h6 class="fw-bold mb-2">اطلاعات پرداخت</h6>
|
||||
{% if instance.broker.company.card_number %}
|
||||
<div class="small mb-1"><span class="text-muted">شماره کارت:</span> {{ instance.broker.company.card_number }}</div>
|
||||
{% endif %}
|
||||
{% if instance.broker.company.account_number %}
|
||||
<div class="small mb-1"><span class="text-muted">شماره حساب:</span> {{ instance.broker.company.account_number }}</div>
|
||||
{% endif %}
|
||||
{% if instance.broker.company.sheba_number %}
|
||||
<div class="small mb-1"><span class="text-muted">شماره شبا:</span> {{ instance.broker.company.sheba_number }}</div>
|
||||
{% endif %}
|
||||
{% if instance.broker.company.bank_name %}
|
||||
<div class="small"><span class="text-muted">بانک:</span> {{ instance.broker.company.get_bank_name_display }}</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
<!-- Signature Section (optional, compact) -->
|
||||
{% if quote.notes %}
|
||||
<div class="mt-3 small text-muted">یادداشت: {{ quote.notes }}</div>
|
||||
{% endif %}
|
||||
|
||||
<!-- Additional Info -->
|
||||
<div class="mb-4">
|
||||
<p><strong>صادر کننده:</strong> {{ quote.created_by.get_full_name }}</p>
|
||||
<p class="text-muted">این پیشفاکتور تا تاریخ {{ quote.valid_until|date:"Y/m/d" }} معتبر است.</p>
|
||||
</div>
|
||||
|
||||
<!-- Signature Section -->
|
||||
<div class="signature-section">
|
||||
<div class="row">
|
||||
<div class="col-6">
|
||||
<div class="text-center">
|
||||
<p class="mb-2"><strong>امضای مشترک</strong></p>
|
||||
<div class="signature-box">
|
||||
امضا و مهر
|
||||
</div>
|
||||
<p class="mt-2 small">تاریخ: ____/____/____</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-6">
|
||||
<div class="text-center">
|
||||
<p class="mb-2"><strong>امضای شرکت</strong></p>
|
||||
<div class="signature-box">
|
||||
امضا و مهر
|
||||
</div>
|
||||
<p class="mt-2 small">تاریخ: ____/____/____</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Footer -->
|
||||
<div class="text-center mt-4 small text-muted">
|
||||
این پیشفاکتور توسط سیستم مدیریت فرآیندها تولید شده است.
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
// Auto print on load (optional)
|
||||
// window.onload = function() { window.print(); }
|
||||
window.onload = function() {
|
||||
window.print();
|
||||
setTimeout(function(){ window.close(); }, 200);
|
||||
};
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
@ -19,6 +19,10 @@
|
|||
|
||||
{% block content %}
|
||||
{% include '_toasts.html' %}
|
||||
|
||||
<!-- Instance Info Modal -->
|
||||
{% instance_info_modal instance %}
|
||||
|
||||
<div class="container-xxl flex-grow-1 container-p-y">
|
||||
<div class="row">
|
||||
<div class="col-12 mb-4">
|
||||
|
@ -26,11 +30,13 @@
|
|||
<div>
|
||||
<h4 class="mb-1">{{ step.name }}: {{ instance.process.name }}</h4>
|
||||
<small class="text-muted d-block">
|
||||
اشتراک آب: {{ instance.well.water_subscription_number|default:"-" }}
|
||||
| نماینده: {{ instance.representative.profile.national_code|default:"-" }}
|
||||
{% instance_info instance %}
|
||||
</small>
|
||||
</div>
|
||||
<a href="{% url 'processes:request_list' %}" class="btn btn-outline-secondary">بازگشت</a>
|
||||
<a href="{% url 'processes:request_list' %}" class="btn btn-outline-secondary">
|
||||
<i class="bx bx-chevron-right bx-sm ms-sm-n2"></i>
|
||||
بازگشت
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<div class="bs-stepper wizard-vertical vertical mt-2">
|
||||
|
@ -50,7 +56,7 @@
|
|||
<div class="col-12 mb-3">
|
||||
<div class="alert alert-info">
|
||||
<h6>پیشفاکتور موجود</h6>
|
||||
<span class="mb-1">نام: {{ existing_quote.name }} | </span>
|
||||
<span class="mb-1">{{ existing_quote.name }} | </span>
|
||||
<span class="mb-1">مبلغ کل: {{ existing_quote.final_amount|floatformat:0|intcomma:False }} تومان | </span>
|
||||
<span class="mb-0">وضعیت: {{ existing_quote.get_status_display_with_color|safe }}</span>
|
||||
</div>
|
||||
|
@ -212,4 +218,6 @@
|
|||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
|
||||
{% endblock %}
|
||||
|
|
|
@ -15,6 +15,7 @@ from common.consts import UserRoles
|
|||
from .models import Item, Quote, QuoteItem, Payment, Invoice
|
||||
from installations.models import InstallationReport, InstallationItemChange
|
||||
|
||||
|
||||
@login_required
|
||||
def quote_step(request, instance_id, step_id):
|
||||
"""مرحله انتخاب اقلام و ساخت پیشفاکتور"""
|
||||
|
@ -62,6 +63,7 @@ def quote_step(request, instance_id, step_id):
|
|||
'is_broker': is_broker,
|
||||
})
|
||||
|
||||
|
||||
@require_POST
|
||||
@login_required
|
||||
def create_quote(request, instance_id, step_id):
|
||||
|
@ -90,7 +92,7 @@ def create_quote(request, instance_id, step_id):
|
|||
except Exception:
|
||||
continue
|
||||
|
||||
default_item_ids = set(Item.objects.filter(is_default_in_quotes=True, is_deleted=False).values_list('id', flat=True))
|
||||
default_item_ids = set(Item.objects.filter(is_default_in_quotes=True, is_deleted=False, is_special=False).values_list('id', flat=True))
|
||||
if default_item_ids:
|
||||
for default_id in default_item_ids:
|
||||
if default_id not in payload_by_id:
|
||||
|
@ -158,11 +160,12 @@ def create_quote(request, instance_id, step_id):
|
|||
|
||||
return JsonResponse({'success': True, 'quote_id': quote.id, 'redirect': redirect_url})
|
||||
|
||||
|
||||
@login_required
|
||||
def quote_preview_step(request, instance_id, step_id):
|
||||
"""مرحله صدور پیشفاکتور - نمایش و تایید فاکتور"""
|
||||
instance = get_object_or_404(
|
||||
ProcessInstance.objects.select_related('process', 'well', 'requester', 'representative', 'representative__profile'),
|
||||
ProcessInstance.objects.select_related('process', 'well', 'requester', 'representative', 'representative__profile', 'broker', 'broker__company', 'broker__affairs', 'broker__affairs__county', 'broker__affairs__county__city'),
|
||||
id=instance_id
|
||||
)
|
||||
step = get_object_or_404(instance.process.steps, id=step_id)
|
||||
|
|
|
@ -29,7 +29,7 @@ class AffairsAdmin(admin.ModelAdmin):
|
|||
@admin.register(Broker)
|
||||
class BrokerAdmin(admin.ModelAdmin):
|
||||
list_display = ['name', 'affairs', 'slug']
|
||||
list_filter = ['affairs__county__city', 'affairs__county', 'affairs']
|
||||
list_filter = ['affairs__county__city', 'affairs__county', 'affairs' ]
|
||||
search_fields = ['name', 'affairs__name', 'affairs__county__name']
|
||||
readonly_fields = ['deleted_at']
|
||||
prepopulated_fields = {'slug': ('name',)}
|
||||
|
|
20
locations/migrations/0002_broker_company.py
Normal file
20
locations/migrations/0002_broker_company.py
Normal file
|
@ -0,0 +1,20 @@
|
|||
# Generated by Django 5.2.4 on 2025-09-07 10:48
|
||||
|
||||
import django.db.models.deletion
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('accounts', '0001_initial'),
|
||||
('locations', '0001_initial'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='broker',
|
||||
name='company',
|
||||
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to='accounts.company', verbose_name='شرکت'),
|
||||
),
|
||||
]
|
17
locations/migrations/0003_remove_broker_company.py
Normal file
17
locations/migrations/0003_remove_broker_company.py
Normal file
|
@ -0,0 +1,17 @@
|
|||
# Generated by Django 5.2.4 on 2025-09-07 13:43
|
||||
|
||||
from django.db import migrations
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('locations', '0002_broker_company'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.RemoveField(
|
||||
model_name='broker',
|
||||
name='company',
|
||||
),
|
||||
]
|
|
@ -54,6 +54,7 @@ class ProcessInstanceAdmin(SimpleHistoryAdmin):
|
|||
'well_display',
|
||||
'representative',
|
||||
'requester',
|
||||
'broker',
|
||||
'process',
|
||||
'status_display',
|
||||
'priority_display',
|
||||
|
@ -65,7 +66,8 @@ class ProcessInstanceAdmin(SimpleHistoryAdmin):
|
|||
'status',
|
||||
'priority',
|
||||
'created',
|
||||
'well__representative'
|
||||
'well__representative',
|
||||
'broker'
|
||||
]
|
||||
search_fields = [
|
||||
'code',
|
||||
|
@ -86,6 +88,7 @@ class ProcessInstanceAdmin(SimpleHistoryAdmin):
|
|||
'well',
|
||||
'representative',
|
||||
'requester',
|
||||
'broker',
|
||||
'process',
|
||||
'current_step'
|
||||
]
|
||||
|
@ -99,7 +102,7 @@ class ProcessInstanceAdmin(SimpleHistoryAdmin):
|
|||
'fields': ('well', 'representative')
|
||||
}),
|
||||
('اطلاعات درخواست', {
|
||||
'fields': ('requester', 'priority')
|
||||
'fields': ('requester', 'broker', 'priority')
|
||||
}),
|
||||
('وضعیت و پیشرفت', {
|
||||
'fields': ('status', 'current_step')
|
||||
|
|
20
processes/migrations/0002_processinstance_broker.py
Normal file
20
processes/migrations/0002_processinstance_broker.py
Normal file
|
@ -0,0 +1,20 @@
|
|||
# Generated by Django 5.2.4 on 2025-09-07 13:43
|
||||
|
||||
import django.db.models.deletion
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('locations', '0003_remove_broker_company'),
|
||||
('processes', '0001_initial'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='processinstance',
|
||||
name='broker',
|
||||
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='process_instances', to='locations.broker', verbose_name='کارگزار'),
|
||||
),
|
||||
]
|
|
@ -5,7 +5,7 @@ from simple_history.models import HistoricalRecords
|
|||
from django.core.exceptions import ValidationError
|
||||
from django.utils import timezone
|
||||
from django.conf import settings
|
||||
from accounts.models import Role
|
||||
from accounts.models import Role, Broker
|
||||
from _helpers.utils import generate_unique_slug
|
||||
import random
|
||||
|
||||
|
@ -189,6 +189,15 @@ class ProcessInstance(SluggedModel):
|
|||
verbose_name="اولویت"
|
||||
)
|
||||
|
||||
broker = models.ForeignKey(
|
||||
Broker,
|
||||
on_delete=models.SET_NULL,
|
||||
verbose_name="کارگزار",
|
||||
blank=True,
|
||||
null=True,
|
||||
related_name='process_instances'
|
||||
)
|
||||
|
||||
completed_at = models.DateTimeField(
|
||||
null=True,
|
||||
blank=True,
|
||||
|
@ -205,13 +214,6 @@ class ProcessInstance(SluggedModel):
|
|||
return f"{self.process.name} - {self.well.water_subscription_number}"
|
||||
return f"{self.process.name} - {self.requester.get_full_name()}"
|
||||
|
||||
def clean(self):
|
||||
"""اعتبارسنجی مدل"""
|
||||
if self.well and self.representative and self.well.representative != self.representative:
|
||||
raise ValidationError("نماینده درخواست باید همان نماینده ثبت شده در چاه باشد")
|
||||
|
||||
if self.well and self.representative and self.requester == self.representative:
|
||||
raise ValidationError("درخواست کننده نمیتواند نماینده چاه باشد")
|
||||
|
||||
def save(self, *args, **kwargs):
|
||||
# Generate unique 5-digit numeric code if missing
|
||||
|
@ -233,6 +235,13 @@ class ProcessInstance(SluggedModel):
|
|||
if self.status == 'completed' and not self.completed_at:
|
||||
self.completed_at = timezone.now()
|
||||
|
||||
# Auto-set broker if not already set
|
||||
if not self.broker:
|
||||
if self.well and hasattr(self.well, 'broker') and self.well.broker:
|
||||
self.broker = self.well.broker
|
||||
elif self.requester and hasattr(self.requester, 'profile') and self.requester.profile and hasattr(self.requester.profile, 'broker') and self.requester.profile.broker:
|
||||
self.broker = self.requester.profile.broker
|
||||
|
||||
super().save(*args, **kwargs)
|
||||
|
||||
def get_status_display_with_color(self):
|
||||
|
|
275
processes/templates/processes/includes/instance_info_modal.html
Normal file
275
processes/templates/processes/includes/instance_info_modal.html
Normal file
|
@ -0,0 +1,275 @@
|
|||
{% load common_tags %}
|
||||
|
||||
<!-- Modal for Instance Info -->
|
||||
<div class="modal fade" id="{{ modal_id }}" tabindex="-1" aria-hidden="true">
|
||||
<div class="modal-dialog modal-lg">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title">اطلاعات درخواست {{ instance.code }}</h5>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<div class="row g-4">
|
||||
|
||||
<!-- Well Information -->
|
||||
{% if well %}
|
||||
<div class="col-12">
|
||||
<div class="card border-0 bg-light">
|
||||
<div class="card-header bg-label-primary text-white py-2">
|
||||
<h6 class="mb-0">
|
||||
<i class="bx bx-water me-2"></i>اطلاعات چاه
|
||||
</h6>
|
||||
</div>
|
||||
<div class="card-body pt-3">
|
||||
<div class="row g-3">
|
||||
<div class="col-md-6">
|
||||
<div class="d-flex align-items-center mb-2">
|
||||
<i class="bx bx-droplet text-primary me-2"></i>
|
||||
<strong>شماره اشتراک آب:</strong>
|
||||
<span class="ms-2">{{ well.water_subscription_number|default:"-" }}</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<div class="d-flex align-items-center mb-2">
|
||||
<i class="bx bx-bolt text-warning me-2"></i>
|
||||
<strong>شماره اشتراک برق:</strong>
|
||||
<span class="ms-2">{{ well.electricity_subscription_number|default:"-" }}</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<div class="d-flex align-items-center mb-2">
|
||||
<i class="bx bx-barcode text-info me-2"></i>
|
||||
<strong>سریال کنتور:</strong>
|
||||
<span class="ms-2">{{ well.water_meter_serial_number|default:"-" }}</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<div class="d-flex align-items-center mb-2">
|
||||
<i class="bx bx-barcode-reader text-secondary me-2"></i>
|
||||
<strong>سریال قدیمی:</strong>
|
||||
<span class="ms-2">{{ well.water_meter_old_serial_number|default:"-" }}</span>
|
||||
</div>
|
||||
</div>
|
||||
{% if well.water_meter_manufacturer %}
|
||||
<div class="col-md-6">
|
||||
<div class="d-flex align-items-center mb-2">
|
||||
<i class="bx bx-factory text-success me-2"></i>
|
||||
<strong>سازنده کنتور:</strong>
|
||||
<span class="ms-2">{{ well.water_meter_manufacturer.name }}</span>
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
<div class="col-md-6">
|
||||
<div class="d-flex align-items-center mb-2">
|
||||
<i class="bx bx-tachometer text-danger me-2"></i>
|
||||
<strong>قدرت چاه:</strong>
|
||||
<span class="ms-2">{{ well.well_power|default:"-" }}</span>
|
||||
</div>
|
||||
</div>
|
||||
{% if well.utm_x and well.utm_y %}
|
||||
<div class="col-12">
|
||||
<div class="d-flex align-items-center mb-2">
|
||||
<i class="bx bx-map text-info me-2"></i>
|
||||
<strong>مختصات:</strong>
|
||||
<span class="ms-2">X: {{ well.utm_x }}, Y: {{ well.utm_y }}</span>
|
||||
{% if well.utm_zone %}<span class="text-muted ms-2">(Zone: {{ well.utm_zone }})</span>{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
{% if well.county %}
|
||||
<div class="col-md-6">
|
||||
<div class="d-flex align-items-center mb-2">
|
||||
<i class="bx bx-map-pin text-warning me-2"></i>
|
||||
<strong>شهرستان:</strong>
|
||||
<span class="ms-2">{{ well.county }}</span>
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
{% if well.affairs %}
|
||||
<div class="col-md-6">
|
||||
<div class="d-flex align-items-center mb-2">
|
||||
<i class="bx bx-building text-primary me-2"></i>
|
||||
<strong>امور:</strong>
|
||||
<span class="ms-2">{{ well.affairs }}</span>
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
{% if well.reference_letter_number %}
|
||||
<div class="col-md-6">
|
||||
<div class="d-flex align-items-center mb-2">
|
||||
<i class="bx bx-file text-secondary me-2"></i>
|
||||
<strong>شماره معرفی نامه:</strong>
|
||||
<span class="ms-2">{{ well.reference_letter_number }}</span>
|
||||
{% if well.reference_letter_date %}
|
||||
<span class="text-muted ms-2">({{ well.reference_letter_date|to_jalali }})</span>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
{% if well.representative_letter_file %}
|
||||
<div class="col-md-6">
|
||||
<div class="d-flex align-items-center mb-2">
|
||||
<i class="bx bx-file text-secondary me-2"></i>
|
||||
<strong>فایل نامه نمایندگی:</strong>
|
||||
<a href="{{ well.representative_letter_file.url }}" class="ms-2">دانلود</a>
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
<!-- Representative Information -->
|
||||
{% if representative %}
|
||||
<div class="col-12">
|
||||
<div class="card border-0 bg-light">
|
||||
<div class="card-header bg-label-success text-white py-2">
|
||||
<h6 class="mb-0">
|
||||
<i class="bx bx-user me-2"></i>اطلاعات نماینده
|
||||
</h6>
|
||||
</div>
|
||||
<div class="card-body pt-3">
|
||||
<div class="row g-3">
|
||||
<div class="col-md-6">
|
||||
<div class="d-flex align-items-center mb-2">
|
||||
<i class="bx bx-user-circle text-primary me-2"></i>
|
||||
<strong>نام و نام خانوادگی:</strong>
|
||||
<span class="ms-2">{{ representative.get_full_name|default:representative.username }}</span>
|
||||
</div>
|
||||
</div>
|
||||
{% if representative.profile.national_code %}
|
||||
<div class="col-md-6">
|
||||
<div class="d-flex align-items-center mb-2">
|
||||
<i class="bx bx-id-card text-info me-2"></i>
|
||||
<strong>کد ملی:</strong>
|
||||
<span class="ms-2">{{ representative.profile.national_code }}</span>
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
{% if representative.profile.phone_number_1 %}
|
||||
<div class="col-md-6">
|
||||
<div class="d-flex align-items-center mb-2">
|
||||
<i class="bx bx-phone text-success me-2"></i>
|
||||
<strong>تلفن اول:</strong>
|
||||
<span class="ms-2">{{ representative.profile.phone_number_1 }}</span>
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
{% if representative.profile.phone_number_2 %}
|
||||
<div class="col-md-6">
|
||||
<div class="d-flex align-items-center mb-2">
|
||||
<i class="bx bx-phone text-success me-2"></i>
|
||||
<strong>تلفن دوم:</strong>
|
||||
<span class="ms-2">{{ representative.profile.phone_number_2 }}</span>
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
{% if representative.profile.bank_name %}
|
||||
<div class="col-md-6">
|
||||
<div class="d-flex align-items-center mb-2">
|
||||
<i class="bx bx-credit-card text-warning me-2"></i>
|
||||
<strong>بانک:</strong>
|
||||
<span class="ms-2">{{ representative.profile.get_bank_name_display }}</span>
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
{% if representative.profile.card_number %}
|
||||
<div class="col-md-6">
|
||||
<div class="d-flex align-items-center mb-2">
|
||||
<i class="bx bx-credit-card-alt text-secondary me-2"></i>
|
||||
<strong>شماره کارت:</strong>
|
||||
<span class="ms-2">{{ representative.profile.card_number }}</span>
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
{% if representative.profile.account_number %}
|
||||
<div class="col-md-6">
|
||||
<div class="d-flex align-items-center mb-2">
|
||||
<i class="bx bx-wallet text-info me-2"></i>
|
||||
<strong>شماره حساب:</strong>
|
||||
<span class="ms-2">{{ representative.profile.account_number }}</span>
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
{% if representative.profile.address %}
|
||||
<div class="col-md-6">
|
||||
<div class="d-flex align-items-start mb-2">
|
||||
<i class="bx bx-map text-danger me-2 mt-1"></i>
|
||||
<div>
|
||||
<strong>آدرس:</strong>
|
||||
<p class="mb-0 ms-2 text-wrap">{{ representative.profile.address }}</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
<!-- Process Information -->
|
||||
<div class="col-12">
|
||||
<div class="card border-0 bg-light">
|
||||
<div class="card-header bg-label-info text-white py-2">
|
||||
<h6 class="mb-0">
|
||||
<i class="bx bx-cog me-2"></i>اطلاعات فرآیند
|
||||
</h6>
|
||||
</div>
|
||||
<div class="card-body pt-3">
|
||||
<div class="row g-3">
|
||||
<div class="col-md-6">
|
||||
<div class="d-flex align-items-center mb-2">
|
||||
<i class="bx bx-list-ul text-primary me-2"></i>
|
||||
<strong>نوع فرآیند:</strong>
|
||||
<span class="ms-2">{{ instance.process.name }}</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<div class="d-flex align-items-center mb-2">
|
||||
<i class="bx bx-calendar text-success me-2"></i>
|
||||
<strong>تاریخ ایجاد:</strong>
|
||||
<span class="ms-2">{{ instance.jcreated }}</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<div class="d-flex align-items-center mb-2">
|
||||
<i class="bx bx-check-circle text-info me-2"></i>
|
||||
<strong>وضعیت:</strong>
|
||||
<span class="ms-2 badge bg-label-primary">{{ instance.get_status_display }}</span>
|
||||
</div>
|
||||
</div>
|
||||
{% if instance.current_step %}
|
||||
<div class="col-md-6">
|
||||
<div class="d-flex align-items-center mb-2">
|
||||
<i class="bx bx-step-forward text-primary me-2"></i>
|
||||
<strong>مرحله فعلی:</strong>
|
||||
<span class="ms-2 badge bg-label-success">{{ instance.current_step.name }}</span>
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
{% if instance.description %}
|
||||
<div class="col-md-6">
|
||||
<div class="d-flex align-items-start mb-2">
|
||||
<i class="bx bx-note text-secondary me-2 mt-1"></i>
|
||||
<div>
|
||||
<strong>توضیحات:</strong>
|
||||
<p class="mb-0 ms-2 text-wrap">{{ instance.description }}</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">بستن</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
|
@ -50,3 +50,57 @@ def stepper_header(instance, current_step=None):
|
|||
}
|
||||
|
||||
# moved to _base/common/templatetags/common_tags.py
|
||||
|
||||
@register.inclusion_tag('processes/includes/instance_info_modal.html')
|
||||
def instance_info_modal(instance, modal_id=None):
|
||||
"""
|
||||
نمایش مدال اطلاعات کامل چاه و نماینده
|
||||
|
||||
استفاده:
|
||||
{% load processes_tags %}
|
||||
{% instance_info_modal instance %}
|
||||
|
||||
یا با modal_id سفارشی:
|
||||
{% instance_info_modal instance "myCustomModal" %}
|
||||
"""
|
||||
if not isinstance(instance, ProcessInstance):
|
||||
return {}
|
||||
|
||||
if not modal_id:
|
||||
modal_id = f"instanceInfoModal_{instance.id}"
|
||||
|
||||
return {
|
||||
'instance': instance,
|
||||
'modal_id': modal_id,
|
||||
'well': instance.well,
|
||||
'representative': instance.representative,
|
||||
}
|
||||
|
||||
@register.simple_tag
|
||||
def instance_info(instance, modal_id=None):
|
||||
"""
|
||||
آیکون info برای نمایش مدال اطلاعات
|
||||
|
||||
استفاده:
|
||||
{% load processes_tags %}
|
||||
نام کاربر: {{ user.name }} {% instance_info_icon instance %}
|
||||
|
||||
یا با modal_id سفارشی:
|
||||
{% instance_info_icon instance "myCustomModal" %}
|
||||
"""
|
||||
if not isinstance(instance, ProcessInstance):
|
||||
return ""
|
||||
|
||||
if not modal_id:
|
||||
modal_id = f"instanceInfoModal_{instance.id}"
|
||||
|
||||
html = f'''
|
||||
اشتراک آب: {instance.well.water_subscription_number }
|
||||
| نماینده: {instance.representative.profile.national_code }
|
||||
<i class="bx bx-info-circle text-muted ms-1"
|
||||
style="cursor: pointer; font-size: 14px;"
|
||||
data-bs-toggle="modal"
|
||||
data-bs-target="#{modal_id}"
|
||||
title="اطلاعات کامل چاه و نماینده"></i>
|
||||
'''
|
||||
return mark_safe(html)
|
||||
|
|
|
@ -237,6 +237,7 @@ def create_request_with_entities(request):
|
|||
well=well,
|
||||
representative=representative_user,
|
||||
requester=request.user,
|
||||
broker=request.user.profile.broker if request.user.profile else None,
|
||||
status='pending',
|
||||
priority='medium',
|
||||
)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue