$(document).ready(function(){ $("#tree").treeview({ // animated: "fast", // collapsed: true, // unique: true, // control: "#treecontrol", persist: "cookie", cookieId: "treeview-bm" }); // $("#tree").css("display", "block"); /* $('.treeItem').click(function (e) { var $this = $(this); var $treeId = $this.attr("id_TreeDetail"); $('.treeItem[class*="selected"]').removeClass("selected"); $('.treeItem[id_treedetail*="'+$treeId+'"]').addClass("selected"); // $this.css("background-color", "silver"); $.ajax({ url: "goodsTable.phtml?id_TreeDetail="+$treeId, cache: false, success: function(html){ $("#goodsTable").html(html); initAfterRefreshTable(); } }); return false; }); */ $('#onlyOnStock').click(function (e) { var $this = $(this); var $onlyOnStock = $this.attr('checked'); $.ajax({ url: "goodsTable.phtml?onlyOnStock="+$onlyOnStock, cache: false, success: function(html){ $("#goodsTable").html(html); initAfterRefreshTable(); } }); }); $('#onlyOnTransit').click(function (e) { var $this = $(this); var $onlyOnTransit = $this.attr('checked'); $.ajax({ url: "goodsTable.phtml?onlyOnTransit="+$onlyOnTransit, cache: false, success: function(html){ $("#goodsTable").html(html); initAfterRefreshTable(); } }); }); $('#filterTextButton').click(function (e) { var $this = $(this); var $searchText = $('#filterText').val(); var $categorySearch = $('#categorySearch').attr('checked'); $.ajax({ url: "goodsTable.phtml?searchText="+$searchText+"&categorySearch="+$categorySearch, cache: false, success: function(html){ $("#goodsTable").html(html); initAfterRefreshTable(); } }); }); $('#onlyRequest').click(function (e) { var $this = $(this); var $onlyRequest = $this.attr('checked'); $.ajax({ url: "goodsTable.phtml?onlyRequest="+$onlyRequest, cache: false, success: function(html){ $("#goodsTable").html(html); initAfterRefreshTable(); } }); }); $('.invOpen').click(function (e) { var $this = $(this); var $id_Invoice = $this.attr('iid'); var $opened = $this.attr('opened'); if ($opened == 'true') { $this.attr('opened', 'false'); $("#invDetail"+$id_Invoice).removeClass("displayInvDetail"); $("#invDetail"+$id_Invoice).addClass("hiddenInvDetail"); } else { $.ajax({ url: "requestActions.phtml?action=getDetail&id_invoice="+$id_Invoice, cache: false, success: function(html){ $("#invDetail"+$id_Invoice).html(html); $("#invDetail"+$id_Invoice).removeClass("hiddenInvDetail"); $("#invDetail"+$id_Invoice).addClass("displayInvDetail"); $this.attr('opened', 'true'); } }); } }); $('#payerSelect').change(function (e) { var $this = $(this); $.ajax({ url: "requestActions.phtml?action=getPayerInfo&id_Payer="+$this.val(), cache: false, success: function(html){ $("#payerInfo").html(html); } }); }); $('#logon').click(function (e) { var $this = $(this); $("#loginDialog").dialog( { buttons: { "Войти": function() { $("#loginDialog form").submit(); } } } ); }); initAfterRefreshTable(); initAfterRefreshRequest(); }); initAfterRefreshTable = function () { // var $id_TreeDetail = $('.treeItem[class*="selected"]').attr("id_TreeDetail"); $('.orderable').click(function (e) { var $this = $(this); var $orderId = $this.attr("orderId"); $.ajax({ url: "goodsTable.phtml?orderId="+$orderId, cache: false, success: function(html){ $("#goodsTable").html(html); initAfterRefreshTable(); } }); }); /* $('.page').click(function (e) { var $this = $(this); var $page = $this.attr("page"); $.ajax({ url: "goodsTable.phtml?page="+$page, cache: false, success: function(html){ $("#goodsTable").html(html); initAfterRefreshTable(); } }); }); */ $('.showGoodInfo').click(function (e) { var $this = $(this); var $id_Good=$this.attr('id_Good'); var $title=$this.html(); $.ajax({ url: "goodInfo.phtml?id_Good="+$id_Good, cache: false, success: function(html){ $("#goodInfo").html(html); $("#goodInfo").dialog({ autoOpen: true, width: 900, height: 500, title: $title }) } }); }); jQuery.fn.caseAddInit = function ($this) { var $id_Good=$this.attr('id_Good'); var $qty = $('#c'+$id_Good).val(); $.ajax({ url: "caseActions.phtml?action=add&id_Good="+$id_Good+"&qty="+$qty, cache: false, success: function(html){ $("#caseSummary").html(html); $.ajax({ url: "caseActions.phtml?action=reloadQty&id_Good="+$id_Good, cache: false, success: function(html){ $("#cr"+$id_Good).html(html); $("#cr"+$id_Good).find('.caseRmImg').click(function (e) { jQuery.fn.caseRmInit($(this)); }); $("#c"+$id_Good).val(''); } }); } }); } $('.caseAdd').click(function (e) { jQuery.fn.caseAddInit($(this)); }); $('.qtyEnter').keypress(function(event) { if ( event.which == 13 ) { jQuery.fn.caseAddInit($(this)); } }); jQuery.fn.caseRmInit = function ($this) { // var $this = $(this); var $id_Good=$this.attr('id_Good'); $.ajax({ url: "caseActions.phtml?action=rm&id_Good="+$id_Good, cache: false, success: function(html){ $("#caseSummary").html(html); $.ajax({ url: "caseActions.phtml?action=reloadQty&id_Good="+$id_Good, cache: false, success: function(html){ $("#cr"+$id_Good).html(html); } }); } }); }; $(".caseRmImg").click(function (e) { jQuery.fn.caseRmInit($(this)); }); } /* $(".rmButton").click(function(e){ var $this = $(this); var $wordId = $this.attr("wordId"); var $itemId = $this.attr("itemId"); $.ajax({ url: "ajaxSearchWordsAdd.phtml?action=rm&item_id=&wordId="+$wordId, cache: false, success: function(html){ $("#words").html(html); afterAjaxInit(); } }); } */ initAfterRefreshRequest = function () { $('.removeFromRequest').click(function (e) { var $this = $(this); var $id_Good = $this.attr("id_Good"); $.ajax({ url: "requestActions.phtml?action=rm&id_Good="+$id_Good, cache: false, success: function(html){ $("#requestBlock").html(html); initAfterRefreshRequest(); } }); }); $('.requestQty').keypress(function (e) { var $this = $(this); var $id_Good = $this.attr("id_Good"); $('#caseUpdateButton').css("display", "block"); }); $('#caseUpdateButton').click(function (e) { var $req = ""; $('.requestQty').each(function (e) { var $e = $(this); var $id_Good = $e.attr("id_Good"); var $qty = $e.val(); $req = $req+"c["+$id_Good+"]="+$qty+"&"; $.ajax({ url: "requestActions.phtml?action=update&"+$req, cache: false, success: function(html){ $("#requestBlock").html(html); initAfterRefreshRequest(); } }); }); }); }