modal add check data

This commit is contained in:
javad committed 2026-07-31 22:25:48 +03:30
1 parent 8b73db4de3
commit b66fe69660
4 files changed
+416 -64

No files matched your search

@@ -122,6 +122,7 @@
<th>نوع</th>
<th>وضعیت</th>
<th>عملیات</th>
<th>تکمیل اطلاعات چک</th>
<th>تاریخ سررسید</th>
<th>ردیف چک</th>
<th>شناسه صیادی</th>
@@ -171,6 +172,22 @@
{% endif %}
</td>
<td>
{% if sarresid.type == 'check' %}
<button class="button is-small is-info is-light has-text-weight-bold btn-update-check"
data-id="{{ sarresid.id }}"
data-row="{{ sarresid.check_row_number|default:'' }}"
data-sayyad="{{ sarresid.check_sayyad_id|default:'' }}"
data-owner="{{ sarresid.check_owner_name|default:'' }}"
data-phone="{{ sarresid.check_owner_phone|default:'' }}">
<span class="icon is-small"><i class="fas fa-edit"></i></span>
<span>افزودن اطلاعات</span>
</button>
{% else %}
<span class="has-text-grey-light">-</span>
{% endif %}
</td>
<td>{{ sarresid.sarresidDT | toJalali }}</td>
<td class="search-row-num has-text-weight-semibold">
@@ -301,6 +318,54 @@
</div>
</form>
<form class="modal modalUpdateCheck" method="post" action="" id="updateCheckForm">
{% csrf_token %}
<div class="modal-background"></div>
<div class="modal-card">
<header class="modal-card-head">
<p class="modal-card-title">تکمیل اطلاعات چک صیادی</p>
<button type="button" class="delete" aria-label="close"></button>
</header>
<section class="modal-card-body">
<div class="field">
<label class="label">شماره ردیف / سریال چک <span class="has-text-danger">*</span></label>
<div class="control">
<input id="up_check_row" name="check_row_number" class="input reset_input" type="text" required placeholder="مثال: 123456">
</div>
</div>
<div class="field">
<label class="label">شناسه صیادی (۱۶ رقم) <span class="has-text-danger">*</span></label>
<div class="control">
<input id="up_check_sayyad" name="check_sayyad_id" class="input reset_input" type="text" required inputmode="numeric" pattern="[0-9]{16}" minlength="16" maxlength="16" placeholder="فقط اعداد ۱۶ رقمی" title="لطفاً دقیقاً ۱۶ رقم وارد کنید">
</div>
</div>
<div class="field">
<label class="label">نام و نام‌خانوادگی صاحب حساب <span class="has-text-danger">*</span></label>
<div class="control">
<input id="up_check_owner" name="check_owner_name" class="input reset_input" type="text" required placeholder="نام مالک چک">
</div>
</div>
<div class="field">
<label class="label">تلفن مالک چک (اختیاری)</label>
<div class="control">
<input id="up_check_phone" name="check_owner_phone" class="input reset_input" type="text" inputmode="numeric" pattern="[0-9]*" maxlength="11" placeholder="مثال: 09123456789">
</div>
</div>
</section>
<footer class="modal-card-foot">
<button type="submit" class="button is-info">
<i class="fas fa-check ml-1"></i> ذخیره اطلاعات
</button>
<span class="button cancellBTNSR">لغو</span>
</footer>
</div>
</form>
<form class="modal nesiyeModal" method="post" action="{% url 'admin_panel:pardakhtNesiye' customer.id %}" id="pardakhtNesiyeForm">
{% csrf_token %}
<div class="modal-background"></div>
@@ -432,22 +497,44 @@
});
// ----------------------------------------------------
// مودال‌ها
// مودال‌ها و باز و بسته شدن آنها
// ----------------------------------------------------
$("#newSarresid").click(function(){
$(".modalAddNew").addClass("is-active");
});
// رویداد کلیک برای باز کردن مُدال تکمیل اطلاعات چک
$(".btn-update-check").click(function(){
let sarresidId = $(this).data('id');
let rowNum = $(this).data('row');
let sayyadId = $(this).data('sayyad');
let ownerName = $(this).data('owner');
let ownerPhone = $(this).data('phone');
// مقداردهی فرم با اطلاعات قبلی
$("#up_check_row").val(rowNum !== 'None' ? rowNum : '');
$("#up_check_sayyad").val(sayyadId !== 'None' ? sayyadId : '');
$("#up_check_owner").val(ownerName !== 'None' ? ownerName : '');
$("#up_check_phone").val(ownerPhone !== 'None' ? ownerPhone : '');
// تنظیم آدرس (Action) فرم برای این آیدی خاص
$("#updateCheckForm").attr('action', '/panel/sarresid/update-check-info/' + sarresidId);
// باز کردن مُدال
$(".modalUpdateCheck").addClass("is-active");
});
// بستن تمامی مدال‌ها
$(".modal-background, .delete, .cancellBTNSR").click(function(){
$(".modal").removeClass("is-active");
$('.reset_input').val('');
$('.reset_input').not(':hidden').val('');
$('#priceInWords, #nextPriceInWords').text('');
$("#check_extra_fields").hide();
$(".is-required-check").prop('required', false);
});
// ----------------------------------------------------
// تقویم شمسی (اصلاح شده)
// تقویم شمسی
// ----------------------------------------------------
$("#NewSarResid").pDatepicker({
initialValue: false,
+276 -61
View File
@@ -4,6 +4,7 @@
{% if perms.admin_panel.ViewReportMali %}
{% block bodyPage %}
<style>
/* استایل کارت‌های تحلیل ریسک */
.risk-card { transition: transform 0.2s, box-shadow 0.2s; border-radius: 8px; border: 1px solid #eee; }
.risk-card:hover { transform: translateY(-3px); box-shadow: 0 4px 15px rgba(0,0,0,0.05); }
.border-danger { border-bottom: 4px solid #f14668 !important; }
@@ -11,6 +12,52 @@
.border-info { border-bottom: 4px solid #3e8ed0 !important; }
.border-dark { border-bottom: 4px solid #363636 !important; }
.filter-tabs { margin-bottom: 1.5rem; }
/* استایل اختصاصی شناسه صیادی */
.sayyad-code {
font-family: monospace, monospace;
letter-spacing: 1px;
font-weight: 700;
color: #1e293b;
background-color: #f1f5f9;
padding: 3px 8px;
border-radius: 4px;
display: inline-block;
}
/* تنظیمات جدول جهت حفظ حالت سطری و عدم به‌هم‌ریختگی */
.table th {
vertical-align: middle !important;
background-color: #f8fafc;
white-space: nowrap;
}
.table td {
vertical-align: middle !important;
white-space: nowrap;
}
.price-preview {
font-size: 0.85rem;
color: #2563eb;
font-weight: 600;
margin-top: 4px;
display: block;
}
/* کانتینر اسکرول افقی واکنش‌گرا در موبایل */
.table-responsive-wrapper {
width: 100%;
overflow-x: auto;
-webkit-overflow-scrolling: touch;
border-radius: 8px;
border: 1px solid #eaeaea;
}
@media screen and (max-width: 768px) {
.table th, .table td {
padding: 0.5em 0.6em !important;
font-size: 0.85rem;
}
}
</style>
<div class="container is-fluid mt-4 mb-6">
@@ -83,47 +130,50 @@
</p>
{% endif %}
<div class="table-container column is-12-desktop is-12-mobile m-0 shadow-sm" style="border-radius: 8px; border: 1px solid #eaeaea;">
<table class="table m-auto has-text-centered is-bordered is-striped is-narrow is-fullwidth is-hoverable mojodiTB">
<div class="table-responsive-wrapper shadow-sm mb-4">
<table class="table m-auto has-text-centered is-bordered is-striped is-narrow is-fullwidth is-hoverable mojodiTB mb-0" id="sarresidTable">
<thead class="has-background-light">
<tr>
<th style="min-width: 150px;">مبلغ (تومان)</th>
<th style="min-width: 150px;">نام مشتری</th>
<th style="min-width: 100px;">نوع سند</th>
<th style="min-width: 120px;">سررسید</th>
<th style="min-width: 120px;">تاریخ ثبت</th>
<th style="min-width: 300px;">توضیحات</th>
<th style="min-width: 100px;">وضعیت</th>
<th style="min-width: 100px;">عملیات</th>
<th style="width: 40px;">#</th>
<th>مبلغ (تومان)</th>
<th>نام مشتری</th>
<th>نوع سند</th>
<th>وضعیت</th>
<th>عملیات</th>
<th>تکمیل اطلاعات چک</th>
<th>سررسید</th>
<th>تاریخ ثبت</th>
<th>ردیف چک</th>
<th>شناسه صیادی</th>
<th>صاحب حساب (تلفن)</th>
<th>توضیحات</th>
</tr>
</thead>
<tbody id="listPrds">
{% for sarresid in all_sarresid %}
<tr class="IteamPrd">
<td>{{ forloop.counter }}</td>
<td>
<span class="bedehkar toCurrency has-text-weight-bold">{{ sarresid.price }}</span>
<span class="bedehkar toCurrency has-text-weight-bold is-size-6">{{ sarresid.price }}</span>
</td>
<td>
<a target="_blank" href="{% url 'admin_panel:customerNew' sarresid.customer.id %}" class="has-text-link">
<a target="_blank" href="{% url 'admin_panel:customerNew' sarresid.customer.id %}" class="has-text-link has-text-weight-semibold">
{{ sarresid.customer.name_family }}
</a>
</td>
<td>
{% if sarresid.type == 'check' %}<span class="tag is-light is-rounded">چک</span>{% endif %}
{% if sarresid.type == 'nesiye' %}<span class="tag is-white is-rounded border">نسیه</span>{% endif %}
</td>
<td class="has-text-danger-dark">{{ sarresid.sarresidDT | toJalali }}</td>
<td class="has-text-grey is-size-7">{{ sarresid.createdDT | toJalali }}</td>
<td class="desc is-size-7" style="text-align: right;">
{% if sarresid.desc %}{{ sarresid.desc }}<br>{% endif %}
{% if sarresid.factor %}
<span class="tag is-light is-info">فاکتور شماره {{ sarresid.factor.id }}</span>
{% endif %}
{% if sarresid.type == 'check' %}<span class="tag is-info is-light has-text-weight-bold">چک</span>{% endif %}
{% if sarresid.type == 'nesiye' %}<span class="tag is-warning is-light has-text-weight-bold">نسیه</span>{% endif %}
</td>
<td>
{% if sarresid.payStatus == "true" %}<span class="has-text-success">پرداخت شده</span>{% endif %}
{% if sarresid.payStatus == "false" %}<span class="has-text-danger">پرداخت نشده</span>{% endif %}
{% if sarresid.payStatus == "true" %}<span class="has-text-success has-text-weight-bold is-size-7"><i class="fas fa-check-circle ml-1"></i>پرداخت شده</span>{% endif %}
{% if sarresid.payStatus == "false" %}<span class="has-text-danger has-text-weight-bold is-size-7"><i class="fas fa-clock ml-1"></i>پرداخت نشده</span>{% endif %}
</td>
<td>
{% if sarresid.payStatus == "false" %}
<button class="button is-danger is-small is-outlined VosolButton" csid="{{ sarresid.customer.id }}" price="{{ sarresid.price }}" type="{{ sarresid.type }}" articlID="{{ sarresid.id }}">وصول شد</button>
@@ -131,10 +181,59 @@
<span class="icon has-text-success"><i class="fas fa-check-circle"></i> بله</span>
{% endif %}
</td>
<td>
{% if sarresid.type == 'check' %}
<button class="button is-small is-info is-light has-text-weight-bold btn-update-check"
data-id="{{ sarresid.id }}"
data-row="{{ sarresid.check_row_number|default:'' }}"
data-sayyad="{{ sarresid.check_sayyad_id|default:'' }}"
data-owner="{{ sarresid.check_owner_name|default:'' }}"
data-phone="{{ sarresid.check_owner_phone|default:'' }}">
<span class="icon is-small"><i class="fas fa-edit"></i></span>
<span>افزودن اطلاعات</span>
</button>
{% else %}
<span class="has-text-grey-light">-</span>
{% endif %}
</td>
<td class="has-text-danger-dark has-text-weight-semibold">{{ sarresid.sarresidDT | toJalali }}</td>
<td class="has-text-grey is-size-7">{{ sarresid.createdDT | toJalali }}</td>
<td class="has-text-weight-semibold">
{{ sarresid.check_row_number|default:"-" }}
</td>
<td>
{% if sarresid.check_sayyad_id %}
<span class="sayyad-code">{{ sarresid.check_sayyad_id }}</span>
{% else %}
-
{% endif %}
</td>
<td>
{% if sarresid.check_owner_name %}
<div class="has-text-dark has-text-weight-semibold is-size-7">{{ sarresid.check_owner_name }}</div>
{% if sarresid.check_owner_phone %}
<div class="has-text-grey is-size-7 mt-1" dir="ltr">{{ sarresid.check_owner_phone }}</div>
{% endif %}
{% else %}
<span class="has-text-grey-light">-</span>
{% endif %}
</td>
<td class="desc is-size-7" style="text-align: right;">
{% if sarresid.desc %}{{ sarresid.desc }}<br>{% endif %}
{% if sarresid.factor %}
<span class="tag is-light is-info mt-1">فاکتور شماره {{ sarresid.factor.id }}</span>
{% endif %}
</td>
</tr>
{% empty %}
<tr>
<td colspan="8" class="has-text-grey p-5">هیچ سندی در این محدوده یافت نشد.</td>
<td colspan="13" class="has-text-grey p-5">هیچ سندی در این محدوده یافت نشد.</td>
</tr>
{% endfor %}
</tbody>
@@ -175,34 +274,86 @@
</div>
</div>
<form class="modal nesiyeModal" method="post" action="{% url 'admin_panel:pardakhtNesiye' 9101010101 %}">
<form class="modal modalUpdateCheck" method="post" action="" id="updateCheckForm">
{% csrf_token %}
<div class="modal-background"></div>
<div class="modal-card">
<header class="modal-card-head">
<p class="modal-card-title">تکمیل اطلاعات چک صیادی</p>
<button type="button" class="delete" aria-label="close"></button>
</header>
<section class="modal-card-body">
<div class="field">
<label class="label">شماره ردیف / سریال چک <span class="has-text-danger">*</span></label>
<div class="control">
<input id="up_check_row" name="check_row_number" class="input reset_input" type="text" required placeholder="مثال: 123456">
</div>
</div>
<div class="field">
<label class="label">شناسه صیادی (۱۶ رقم) <span class="has-text-danger">*</span></label>
<div class="control">
<input id="up_check_sayyad" name="check_sayyad_id" class="input reset_input" type="text" required inputmode="numeric" pattern="[0-9]{16}" minlength="16" maxlength="16" placeholder="فقط اعداد ۱۶ رقمی" title="لطفاً دقیقاً ۱۶ رقم وارد کنید">
</div>
</div>
<div class="field">
<label class="label">نام و نام‌خانوادگی صاحب حساب <span class="has-text-danger">*</span></label>
<div class="control">
<input id="up_check_owner" name="check_owner_name" class="input reset_input" type="text" required placeholder="نام مالک چک">
</div>
</div>
<div class="field">
<label class="label">تلفن مالک چک (اختیاری)</label>
<div class="control">
<input id="up_check_phone" name="check_owner_phone" class="input reset_input" type="text" inputmode="numeric" pattern="[0-9]*" maxlength="11" placeholder="مثال: 09123456789">
</div>
</div>
</section>
<footer class="modal-card-foot">
<button type="submit" class="button is-info">
<i class="fas fa-check ml-1"></i> ذخیره اطلاعات
</button>
<span class="button cancellBTNSR">لغو</span>
</footer>
</div>
</form>
<form class="modal nesiyeModal" method="post" action="{% url 'admin_panel:pardakhtNesiye' 9101010101 %}" id="pardakhtNesiyeForm">
{% csrf_token %}
<div class="modal-background"></div>
<div class="modal-card">
<header class="modal-card-head">
<p class="modal-card-title">نسیه</p>
<button class="delete" aria-label="close"></button>
<button type="button" class="delete" aria-label="close"></button>
</header>
<section class="modal-card-body">
<div class="field">
<label class="label">مانده از این نسیه</label>
<div class="control">
<input id="priceBedehi" disabled class="input reset_input" type="text" placeholder="واحد تومان">
<input id="priceBedehi" disabled class="input reset_input has-text-weight-bold" type="text" placeholder="واحد تومان">
</div>
</div>
<input name="sr_articlID" id="sr_articlID" class="input reset_input is-hidden" type="text">
<div class="field">
<label class="label">مبلغ پرداختی فعلی</label>
<label class="label">مبلغ پرداختی فعلی <span class="has-text-danger">*</span></label>
<div class="control">
<input name="next_sarresidPrice" required class="input reset_input" type="text" placeholder="واحد تومان">
<input id="formattedNextPriceInput" required class="input reset_input comma-separator" type="text" inputmode="numeric" placeholder="مبلغ واریزی (تومان)">
<input type="hidden" name="next_sarresidPrice" id="realNextPriceInput" class="reset_input">
<span class="price-preview" id="nextPriceInWords"></span>
</div>
</div>
<div class="field">
<label class="label">نحوه پرداخت</label>
<label class="label">نحوه پرداخت <span class="has-text-danger">*</span></label>
<div class="control">
<div class="select is-fullwidth">
<select required class="reset_input" name="nahvePardakht">
<option></option>
<option value=""></option>
<option value="check">چک</option>
<option value="naghd">نقد</option>
<option value="kartbekart">کارت به کارت</option>
@@ -212,19 +363,22 @@
</div>
</div>
</div>
<div class="field">
<label class="label">سررسید بعدی</label>
<label class="label">سررسید بعدی <span class="has-text-danger">*</span></label>
<div class="control">
<input name="xxxxxaaaa" required class="input reset_input" id="NextSarResid" type="text">
<input required class="input reset_input" id="NextSarResid" type="text" autocomplete="off" readonly style="cursor: pointer;" placeholder="برای انتخاب تاریخ کلیک کنید">
</div>
</div>
<div class="field">
<label class="label">توضیحات</label>
<div class="control">
<textarea name="desc_sar" class="input"></textarea>
<textarea name="desc_sar" class="input reset_input" rows="2"></textarea>
</div>
</div>
<input required type="text" class="is-hidden reset_input" name="next_sarresidDateTime" id="NextSarResidVal">
<input type="hidden" name="next_sarresidDateTime" id="NextSarResidVal" class="reset_input">
</section>
<footer class="modal-card-foot">
<input type="submit" class="button is-success" value="ثبت">
@@ -240,41 +394,93 @@
$(document).ready(function() {
var csrftoken = jQuery("[name=csrfmiddlewaretoken]").val();
$(".modal-background").click(function(){
$(".modal").removeClass("is-active");
$('.reset_input').val('');
})
$(".cancellBTNSR").click(function(){
$(".modal").removeClass("is-active");
$('.reset_input').val('');
})
// ----------------------------------------------------
// فرمت‌بندی اعداد (سه رقم سه رقم)
// ----------------------------------------------------
function formatNumber(num) {
return num.toString().replace(/\D/g, "").replace(/\B(?=(\d{3})+(?!\d))/g, ",");
}
$(document).on('input', '.comma-separator', function() {
let val = $(this).val();
let rawVal = val.replace(/,/g, '');
if (rawVal && !isNaN(rawVal)) {
$(this).val(formatNumber(rawVal));
if ($(this).attr('id') === 'formattedNextPriceInput') {
$('#realNextPriceInput').val(rawVal);
$('#nextPriceInWords').text(formatNumber(rawVal) + ' تومان');
}
} else {
$(this).val('');
$('#realNextPriceInput').val('');
$('#nextPriceInWords').text('');
}
});
// ----------------------------------------------------
// بستن مودال‌ها
// ----------------------------------------------------
$(".modal-background, .delete, .cancellBTNSR").click(function(){
$(".modal").removeClass("is-active");
$('.reset_input').val('');
$('#nextPriceInWords').text('');
});
// ----------------------------------------------------
// رویداد باز کردن مُدال ویرایش چک (جدید)
// ----------------------------------------------------
$(".btn-update-check").click(function(){
let sarresidId = $(this).data('id');
let rowNum = $(this).data('row');
let sayyadId = $(this).data('sayyad');
let ownerName = $(this).data('owner');
let ownerPhone = $(this).data('phone');
// مقداردهی فرم با اطلاعات قبلی
$("#up_check_row").val(rowNum !== 'None' ? rowNum : '');
$("#up_check_sayyad").val(sayyadId !== 'None' ? sayyadId : '');
$("#up_check_owner").val(ownerName !== 'None' ? ownerName : '');
$("#up_check_phone").val(ownerPhone !== 'None' ? ownerPhone : '');
// تنظیم آدرس (Action) فرم برای این آیدی خاص
$("#updateCheckForm").attr('action', '/panel/sarresid/update-check-info/' + sarresidId);
// باز کردن مُدال
$(".modalUpdateCheck").addClass("is-active");
});
// ----------------------------------------------------
// تقویم شمسی
// ----------------------------------------------------
$("#NextSarResid").pDatepicker({
initialValue: false,
initialValueType: 'en',
format: 'YYYY/MM/DD',
autoClose: true,
calendar:{
calendar: {
persian: { locale: 'fa' }
},
onSelect: (unix)=>{
$("#NextSarResidVal").val(unix)
onSelect: function(unix) {
$("#NextSarResidVal").val(unix);
}
});
var csid = null
// ----------------------------------------------------
// دکمه‌های وصول شد
// ----------------------------------------------------
var csid = null;
$(".VosolButton").click(function(){
var articlID = $(this).attr("articlID")
var type = $(this).attr("type")
var price = $(this).attr("price")
csid = $(this).attr("csid")
var articlID = $(this).attr("articlID");
var type = $(this).attr("type");
var price = $(this).attr("price");
csid = $(this).attr("csid");
if(type=="check"){
if( confirm('چک وصول شده؟') ){
var prompt_desc = prompt('لطفا توضیحات را وارد کنید و تایید کنید')
var prompt_desc = prompt('لطفا توضیحات را وارد کنید و تایید کنید');
var url_check = '/panel/passCheck/'+articlID;
if( prompt_desc ){
if( prompt_desc !== null ){ // اگر کاربر لغو نکرد
$.ajax({
url: url_check,
type: 'post',
@@ -287,17 +493,26 @@ $(document).ready(function() {
}
}
} else {
var actionUrl = $(".nesiyeModal").attr('action')
var actionUrl = $(".nesiyeModal").attr('action');
$(".nesiyeModal").addClass("is-active");
$("#priceBedehi").val(price);
$("#sr_articlID").val(articlID)
$("#priceBedehi").val(formatNumber(price));
$("#sr_articlID").val(articlID);
}
});
$("form").submit(function(e){
var actionUrl = $(".nesiyeModal").attr('action')
$(".nesiyeModal").attr('action', actionUrl.replace("9101010101", csid ) )
// ----------------------------------------------------
// ارسال فرم پرداخت نسیه
// ----------------------------------------------------
$("#pardakhtNesiyeForm").submit(function(e){
if(!$("#NextSarResidVal").val()){
alert("لطفاً تاریخ سررسید بعدی را انتخاب کنید.");
e.preventDefault();
return false;
}
var actionUrl = $(this).attr('action');
$(this).attr('action', actionUrl.replace("9101010101", csid ));
});
});
</script>
{% endblock %}
+1
View File
@@ -71,6 +71,7 @@ urlpatterns = [
path('ActionList/all', views.ActionListAll, name='ActionListAll'),
path('passCheck/<int:articl_id>', views.passCheck, name='passCheck'),
path('sarresid/update-check-info/<int:sarresid_id>', views.update_check_info, name='update_check_info'),
path('addSarresid/<int:cs_id>', views.addSarresid, name='addSarresid'),
path('pardakhtNesiye/<int:cs_id>', views.pardakhtNesiye, name='pardakhtNesiye'),
+49
View File
@@ -2270,6 +2270,55 @@ def passCheck(request, articl_id):
#return redirect(request.META.get('HTTP_REFERER'))
@login_required(login_url='/panel/p_login/')
@permission_required('admin_panel.ViewStore', raise_exception=True)
@require_POST
def update_check_info(request, sarresid_id):
# دریافت رکورد مورد نظر
sarresid = get_object_or_404(Sarresid, id=sarresid_id)
# اطمینان از اینکه آیتم حتما چک است
if sarresid.type != 'check':
messages.error(request, "عملیات نامعتبر: این سند چک نیست.")
return redirect(request.META.get('HTTP_REFERER', '/'))
# دریافت مقادیر فرم با حذف فاصله‌های اضافی
check_row_number = request.POST.get('check_row_number', '').strip()
check_sayyad_id = request.POST.get('check_sayyad_id', '').strip()
check_owner_name = request.POST.get('check_owner_name', '').strip()
check_owner_phone = request.POST.get('check_owner_phone', '').strip()
# اعتبارسنجی فیلدهای اجباری
if not check_row_number or not check_sayyad_id or not check_owner_name:
messages.error(request, "شماره ردیف، شناسه صیادی و نام مالک اجباری است.")
return redirect(request.META.get('HTTP_REFERER', '/'))
# اعتبارسنجی شناسه صیادی (باید دقیقا ۱۶ رقم عدد باشد)
if not check_sayyad_id.isdigit() or len(check_sayyad_id) != 16:
messages.error(request, "شناسه صیادی باید دقیقاً ۱۶ رقم عدد باشد.")
return redirect(request.META.get('HTTP_REFERER', '/'))
# اعتبارسنجی شماره تلفن (در صورت وارد شدن باید فقط عدد باشد)
if check_owner_phone and not check_owner_phone.isdigit():
messages.error(request, "شماره تلفن مالک چک باید فقط شامل اعداد باشد.")
return redirect(request.META.get('HTTP_REFERER', '/'))
try:
# بروزرسانی اطلاعات
sarresid.check_row_number = check_row_number
sarresid.check_sayyad_id = check_sayyad_id
sarresid.check_owner_name = check_owner_name
sarresid.check_owner_phone = check_owner_phone
# آپدیت فیلد توضیحات با اطلاعات جدید
sarresid.desc = f"صیادی: {check_sayyad_id} | مالک: {check_owner_name} | تلفن: {check_owner_phone or 'ندارد'}"
sarresid.save()
messages.success(request, "اطلاعات چک با موفقیت ثبت/بروزرسانی شد.")
except Exception as e:
messages.error(request, "خطای سیستمی در بروزرسانی اطلاعات رخ داد.")
return redirect(request.META.get('HTTP_REFERER', '/'))
@login_required(login_url='/panel/p_login/')
@permission_required('admin_panel.ViewStore', raise_exception=True)
def addSarresid(request, cs_id):