/** * :folding=explicit:collapseFolds=1: */ //{{{ changeCategory() function changeCategory(fEdit) { var idProducer = document.getElementById('producer_id').value; var req = new JsHttpRequest(); req.onreadystatechange = function() { if (req.readyState == 4) { if (req.responseJS) { var aCategory = req.responseJS.listCategory; document.getElementById('category_id_p').innerHTML = aCategory; if (fEdit) { var tmp = document.getElementById('category_id'); for (var i = 0; i < tmp.length; i ++) { if (in_array(tmp.options[i].value, listSel)) tmp.options[i].selected = true; } } } } } req.caching = true; req.open('POST', '/rs/get_category/', true); req.send({producer_id: idProducer, fedit: fEdit ? 1 : 0}); } //}}} //{{{ changeTypeClient() function changeTypeClient() { var typeClient = document.getElementById('type_client').value; var req = new JsHttpRequest(); req.onreadystatechange = function() { if (req.readyState == 4) { if (req.responseJS) { var aClient = req.responseJS.list_client; var listClient = document.getElementById('client_id'); listClient.options.length = 0; // Выводим начальное значение listClient.options[0] = new Option('- Выберите -', 0); var i = 1; for (var key in aClient) { listClient.options[i] = new Option((aClient[key]['client_firm'] ? aClient[key]['client_firm'] : aClient[key]['client_name']), aClient[key]['client_id']); i ++; } // разблокируем для вывода if (i > 1) listClient.disabled = false; } } } document.getElementById('client_id').disabled = true; req.caching = true; req.open('POST', '/rs/get_client/', true); req.send({client_type: typeClient}); } //}}} //{{{ addCartItem() function addCartItem(id) { var req = new JsHttpRequest(); req.onreadystatechange = function() { if (req.readyState == 4) { if (req.responseJS) { $_j('#cart_status').empty().append(req.responseJS.cart_status); } } } req.caching = false; req.open('POST', '/rs/add_cart_item/', true); req.send({id_item: id}); } //}}} //{{{ removeItem() function removeItem(id) { var req = new JsHttpRequest(); req.onreadystatechange = function() { if (req.readyState == 4) { if (req.responseJS) { $_j('#cart_status').empty().append(req.responseJS.cart_status); $_j('#cart_show').empty().append(req.responseJS.cart_show); } } } req.caching = false; req.open('POST', '/rs/remove_cart_item/', true); req.send({id_item: id}); } //}}} //{{{ updateCart() function updateCart() { var list={}, req = new JsHttpRequest(); $_j('input.jq_pseudo_i').each(function () { list[this.name.replace(/^basket\[(\d+)\]/i, '$1')] = this.value; }); req.onreadystatechange = function() { if (req.readyState == 4) { if (req.responseJS) { $_j('#cart_status').empty().append(req.responseJS.cart_status); $_j('#cart_show').empty().append(req.responseJS.cart_show); } } } req.caching = false; req.open('POST', '/rs/update_cart_list/', true); req.send({list: list}); } //}}} //{{{ requestDealer() function requestDealer(id) { var list={}, req = new JsHttpRequest(); $_j('input.jq_pseudo_i').each(function () { list[this.name.replace(/^basket\[(\d+)\]/i, '$1')] = this.value; }); req.onreadystatechange = function() { if (req.readyState == 4) { if (req.responseJS) { if (parseInt(req.responseJS.num) > 0) location.href = '/basket/'; else alert('Введите в поля нужное количество товара!'); } } } req.caching = false; req.open('POST', '/rs/request_dealer/', true); req.send({list: list}); } //}}}