PageSourceSearch

https://netvarikozu.ru/js/getmodels.js

js netvarikozu.ru collected 2026-10-09 23:47:14 UTC 19,452 bytes, 585 lines download raw bytes

1function trim(str) {
2	var newstr=str.replace(/\&nbsp\;/g,"\xa0");
3	newstr=newstr.replace(/^\s+|\s+$/g,"");
4	return newstr;
5}
6
7function ReturnSelName(SelList){
8	var Texta = "нет";
9	if(SelList.selectedIndex != -1) Texta = SelList.options[SelList.selectedIndex].text;
10	return Texta;
11}
12
13//============================ РАБОТА С КАТЕГОРИЯМИ ===========================
14//Очищаем зависимый список
15function ClearSlaveListCat(SlaveList){
16	while (SlaveList.length > 0) SlaveList.options[0] = null;
17	if (SlaveList.id == 'tSubSubCategory')SlaveList.style.background = "silver";
18}
19
20//Заполнение карточки товара
21function FillGoodsCart(){
22	var Goods = document.getElementById('tGoods');
23	var NameGoods = document.getElementById('namegoods');
24	NameGoods.innerHTML = "";
25	document.getElementById('nameproducer').innerHTML = "";
26	document.getElementById('namemeasure').innerHTML = "";
27	document.getElementById('NameImages').innerHTML = "";
28	NameGoods.innerHTML = ReturnSelName(Goods);
29	return true;
30}
31
32function alertContentCat(){
33	try {
34		if (http_requestCat.readyState == 4) {
35			if (http_requestCat.status == 200) {
36				FillSlaveListCat(http_requestCat.responseText);
37			}
38			else{
39				alert('Проблема с запросом.');
40			}
41		}
42	}
43	catch( e ) {
44		alert('Произошло исключение: ' + e.description);
45	}
46}
47
48function FillSlaveListCat(responseText){
49	if (trim(responseText) != ""){
50		var slaves = responseText.split('#');
51		for(var skey in slaves){
52			if (slaves[skey].length > 0){
53				var elements = slaves[skey].split(';')
54				var i = 0;
55				var SlaveList="";
56				var Slave = "";
57				for(var key in elements){
58					var element = elements[key].split(':');
59					if (key < 1){
60						SlaveList = document.getElementById(element[1]);
61						if (element[1] == 'tSubSubCategory') SlaveList.style.background = "white";
62						//	i = 1;
63							//SlaveList.options[0] = new Option("========== нет ==========", 0, false, false);
64					//	}
65					}
66					else{
67						Slave = new Option(element[1], element[0], false, false);
68						SlaveList.options[i++] = Slave;
69					}
70				}
71			}
72		}
73	}
74	return true;
75}
76
77function HTTP_MakeRequestCat(url){
78	http_requestCat = false;
79	if (window.XMLHttpRequest){
80		http_requestCat = new XMLHttpRequest();
81		if (http_requestCat.overrideMimeType){
82			http_requestCat.overrideMimeType('text/xml');
83		}
84	}
85	else if (window.ActiveXObject){
86		try{
87			http_requestCat = new ActiveXObject("Msxml2.XMLHTTP");
88		}
89		catch (e){
90			try{
91				http_requestCat = new ActiveXObject("Microsoft.XMLHTTP");
92			}
93			catch (e){}
94		}
95	}
96	if (!http_requestCat){
97		alert('Не получается отправить XMLHTTP запрос');
98		return false;
99	}
100	http_requestCat.onreadystatechange = alertContentCat;
101	http_requestCat.open('GET', url, true);
102	http_requestCat.send(null);
103}
104
105//============================ РАБОТА С НОМЕНКЛАТУРОЙ ===========================
106//Очищаем зависимый список товаров
107function ClearSlaveListGoods(SlaveList){
108	while (SlaveList.length > 0) SlaveList.options[0] = null;
109}
110function alertContentGoods(){
111	try {
112		if (http_requestGoods.readyState == 4) {
113			if (http_requestGoods.status == 200) {
114				FillSlaveListGoods(http_requestGoods.responseText);
115			}
116			else{
117				alert('Проблема с запросом.');
118			}
119		}
120	}
121	catch( e ) {
122		alert('Произошло исключение: ' + e.description);
123	}
124}
125function FillSlaveListGoods(responseText){
126	if (trim(responseText) != ""){
127		var slaves = responseText.split('#');
128		for(var skey in slaves){
129			if (slaves[skey].length > 0){
130				var elements = slaves[skey].split(';')
131				var i = 0;
132				var SlaveList="";
133				var Slave = "";
134				for(var key in elements){
135					var element = elements[key].split(':');
136					if (key < 1){
137						SlaveList = document.getElementById(element[1]);
138					}
139					else{
140						Slave = new Option(element[1], element[0], false, false);
141						SlaveList.options[i++] = Slave;
142					}
143
144				}
145			}
146		}
147	}
148	return true;
149}
150function HTTP_MakeRequestGoods(url){
151	http_requestGoods = false;
152	if (window.XMLHttpRequest){
153		http_requestGoods = new XMLHttpRequest();
154		if (http_requestGoods.overrideMimeType){
155			http_requestGoods.overrideMimeType('text/xml');
156		}
157	}
158	else if (window.ActiveXObject){
159		try{
160			http_requestGoods = new ActiveXObject("Msxml2.XMLHTTP");
161		}
162		catch (e){
163			try{
164				http_requestGoods = new ActiveXObject("Microsoft.XMLHTTP");
165			}
166			catch (e){}
167		}
168	}
169	if (!http_requestGoods){
170		alert('Не получается отправить XMLHTTP запрос');
171		return false;
172	}
173	http_requestGoods.onreadystatechange = alertContentGoods;
174	http_requestGoods.open('GET', url, true);
175	http_requestGoods.send(null);
176}
177
178//======================== РАБОТА С ТОВАРОМ =====================================
179function HTTP_MakeRequestGoodsItems(url){
180	http_requestGoodsItems = false;
181	if (window.XMLHttpRequest){
182		http_requestGoodsItems = new XMLHttpRequest();
183		if (http_requestGoodsItems.overrideMimeType){
184			http_requestGoodsItems.overrideMimeType('text/xml');
185		}
186	}
187	else if (window.ActiveXObject){
188		try{
189			http_requestGoodsItems = new ActiveXObject("Msxml2.XMLHTTP");
190		}     
191		catch (e){
192			try{
193				http_requestGoodsItems = new ActiveXObject("Microsoft.XMLHTTP");
194			}
195			catch (e){}
196		}
197	}
198	if (!http_requestGoodsItems){
199		alert('Не получается отправить XMLHTTP запрос');
200		return false;
201	}
202	http_requestGoodsItems.onreadystatechange = alertContentsGoodsItems;
203	http_requestGoodsItems.open('GET', url, true);
204	http_requestGoodsItems.send(null);
205}
206
207function alertContentsGoodsItems(){
208	try {
209		if (http_requestGoodsItems.readyState == 4) {
210			if (http_requestGoodsItems.status == 200) {
211				ShowGoodsItemsTable(http_requestGoodsItems.responseText);
212			}
213			else{
214				alert('Проблема с запросом.');
215			}
216		}
217	}
218	catch( e ) {
219		alert('Произошло исключение: ' + e.description);
220	}
221}
222
223function ShowGoodsItemsTable(responseText){
224	document.getElementById('tGoodsItems').innerHTML = responseText;
225	return true;
226}
227
228//======================== РАБОТА С ТОВАРОМ =====================================
229
230function alertContentsParamDetail(){
231	try {
232		if (http_requestGoodsDetail.readyState == 4) {
233			if (http_requestGoodsDetail.status == 200) {
234				var details = http_requestGoodsDetail.responseText.split('|');
235				document.getElementById('nameproducer').innerHTML = details[1] + " ("+details[2]+")";
236				document.getElementById('namemeasure').innerHTML = details[3];
237			}
238			else{
239				alert('Проблема с запросом.');
240			}
241		}
242	}
243	catch( e ) {
244		alert('Произошло исключение: ' + e.description);
245	}
246}
247
248function HTTP_MakeRequestGoodsDetail(url){
249	http_requestGoodsDetail = false;
250	if (window.XMLHttpRequest){
251		http_requestGoodsDetail = new XMLHttpRequest();
252		if (http_requestGoodsDetail.overrideMimeType){
253			http_requestGoodsDetail.overrideMimeType('text/xml');
254		}
255	}
256	else if (window.ActiveXObject){
257		try{
258			http_requestGoodsDetail = new ActiveXObject("Msxml2.XMLHTTP");
259		}     
260		catch (e){
261			try{
262				http_requestGoodsDetail = new ActiveXObject("Microsoft.XMLHTTP");
263			}
264			catch (e){}
265		}
266	}
267	if (!http_requestGoodsDetail){
268		alert('Не получается отправить XMLHTTP запрос');
269		return false;
270	}
271	http_requestGoodsDetail.onreadystatechange = alertContentsParamDetail;
272	http_requestGoodsDetail.open('GET', url, true);
273	http_requestGoodsDetail.send(null);
274}
275/******************************************************************************************************************************/
276/************************************************** Отображение изображений ***************************************************/
277function alertCategoryImages(){
278	try {
279		if (http_requestGoodsImages.readyState == 4) {
280			if (http_requestGoodsImages.status == 200) {
281				document.getElementById('NameImagesCategory').innerHTML = http_requestGoodsImages.responseText;
282			}
283			else{
284				alert('Проблема с запросом.');
285			}
286		}
287	}
288	catch( e ) {
289		alert('Произошло исключение: ' + e.description);
290	}
291}
292function alertSubCategoryImages(){
293	try {
294		if (http_requestGoodsImages.readyState == 4) {
295			if (http_requestGoodsImages.status == 200) {
296				document.getElementById('NameImagesSubCategory').innerHTML = http_requestGoodsImages.responseText;
297			}
298			else{
299				alert('Проблема с запросом.');
300			}
301		}
302	}
303	catch( e ) {
304		alert('Произошло исключение: ' + e.description);
305	}
306}
307function alertSubSubCategoryImages(){
308	try {
309		if (http_requestGoodsImages.readyState == 4) {
310			if (http_requestGoodsImages.status == 200) {
311				document.getElementById('NameImagesSubSubCategory').innerHTML = http_requestGoodsImages.responseText;
312			}
313			else{
314				alert('Проблема с запросом.');
315			}
316		}
317	}
318	catch( e ) {
319		alert('Произошло исключение: ' + e.description);
320	}
321}
322function alertGoodsImages(){
323	try {
324		if (http_requestGoodsImages.readyState == 4) {
325			if (http_requestGoodsImages.status == 200) {
326				document.getElementById('NameImages').innerHTML = http_requestGoodsImages.responseText;
327			}
328			else{
329				alert('Проблема с запросом.');
330			}
331		}
332	}
333	catch( e ) {
334		alert('Произошло исключение: ' + e.description);
335	}
336}
337
338function HTTP_MakeRequestGoodsImages(url, param){
339	http_requestGoodsImages = false;
340	if (window.XMLHttpRequest){
341		http_requestGoodsImages = new XMLHttpRequest();
342		if (http_requestGoodsImages.overrideMimeType){
343			http_requestGoodsImages.overrideMimeType('text/xml');
344		}
345	}
346	else if (window.ActiveXObject){
347		try{
348			http_requestGoodsImages = new ActiveXObject("Msxml2.XMLHTTP");
349		}     
350		catch (e){
351			try{
352				http_requestGoodsImages = new ActiveXObject("Microsoft.XMLHTTP");
353			}
354			catch (e){}
355		}
356	}
357	if (!http_requestGoodsImages){
358		alert('Не получается отправить XMLHTTP запрос');
359		return false;
360	}
361	switch (param){
362		case 'tCategory':
363			http_requestGoodsImages.onreadystatechange = alertCategoryImages;
364		break;
365		case 'tSubCategory':
366			http_requestGoodsImages.onreadystatechange = alertSubCategoryImages;
367		break;
368		case 'tSubSubCategory':
369			http_requestGoodsImages.onreadystatechange = alertSubSubCategoryImages;
370		break;
371		case 'tGoods':
372			http_requestGoodsImages.onreadystatechange = alertGoodsImages;
373		break;
374	}
375	http_requestGoodsImages.open('GET', url, true);
376	http_requestGoodsImages.send(null);
377}
378
379/******************************************************************************************************************************/
380/************************************************** Запросы к таблицам ********************************************************/
381//Получение списка разделов
382function GetCategoryList(){
383	ClearSlaveListCat(document.getElementById('tCategory'));
384	ClearSlaveListCat(document.getElementById('tSubCategory'));
385	ClearSlaveListCat(document.getElementById('tSubSubCategory'));
386	ClearSlaveListGoods(document.getElementById('tGoods'));
387	FillGoodsCart();
388	HTTP_MakeRequestCat("../include/getrecords.php?IdCategory=no");
389
390	return true;
391}
392//Получение категории по разделу
393function GetSubCategoryList(OwnerList, FillGoods){
394	ClearSlaveListCat(document.getElementById('tSubCategory'));
395	ClearSlaveListCat(document.getElementById('tSubSubCategory'));
396	ClearSlaveListGoods(document.getElementById('tGoods'));
397	if (FillGoods){
398		FillGoodsCart();
399		document.getElementById('NameImagesSubCategory').innerHTML = "";
400		document.getElementById('NameImagesSubSubCategory').innerHTML = "";
401	}
402	HTTP_MakeRequestCat("../include/getrecords.php?IdCategory=" + OwnerList.value);
403	if (FillGoods) HTTP_MakeRequestGoodsImages("../include/getimagesgoods.php?type=tCategory&IdCategory=" + OwnerList.value, OwnerList.id);
404	return true;
405}
406//Получение подраздела по разделу
407function  GetSubSubCategoryList(OwnerList, FillGoods){
408	ClearSlaveListCat(document.getElementById('tSubSubCategory'));
409	ClearSlaveListGoods(document.getElementById('tGoods'));
410	if (FillGoods){
411		FillGoodsCart();
412		document.getElementById('NameImagesSubCategory').innerHTML = "";
413	}
414	HTTP_MakeRequestCat("../include/getrecords.php?IdSubCategory=" + OwnerList.value);
415	HTTP_MakeRequestGoods("../include/getgoods.php?IdSubCategory=" + OwnerList.value);
416	if (FillGoods) HTTP_MakeRequestGoodsImages("../include/getimagesgoods.php?type=tSubCategory&IdCategory=" + document.getElementById('tCategory').value + "&IdSubCategory=" + OwnerList.value, OwnerList.id);
417	return true;
418}
419
420//Получение номенклатуры по подразделу
421function  GetGoodsList(OwnerList, FillGoods){
422	ClearSlaveListCat(document.getElementById('tGoods'));
423	if (FillGoods) FillGoodsCart();		
424	HTTP_MakeRequestCat("../include/getrecords.php?IdSubSubCategory=" + OwnerList.value);
425	if (FillGoods) HTTP_MakeRequestGoodsImages("../include/getimagesgoods.php?type=tSubSubCategory&IdCategory=" + document.getElementById('tCategory').value + "&IdSubCategory=" +  document.getElementById('tSubCategory').value + "&IdSubSubCategory=" + OwnerList.value, OwnerList.id);
426	return true;
427}
428
429//Получение единиц товара по номенклатуре товара
430function  GetGoodsItemsList(OwnerList){
431	FillGoodsCart();
432	HTTP_MakeRequestGoodsItems("../include/getrecords.php?IdGoods=" + OwnerList.value);
433	HTTP_MakeRequestGoodsDetail("../include/getrecords.php?IdGoods=" + OwnerList.value +"&param=detail");
434	SubSub = document.getElementById('tSubSubCategory');
435	IdSubSub = 0;
436	if(SubSub.selectedIndex != -1) IdSubSub = SubSub.value;
437	HTTP_MakeRequestGoodsImages("../include/getimagesgoods.php?type=tGoods&IdCategory=" + document.getElementById('tCategory').value + "&IdSubCategory=" +  document.getElementById('tSubCategory').value + "&IdSubSubCategory=" + IdSubSub + "&IdGoods=" + OwnerList.value,  OwnerList.id);	
438	return true;
439}
440/******************************************************************************************************************************/
441/************************************************* РЕДАКТИРОВАНИЕ СПРАВОЧНИКОВ ************************************************/
442function alertContentCatUpdate(){
443	try {
444		if (http_requestCat.readyState == 4) {
445			if (http_requestCat.status == 200) {
446				if (http_requestCatUpdate.responseText != "") alert (http_requestCatUpdate.responseText);
447			}
448			else{
449				alert('Проблема с запросом.');
450			}
451		}
452	}
453	catch( e ) {
454		alert('Произошло исключение: ' + e.description);
455	}
456}
457
458function HTTP_MakeRequestCatUpdate(url, param){
459	http_requestCatUpdate = false;
460	if (window.XMLHttpRequest){
461		http_requestCatUpdate = new XMLHttpRequest();
462		if (http_requestCatUpdate.overrideMimeType){
463			http_requestCatUpdate.overrideMimeType('text/xml');
464		}
465	}
466	else if (window.ActiveXObject){
467		try{
468			http_requestCatUpdate = new ActiveXObject("Msxml2.XMLHTTP");
469		}
470		catch (e){
471			try{
472				http_requestCatUpdate = new ActiveXObject("Microsoft.XMLHTTP");
473			}
474			catch (e){}
475		}
476	}
477	if (!http_requestCatUpdate){
478		alert('Не получается отправить XMLHTTP запрос');
479		return false;
480	}
481	switch (param){
482		case 'add':
483			http_requestCatUpdate.onreadystatechange = alertContentCatUpdate;
484		break;
485	}
486
487	http_requestCatUpdate.open('GET', url, true);
488	http_requestCatUpdate.send(null);
489}
490
491function UpdateItemCatalog(owner){
492	stId = owner.id;
493	stAction = stId.substr(0,3);
494	stTable = stId.substr(3,stId.length);
495	tListName = "";
496	tList = document.getElementById(stTable);
497	switch(stTable){
498		case "tCategory":
499			tListName = "раздел";
500		break;
501		case "tSubCategory":
502			IdCategory = t
502Category.value;
503			tListName = "категорию";
504		break;
505		case "tSubSubCategory":
506			IdCategory = tCategory.value;
507			IdSubCategory = tSubCategory.value;
508			tListName = "подкатегорию";
509		break;
510		case "tGoods":
511			IdCategory = document.getElementById('tCategory').value;
512			IdSubCategory = tSubCategory.value;
513			IdSubSubCategory = tSubSubCategory.value;
514			tListName = "номенклатуру";
515		break;
516	}
517	switch (stAction){
518		case "add":
519			NameAlbumNew = trim(prompt('Создать ' + tListName + ": ", ""));
520			if (NameAlbumNew != null && NameAlbumNew != ""){
521				tCategory = document.getElementById('tCategory');
522				tSubCategory = document.getElementById('tSubCategory');
523				tSubSubCategory = document.getElementById('tSubSubCategory');
524				IdCategory = 0;
525				IdSubCategory = 0;
526				IdSubSubCategory = 0;
527				bError = false;
528				switch(stTable){
529					case "tSubCategory":
530						IdCategory = tCategory.value;
531					break;
532					case "tSubSubCategory":
533						IdCategory = tCategory.value;
534						IdSubCategory = tSubCategory.value;
535					break;
536					case "tGoods":
537						IdCategory = document.getElementById('tCategory').value;
538						IdSubCategory = tSubCategory.value;
539						if (tSubSubCategory.selectedIndex >= 0) IdSubSubCategory = tSubSubCategory.value;
540					break;
541				}
542				stTmp = "&IdCategory=" + IdCategory + "&IdSubCategory=" + IdSubCategory;
543				HTTP_MakeRequestCatUpdate( "../include/ajax_universal.php?func=AddCatalog&TableName=" + stTable + "&NewName=" + NameAlbumNew + stTmp, "add");
544			}
545		break;
546		case "del":
547			if (tList.selectedIndex >= 0){
548				if (confirm("Вы действительно хотите удалить " + tListName + " [" + tList.options[tList.options.selectedIndex].text + "]?")) {
549					HTTP_MakeRequestCatUpdate( "../include/ajax_universal.php?func=DelCatalog&TableName=" + stTable + "&IddItem=" + tList.value, "add");
550				}
551			}
552			else {
553				alert("Выберите " + tListName + " для удаления!");
554			}
555		break;
556		case "edt":
557			previndex = tList.selectedIndex; 
558			if (previndex >= 0){
559				NameAlbum = tList.options[previndex].text;
560				NameAlbumNew = trim(prompt('Редактировать ' + tListName + ": ", NameAlbum));
561				if (NameAlbumNew != null && NameAlbumNew != ""){
562					HTTP_MakeRequestCatUpdate( "../include/ajax_universal.php?func=EditCatalog&TableName=" + stTable + "&IddItem=" + tList.value + "&NewName=" + NameAlbumNew, "add");
563					switch(stTable){
564						case "tCategory":
565							GetCategoryList();
566						break;
567						case "tSubCategory":
568							GetSubCategoryList(document.getElementById('tCategory'), true);
569						break;
570						case "tSubSubCategory":
571							GetSubSubCategoryList(document.getElementById('tSubCategory'), true);
572						break;
573						case "tGoods":
574							GetGoodsList(document.getElementById('tSubSubCategory'), true);
575						break;
576					}
577				}
578			}
579			else{
580				alert("Выберите " + tListName + " для редактирования!");
581			}
582		break;
583	}
584}
585

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.