209 lines
6.8 KiB
JavaScript
209 lines
6.8 KiB
JavaScript
$(document).ready(function() {
|
|
//::::::::::::::::::::::
|
|
|
|
$("#cl1").prop("checked", true);
|
|
// $("#fs2").prop("checked", true);
|
|
// $("#tmp3").prop("checked", true);
|
|
|
|
|
|
table = $("#NTbl").DataTable({
|
|
dom: "lBfrtip",
|
|
pagingType: "simple_numbers",
|
|
"autoWidth": false,
|
|
pageLength: 5,
|
|
language: {
|
|
sEmptyTable: "هیچ دادهای در جدول وجود ندارد",
|
|
sInfo: "نمایش _START_ تا _END_ از _TOTAL_ ردیف",
|
|
sInfoEmpty: "نمایش 0 تا 0 از 0 ردیف",
|
|
sInfoFiltered: "(فیلتر شده از _MAX_ ردیف)",
|
|
sInfoPostFix: "",
|
|
sInfoThousands: ",",
|
|
sLengthMenu: "نمایش _MENU_ ردیف",
|
|
sLoadingRecords: "در حال بارگزاری...",
|
|
sProcessing: "در حال پردازش...",
|
|
sSearch: "جستجو / فیلتر: ",
|
|
sZeroRecords: "رکوردی با این مشخصات پیدا نشد",
|
|
oPaginate: {
|
|
sFirst: "برگهی نخست",
|
|
sLast: "برگهی آخر",
|
|
sNext: "بعدی",
|
|
sPrevious: "قبلی",
|
|
},
|
|
oAria: {
|
|
sSortAscending: ": فعال سازی نمایش به صورت صعودی",
|
|
sSortDescending: ": فعال سازی نمایش به صورت نزولی",
|
|
},
|
|
},
|
|
processing: true,
|
|
select: true,
|
|
destroy: true,
|
|
|
|
ajax: {
|
|
url: "http://192.168.1.75/rms_new/public/index.php/api/WStat/all",
|
|
type: "GET",
|
|
error: function(jqXHR, textStatus, errorThrown) {
|
|
allert("!!" + errorThrown);
|
|
}
|
|
|
|
},
|
|
columns: [
|
|
{ className: "text-center", data: "id" },
|
|
{ className: "text-center", data: "notice_text" },
|
|
{
|
|
"title": "عملیات",
|
|
"width": '15%',
|
|
className: "text-center",
|
|
"data": null,
|
|
render: function(data, type, row) {
|
|
return '<button class="buttonx edit_row"><i class="ui-tooltip fa fa-pencil" style="font-size: 15px;color:blue" data-original-title="Edit"></i> ویرایش</button><button class="buttonx delete_row"><i class="ui-tooltip fa fa-trash-o" style="font-size: 15px;color:red" data-original-title="Delete"></i> حذف</button>'
|
|
}
|
|
}
|
|
|
|
|
|
],
|
|
|
|
|
|
|
|
initComplete: function() {
|
|
|
|
// var tablex = $('#NTbl').DataTable({ scrollY: "300px", scrollX: true, scrollCollapse: true, columnDefs: [{ width: '15%', targets: 2 }] });
|
|
// new $.fn.dataTable.FixedColumns(tablex);
|
|
//=================================================================
|
|
$("#NTbl #amaliat").css('width', '100px');
|
|
$("#NTbl #radif").css('width', '50px');
|
|
$('#NTbl tr').css("height", "5px");
|
|
//===============maxter ::::::::::::::::::
|
|
//===========================Delete rec =====================================
|
|
$('#NTbl').on('click', 'button.delete_row', function(e) {
|
|
e.preventDefault();
|
|
data_row = table.row($(this).closest('tr')).data();
|
|
rowid = data_row.id;
|
|
var element = $(this);
|
|
var info = { id: data_row.id };
|
|
|
|
$('#ModalConfirmDel').modal({})
|
|
.on('click', '#deleterec', function(e) {
|
|
$.ajax({
|
|
type: "POST",
|
|
crossDomain: true,
|
|
url: "http://192.168.1.75/rms_new/public/index.php/api/WStat/delete",
|
|
// url: "https://141.ir/adminpanel/deletecamera/",
|
|
data: info,
|
|
|
|
success: function() {
|
|
|
|
$('#NTbl').DataTable().ajax.reload(null, false);
|
|
|
|
|
|
$('#ModalConfirmDel').modal('hide');
|
|
},
|
|
// error: function (xhr, status) {
|
|
// alert("error");
|
|
// }
|
|
});
|
|
});
|
|
$("#canceldel").on('click', function(e) {
|
|
e.preventDefault();
|
|
$('#ModalConfirmDel').modal.model('hide');
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$(this).parents(".show").animate({ backgroundColor: "#003" }, "slow")
|
|
.animate({ opacity: "hide" }, "slow");
|
|
|
|
});
|
|
//:::::::::::::::::::::::::::::::::::::::::::::::::::::
|
|
$('#NTbl').on('click', 'button.edit_row', function(e) {
|
|
e.preventDefault();
|
|
editurl = "http://192.168.1.75/rms_new/public/index.php/api/WStat/update";
|
|
data_row = table.row($(this).closest('tr')).data();
|
|
console.log(data_row);
|
|
rowid = data_row.id;
|
|
idup = data_row.id;
|
|
// $("#NewsModal #submitnews").attr("app","2");
|
|
appupdate = true;
|
|
$("#NewsModal #submitnews").text("بروزرسانی");
|
|
$("#NewsModal").modal('show');
|
|
var strvl;
|
|
strvl = data_row["notice_text"];
|
|
console.log(strvl);
|
|
$("#NewsModal #notice_text").val(strvl);
|
|
// $("textarea#notice_text").text(strvl);
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
});
|
|
|
|
|
|
//::::::::::::::::::::::::::::::::::
|
|
table.columns.adjust().draw();
|
|
//==Request Functions:::::::::::::
|
|
$("#NewsModal #submitnews").click(function() {
|
|
var urlapp = "http://192.168.1.75/rms_new/public/index.php/api/WStat/store/";
|
|
var txtnews = $("#notice_text").val();
|
|
if (appupdate) {
|
|
urlapp = "http://192.168.1.75/rms_new/public/index.php/api/WStat/update/";
|
|
|
|
}
|
|
|
|
$.post(urlapp, { notice_text: txtnews, id: idup }, function(data, status) {
|
|
|
|
$("#modal-success").modal("show");
|
|
|
|
$("#NewsModal").modal('hide');
|
|
$("#NewsModal #submitnews").text("ثبت ");
|
|
appupdate = false;
|
|
idup = null;
|
|
// $("#ok-sabt").css("z-index","1000");
|
|
table.ajax.reload();
|
|
// $("#ok-sabt").fadeIn("slow");
|
|
}).fail(function() {
|
|
alert("ثبت نشد !!!");
|
|
// $("#no-sabt").css("z-index","1000");
|
|
// $("#no-sabt").fadeIn("slow");
|
|
|
|
|
|
});
|
|
|
|
});
|
|
$("#ok-cls").click(function() {
|
|
|
|
$("#ok-sabt").hide();
|
|
|
|
});
|
|
$("#no-cls").click(function() {
|
|
$("#no-sabt").hide();
|
|
|
|
});
|
|
$("#add-news-button").click(function() {
|
|
$("#NewsModal #notice_text").text("");
|
|
|
|
});
|
|
|
|
|
|
|
|
});
|
|
|
|
function DoEmpty() {
|
|
$("#NewsModal #notice_text").val("");
|
|
|
|
}
|
|
//======================================
|