Files
Backend-Api/ServiceHost/Areas/Admin/Pages/Company/SmsResult/_SmsSettingPartials/InstantSms.cshtml
2025-11-18 15:10:32 +03:30

236 lines
7.7 KiB
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
@Html.AntiForgeryToken()
@{
<style>
.modal .modal-dialog .modal-content{
padding-bottom: 10px !important;
}
.modal-title{
position: absolute;
width: 291px;
font-size: 18px;
background-color: inherit;
left: 47%;
top: 19px;
margin-left: -100px;
text-align: center;
color: black;
border: 1px solid #00000030;
border-radius: 9px;
padding: 2px 0px;
}
.skeleton-loader {
width: 100%;
height: 35px;
background: linear-gradient(90deg, #EEEEEE 25%, #DEDEDE 50%, #EEEEEE 75%);
background-size: 200% 100%;
animation: loading 2s infinite ease-in-out;
border-radius: 8px;
margin-bottom: 3px
}
.progBar {
display: none;
}
#createProcess {
background-color: #fdfdfd;
height: 70px;
border-radius: 7px;
margin: 4px 2px 4px 2px;
box-shadow: 0px 1px 7px 0 #155c5c;
}
.progress-bar {
color: #fff !important;
font-size: 17px !important;
line-height: 23px !important;
border-radius: 10px !important;
}
@@keyframes loading {
0% {
background-position: 200% 0;
}
100% {
background-position: -200% 0;
}
}
</style>
}
<div class="modal-header">
<h5 class="modal-title">ارسال آنی پیامک یادآور</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="بستن">
<span aria-hidden="true">&times;</span>
</button>
</div>
<div class="card card-pattern m-t-10" style="border-radius: 15px 15px 0px 0px;">
<div class="container-fluid">
<!-- هدر -->
<div class="row fw-bold mb-2 head-table">
<div class="col-2 col-md-1">ردیف</div>
<div class="col-10 col-md-3"> نام طرف حساب </div>
<div class="col-6 col-md-3"> شماره تماس </div>
<div class="col-6 col-md-3" style="text-align:left; left:1.2%"> مبلغ بدهی </div>
<div class="col-12 col-md-2" style="float:right;text-align:right; direction:ltr; left: 1.2%">
تیک ارسال
<label class="switch">
<input id="checkAll" type="checkbox" checked />
<span class="slider round"></span>
</label>
</div>
</div>
</div>
</div>
<div id="createProcess" class="row progress-bar-striped progBar">
<div class="form-group" style="padding: 0px 10px;">
<span style="text-align: center">
<h3 style="font-size: 15px;color: #767575;margin-top: 3px;margin-bottom:0px">درصد ارسال پیامک ها</h3>
</span>
<div class="progress" style="height: 20px">
<div id="progress-bar-w" style="background-color: rgb(16 170 18)" class="progress-bar progress-bar-striped progress-bar-animated" role="progressbar" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100"></div>
</div>
</div>
</div>
<div class="card card-pattern " style="margin-top:2px;height:600px; overflow-y:scroll; border-radius: 0 0 15px 15px">
<div class="container-fluid" id="partialAppend">
<div id="loading">
@for (var j = 0; j < 16; j++)
{
<div class="skeleton-loader"></div>
}
</div>
</div>
</div>
<div class="modal-footer border-0">
<button type="button" onclick="sendToSms()" class="btn btn-success px-4 rounded-pill">ارسال پیامک</button>
<button type="button" class="btn btn-outline-secondary px-4 rounded-pill" data-dismiss="modal">بستن</button>
</div>
<script>
$(document).ready(function () {
var url = "/Admin/Company/SmsResult/SmsSettings?handler=InstantReminderSendSms";
$.get(url, function (data) {
$("#loading").hide();
$("#partialAppend").html(data);
});
var gNo = Number(7);
setTimeout(function () {
connectToGroupW(gNo);
},
2000);
});
console.log('befor start ...');
var connection = new signalR.HubConnectionBuilder().withUrl("/trackingSendSmsHub").build();
connection.start().then(function () {
console.log("connect.....!");
}).catch(function (err) {
return console.error(err.toString());
});
function connectToGroupW(id) {
connection.invoke("send", id)
.catch(function (err) {
console.error(err.toString());
});
console.log(`connected to group...${id}`);
}
connection.on('showStatus',
function (percent) {
$('#progress-bar-w').css("width", percent + "%");
$('#progress-bar-w').text(percent + '%');
});
//ارسال پیامک
function sendToSms() {
const recordItems = document.querySelectorAll(".record");
const command = [];
recordItems.forEach(recordItem => {
const checkbox = recordItem.querySelector('input[type="checkbox"]');
if (checkbox && checkbox.checked) {
const SmsListData = {
PhoneNumber: checkbox.dataset.phonenumber,
TemplateId: Number(checkbox.dataset.templateid),
PartyName: checkbox.dataset.partyname,
Amount: checkbox.dataset.amount,
ContractingPartyId: Number(checkbox.dataset.contractingpartyid),
AproveId: checkbox.dataset.aproveid,
TypeOfSmsMethod: checkbox.dataset.typeofsmsmethod,
Code1: checkbox.dataset.code1,
Code2: checkbox.dataset.code2,
InstitutionContractId: Number(checkbox.dataset.institutioncontractid)
};
command.push(SmsListData);
}
});
if (command.length === 0) {
$.Notification.autoHideNotify('error', 'top center', 'پیام سیستم ', "هیچ موردی انتخاب نشده است");
return;
}
$('#createProcess').removeClass("progBar");
var urlAjaxToSendSms = '@Url.Page("/Company/SmsResult/SmsSettings", "InstantReminderSendSms")';
$.ajax({
url: urlAjaxToSendSms,
type: "POST",
contentType: "application/json",
headers: { "RequestVerificationToken": $('input[name="__RequestVerificationToken"]').val() },
data: JSON.stringify(command),
success: function (response) {
if (response.isSuccess) {
$.Notification.autoHideNotify('success', 'top center', 'پیام سیستم ', response.message);
} else {
$.Notification.autoHideNotify('error', 'top center', 'پیام سیستم ', response.message);
}
},
error: function () {
$.Notification.autoHideNotify('error', 'top center', 'پیام سیستم ', "خطا در ارسال اطلاعات");
}
});
}
//روشن یا خاموش کردن تیک برای همه
$('#checkAll').on('change', function () {
const status = this.checked; // true یا false
$('input[type="checkbox"]').each(function () {
$(this).prop('checked', status);
});
});
</script>