', { 'class': 'edit-organization-bg' })); $('.edit-organization-bg').show(); if ($('.edit-organization-popup').length == 0) $('body').append($('
', { 'class': 'edit-organization-popup' })); $.ajax({ url: "/ajax/editorganization?v=" + ISCommon.GetV(), data: { Id: Id, OrganizationsClassId: ISOrganizationEdit.OrganizationsClassId }, cache: true, success: function (d) { $('.edit-organization-popup').html(d.View); ISOrganizationEdit.HistoryId = d.HistoryId; ISOrganizationEdit.EditShowInit(); } }); }, EditShowInit: function () { $('.search-organization-popup').hide(); if ($('.edit-organization-form #Id').val() != '0') $('.edit-organization-popup .heading .messages p').text('Корректировка записи в базе ОРГАНИЗАЦИЙ'); else $('.edit-organization-popup .heading .messages p').text('Новая запись в базе ОРГАНИЗАЦИЙ'); var newWidth = ($("#container").width() < 1000) ? $("#container").width() : 1000; $('.edit-organization-bg').css({ top: 0, height: $(document).outerHeight() }); $('.edit-organization-popup').css({ top: $(window).scrollTop(), width: newWidth, marginLeft: 0 - (newWidth / 2) }); $('.edit-organization-popup .heading a.close').unbind('click'); $('.edit-organization-popup .heading a.close').click(function () { ISOrganizationEdit.EditHide(); return false; }); $(".edit-organization-form select").not(".ex").chosen(); $(".edit-organization-form #Text").ckeditor({ height: 140, width: 723, toolbar: [['Source', 'Bold', 'Italic', 'Underline', 'Strike', 'Subscript', 'Superscript', 'RemoveFormat', 'SpellChecker', 'Scayt', '-', 'NumberedList', 'BulletedList', 'Table'], ['JustifyLeft', 'JustifyCenter', 'JustifyRight', 'JustifyBlock'], ['Link', 'Unlink'], ["Maximize", "Image"]] }) .ckeditor(function () { ISOrganizationEdit.DataForForm = ISOrganizationEdit.GetDataFromForm(); $('.edit-organization-popup').show(); }); $(".edit-organization-form #President,.edit-organization-form #Address").ckeditor({ height: 140, width: 723, toolbar: [['Source', 'Bold', 'Italic', 'Underline', 'Strike', 'Subscript', 'Superscript', 'RemoveFormat', 'SpellChecker', 'Scayt', '-', 'NumberedList', 'BulletedList', 'Table'], ['JustifyLeft', 'JustifyCenter', 'JustifyRight', 'JustifyBlock'], ['Link', 'Unlink'], ["Maximize", "Image"]] }) .ckeditor(function () { ISOrganizationEdit.DataForForm = ISOrganizationEdit.GetDataFromForm(); $('.edit-organization-popup').show(); }); $(".edit-organization-form #BirthDate") .datepicker({ addClass: 'edit-organization', language: "ru", format: "dd.mm.yyyy" }) .on('changeDate', function (ev) { var BirthDate = new Date(ev.date); $('#BirthYear').val(BirthDate.getFullYear().toString()).trigger("liszt:updated"); }).data('datepicker'); $('.edit-organization-form .form-actions a.button').unbind('click'); $('.edit-organization-form .form-actions a.button').click(function () { ISOrganizationEdit.Save(); return false; }); $(".edit-organization-form .control-group.upload-photo #fileupload").unbind('change'); $(".edit-organization-form .control-group.upload-photo #fileupload").change(function () { $('.edit-organization-form').ajaxSubmit({ url: '/ajax/uploadorganization?v=' + ISCommon.GetV(), success: function (d) { if ('yes' == d.Result) { $('.control-group.upload-photo #Logo').val(d.FileNameGuid); $('.control-group.upload-photo #FileName').val(d.FileName); $(".control-group.upload-photo .controls.image").html('
'); } else if (d.Message != null && d.Message != '') $(".edit-organization-form .control-group.upload-photo .messages").text(d.Message); } }); }); $('.edit-organization-form #Name, .edit-organization-form #NameMini').unbind('change'); $('.edit-organization-form #Name, .edit-organization-form #NameMini').change(function () { if (($('.edit-organization-form #Name').val() != '' || $('.edit-organization-form #NameMini').val() != '') && $('.edit-organization-form #Id').val() == '0') { $.ajax({ url: "/ajax/checkorganizations?v=" + ISCommon.GetV(), data: { N: $('.edit-organization-form #Name').val(), NM: $('.edit-organization-form #NameMini').val(), OrganizationsClassId: ISOrganizationEdit.OrganizationsClassId }, cache: true, success: function (d) { if ('yes' == d.Result) { $('.edit-organization-popup .heading .messages a').text(''); if (d.Organizations.length > 0) { var message = "Найдено 0 организации:"; if (d.Organizations.length == 1 || (d.Organizations.length > 20 && d.Organizations.length % 10 == 1)) message = "Найдена " + d.Organizations.length + " организация:"; else if ((d.Organizations.length > 4 && d.Organizations.length < 21) || (d.Organizations.length > 20 && (d.Organizations.length % 10 > 4 || d.Organizations.length % 10 == 0))) message = "Найдено " + d.Organizations.length + " организации:"; else if ((d.Organizations.length > 1 && d.Organizations.length < 5) || (d.Organizations.length > 20 && d.Organizations.length % 10 > 1 && d.Organizations.length % 10 < 5)) message = "Найдено " + d.Organizations.length + " организации:"; for (var i = 0; i < d.Organizations.length; i++) message += '
' + d.Organizations[i].Name + ''; $('.edit-organization-popup .heading .messages a').html(message); $('.edit-organization-popup .heading .messages a').show(); $('.edit-organization-popup .heading .messages a span').unbind('click'); $('.edit-organization-popup .heading .messages a span').click(function () { ISOrganizationEdit.EditShow($(this).data('organizationid')); return false; }); } else $('.edit-organization-popup .heading .messages a').hide(); } else $('.edit-organization-popup .heading .messages a').hide(); } }); } }); $('.edit-organization-popup .heading .messages a').unbind('click'); $('.edit-organization-popup .heading .messages a').click(function () { $('.registration-organization-popup').css({ top: $(window).scrollTop() }); $('.registration-organization-popup').css({ 'z-index': '1200' }); $('.registration-organization-popup').show(); $('.registration-organization-popup .inside_popup').hide(); $('.registration-organization-popup .mesageforremove').show(); return false; }); $('.edit-organization-popup #EOrganizationsClassId').unbind('change'); $('.edit-organization-popup #EOrganizationsClassId').change(function () { if ($(this).val()) { $.ajax({ url: "/ajax/filteredorganizationstypesbyorganizationsclass?v=" + ISCommon.GetV(), data: { OrganizationsClassId: $(this).val() }, success: function (d) { var selected = $(".edit-organization-popup #EOrganizationsTypesId").val(); $(".edit-organization-popup #EOrganizationsTypesId").empty(); $(".edit-organization-popup #EOrganizationsTypesId").append($("