PageSourceSearch

https://www.madnesslive.es/modules/megaproduct/js/mpcustom.js?v=19

js madnesslive.es collected 2026-09-24 20:37:00 UTC 9,485 bytes, 292 lines download raw bytes

1$(document).ready(function(){
2	if($('.mpTableCustom input').length)
3	{
4		$('.mpTableCustom input').blur(function(){
5			updateCustomData(this);
6		});
7		$('.mpTableCustom select').change(function(){
8			updateCustomData(this);
9		});	
10	}
11	loadEventMPAccount();
12	
13});
14function loadEventMPAccount(){
15	
16	if($("#mpProductCustomerList").length){
17		 $("#mpProductCustomerList").dataTable({
18				"bJQueryUI": true,
19				"bPaginate": false,
20				"bLengthChange": false,
21				"bFilter": true,
22				"bSort": true,
23				"bInfo": false,
24				"bAutoWidth": false,
25				"iDisplayLength": 50,
26				"dom": 'Bfrtip',
27				"buttons": [
28        			 
29        	            
30        	            'csvHtml5',
31        	        ],
32        "footerCallback": function ( row, data, start, end, display ) {
33		            var api = this.api(), data;
34
35		            // Remove the formatting to get integer data for summation
36		            var intVal = function ( i ) {
37		                return typeof i === 'string' ?
38		                    i.replace(',','.').replace(/[^\d.]/g, '')*1 :
39		                    typeof i === 'number' ?
40		                        i : 0;
41		            };
42		            // Total over all pages
43		            total = api
44		                .column(9)
45		                .data()
46		                .reduce( function (a, b) {
47		                    return intVal(a) + intVal(b);
48		                } );
49		            
50		            totalQty = api
51		                .column(8)
52		                .data()
53		                .reduce( function (a, b) {
54		                    return intVal(a) + intVal(b);
55		                } );    
56
57		            // Total over this page
58		            pageTotal = api
59		                .column(9, { page: 'current'} )
60		                .data()
61		                .reduce( function (a, b) {
62		                    return intVal(a) + intVal(b);
63		                }, 0 );
64		             // Total over this page
65		            pageTotalQty = api
66		                .column(8, { page: 'current'} )
67		                .data()
68		                .reduce( function (a, b) {
69		                    return intVal(a) + intVal(b);
70		                }, 0 );    
71
72		            pageTotal =parseFloat(Math.round(pageTotal * 100) / 100).toFixed(2);
73		            total =parseFloat(Math.round(total * 100) / 100).toFixed(2);
74		            
75		           // pageTotalQty =parseFloat(Math.round(pageTotalQty * 100) / 100).toFixed(2);
76		            //totalQty =parseFloat(Math.round(totalQty * 100) / 100).toFixed(2);
77		            
78		            // Update footer
79		            $(api.column(9).footer()).html(
80		                ''+pageTotal +' ('+ total +')'
81		            );
82		            $(api.column(8).footer()).html(
83		                ''+pageTotalQty +' / '+ totalQty 
84		            );
85
86				},
87	        
88        "initComplete": function () {
89    	            this.api().columns().every( function () {
90    	            	var column = this;
91    	            	if($(column.footer()).hasClass('dtselector'))
92    	            	{  
93    	  	                var select = $('<select><option value=""></option></select>')
94    	  	                    .appendTo( $(column.footer()).empty() )
95    	  	                    .on( 'change', function () {
96    	  	                        var val = $.fn.dataTable.util.escapeRegex(
97    	  	                            $(this).val()
98    	  	                        );
99    	  	 
100    	  	                        column
101    	  	                            .search( val ? '^'+val+'$' : '', true, false )
102    	  	                            .draw();
103    	  	                    } );
104    	  	 
105    	  	                column.data().unique().sort().each( function ( d, j ) {
106    	  	                    select.append( '<option value="'+d+'">'+d+'</option>' )
107    	  	                } );
108    	            	} 
109    	            	if($(column.header()).hasClass('dtselector'))
110    	            	{  
111    	  	                var select = $('<br/><select><option value=""></option></select>')
112    	  	                    .appendTo( $(column.header()) )
113    	  	                    .on( 'change', function () {
114    	  	                        var val = $.fn.dataTable.util.escapeRegex(
115    	  	                            $(this).val()
116    	  	                        );
117    	  	 
118    	  	                        column
119    	  	                            .search( val ? '^'+val+'$' : '', true, false )
120    	  	                            .draw();
121    	  	                    } );
122    	  	 
123    	  	                column.data().unique().sort().each( function ( d, j ) {
124    	  	                    select.append( '<option value="'+d+'">'+d+'</option>' )
125    	  	                } );
126    	            	} 
127    	            	if ($(column.footer()).hasClass('dtinput'))
128    	            	{  
129    	  	                var select = $('<input>')
130    	  	                    .appendTo( $(column.footer()).empty() )
131    	  	                    .on( 'change', function () {
132    	  	                        var val = $.fn.dataTable.util.escapeRegex(
133    	  	                            $(this).val()
134    	  	                        );
135    	  	 
136    	  	                        column
137    	  	                            .search(val)
138    	  	                            .draw();
139    	  	                    } );
140    	  	 
141    	  	               
142    	            	}
143    	            	if ($(column.header()).hasClass('dtinput'))
144    	            	{  
145    	            		var select = $('<br/>')
146	  	                    .appendTo( $(column.header()));
147    	  	                select = $('<input>')
148    	  	                    .appendTo( $(column.header()))
149    	  	                    .on( 'change', function () {
150    	  	                        var val = $.fn.dataTable.util.escapeRegex(
151    	  	                            $(this).val()
152    	  	                        );
153    	  	 
154    	  	                        column
155    	  	                            .search(val)
156    	  	                            .draw();
157    	  	                    } );     
158    	            	}
159    	            } );
160    	        }
161      });
162	}
163}
164function updateCustomData(el)
165{
166	var tr = $(el).parents('tr:first');
167	var id = $(tr).data('id');
168	var id_megacart = $(tr).data('mega');
169	var mpname = $(tr).find('.mpName').val();
170	var mpmobile = $(tr).find('.mpPhone').val();
171	var mpemail = $(tr).find('.mpEmail').val();
172	var mpsex = $(tr).find('.mpSex').val();
173	var mpdni = $(tr).find('.mpDni').val();
174	
175	var url = '../modules/megaproduct/ajax_admin.php';
176	var fieldArray = {id:id,id_megacart:id_megacart,name:mpname,mobile:mpmobile,email:mpemail,sex:mpsex,dni:mpdni};
177	var fieldData = '&action=saveCustomData&mpcustom='+JSON.stringify(fieldArray);
178	var posting = $.post( url, fieldData);
179
180}
181
182function applyMPCustomPersonalization()
183{
184	if(!$('#megaproduct').length ||  !$('#customMPForm').length)
185	return;
186	
187	var qty = parseInt($('#quantity_wanted').val());
188	if($('#addTicketZones').length)
189	{
190		qty = getQuantityMegaSeats();
191	}
192	var form = $('#customMPForm').html();
193	$('#customQuantityMPForm').html('');
194	for(var i=0;i<qty;i++)
195	{
196		
197		var k = i+1;
198		formfinal = form.replaceAll('sex0','sex'+k);
199		$('#customQuantityMPForm').append('<div id="customMPForm'+k+'" class="customMPForm" style="display:none">'+formfinal+'</div>');
200	}
201	$('#customMPBefore').hide();
202	if(qty==1)
203	{
204		
205		$('#customMPNext').hide();
206	}
207	else
208	{
209		
210		$('#customMPNext').show();
211	}
212	$('#customMPNumber').html(1);
213	$('#customMPTotal').html(qty);
214	$('#customQuantityMPForm').find('.customMPForm:first').show();
215}
216function showMPCustomEmail(el){
217	var divcontent = $(el).parents('.customMPForm:first').find('.customMPEmail');
218	if($(divcontent).is(":visible"))
219		$(divcontent).find('input').val('');
220	$(divcontent).toggle();
221}
222function showMPPageCustom(type){
223	$('#customMPNext').show();
224	$('#customMPBefore').show();
225	$('.customMPForm').hide();
226	
227	var page = parseInt($('#customMPNumber').html());
228	var totalpage = parseInt($('#customMPTotal').html());
229	var newpage = 0;
230	if(type=='next')
231	{
232		newpage = page+1;
233		$('#customMPBefore').show();
234	}
235	if(type=='before')
236	{
237		newpage = page-1;
238	}
239	showMPPage(newpage);
240}
241function showMPPage(page)
242{
243	$('#customMPError').hide();
244	var totalpage = parseInt($('#customMPTotal').html());
245	$('.customMPForm').hide();
246	$('#customMPForm'+page).show();
247	$('#customMPNumber').html(page);
248	if(page==1)
249		$('#customMPBefore').hide();
250	if(totalpage==page)
251		$('#customMPNext').hide();
252}
253function listMPCustom()
254{
255	_MP.arrayCustom = new Array();
256	var customgroups = new Array();
257	var i = 1;
258	var hasError = false;
259	$('#customQuantityMPForm .customMPForm').each(function(){
260		var sex = $(this).find('input[name=sex'+i+']:checked').val();
261		var name = $(this).find('#name').val();
262		var dni = $(this).find('#dni').val();
263		var mobile_phone = $(this).find('#mobile_phone').val();
264		var email = $(this).find('#email').val();
265		var arrayValues =  {sex: sex, name: name, dni: dni, mobile: mobile_phone, email: email};
266		if(name=='' || dni=='')
267		{
268			hasError = true;
269			showMPPage(i);
270			$('#customMPError').show();
271			return false;
272		}
273		customgroups[i-1]=arrayValues;
274		i++;
275	});
276	
277	if(!hasError && customgroups.length)
278	{
279		_MP.arrayCustom = customgroups;
280		if($('#addListSeat').length)
281			$('#addListSeat').click();
282		else
283			$('#btnAddCalculeService').click();
284	}
285	
286	return '';
287};
288
289String.prototype.replaceAll = function(search, replacement) {
290    var target = this;
291    return target.replace(new RegExp(search, 'g'), replacement);
292};

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.