///
var getUrl = window.location;
if (getUrl.host.indexOf("beta55.") >= 0) {
var baseUrl = getUrl.protocol + "//" + getUrl.host + "/" + getUrl.pathname.split('/')[1] + "/";;
}
else {
var baseUrl = getUrl.protocol + "//" + getUrl.host + "/";
}
var CommonURL = baseUrl;
var ID_1 = "";
var Type_1 = "";
var Cond1_1 = "";
var BlockUIStatus = 0;
$(document).ready(function () {
if (top.location.hostname != self.location.hostname) {
top.location.href = self.location.href;
}
$(".CloseErrorMsg").click(function () {
$(".ErrorMsg").hide();
return false;
});
$(".Number,.Amount,.Weight").css('text-align', 'left');
$(".Number").keyup(function (e) {
if (/\D/g.test(this.value)) this.value = this.value.replace(/[^0-9]/g, '')
});
$(".number").keyup(function (e) {
if (/\D/g.test(this.value)) this.value = this.value.replace(/[^0-9-]/g, '')
});
$(".Phone").keyup(function (e) {
if (/\D/g.test(this.value)) this.value = this.value.replace(/[^0-9]/g, '')
});
$(".Phone").css('text-align', 'left');
$(".Amount").keyup(function (e) {
if (/\D/g.test(this.value)) {
if (this.value.length == 1) this.value = this.value.replace(/[.]/g, '0.');
this.value = this.value.replace(/[^0-9\.{2}[0-9]]/g, '')
if (this.value.split(".").length > 2) this.value = this.value.replace(/\.+?$/, '')
if (this.value.split(".").length > 2) this.value = this.value.replace(this.value, '')
if (this.value.charAt(0) == ".") this.value = this.value.replace(this.value, '0' + this.value)
}
});
$(".Weight").keyup(function (e) {
if (/\D/g.test(this.value)) {
if (this.value.length == 1) this.value = this.value.replace(/[.]/g, '0.');
this.value = this.value.replace(/[^0-9\.]/g, '')
if (this.value.split(".").length > 2) this.value = this.value.replace(/\.+?$/, '')
if (this.value.split(".").length > 2) this.value = this.value.replace(this.value, '')
if (this.value.charAt(0) == ".") this.value = this.value.replace(this.value, '0' + this.value)
}
});
$(".Number").blur(function (e) {
if ($.isNumeric(this.value))
this.value = parseFloat(this.value).toFixed(0);
});
$(".Amount").blur(function (e) {
if ($.isNumeric(this.value))
this.value = parseFloat(this.value).toFixed(2);
});
$(".Weight").blur(function (e) {
if ($.isNumeric(this.value))
this.value = parseFloat(this.value).toFixed(3);
});
$("#txtSearchText").keyup(function () {
BindMenu();
});
ResetFocus();
$(document).on("DOMNodeInserted", function (e) {
ResetFocus();
});
var tabindex = 1;
$(document).on("click", "#RecordTable tr", function () {
var selected = $(this).hasClass("highlight");
$("#RecordTable tr").removeClass("highlight");
//if (!selected)
$(this).addClass("highlight");
});
$("#txtSearch").keydown(function (e) {
if (e.which == 13) {
$("#btnSearch").focus();
$("#btnSearch").select();
return false;
}
});
$("#btnSearchDrildownData").click(function () {
SearchData(ID_1, Type_1, Cond1_1);
return false;
});
$('input[type=text]').blur(function () {
if (event.target.type !== "textarea" && event.target.type !== "password" && event.target.id !== "txtEmailId") {
$(this).val($(this).val().());
}
});
//showCompanyMessage(1);
// ShowNotification();
});
function FixTableHeader() {
setTimeout(function () {
$("#RecordTable,.RecordTable,.table").tableHeadFixer();
}, 100);
}
function AutoComplete(ID, Type, contextKey, contextKey2) {
$("#" + ID).autocomplete({
// autoFocus: true,
minLength: 1,
source: function (request, response) {
$.ajax({
url: CommonURL + "/AutoComplete/Index",
type: "POST",
dataType: "json",
data: { Prefix: request.term, Type: Type, contextKey: $("#" + contextKey).val(), contextKey2: $("#" + contextKey2).val() },
success: function (data) {
response(data);
},
error: function (xhr, err) {
var responseTitle = $(xhr.responseText).filter('title').get(0);
alert($(responseTitle).text() + "\n" + AjaxError(xhr, err));
UnBlockUI();
}
});
},
messages: {
noResults: '',
results: function (resultsCount) { }
}
});
}
function SortTable() {
$('th').click(function () {
var table = $(this).parents('table').eq(0)
var rows = table.find('tr:gt(0)').toArray().sort(comparer($(this).index()))
this.asc = !this.asc
if (!this.asc) { rows = rows.reverse() }
for (var i = 0; i < rows.length; i++) {
table.append(rows[i]);
}
})
function comparer(index) {
return function (a, b) {
var valA = getCellValue(a, index), valB = getCellValue(b, index)
return $.isNumeric(valA) && $.isNumeric(valB) ? valA - valB : valA.toString().localeCompare(valB)
}
}
function getCellValue(row, index) { return $(row).children('td').eq(index).text() }
}
function resizeTableColumn() {
$("#RecordTable,.RecordTable").colResizable({
liveDrag: true,
//gripInnerHtml: "
",
draggingClass: "dragging",
resizeMode: "overflow",
partialRefresh: true,
onDrag: onTableDraged
});
}
function onTableDraged() {
$("#RecordTable").css("white-space","normal");
}
function isNumber(evt) {
evt = (evt) ? evt : window.event;
var charCode = (evt.which) ? evt.which : evt.keyCode;
if (charCode > 31 && (charCode < 48 || charCode > 57)) {
return false;
}
return true;
}
function ValidateEmail(mail) {
if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(mail)) {
return (true)
}
return (false)
}
function ValidateNumber(e) {
if ($.inArray(e.keyCode, [46, 8, 9, 27, 13, 110, 190]) !== -1 ||
// Allow: Ctrl+A
(e.keyCode == 65 && e.ctrlKey === true) ||
// Allow: Ctrl+C
(e.keyCode == 67 && e.ctrlKey === true) ||
// Allow: Ctrl+X
(e.keyCode == 88 && e.ctrlKey === true) ||
// Allow: home, end, left, right
(e.keyCode >= 35 && e.keyCode <= 39)) {
// let it happen, don't do anything
return;
}
// Ensure that it is a number and stop the keypress
if ((e.shiftKey || (e.keyCode < 48 || e.keyCode > 57)) && (e.keyCode < 96 || e.keyCode > 105)) {
e.preventDefault();
}
};
function BlockUI() {//Must Use BlockUI.js on Page---------------->>>>>
BlockUIStatus = 1;
$(document).ready(function () {
$.blockUI({
css: {
border: 'none',
padding: '15px',
backgroundColor: '#000',
'-webkit-border-radius': '10px',
'-moz-border-radius': '10px',
opacity: .5,
color: '#fff'
}
});
});
}
function UnBlockUI() {
BlockUIStatus = 0;
$(document).ready(function () {
setTimeout($.unblockUI, 0);
});
}
function AddLoaderOnButton(btn) {
if (btn.substring(0, 1) == ".") {
$(btn + ">i").addClass("fa-spinner fa-spin");
$(btn).attr("disabled", "disabled");
} else {
$("#" + btn + ">i").addClass("fa-spinner fa-spin");
$("#" + btn).attr("disabled", "disabled");
}
}
function RemoveLoaderOnButton(btn) {
if (btn.substring(0, 1) == ".") {
$(btn + ">i").removeClass("fa-spinner fa-spin");
$(btn).removeAttr("disabled");
} else {
$("#" + btn + ">i").removeClass("fa-spinner fa-spin");
$("#" + btn).removeAttr("disabled");
}
}
function setTimemask(id) {
$(document).ready(function () {
$("#" + id).mask("99:99");
});
}
function Growl(msg) {
BlockUIStatus = 2;
$(document).ready(function () {
$.growlUI('✔', msg);
});
}
function Time24Hours(txt) {
var time = txt.value;
var char1 = time.substring(0, 1);
var char2 = time.substring(1, 2);
var char3 = time.substring(2, 3);
var char4 = time.substring(3, 4);
var char5 = time.substring(4, 5);
if (char1 != "" && char1 != "_" && eval(char1) > 2) {
txt.value = "_" + char2 + char3 + char4 + char5;
txt.select();
}
else if (char2 != "" && char2 != "_" && eval(char1 + char2) > 23) {
txt.value = char1 + "_" + char3 + char4 + char5;
txt.select();
}
else if (char4 != "" && char4 != "_" && eval(char4) > 5) {
txt.value = char1 + char2 + char3 + "_" + char5;
txt.select();
}
else if (char5 != "" && char5 != "_" && eval(char4 + char5) > 59) {
txt.value = char1 + char2 + char3 + char4 + "_";
txt.select();
}
//if (char1 != "" && char2 != "" && char4 != "" && char1 != "_" && char2 != "_" && char4 != "_" && eval(char1 + char2) == 23 && eval(char4) > 0) {
// txt.value = char1 + char2 + char3 + "_" + "_";
// txt.select();
//}
//else if (char1 != "" && char2 != "" && char5 != "" && char1 != "_" && char2 != "_" && char5 != "_" && eval(char1 + char2) == 23 && eval(char5) > 0) {
// txt.value = char1 + char2 + char3 + char4 + "_";
// txt.select();
//}
}
function setmask(id) {
$(document).ready(function () {
$("#" + id).mask("99-aaa-9999");
//$("#" + id).val("");
});
}
function Pager(a, b) {
var c = '{0}';
var d = "{0}";
var e, f, g;
var g = 5;
var h = Math.ceil(b.RecordCount / b.PageSize);
if (b.PageIndex > h) { b.PageIndex = h }
var i = "";
if (h > 1) {
f = h > g ? g : h; e = b.PageIndex > 1 && b.PageIndex + g - 1 < g ? b.PageIndex : 1;
if (b.PageIndex > g % 2) {
if (b.PageIndex == 2) f = 5;
else f = b.PageIndex + 2
}
else {
f = g - b.PageIndex + 1
}
if (f - (g - 1) > e) {
e = f - (g - 1)
}
if (f > h) {
f = h; e = f - g + 1 > 0 ? f - g + 1 : 1
}
var j = (b.PageIndex - 1) * b.PageSize + 1;
var k = j + b.PageSize - 1;
if (k > b.RecordCount) {
k = b.RecordCount
}
i = ""; // "Records " + (j == 0 ? 1 : j) + " - " + k + " of " + b.RecordCount + " ";
if (b.PageIndex > 1) {
i += c.replace("{0}", "<<").replace("{1}", "1");
i += c.replace("{0}", "<").replace("{1}", b.PageIndex - 1)
}
for (var l = e; l <= f; l++) {
if (l == b.PageIndex) {
i += d.replace("{0}", l)
}
else {
i += c.replace("{0}", l).replace("{1}", l)
}
}
if (b.PageIndex < h) {
i += c.replace("{0}", ">").replace("{1}", b.PageIndex + 1);
i += c.replace("{0}", ">>").replace("{1}", h)
}
} a.html(i);
try {
a[0].disabled = false
}
catch (m) { }
}
(function (a) {
a.fn.A_Pager = function (b) {
var c = {};
var b = a.extend(c, b);
return this.each(function () {
Pager(a(this), b)
})
}
})(jQuery);
function GetMsgBox(Msg, Type) {
if (Msg !== undefined && Msg != "") {
if (Type == "S") {
$(".ErrorMsg").show();
$(".ErrorMsg").css("background-color", "#d4edda");
$(".lblErrorMsg").css("color", "#3b754f");
$(".divicon").removeClass("ace-icon fa fa-ban danger");
$(".divicon").addClass("fa fa-check").css("color", "#3b754f");
}
else if (Type == "E") {
$(".ErrorMsg").show();
$(".ErrorMsg").css("background-color", "#f8d7da");
$(".lblErrorMsg").css("color", "#7b4055");
$(".divicon").removeClass("fa fa-check");
$(".divicon").addClass("ace-icon fa fa-ban danger").css("color", "#7b4055");
//alert(Msg);
}
$(".lblErrorMsg").html(Msg);
}
}
function ResetFocus() {
//$(':input:visible:enabled:not(textarea),select')
var inputs = $(':input:visible:enabled,select').keypress(function (e) {
if (e.which == 13 && event.target.type != "textarea") {
e.preventDefault();
var nextInput = inputs.get(inputs.index(this) + 1);
if (nextInput) {
nextInput.focus();
// nextInput.select();
}
}
});
}
function htmlDecoder(Text) {
//var decoded = $('').html(Text).text();
//return decoded;
return Text;
}
function NotPermission() {
alert("You don't have permission for this operation!\nSystem is redirecting you to login page, Please login again.");
$(window.location).attr("href", CommonURL + "UserLogin/Default");
}
function SessionExpire() {
//alert("Your session has been expired!\nSystem is redirecting you to login page, Please login again.");
$(window.location).attr("href", CommonURL + "Dashboard/ViewPage");
}
AddAntiForgeryToken = function (data) {
data.Token = $("#_Token").val();
data.__RequestVerificationToken = $("input[name=__RequestVerificationToken]").val();
data.SortType = $("#hfSortTxt").val();
data.ColumnName = $("#hfColumnName").val();
return data;
};
function BindMenu() {
try {
$.post(CommonURL + "/Navbar/BindMenu",
{
SearchText: $("#txtSearchText").val()
},
function (data) {
if (data.Result === undefined) {
alert(AjaxError(0, 0));
return false;
}
if (data.Result == "EXPIRED") {
SessionExpire();
return false;
}
else if (data.Menu != "") {
$("#divnavbar").show();
$("#lblSearchText").html(data.Menu);
}
else {
$("#divnavbar").hide();
$("#lblSearchText").html("");
}
}).fail(function (xhr, err) {
var responseTitle = $(xhr.responseText).filter('title').get(0);
alert($(responseTitle).text() + "\n" + AjaxError(xhr, err));
});
}
catch (e) {
alert("Error In BindMenu: " + e.message);
}
}
function FixedHeader() {
var tableOffset = $("#table-1").offset().top;
var $header = $("#table-1 > thead").clone();
var $fixedHeader = $("#header-fixed").append($header);
$(window).bind("scroll", function () {
var offset = $(this).scrollTop();
if (offset >= tableOffset && $fixedHeader.is(":hidden")) {
$fixedHeader.show();
}
else if (offset < tableOffset) {
$fixedHeader.hide();
}
});
}
function AjaxError(jqXHR, exception) {
if (jqXHR == 0 && exception == 0) {
return ("There is unexpected error perform by application, Please clear the cache of browser and try again.!");
} else if (jqXHR.status === 0) {
return ('Not connected.\nPlease verify your network connection.');
} else if (jqXHR.status == 404) {
return ('The requested page not found. [404]');
} else if (jqXHR.status == 500) {
return ('Internal Server Error [500].');
} else if (exception === 'parsererror') {
return ('Requested JSON parse failed.');
} else if (exception === 'timeout') {
return ('Time out error.');
} else if (exception === 'abort') {
return ('Ajax request aborted.');
} else {
return ('Uncaught Error.\n' + jqXHR.responseText);
}
}
function OpenEntryPopUp(formName, controlID, functionName) {
BlockUI();
var windowWidth = $(window).width();
if (formName == "PinCode") {
var page = CommonURL + "Master/PinCodeMaster?IsPopup=1&controlID=" + controlID + "&functionName=" + functionName;
var $dialog = $('')
.html('')
.dialog({
autoOpen: false, modal: true, height: 500, width: 400, title: "Pin Code Master"
});
$dialog.dialog('open');
}
else if (formName == "ConsignorConsignee") {
var page = CommonURL + "Client/ConsignorConsigneeMaster?IsPopup=1&controlID=" + controlID + "&functionName=" + functionName;
var $dialog = $('')
.html('')
.dialog({
autoOpen: false, modal: true, height: 700, width: 600, title: "Consignor Consignee Master"
});
$dialog.dialog('open');
}
else if (formName == "PacketBooking") {
var page = CommonURL + "Operation/Packetbooking/UPD?IsPopup=1&controlID=" + controlID + "&functionName=" + functionName;
var $dialog = $('')
.html('')
.dialog({
autoOpen: false, modal: true, height: 700, width: (windowWidth - 200), title: "Update AWB: " + controlID + ""
});
$dialog.dialog('open');
}
else if (formName == "ClientSpecialRate") {
var page = CommonURL + "Invoice/SpecialClientRateMaster?IsPopup=1&controlID=" + controlID + "&functionName=" + functionName;
var $dialog = $('')
.html('')
.dialog({
autoOpen: false, modal: true, height: 500, width: 500, title: "Special Rate [" + controlID + "]"
});
$dialog.dialog('open');
}
else if (formName == "ClientSpecialRate_AwbChecking") {
var page = CommonURL + "Invoice/SpecialClientRateMaster?IsPopup=1&controlID=" + controlID + "&functionName=" + functionName + "&PageType=ACC";
var $dialog = $('')
.html('')
.dialog({
autoOpen: false, modal: true, height: 500, width: 500, title: "Special Rate [" + controlID + "]"
});
$dialog.dialog('open');
}
else if (formName == "JournalVoucher") {
var page = CommonURL + "Accounts/JournalVoucher?IsPopup=1&controlID=" + controlID + "&functionName=" + functionName;
var $dialog = $('')
.html('')
.dialog({
autoOpen: false, modal: true, height: 500, width: 1100, title: "Journal Entry"
});
$dialog.dialog('open');
}
else if (formName == "ReceiptVoucher") {
var page = CommonURL + "Accounts/ReceiptVoucher?IsPopup=1&controlID=" + controlID + "&functionName=" + functionName;
var $dialog = $('')
.html('')
.dialog({
autoOpen: false, modal: true, height: 500, width: 1100, title: "Receipt Entry"
});
$dialog.dialog('open');
}
else if (formName == "OutStandingDetail") {
var page = CommonURL + "Accounts/ClientOutStandingDetails?IsPopup=1&" + controlID + "&functionName=" + functionName;
var $dialog = $('')
.html('')
.dialog({
autoOpen: false, modal: true, height: 500, width: 1100, title: "Out Standing Detail"
});
$dialog.dialog('open');
}
else if (formName == "AccountMaster") {
var page = CommonURL + "Accounts/AccountMaster?IsPopup=1&controlID=" + controlID + "&functionName=" + functionName;
var $dialog = $('')
.html('')
.dialog({
autoOpen: false, modal: true, height: 500, width: 500, title: "Account Master"
});
$dialog.dialog('open');
}
}
function OpenEntryPopUpShortCutKey(formName, controlID, functionName) {
if ((event.which || event.keyCode) == 112) {
OpenEntryPopUp(formName, controlID, functionName);
}
}
function OpenMasterDataPopup(ID, Type, Cond1, Width, Height) {
if ((event.which || event.keyCode) == 113) {
ID_1 = ID;
Type_1 = Type;
Cond1_1 = Cond1;
$(".Open-Master-Data-Popup").modal({ backdrop: 'static', keyboard: false }).draggable({
handle: ".modal-header"
});
$("#txtSearchData").val("");
$("#lblShowData").html("");
$("#lblTotalRecords").html("");
$("#lblMasterPopupTitle").html("");
SearchData(ID, Type, Cond1);
}
}
function SelectRecord(Value, ID) {
$(".Open-Master-Data-Popup").modal('hide');
$("#" + ID).val(Value)
$("#txtSearchData").val("");
$("#lblMasterPopupTitle").html("");
$("#" + ID).focus();
}
function Datepicker() {
$(".datepicker").datepicker({
format: 'd-M-yyyy',
autoclose: true,
leftArrow: '«',
rightArrow: '»',
todayHighlight: true,
changeMonth: true,
changeYear: true,
yearRange: '1950:2030'
})
}
function EncryptText(txtbox, keyV) {
var txtValue = $("#" + txtbox);
if (txtValue.val() == "") {
alert('Please enter Value');
return false;
}
else if (keyV == "") {
alert('Please enter key');
return false;
}
else if (keyV.length != 16) {
alert('key length should be 16 characters');
return false;
}
else {
var key = CryptoJS.enc.Utf8.parse(keyV);
var iv = CryptoJS.enc.Utf8.parse(keyV);
var encryptedText = CryptoJS.AES.encrypt(CryptoJS.enc.Utf8.parse(txtValue.val()), key,
{
keySize: 128 / 8,
iv: iv,
mode: CryptoJS.mode.CBC,
padding: CryptoJS.pad.Pkcs7
});
txtValue.val(encryptedText);
//alert('encrypted text :' + encryptedText);
}
}
function printDiv(divID, PrintName, borderRequired, fontSize) {
if (PrintName === undefined || PrintName == "") {
PrintName = "Print";
}
if (fontSize === undefined || fontSize == "") {
fontSize = "10";
}
if (borderRequired === undefined || borderRequired == "") {
borderRequired = "1";
}
var css = "";
css += "";
var divToPrint = document.getElementById(divID);
var newWin = window.open('', 'Print-Window');
newWin.document.open();
newWin.document.write("" + PrintName + "" + css + "" + divToPrint.innerHTML + "");
newWin.document.close();
setTimeout(function () { newWin.close(); }, 10);
}
function showCompanyMessage(CallType) {
try {
if ($("#hfLoginCompanyCode").val() !== undefined) {
$.post(CommonURL + "Dashboard/showCompanyMessage",
{},
function (data) {
if (data.Result === undefined) {
alert(AjaxError(0, 0));
}
if (data.Result == "EXPIRED") {
SessionExpire();
}
else if (data.Result != "") {
alert(data.Result);
}
else {
if ($("#hfLoginUserType").val() == "CLIENT") {
$("#lblBalanceAmount").hide();
}
else {
$("#lblBalanceAmount").html(data.BalanceAmount);
}
if (CallType == 1) {
if (data.CompanyMessage != "") {
$("#lblCompanyMessage").html(data.CompanyMessage);
$("#dvCompanyMessage").show(500);
//$("#dvCompanyMessage").animate({
// height: 'toggle'
//});
}
}
}
}).fail(function (xhr, err) {
var responseTitle = $(xhr.responseText).filter('title').get(0);
alert($(responseTitle).text() + "\n" + AjaxError(xhr, err));
});
}
}
catch (e) {
alert("showCompanyMessage: " + e.message);
}
}
function getCurrentFinancialYear() {
var fiscalyear = "";
var today = new Date();
if ((today.getMonth() + 1) <= 3) {
fiscalyear = (today.getFullYear() - 1) + "-" + today.getFullYear()
} else {
fiscalyear = today.getFullYear() + "-" + (today.getFullYear() + 1)
}
return fiscalyear
}
function ShowNotification() {
GetTotalComplaintRequest();
setTimeout("ShowNotification();", 10000);
}
function NumberOnlyWithCharacters() {
var number = event.keyCode;
if ((number > 64 && number < 91) || (number > 96 && number < 123) || (number > 47 && number < 58) || number == 44 || number == 13)
return true;
else
return false;
}
function NumberOnlyWithCharactersWithSpace() {
var number = event.keyCode;
if ((number > 64 && number < 91) || (number > 96 && number < 123) || (number > 47 && number < 58) || number == 44 || number == 13 || number == 32)
return true;
else
return false;
}
function SortByArrow(element) {
var hfSortTxt = document.getElementById("hfSortTxt");
var hfColumnName = document.getElementById("hfColumnName");
if (element.id == "SortedUpA") {
hfSortTxt.value = "Asc";
hfColumnName.value = element.parentNode.textContent;
ShowDataSearch();
}
else if (element.id == "SortedDoDes") {
hfSortTxt.value = "Desc";
hfColumnName.value = element.parentNode.textContent;
ShowDataSearch();
}
}
function GetQueryStringParams(sParam) {
var sPageURL = window.location.search.substring(1);
var sURLVariables = sPageURL.split('&');
for (var i = 0; i < sURLVariables.length; i++) {
var sParameterName = sURLVariables[i].split('=');
if (sParameterName[0] == sParam) {
return sParameterName[1];
}
}
}
function BindDropDownData(Type, Key, ID,RegistrationNo) {
try {
$.post(CommonURL + "Vacancy/BindDropDown",
AddAntiForgeryToken({
Type: Type,
Key: Key,
RegistrationNo:RegistrationNo,
}), function (data) {
if (data.Result === undefined) {
alert(AjaxError(0, 0));
}
else {
$("#" + ID).html(data.DropDownList);
}
}).fail(function (xhr, err) {
var responseTitle = $(xhr.responseText).filter('title').get(0);
alert($(responseTitle).text() + "\n" + AjaxError(xhr, err));
});
}
catch (e) {
alert("Error In BindDropDowm: " + e.message, "E");
}
}