Blame view

webroot/js/script.js 4.04 KB
6c4edfa3   Alexandre   First Commit LabI...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
/**
 * empty a SELECT field given its name and default option
 * call example : emptySelectOptions("#MaterielSousCategorieId","Choisir une sous-catégorie")
 * 
 */
function emptySelectOptions(selectFieldId, defaultOption) {
	var newOptions = {
		"" : defaultOption
	};
	//var selectedOption = "Choisir une sous-catégorie";
	var select = $(selectFieldId);
	var options;
	if(select.prop) {
		options = select.prop("options");
	}
	else {
		options = select.attr("options");
	}
	$("option", select).remove();
	$.each(newOptions, function(val, text) {
		options[options.length] = new Option(text, val);
	});
	//select.val(selectedOption);
}

/**
 * Ajax request that updates a SELECT options (selectId) according to the selection made in another SELECT (otherSelectId)
 * For now, works only from Materiels VIEW (otherwise, replace "materiels" below with your view name)
 * 
 * call example : 
 * updateSelectOptionsFromAnother("#MaterielCategorieId", "#MaterielSurCategorieId", "Categories/getAll", "catégorie")
 * This would update the options of the SELECT named "MaterielCategorieId" from the selected value of the SELECT named MaterielSurCategorieId
 *
 */
function updateSelectOptionsFromAnother(selectId, otherSelectId, requestName, emptyOptionName) {
	var reg=new RegExp("(materiels).*$","g");
	var currentURL = window.location.pathname;
	var newURL = currentURL.replace(reg, requestName);
	$.ajax({
		async:true,
		data:$(otherSelectId).serialize(),
		dataType:"html",
		success:function (data, textStatus) {
			if (emptyOptionName == "") $(selectId).val(data);
			else {
6c4edfa3   Alexandre   First Commit LabI...
46
47
48
49
50
				data="<option value=\"\">"+emptyOptionName+"</option>"+data;
				$(selectId).html(data);
			}
		},
		type:"post", url:newURL
6c4edfa3   Alexandre   First Commit LabI...
51
52
53
54
55
56
57
58
59
60
	});
}


$(document).ready(function() {
	//Page index de matériel
	$('#t_informations').click(function() {
		$('#informations').toggle('fast');
		toogleChevron('#i_informations');
	});
cb0ff3ca   Alexandre   Version: 2.4.3.1
61
62
63
64
	$('#t_informations_admin').click(function() {
		$('#informations_admin').toggle('fast');
		toogleChevron('#i_informations_admin');
	});
6c4edfa3   Alexandre   First Commit LabI...
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
	$('#t_suivis').click(function() {
		$('#suivis').toggle('fast');
		toogleChevron('#i_suivis');
	});
	$('#t_emprunts').click(function() {
		$('#emprunts').toggle('fast');
		toogleChevron('#i_emprunts');
	});
	$('#t_fichiers').click(function() {
		$('#fichiers').toggle('fast');
		toogleChevron('#i_fichiers');
	});	
	
	//Page find de matériel
	$('#t_filter').click(function() {
		$('#filter').toggle('fast');
		toogleChevron('#i_filter');
	});
	$('#t_result').click(function() {
		$('#result').toggle('fast');
		toogleChevron('#i_result');
	});
});

function toogleChevron(element) {
	if ($(element).hasClass('icon-chevron-down')) {
			$(element).removeClass('icon-chevron-down');
			$(element).addClass('icon-chevron-up');
	}
	else {
		$(element).removeClass('icon-chevron-up');
		$(element).addClass('icon-chevron-down');
	}
}

function emprunt_interne_externe() {
	$('#interne').toggle();
	$('#externe').toggle();		
}

aa205f2e   Alexandre   Version: 2.4.2.21
105
106
107
108
function display_ldap() {
	$('#ldap').toggle();
}

6c4edfa3   Alexandre   First Commit LabI...
109
110
111
112
113
114
115
function selectAll() {
	for(i = 0; i < document.getElementsByTagName("input").length; i++)
		document.getElementsByTagName("input")[i].checked = true;
}
function selectNone() {
	for(i = 0; i < document.getElementsByTagName("input").length; i++)
		document.getElementsByTagName("input")[i].checked = false;
3ef8f907   Alexandre   Version: 2.4.5.0
116
117
118
119
120
121
122
123
124
}

function changeAdminEdit() {
	if (document.getElementById('eotp').disabled) {
		document.getElementById('eotp').disabled=false;
		document.getElementById('numero-commande').disabled=false;
		document.getElementById('code-comptable').disabled=false;
		document.getElementById('numero-inventaire-organisme').disabled=false;
		document.getElementById('numero-inventaire-old').disabled=false;
ed4c8419   mimelhaine   Test avant merge
125
		document.getElementById('num_labo').disabled=false;
3ef8f907   Alexandre   Version: 2.4.5.0
126
127
128
129
130
131
	}
	else {
		document.getElementById('eotp').disabled=true;
		document.getElementById('numero-commande').disabled=true;
		document.getElementById('code-comptable').disabled=true;
		document.getElementById('numero-inventaire-organisme').disabled=true;
ed4c8419   mimelhaine   Test avant merge
132
133
		document.getElementById('numero-inventaire-old').disabled=true;
		document.getElementById('num_labo').disabled=true; 
3ef8f907   Alexandre   Version: 2.4.5.0
134
	}
6c4edfa3   Alexandre   First Commit LabI...
135
}