Files
BoilerPlate/Views/Panel/Users.cshtml
2025-07-23 18:54:59 +03:30

136 lines
6.7 KiB
Plaintext

@using boilerplate.Models
@model List<UserModel>
@{
ViewBag.Title = "کاربران";
Layout = "~/Views/_PanelSideBar.cshtml";
}
<div class="row">
<div class="col-12">
<div class="card card-custom">
<div class="card-header flex-wrap border-0 pt-6 pb-0">
<div class="card-title">
<h3 class="card-label">@ViewBag.Title</h3>
</div>
<div class="card-toolbar">
<a class="btn btn-primary font-weight-bolder" href="Panel/User/0">
<span class="svg-icon svg-icon-md m-0">
جدید&nbsp;&nbsp;
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="24px" height="24px" viewBox="0 0 24 24" version="1.1">
<g stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
<rect x="0" y="0" width="24" height="24" />
<circle fill="#000000" opacity="0.3" cx="12" cy="12" r="10" />
<path d="M11,11 L11,7 C11,6.44771525 11.4477153,6 12,6 C12.5522847,6 13,6.44771525 13,7 L13,11 L17,11 C17.5522847,11 18,11.4477153 18,12 C18,12.5522847 17.5522847,13 17,13 L13,13 L13,17 C13,17.5522847 12.5522847,18 12,18 C11.4477153,18 11,17.5522847 11,17 L11,13 L7,13 C6.44771525,13 6,12.5522847 6,12 C6,11.4477153 6.44771525,11 7,11 L11,11 Z" fill="#000000" />
</g>
</svg>
</span>
</a>
</div>
</div>
<div class="card-body">
<table class="table table-separate text-center table-vertical-center table-hover table-head-custom table-checkable" id="DatatableList">
<thead>
<tr>
<th>ردیف</th>
<th>نام و نام خانوادگی</th>
<th>شماره موبایل</th>
<th>کد</th>
<th>وضعیت</th>
<th>نقش</th>
<th>تاریخ ایجاد</th>
<th>مدیریت</th>
</tr>
</thead>
<tbody>
@try
{
int Counter = 0;
foreach (var item in Model)
{
Counter++;
<tr id="RowSection_@item.Id">
<td>@Counter</td>
<td>@item.Name @item.Family</td>
<td>@item.Phone</td>
<td>@item.Code</td>
<td>
@if (item.Status == 0)
{
<span class="label label-xl label-secondary label-pill label-inline">در انتظار احرازهویت</span>
}
else if (item.Status == 1)
{
<span class="label label-xl label-success label-pill label-inline">فعال</span>
}
else
{
<span class="label label-xl label-warning label-pill label-inline">غیرفعال</span>
}
</td>
<td>
@if (item.Role == "User")
{
<span class="label label-xl label-info label-pill label-inline">کاربر</span>
}
else
{
<span class="label label-xl label-success label-pill label-inline">مدیر</span>
}
</td>
<td dir="ltr">@item.CreatedDate</td>
<td>
<a class="btn btn-success btn-sm mb-1" href="~/Panel/User/@item.Id">مدیریت</a>
@if (item.Role == "User")
{
<a class="btn btn-info btn-sm mb-1" onclick="Login(@item.Id)">ورود به پنل</a>
}
</td>
</tr>
}
}
catch { }
</tbody>
</table>
</div>
</div>
</div>
</div>
@section Script {
<script>
$("#UserList").addClass("menu-item-open");
$("#UsersMenu").addClass("menu-item-active");
$(document).ready(function () {
$("#DatatableList").DataTable({
order: [[0, 'asc']],
scrollX: true,
language: { url: 'Media/datatables.json' },
columnDefs: [{ targets: [0, 3, 4], type: "num" }]
});
});
function Login(Id) {
Swal.fire({
title: "آیا مایل به ورود به پنل کاربر مورد نظر هستید ؟",
text: "",
icon: "info",
showCancelButton: true,
confirmButtonColor: '#3085d6',
cancelButtonColor: '#d33',
cancelButtonText: 'خیر',
confirmButtonText: 'بله'
}).then((result) => {
if (result.value) {
$.post(`../Admin/PanelLogin/User/${Id}`).done(function (data) {
if (data.Status == "Success") {
location.href = "../Panel/Index";
} else {
toastr.warning("خطا هنگام برقراری ارتباط با سرور");
}
}).fail(function () {
toastr.error("خطا هنگام برقراری ارتباط با سرور");
});
}
});
}
</script>
}