test

0
17 апр 2015 13:59
sdwewe

Ответов: 9

1
17 апр 2015 14:02
erererrwerwrwedwww
0
21 апр 2015 11:34
rtrtet
0
17 апр 2015 14:00
sdwdwdwdwdwqddede
-1
17 апр 2015 14:12
вввввв
-1
17 апр 2015 14:10
var cardContractActivity = {
init: function () {
var me = this;
this.cleanUnusedCookies();

this.postaddressCladdr = $("#postaddress").cofUltimateCladdr();
this.payerCladdr = $("#payer").cofUltimateCladdr();
this.consigneeCladdr = $("#consignee").cofUltimateCladdr();
this.baCladdr = $("#ba").cofUltimateCladdr();
this.cpCladdr = $("#cp").cofUltimateCladdr();
this.cpSewerCladdr = $("#cp_sewer").cofUltimateCladdr();
this.payerCladdr.onChange = function (cityId, districtId, streetId, house, office) {
if (me.consigneeCladdr.city == null || me.consigneeCladdr.street == null) {
me.payerCladdr.copyTo(me.consigneeCladdr);
}
};

$("#btn-copy").click(function () {
$("#cpParams").find("input,select").each(function () {
var name = $(this).attr("name");
if (!!name) {
var value = $(this).val();
var id2 = name.replace(/'cp_/g, "'cp_sewer_");
id2 = id2.replace(/'/g, "\\'");

$("[name='" + id2 + "']").val(value);
}
});
});

$("#CPResource").change(function () {
var id = $("#CPResource").val();
$("#CPSource").foo("t" + id);
$("#CPType").foo("t" + id);
});
var id = $("#CPResource").val();
$("#CPSource option:not(.t" + id + ")").appendTo($("#CPSource").siblings("div.hiddenOptions"));
$("#CPType option:not(.t" + id + ")").appendTo($("#CPType").siblings("div.hiddenOptions"));

$("#CPSewerResource").change(function () {
var id = $("#CPSewerResource").val();
$("#CPSewerSource").foo("t" + id);
$("#CPSewerType").foo("t" + id);
});
var id = $("#CPSewerResource").val();
$("#CPSewerSource option:not(.t" + id + ")").appendTo($("#CPSewerSource").siblings("div.hiddenOptions"));
$("#CPSewerType option:not(.t" + id + ")").appendTo($("#CPSewerType").siblings("div.hiddenOptions"));


var cpnamechanged = false;
$("#connection-union-name").keyup(function () {
if (!cpnamechanged) {
var name = $(this).val();
$("#CPName").val(name);
}
});


$("#CPName").change(function () {
var name = $(this).val();
if (!name || name == "") {
cpnamechanged = false;
} else {
cpnamechanged = true;
}
})



this.juraddressCladdr = $("#juraddress");
if (this.juraddressCladdr.length > 0) {
this.juraddressCladdr = this.juraddressCladdr.cofUltimateCladdr();
this.juraddressCladdr.onChange = function (cityId, districtId, streetId, house, office) {
if (me.payerCladdr.city == null || me.payerCladdr.street == null) {
me.juraddressCladdr.copyTo(me.payerCladdr);
}
};
}

me.contractNumberOld = $("#contractNumber").val();

$("#contractType").change(function () {
var id = $("#contractType").val();
$("#contractKind").foo("t" + id);
});
//
// $(".datepicker").datepicker({
// format: 'dd/mm/yyyy'
// });

// $("#department").change(function () {
// var id = $("#department").val();
// console.log(id);
// $("#engineer1").foo("t"+id);
// $("#engineer2").foo("t"+id);
// $("#engineer3").foo("t"+id);
//// $("#engineer1 option").toggleOption(false);
//// $("#engineer2 option").toggleOption(false);
//// $("#engineer3 option").toggleOption(false);
//// $("#engineer1 option.t" + id).toggleOption(true);
//// $("#engineer1 option.t" + id).first().attr("selected", true);
//// $("#engineer2 option.t" + id).toggleOption(true);
//// $("#engineer2 option.t" + id).first().attr("selected", true);
//// $("#engineer3 option.t" + id).toggleOption(true);
//// $("#engineer3 option.t" + id).first().attr("selected", true);
// });


// var id = $("#department").val();
// $("#engineer1 option:not(.t"+id+")").appendTo($("#engineer1").siblings("div.hiddenOptions"));
// $("#engineer2 option:not(.t"+id+")").appendTo($("#engineer2").siblings("div.hiddenOptions"));
// $("#engineer3 option:not(.t"+id+")").appendTo($("#engineer3").siblings("div.hiddenOptions"));
// $("#engineer2 option").toggleOption(false);
// $("#engineer3 option").toggleOption(false);
// $("#engineer1 option.t" + id).toggleOption(true);
// $("#engineer2 option.t" + id).toggleOption(true);
// $("#engineer3 option.t" + id).toggleOption(true);

id = $("#contractType").val();
$("#contractKind option:not(.t" + id + ")").appendTo($("#contractKind").siblings("div.hiddenOptions"));

var clientId = $("#client-id").val();
var contractId = $("#contract-id").val();
var contractClientId = $("#contractClient-id").val();
this.contractClientId = contractClientId;
accordionFunc();

initUI();
$(".switch").bootstrapSwitch();
$("form").valid();

if (!contractId) {
var name = $("#data\\'contractParams_subscriber\\'").val();
$("#data\\'billingParams_payerName\\'").val(name);
$("#data\\'billingParams_consigneeName\\'").val(name);
}

// Restore history to form
if (cardContractActivity.formHistory) {
restoreSerializedForm(cardContractActivity);
}

$("#bankRequisitesBank").change(function () {
var correspondentAccount = $("#bankRequisitesBank option:selected").data("correspondent-account");
if (!$("#bik").is(":focus")) {
var bik = $("#bankRequisitesBank option:selected").data("bik");
$("#bik").val(bik);
}
$("#correspondentAccount").val(correspondentAccount);
});

$('#bik').keyup(function () {
var bik = $("#bik").val();

var ho = $("#bankRequisitesBank").siblings("div.hiddenOptions");
if (!!bik) {

ho.append($("#bankRequisitesBank").find("optgroup"));

ho.find("option[data-bik^=" + bik + "]").parent().appendTo($("#bankRequisitesBank"));


var id = $("#bankRequisitesBank option[data-bik^=" + bik + "]").first().val();
$("#bankRequisitesBank").val(id).change();
} else {
ho.find("optgroup").appendTo($("#bankRequisitesBank"));
}


}).focusout(function () {
var bik = $("#bankRequisitesBank option:selected").data("bik");
$("#bik").val(bik);
});

$("#bik").keyup();

$("#btn-edit-contract").click(function () {
$(".editable").attr("disabled", false);
$('#btn-submit').attr("disabled", false);
$('#btn-reset').attr("disabled", false);
});

// Auth: For JUR group
if (USER_GROUP == "JUR_GROUP") {
$("#btn-break-contract").click(function () {
if ($(this).attr("disabled"))
return;

$("#btn-break-contract-modal").modal();
});

$("#btn-break-contract-confirm").click(function () {
var date = $("#break-date").val();
// var sum = $("#break-sum").val();

if (date.length == 0 || sum.length == 0) {
showError("Заполните поля.");
return;
}

$.ajax({
type: "post",
data: "cid=" + contractId + "&date=" + date,// + "&sum=" + sum,
url: "/app/contract/state/break",
success: function (resp) {
showSuccess("Договор успешно расторгнут.");
$("#btn-break-contract").attr("disabled", true);
$("#btn-break-contract-modal").modal('hide');

$("#contractParamsStatus option").removeAttr("selected");
$("#contractParamsStatus option[value='" + 2 + "']").attr("selected", true);
$("#contractParamsDateTerminate").val(date);
},
error: function (e) {
showError('Ошибка: ' + e.statusText);
}
});
});

$("#btn-add-object").click(function () {
if ($(this).attr("disabled"))
return;
});

$("#btn-delete-object").click(function () {
if ($(this).attr("disabled"))
return;

var objectId = $("#contract-objects-list")[0].selected;
$.ajax({
type: "post",
data: "id=" + objectId,
url: "/app/contract/object/delete",
success: function (resp) {
showSuccess("Объект успешно удалён.");

me.loadContractObjectsList([
{field: "contractClient.id", value: contractClientId, filterType: "EQ"}
]);
},
error: function (e) {
showError('Ошибка: ' + e.statusText);
}
});
});
}

if (USER_GROUP != "JUR_GROUP") {
var funcSave = function (group, code) {
var params = "id=" + contractClientId;
if (group)
params += ("&gr=" + group);
if (code)
params += ("&code=" + code);

$.ajax({
type: "post",
data: params,
url: "/app/contract/state/start",
success: function (resp) {
showSuccess("Договор успешно заключен.");
$("#btn-contract-conclusion-modal").modal('hide');
},
error: function (e) {
showError('Ошибка: ' + e.responseText);
}
});
};

$("#btn-contract-conclusion-apply").click(function () {
var group = $("#cc-group").val().trim();
var code = $("#cc-code").val().trim();
funcSave(group, code);
});

$("#btn-contract-conclusion-dismiss").click(function () {
funcSave();
});
}


$("#contractParamsStatus").change(function () {
// Если статус "заключен"
if ($(this).val() == 1)
$("#btn-contract-conclusion-modal").modal('show');
});

var funcAddPerson = function (type) {
cardContractActivity.createEmployee = type;
cardContractActivity.formHistory = $("#form-contract").serialize();
goto("/clientemployee", null);
};
$("#btn-add-chief").click(function () {
funcAddPerson(1);
});
$("#btn-add-responsible").click(function () {
funcAddPerson(2);
});

$("#btn-submit").click(function () {
var valid = $("form").valid();
if (!valid) {
showInfo("Заполните все обязательные поля");
markRequiredGroups();
return;
}

if (USER_GROUP == "JUR_GROUP") {
if (contractId == null && !me.cpCladdr.house) {
showInfo("Заполните адрес в параметрах здания до уровня дом");
return;
}
} else {
if (contractId == null && !me.baCladdr.house) {
showInfo("Заполните адрес в параметрах здания до уровня дом");
return;
}
}

var contractNumberNew = $("#contractNumber").focusout().val();

var save = function () {
$.ajax({
type: "post",
data: $("#form-contract").serialize(),
url: "/app/contract/save",
success: function (resp) {
me.contractNumberOld = contractNumberNew;
showSuccess("Договор успешно сохранён.");
me.loadContractParamsHistoryList([
{field: "contractClient.id", value: contractClientId, filterType: "EQ"}
]);
location.href = "/#/contract/" + resp;
},
error: function (e) {
showError('Ошибка: ' + e.statusText);
}
});
};


if (contractNumberNew != me.contractNumberOld) {
$.ajax({
type: "get",
data: {number: $("#contractNumber").val()},
url: "/app/contract/checkNumber",
success: function (resp) {
if ((resp == "ERROR" && confirm("Договор с номером '" + contractNumberNew + "' уже существует, все равно сохранить?")) || resp == "OK") {
save();
} else {
showInfo("Сохранение отменено");
}
}
});
} else {
save();
}


});

$("#btn-reset").click(function () {
$("#form-client").each(function () {
this.reset();
});
showSuccess("Все изменения отменены.");
});

$("#btn-generate-doc").click(function () {
var contractClientId = $("#contractClient-id").val();
goto("/createcontractdocument", contractClientId);
});

$("#btn-search-connpoint").click(function () {
goto("/search_connpoint", contractId);
});

$("#btn-add-connpoint").click(function () {
goto("/connpoint", null);
});

$("#btn-add-connpoint-common").click(function () {
goto("/connpoint-common", null);
});

this.loadFromCookies();

this.loadContractPaymentsList([
{field: "contractClient.id", value: contractClientId, filterType: "EQ"}
]);
this.loadContractBillsList([
{field: "contractClient.id", value: contractClientId, filterType: "EQ"}
]);

this.loadContractObjectsList([
{field: "contractClient.id", value: contractClientId, filterType: "EQ"}
]);

this.loadContractSubSubscribersList([
{field: "client.id", value: clientId, filterType: "EQ"}
]);

this.loadContractParamsHistoryList([
{field: "contractClient.id", value: contractClientId, filterType: "EQ"}
]);

if (!contractId) {
$("#btn-edit-contract").click();
}
},
loadFromCookies: function () {
var cookie = $.cookie("data['contractParams_upperCalcPointId']");
if (cookie) {
$("#contractParams_upperCalcPointId").val(cookie);
$.cookie("data['contractParams_upperCalcPointId']", null);
}

cookie = $.cookie("data['contractParams_upperSubscriberName']");
if (cookie) {
$("#contractParams_upperSubscriberName").val(cookie);
$.cookie("data['contractParams_upperSubscriberName']", null);
}
},
/** Payments and Bills -> Payments */
loadContractPaymentsList: function (filters) {
$("#contract-payments-list").cofTable({dataUrl: '/app/contract/payments/list',
params: {filter: JSON.stringify(filters)},
afterLoad: function (table) {
table.find("tbody tr").dblclick(function () {
});
}
});
},
/** Payments and Bills -> Bills */
loadContractBillsList: function (filters) {
$("#contract-bills-list").cofTable({dataUrl: '/app/contract/bills/list',
params: {filter: JSON.stringify(filters)},
afterLoad: function (table) {
table.find("tbody tr").dblclick(function () {
});
}
});
},

/** Objects -> Objects */
loadContractObjectsList: function (filters) {
var me = this;
$("#contract-objects-list").cofTable({dataUrl: '/app/contract/objects/list',
params: {filter: JSON.stringify(filters)},
actionBar: $("#ab-objects"),
afterLoad: function (table) {
table.find("tbody tr").dblclick(function () {
var cpuId = $(this).data("id");
goto("/connpointunion", cpuId);
});
table.find("tbody tr").click(function () {
var connectionPointUnionId = $(this).data("id");
var connectionPointUnionName = $(this).find("td.td_name").text()
var rowObject = $(this)[0].object;

$.cookie("data['connpoint_union_id']", connectionPointUnionId);
$.cookie("data['connection_union_name']", connectionPointUnionName);

$.cookie("cityId", rowObject["cityId"]);
$.cookie("cityName", rowObject["cityName"]);
$.cookie("districtId", rowObject["districtId"]);
$.cookie("districtName", rowObject["districtName"]);
$.cookie("streetId", rowObject["streetId"]);
$.cookie("streetName", rowObject["streetName"]);
$.cookie("houseNumber", rowObject["houseNumber"]);

me.loadContractObjectCalcPointsList([
{field: "connectionPointUnionList.id", value: connectionPointUnionId, filterType: "EQ"}
]);
});
}
});
},
/** Objects -> Calc Points of Object */
loadContractObjectCalcPointsList: function (filters) {
$("#contract-objectcalcpoints-list").cofTable({dataUrl: '/app/contract/objectcalcpoints/list',
params: {filter: JSON.stringify(filters)},
afterLoad: function (table) {
table.find("tbody tr").dblclick(function () {
var cpId = $(this).data("id");
$.cookie("data['connpoint_union_id']", null);
$.cookie("data['connection_union_name']", null);


$.cookie("cityId", null);
$.cookie("cityName", null);
$.cookie("districtId", null);
$.cookie("districtName", null);
$.cookie("streetId", null);
$.cookie("streetName", null);
$.cookie("houseNumber", null);
goto("/connpoint", cpId);
});
}
});
},

/** SubSubscribers */
loadContractSubSubscribersList: function (filters) {
var loadTable = function (type) {
if (type) {
filters.push("type", type);
}

$("#contract-subsubscribers-list").cofTable({dataUrl: '/app/contract/subsubscribers/list',
params: {filter: JSON.stringify(filters)},
afterLoad: function (table) {
table.find("tbody tr").dblclick(function () {
});
}
});
};

loadTable(null);
$("#filter-subsubscribers").change(function () {
loadTable($(this).val());
});
},

loadContractParamsHistoryList: function (filters) {
$("#contract-paramshistory-list").cofTable({dataUrl: '/app/contract/paramshistory/list',
params: {filter: JSON.stringify(filters)},
afterLoad: function (table) {
table.find("tbody tr").dblclick(function () {
});
}
});
},

cleanUnusedCookies: function () {
$.cookie("cityId", null);
$.cookie("cityName", null);
$.cookie("districtId", null);
$.cookie("districtName", null);
$.cookie("streetId", null);
$.cookie("streetName", null);
$.cookie("houseNumber", null);
-1
17 апр 2015 14:07
ааааааааа
-1
17 апр 2015 14:03
tttttttttt
-1
17 апр 2015 14:00
aeqqe2
-1
17 апр 2015 13:59
sdweqeeqeq
Модераторы: Lucky senleft guroo kat AlisaTest PetraStill Julik igorss
Сейчас эту тему просматривают: Нет