window.July = {};
July.Common = {};
July.Client = {};
Company
(function (Client) {
function CompanyList() {
/*Private*/
function Add() {
var wnd = $("#divCompanyForm");
var url = util.FullURLByAction('Client/Company/Create');
var title = "Company";
util.OpenInKendoWindow(wnd, url, title);
}
function Edit(id) {
if (id) {
var wnd = $("#divCompanyForm");
var url = util.FullURLByAction('Client/Company/Edit/' + id);
var title = "Company";
util.OpenInKendoWindow(wnd, url, title);
}
}
//public
return {
ReloadGrid: function () {
util.RefreshKendoGrid($("#grid-Company"));
},
init: function () {
$("#grid-Company").dblclick(function (e) {
var id = util.GetKendoGridSelectedId($("#grid-Company"));
Edit(id);
});
$("#add-Company").click(function () {
Add();
});
$(document).on("click", "#edit-Company", function () {
var id = util.GetKendoGridSelectedId($("#grid-Company"));
if (id) {
Edit(id);
}
else {
util.ShowAlertBox("Please select a row to edit.", "Information");
}
});
}
}
}
July.Client.CompanyList = CompanyList;
function CompanyForm() {
/*Private*/
var companyEntityTypeId = 'ac0b0e0e-4dc4-e211-9725-0011258f6fb9';
var companyvalidator;
function checkDuplicateTaxId () {
var result;
var comtaxId = $('#companyForm #txtTaxId').val();
var unmaskTaxId = commoncontent.unmaskTaxIdValue(comtaxId);
var companyId = $('#companyForm #txtCompanyId').val();
action = 'Client/Company/CheckDuplicateCompanyTaxId/?companyId=' + companyId + '&taxId=' + unmaskTaxId
$.ajax({
url: util.FullURLByAction(action),
type: 'GET',
async:false,
dataType: 'json',
success: function (totDupData) {
if (totDupData > 0) {
result = true;
}
else {
resut = false;
}
}
});
return result;
}
function saveCompany (saveandclose) {
//var chkDupTaxId = checkDuplicateTaxId();
//if (chkDupTaxId) {
// $.messager.alert('DUPLICATE DATA', 'Duplicate Tax-ID found in the system', 'error');
//}
//if (!companyvalidator.form()) {
// return false;
//}
//commoncontent.showBlockUI();
var wnd = $("#divCompanyForm");
commoncontent.unmaskTaxId($("#txtTaxId"));
$.ajax({
url: util.FullURLByAction('Client/Company/SaveCompany'),
type: 'POST',
data: $('#companyForm').serialize(),
dataType: 'json',
//async:false,
success: function (result) {
if (result.Success == true) {
var companyList = new July.Client.CompanyList();
companyList.ReloadGrid();
//util.CallParentFunction('ReloadGrid');
if (saveandclose)
{
util.CloseKendoWindow(wnd);
}
if (result.NewModel == true) {
if (!saveandclose) {
$('#txtCompanyId').val(result.Id);
var internetAddressList = new July.Common.InternetAddressList();
internetAddressList.EnableButtons(result.Id, companyEntityTypeId);
var phoneList = new July.Common.PhoneList();
phoneList.EnableButtons(result.Id, companyEntityTypeId);
var addressList = new July.Common.AddressList();
addressList.EnableButtons(result.Id, companyEntityTypeId);
var companyTypeList = new July.Client.xCompanyCompanyTypeList();
companyTypeList.EnableButtons(result.Id);
var divisionList = new July.Client.DivisionList();
divisionList.EnableButtons(result.Id, companyEntityTypeId);
var bankAccountList = new July.Client.BankAccountList();
bankAccountList.EnableButtons(result.Id, companyEntityTypeId);
var companyOwnershipList = new July.Client.CompanyOwnershipList();
companyOwnershipList.EnableButtons(result.Id, companyEntityTypeId);
var iDNumberList = new July.Client.IDNumberList();
iDNumberList.EnableButtons(result.Id, companyEntityTypeId);
}
}
$("#txtTaxId").mask("99-9999999");
}
else {
util.ShowAlertBox("Error occurred. Please try again.", "Error!")
}
},
error: function (error) {
util.ShowAlertBox(error, "Error!")
}
});
}
function deleteCompanyById(companyId) {
$.ajax({
url: util.FullURLByAction('Client/Company/DeleteCompany'),
type: 'POST',
data: { Id: companyId },
dataType: 'json',
//async:false,
success: function (result) {
var companyList = new July.Client.CompanyList();
companyList.ReloadGrid();
var wnd = $("#divCompanyForm");
util.CloseKendoWindow(wnd);
},
error: function (error) {
util.ShowAlertBox(error, "Error!")
}
});
}
//public
return {
init: function () {
$("#companyForm #txtCompanyName").focus();
$("#txtTaxId").mask("99-9999999");
if ($('#companyForm #IsParent').is(':checked')) {
$('#companyForm #ParentId').data("kendoDropDownList").enable(false);
}
$('#companyForm #IsParent').click(function () {
var thisCheck = $(this);
if (thisCheck.is(':checked')) {
$('#companyForm #ParentId').data("kendoDropDownList").enable(false);
}
else {
$('#companyForm #ParentId').data("kendoDropDownList").enable(true);
}
});
$("#lnkCompanySave").click(function () {
var validator = $("#txtCompanyName").kendoValidator().data("kendoValidator");
if(validator.validate())
{
if ($("input[id='txtCompanyId']").val() == '00000000-0000-0000-0000-000000000000') {
$.when(kendo.ui.ExtOkCancelDialog.show({
title: "Confirm",
message: "Are you sure to save this record?",
icon: "k-ext-information"
})
).done(function (response) {
if (response.button == "OK") {
saveCompany(false)
}
});
}
else {
$.when(kendo.ui.ExtOkCancelDialog.show({
title: "Confirm",
message: "Are you sure to Update this record?",
icon: "k-ext-information"
})
).done(function (response) {
if (response.button == "OK") {
saveCompany(false)
}
});
}
}
});
$("#lnkCompanySaveAndClose").click(function () {
if ($("input[id='txtCompanyId']").val() == '00000000-0000-0000-0000-000000000000') {
$.when(kendo.ui.ExtOkCancelDialog.show({
title: "Confirm",
message: "Are you sure to save this record?",
icon: "k-ext-information"
})
).done(function (response) {
if (response.button == "OK") {
saveCompany(true)
}
});
}
else {
$.when(kendo.ui.ExtOkCancelDialog.show({
title: "Confirm",
message: "Are you sure to Update this record?",
icon: "k-ext-information"
})
).done(function (response) {
if (response.button == "OK") {
saveCompany(true)
}
});
}
});
$("#lnkCompanyDelete").click(function () {
$.when(kendo.ui.ExtInputDialog.show({
title: "Confirm Delete",
message: "Are you sure to delete this record? Please type Delete and press Ok.",
required: true,
width: 340,
height: 145
})
).done(function (response) {
if (response.button == "OK") {
if (response.input.toLowerCase() == 'delete') {
deleteCompanyById($('#txtCompanyId').val())
}
}
})
});
$('form#companyForm #company-tab').tabs({
border: false,
onSelect: function (title) {
if ($('#company-tab').attr('title') == title) {
return;
}
$('#company-tab').attr('title', title);
if (title == 'Overview') {
//Internet Address
if ($('form#companyForm #divCompanyInternetAddresses').html() == "") {
var url = util.FullURLByAction('Common/InternetAddress/GetInternetAddressesListView?parentId=' + $('#txtCompanyId').val() + '&parentEntityId=' + companyEntityTypeId);
var res = util.GetRemoteData(url);
$('form#companyForm #divCompanyInternetAddresses').html(res);
}
//Phone
if ($('form#companyForm #divCompanyPhone').html() == "") {
var url = util.FullURLByAction('Common/Phone/GetPhoneListView?parentId=' + $('#txtCompanyId').val() + '&parentEntityId=' + companyEntityTypeId);
var res = util.GetRemoteData(url);
$('form#companyForm #divCompanyPhone').html(res);
}
//Address
if ($('form#companyForm #divCompanyAddresses').html() == "") {
var url = util.FullURLByAction('Common/Address/GetAddressListView?parentId=' + $('#txtCompanyId').val() + '&parentEntityId=' + companyEntityTypeId);
var res = util.GetRemoteData(url);
$('form#companyForm #divCompanyAddresses').html(res);
}
//Company Types
if ($('form#companyForm #divCompanyCompanyTypes').html() == "") {
var url = util.FullURLByAction('Client/CompanyType/GetCompanyTypeListView?parentId=' + $('#txtCompanyId').val());
var res = util.GetRemoteData(url);
$('form#companyForm #divCompanyCompanyTypes').html(res);
}
//accounts
if ($('form#companyForm #divCompanyAccounts').html() == "") {
var url = util.FullURLByAction('Client/AccountPlan/GetAccountListView?companyId=' + $('#txtCompanyId').val());
var res = util.GetRemoteData(url);
$('form#companyForm #divCompanyAccounts').html(res);
}
}
if (title == 'Contacts') {
if ($('form#companyForm #divCompanyContacts').html() == "") {
var url = util.FullURLByAction('Client/Contact/GetContactListView?companyId=' + $('#txtCompanyId').val());
var res = util.GetRemoteData(url);
$('form#companyForm #divCompanyContacts').html(res);
}
}
if (title == 'Prod/Div/Loc') {
//Products
if ($('form#companyForm #divCompanyProduct').html() == "") {
var url = util.FullURLByAction('Fee/Product/GetProductListView?companyId=' + $('#txtCompanyId').val());
var res = util.GetRemoteData(url);
$('form#companyForm #divCompanyProduct').html(res);
}
//Divisions
if ($('form#companyForm #divCompanyDivisions').html() == "") {
var url = util.FullURLByAction('Client/Division/GetDivisionListView?parentId=' + $('#txtCompanyId').val() + '&parentEntityId=' + companyEntityTypeId);
var res = util.GetRemoteData(url);
$('form#companyForm #divCompanyDivisions').html(res);
}
//Locations
if ($('form#companyForm #divCompanyLocations').html() == "") {
var url = util.FullURLByAction('Client/Company/GetLocationListView?parentId=' + $('#txtCompanyId').val() + '&parentEntityId=' + companyEntityTypeId);
var res = util.GetRemoteData(url);
$('form#companyForm #divCompanyLocations').html(res);
}
}
//else if (title == 'Correspondence') {
// if ($('form#companyForm #divCompanyActivities').html() == "") {
// var url = util.FullURLByAction('Common/Activity/GetActivities?parentId=' + $('#txtCompanyId').val() + '&parentEntityId=' + companyEntityTypeId);
// var res = util.GetRemoteData(url);
// $('form#companyForm #divCompanyActivities').html(res);
// activitycontent.init('#divCompanyActivities ');
// activitycontent.loadActivityList('#divCompanyActivities ');
// }
// else {
// activitycontent.loadActivityList('#divCompanyActivities ');
// }
//}
else if (title == 'Banking') {
if ($('form#companyForm #divcompanyBanking').html() == "") {
var url = util.FullURLByAction('Client/BankAccount/BankAccountList?parentId=' + $('#txtCompanyId').val() + '&parentEntityId=' + companyEntityTypeId);
var res = util.GetRemoteData(url);
$('form#companyForm #divcompanyBanking').html(res);
}
}
else if (title == 'Ownership') {
if ($('form#companyForm #divCompanyOwnershipList').html() == "") {
var url = util.FullURLByAction('Client/CompanyOwnership/CompanyOwnershipListView?parentId=' + $('#txtCompanyId').val());
var res = util.GetRemoteData(url);
$('form#companyForm #divCompanyOwnershipList').html(res);
}
}
else if (title == 'ID Numbers') {
if ($('form#companyForm #divCompanyIdNumbers').html() == "") {
var url = util.FullURLByAction('Client/IDNumber/GetIdNumberListView?parentId=' + $('#txtCompanyId').val() + '&parentEntityId=' + companyEntityTypeId + '&parentType=Company');
var res = util.GetRemoteData(url);
$('form#companyForm #divCompanyIdNumbers').html(res);
}
};
}
});
$("#lnkFileManager").click(function () {
var opt = {};
var parentId = $("form#companyForm input[id='ReadableId']").val();
var ParentEntityId = "Company";
opt.url = util.FullURLByAction('FileInfo/AjaxFileBrowser?ParentId=' + parentId + '&ParentEntityId=' + ParentEntityId);
if (opt.Width == null || opt.Width == undefined) {
opt.Width = 980;
}
opt.Title = "TPA File Manager";
util.ShowIFrameDialog(opt);
});
}
}
}
July.Client.CompanyForm = CompanyForm;
}(July.Client));
Index.cshtml(Queue)
<a class="action action-add" id="add-Queue" href="javascript:"><i class="add-icon-for-con"></i></a>
<a class="action action-edit" id="edit-Queue" href="javascript:"><i class="edit-icon-for-con"></i></a>
<div id="divQueue"></div>
<script src="~/Scripts/application/project/QueueData.js"></script>
<script>
var queuelist = new July.Project.QueueList();
queuelist.init();
</script>
Queue
/*==== Created By : Rubol
* Date Created : August 05,2013
========================================*/
(function (Project) {
function QueueList() {
/*Private*/
function addQueue() {
util.ShowIDPDialog(util.FullURLByAction('Queue/Create'), 600, 'Queue', 'Queue', null, 300);
}
function editQueue(id) {
if (id) {
util.ShowIDPDialog(util.FullURLByAction('Queue/Edit/' + id), 600, 'Queue', 'NULL', id, 180);
}
else {
$.messager.alert('Information', 'Please select a row to edit.');
}
}
//public
return {
init: function () {
$("#add-Queue").click(function () {
addQueue();
});
$("#edit-Queue").click(function () {
var grid = $("#grid-Queue").data("kendoGrid");
var row = grid.select();
var dataItem = grid.dataItem(row);
if (!dataItem) $.messager.confirm('Warning', 'Please select a row first.');
var id = dataItem.Id;
editQueue(id);
});
$("#grid-Queue").dblclick(function (e) {
var grid = $("#grid-Queue").data("kendoGrid");
var row = grid.select();
var dataItem = grid.dataItem(row);
var id = dataItem.Id;
editQueue(id);
});
}
}
}
July.Project.QueueList = QueueList;
function QueueForm() {
/*Private*/
function SaveQueue(action) {
action = util.FullURLByAction(action);
$.ajax({
url: action,
type: 'POST',
data: $('#QueueForm').serialize(),
dataType: 'json',
async: false,
success: function (result) {
// $("#divQueue").dialog("close");
if (result) {
util.CallParentFunction('ReloadGrid');
util.CloseIFrame(this);
}
else {
return false;
}
}
});
}
function deletequeuebyid(id) {
$.messager.confirm('confirm', 'are you sure, you want to delete this record?', function (r) {
if (r) {
$.ajax({
url: util.FullURLByAction('Queue/deletequeuebyid/' + id),
type: 'post',
async: false,
success: function (result) {
util.CallParentFunction('ReloadGrid');
util.CloseIFrame(this);
}
});
}
else {
alert("failed to delete item.");
}
});
}
//public
return {
init: function () {
//var data = [
// { name: "Name1", value: 1 },
// { name: "Name2", value: 2 },
// { name: "Name3", value: 3 }
//];
//var dataSource = new kendo.data.DataSource({
// transport: {
// read: {
// url: "http://demos.telerik.com/kendo-ui/service/products",
// dataType: "jsonp"
// }
// }
//});
//$("#BusinessCodeId").kendoDropDownList({
// dataTextField: "name",
// dataValueField: "value",
// optionLabel: "Select Name",
// dataSource: {
// data: data
// }
//});
var validator = $("#QueueForm").kendoValidator().data("kendoValidator");
$("span.k-dropdown").focusout(function () {
validator.validate();
});
$("#lnkQueueSave").click(function () {
var action = 'Queue/SaveQueue';
if ($("input[id='Id']").val() == '00000000-0000-0000-0000-000000000000') {
if (validator.validate()) {
SaveQueue(action);
$("#divQueue").window("close");
}
}
else {
if (validator.validate()) {
$.messager.confirm('Confirm', 'Are you sure you want to save record?', function (r) {
if (r) {
action = 'Queue/SaveQueue';
SaveQueue(action);
}
else {
return false;
}
});
}
}
});
$("a[id=lnkQueueDelete]").click(function () {
// alert("object");
var queueId = $(":input[name='Id']").val();
deletequeuebyid(queueId);
});
}
}
}
July.Project.QueueForm = QueueForm;
}(July.Project));
No comments:
Post a Comment