$(document).ready(function(){ $("body").on('click', '.goodCartEdit', function(){ var item_id = $(this).attr('item_id'); if (item_id ==undefined) { item_id = $(this).parent().attr('item_id'); } if (window.open("/admin/mod_edit.phtml?item_id="+item_id+"&action=edit", "", "status:0; border:thin; dialogWidth:900pt; dialogHeight:600pt; help:0; center:1; ")>0) { document.location.reload(false); } }); $(".goodCartNew").click(function(){ var item_parent_id = $(this).attr('item_parent_id'); var item_parent_id = $("#item").attr('item_id'); var parent_tile = ""; if (item_parent_id!=undefined) { parent_tile = "&item_parent_id="+item_parent_id; } var class_id = $('[subclass]').attr('subclass'); if (class_id == undefined) { class_id = $(this).attr('class_id'); } if (class_id == undefined || class_id == '' || class_id==0) { class_id = selectClass(item_parent_id); } else { if (window.open("/admin/mod_edit.phtml?action=new&class_id="+class_id+parent_tile+"&nc="+Math.random()*100000, "", "status:0; border:thin; dialogWidth:900pt; dialogHeight:600pt; help:0; center:1; ")>0) { // $(this).setActiveFilter({}, {}, {ajaxUpdate:"update"}); document.location.reload(false); } } return false; }); $(".goodCartRemove").click(function(){ var item_id = $(this).parent().attr('item_id'); var prop = { value_id: item_id, name: 'item_id' } $("
Удалить?
").dialog({ buttons: { "Да": function() { params = { item_id: item_id, action: 'del' }; var self=$(this); $.ajax({ url: "/admin/mod_edit.phtml", data: params, type: 'GET', cache: false, success: function(html) { self.dialog("close"); // $(this).setActiveFilter({}, {}, {ajaxUpdate:"update"}); document.location.reload(false); } }); }, "Нет": function() { $(this).dialog("close"); } } }); return false; }); $(".goodCartCopy").click(function(){ var item_id = $(this).attr('item_id'); if (item_id ==undefined) { item_id = $(this).parent().attr('item_id'); } if (window.open("/admin/mod_edit.phtml?item_id="+item_id+"&action=new_copy", "", "status:0; border:thin; dialogWidth:900pt; dialogHeight:600pt; help:0; center:1; ")>0) { $(this).setActiveFilter({}, {}, {ajaxUpdate:"update"}); } }); $.fn.requestListRefresh = function() { var dateFrom = $("#dateFrom").val(); var dateTo = $("#dateTo").val(); var comm = $("h1").attr('comm'); var s = $("#s").val(); var status_ids = []; $("#statusList input:checked").each(function() { var status_id = $(this).attr('status_id'); status_ids.push(status_id); }); $(".admin #container .requests").addClass('loading'); params = { dateFrom: dateFrom, dateTo: dateTo, comm: comm, status_ids: status_ids, s: s }; $.ajax({ url: "/admin/orders.phtml", data: params, type: 'GET', cache: false, success: function(html) { $(".admin #container .requests").html(html); $(".admin #container .requests").removeClass('loading'); } }); } $.datepicker.setDefaults( { firstDay: 1, dayNamesMin: ['вс','пн','вт','ср','чт','пт','сб'], monthNames: ['январь', 'февраль', 'март', 'апрель', 'май', 'июнь', 'июль', 'август', 'сентябрь', 'октябрь', 'ноябрь', 'декабрь'], dateFormat: 'dd.mm.yy' } ); $("#dateFrom").datepicker($.datepicker.regional[ "ru" ]); $("#dateTo").datepicker($.datepicker.regional[ "ru" ]); $("#dateFrom, #dateTo").change(function() { $(this).requestListRefresh(); }); $("#statusList input, .requestsFilters #s_btn").click(function() { $(this).requestListRefresh(); }); $(".adminTable .btn_edit").click(function(){ var item_id = $(this).parents("tr").attr('item_id'); if (window.open("/admin/mod_edit.phtml?item_id="+item_id+"&action=edit", "", "status:0; border:thin; dialogWidth:900pt; dialogHeight:600pt; help:0; center:1; ")>0) { document.location.reload(false); } return false; }); $(".adminTable .btn_remove").click(function() { var item_id = $(this).parents("tr").attr('item_id'); $("
Удалить Элемент?
").dialog({ buttons: { "Да": function() { params = { item_id: item_id, action: 'del' }; $.ajax({ url: "/admin/mod_edit.phtml", data: params, type: 'GET', cache: false, success: function(html) { document.location.reload(false); } }); $(this).dialog("close"); }, "Нет": function() { $(this).dialog("close"); } } }); return false; }) $("body").on('mouseenter', '.adminTable .buttons img', function(){ $(this).addClass('over'); }); $("body").on('mouseleave', ".adminTable .buttons img", function(){ $(this).removeClass('over'); }); $("body").on('mousedown', ".adminTable tr", function(){ $(".adminTable tr").removeClass('selected'); $(this).addClass('selected'); }); $("body").on('dblclick', ".adminTable tr", function(){ var item_id = $(this).attr('item_id'); window.location.href='?item_parent_id='+item_id; }); $("body").on('click', '#container .requests .remove', function() { var order_id = $(this).parents('tr').attr('order_id'); var dateFrom = $("#dateFrom").val(); var dateTo = $("#dateTo").val(); var comm = $("#content #container h2").attr('comm'); $("#rmDialog").dialog({ buttons: { "Да": function() { $("#container .requests").addClass('loading'); params = { order_id: order_id, action: "remove", dateFrom: dateFrom, dateTo: dateTo, comm: comm }; $.ajax({ url: "/order/actions.phtml", data: params, type: 'GET', cache: false, success: function(html) { $("#container .requests").html(html); $("#container .requests").removeClass('loading'); } }); $(this).dialog("close"); }, "Нет": function() { $(this).dialog("close"); } } }); return false; }); $("body").on('click', '#container .requests table tr.ed', function() { var order_id = $(this).attr('order_id'); var self = $(this); $.ajax({ url: '/order/edit.phtml', data: {order_id: order_id}, type: 'GET', cache: false, success: function(html) { var dialog = $("#orderEditDialog"); dialog.html(html); dialog.dialog({ width: 1200, modal: true, buttons: { "OK": function() { $(this).dialog("close"); } }, beforeClose: function() { $(this).saveOrderForm(self); } }); }, beforeSend: function(data){ } }); }); $.fn.saveOrderForm = function(self) { var order_id = self.attr('order_id'); var status_id = $(".requestEditor #orderStatus [name='status']").val(); var comment = $(".requestEditor textarea[name='comment']").val(); params = { action: 'order_save', order_id: order_id, status_id: status_id, comment: comment }; $.ajax({ url: "/order/actions.phtml", data: params, type: 'POST', cache: false, success: function(html) { $.ajax({ url: "/admin/orders_row.phtml", data: params, type: 'GET', cache: false, success: function(html) { self.html(html); self.removeClass('loading'); }, beforeSend: function(data){ self.addClass('loading'); } }); } }); } $("body").on('click', '.requestEditor #items #cnt i, .requestEditor #items #discount i, .requestEditor #items #baseDiscount i, .requestEditor #items .remove', function() { var order_id = $(this).parents('table').attr('order_id'); var click_data = ($(this).attr('class')); var target = $(this).parent().attr('id'); var prod_id = $(this).parents('tr').attr('prod_id'); params = { action: 'order_item_update', click_data: click_data, target: target, order_id: order_id, prod_id: prod_id }; $.ajax({ url: "/order/actions.phtml", data: params, type: 'GET', cache: false, success: function(html) { $(".requestEditor #items").html(html); $(".requestEditor #items").removeClass('loading'); }, beforeSend: function(data){ $(".requestEditor #items").addClass('loading'); } }); }); $("body").on('change', '.requestEditor #items #baseDiscount input, .requestEditor #items #discount input', function() { var order_id = $(this).parents('table').attr('order_id'); var target = $(this).parent().attr('id'); var prod_id = $(this).parents('tr').attr('prod_id'); params = { action: 'order_item_set_discount', value: $(this).val(), target: target, order_id: order_id, prod_id: prod_id }; $.ajax({ url: "/order/actions.phtml", data: params, type: 'GET', cache: false, success: function(html) { $(".requestEditor #items").html(html); $(".requestEditor #items").removeClass('loading'); }, beforeSend: function(data){ $(".requestEditor #items").addClass('loading'); } }); }); $("body").on('change', ".requestEditor #items [name='status']", function() { var order_id = $(this).parents('table').attr('order_id'); var status_id = $(this).val(); var prod_id = $(this).parents('tr').attr('prod_id'); params = { action: 'order_item_update_status', order_id: order_id, prod_id: prod_id, status_id: status_id }; $.ajax({ url: "/order/actions.phtml", data: params, type: 'GET', cache: false, success: function(html) { $(".requestEditor #items").html(html); $(".requestEditor #items").removeClass('loading'); }, beforeSend: function(data){ $(".requestEditor #items").addClass('loading'); } }); }); $(".seo.edit").on("click", function(e) { var url = $(this).attr('url'); if (window.open("/seo/mod_seoedit.phtml?url="+url, "", "")>0) { document.location.reload(false); } return false; }); $(".seo.tEdit").on("click", function(e) { var url = $(this).attr('url'); var src = "/admin/mod_seo.phtml?url="+url; $.fancybox({ 'title' : '', 'titlePosition' : 'inside', 'padding' : 20, 'margin' : 20, 'autoScale' : true, 'transitionIn' : 'none', 'transitionOut' : 'none', 'href' : src, 'type' : 'ajax', 'hideOnContentClick' : true, 'scrolling' : 'no' }); return false; }); $("body").on('click', '.requestEditor .editUserInfo', function() { var user_id = $(this).attr('user_id'); $.ajax({ url: '/auth/ajax_form.phtml', data: {current_user_id: user_id}, type: 'GET', cache: false, success: function(html) { var dialog = $("#userEditDialog"); dialog.html(html); dialog.dialog({ width: 700, modal: true }); }, beforeSend: function(data){ } }); return false; }); $("body").on('click', '#docs .makeXls', function() { var order_id = $(this).attr('order_id'); var type = $(this).attr('type'); if (type=='comm') { window.location.href='/xls/order/'+order_id; } if (type=='comm2') { window.location.href='/xls/order2/'+order_id; } return false; }); /* $("body").on('click', '#usersTable2 tr td:first-child a', function() { var user_id = $(this).attr('user_id'); var self = $(this); $.ajax({ url: '/admin/mod_edit_users.phtml', data: {action: 'edit', id: user_id}, type: 'GET', cache: false, success: function(html) { var dialog = $("#userEditDlg"); dialog.html(html); dialog.dialog({ width: 700, modal: true, buttons: { "Сохранить": function() { saveForm(); $(this).dialog("close"); }, "Закрыть": function() { $(this).dialog("close"); } }, beforeClose: function() { // $(this).saveOrderForm(self); } }); }, beforeSend: function(data){ } }); }); */ $("body").on("click", ".makeMail", function() { var order_id=$(this).attr("order_id"); var type=$(this).attr("type"); $("#orderEditDialog").dialog('close'); $.fancybox({ 'padding' : 20, 'transitionIn' : 'none', 'transitionOut' : 'none', 'href' : '/forms/mail_comm_form.phtml?order_id='+order_id+'&type='+type, 'type' : 'ajax' }); return false; }); $("body").on("click", ".catalogReplyMail", function() { $.fancybox({ 'padding' : 20, 'transitionIn' : 'none', 'transitionOut' : 'none', 'href' : '/forms/mail_catalog_reply_form.phtml', 'type' : 'ajax' }); return false; }); $("#usersTable2").on("click", ".mail1", function() { var user_id = $(this).attr('user_id'); $('
Отправить письмо "Неправильный номер"?
').dialog({ buttons: { "Да": function() { params = { id: user_id }; $.ajax({ url: "/mail/noPhone.phtml", data: params, type: 'GET', cache: false, success: function(html) { $(this).dialog("close"); document.location.reload(false); } }); $(this).dialog("close"); }, "Нет": function() { $(this).dialog("close"); } } }); return false; }); $("#usersTable2").on("click", ".mail2", function() { var user_id = $(this).attr('user_id'); $('
Отправить письмо "Напомнить"?
').dialog({ buttons: { "Да": function() { params = { id: user_id }; $.ajax({ url: "/mail/remember.phtml", data: params, type: 'GET', cache: false, success: function(html) { $(this).dialog("close"); document.location.reload(false); } }); $(this).dialog("close"); }, "Нет": function() { $(this).dialog("close"); } } }); return false; }); $("body").on('click', '#addGoodByArt .btn, #addDiscountByOrder .btn', function() { var order_id = $(this).parent().attr('order_id'); var value = $(this).parent().find('input').val(); if (value!='') { if ($(this).attr('id')=='addGoodByArtBtn') { params = { action: 'addGoodByArt', order_id: order_id, art: value }; } else { params = { action: 'addDiscountByOrder', order_id: order_id, orderDiscount: value }; } $.ajax({ url: "/order/actions.phtml", data: params, type: 'GET', cache: false, success: function(html) { $(".requestEditor #items").html(html); $(".requestEditor #items").removeClass('loading'); }, beforeSend: function(data){ $(".requestEditor #items").addClass('loading'); } }); } }); });