| 
									
										
										
										
											2017-04-15 23:16:20 +02:00
										 |  |  |  | $(document).on('click', '.product-delete-button', function(e) | 
					
						
							|  |  |  |  | { | 
					
						
							|  |  |  |  | 	bootbox.confirm({ | 
					
						
							| 
									
										
										
										
											2018-04-18 19:37:36 +02:00
										 |  |  |  | 		message: L('Are you sure to delete product "#1"?', $(e.currentTarget).attr('data-product-name')), | 
					
						
							| 
									
										
										
										
											2017-04-15 23:16:20 +02:00
										 |  |  |  | 		buttons: { | 
					
						
							|  |  |  |  | 			confirm: { | 
					
						
							| 
									
										
										
										
											2018-04-18 19:37:36 +02:00
										 |  |  |  | 				label: L('Yes'), | 
					
						
							| 
									
										
										
										
											2017-04-15 23:16:20 +02:00
										 |  |  |  | 				className: 'btn-success' | 
					
						
							|  |  |  |  | 			}, | 
					
						
							|  |  |  |  | 			cancel: { | 
					
						
							| 
									
										
										
										
											2018-04-18 19:37:36 +02:00
										 |  |  |  | 				label: L('No'), | 
					
						
							| 
									
										
										
										
											2017-04-15 23:16:20 +02:00
										 |  |  |  | 				className: 'btn-danger' | 
					
						
							|  |  |  |  | 			} | 
					
						
							|  |  |  |  | 		}, | 
					
						
							|  |  |  |  | 		callback: function(result) | 
					
						
							|  |  |  |  | 		{ | 
					
						
							| 
									
										
										
										
											2017-04-20 22:01:14 +02:00
										 |  |  |  | 			if (result === true) | 
					
						
							| 
									
										
										
										
											2017-04-15 23:16:20 +02:00
										 |  |  |  | 			{ | 
					
						
							| 
									
										
										
										
											2018-04-18 19:03:39 +02:00
										 |  |  |  | 				Grocy.Api.Get('delete-object/products/' + $(e.currentTarget).attr('data-product-id'), | 
					
						
							| 
									
										
										
										
											2017-04-15 23:16:20 +02:00
										 |  |  |  | 					function(result) | 
					
						
							|  |  |  |  | 					{ | 
					
						
							| 
									
										
										
										
											2018-04-18 19:03:39 +02:00
										 |  |  |  | 						window.location.href = U('/products'); | 
					
						
							| 
									
										
										
										
											2017-04-15 23:16:20 +02:00
										 |  |  |  | 					}, | 
					
						
							|  |  |  |  | 					function(xhr) | 
					
						
							|  |  |  |  | 					{ | 
					
						
							|  |  |  |  | 						console.error(xhr); | 
					
						
							|  |  |  |  | 					} | 
					
						
							|  |  |  |  | 				); | 
					
						
							|  |  |  |  | 			} | 
					
						
							|  |  |  |  | 		} | 
					
						
							|  |  |  |  | 	}); | 
					
						
							|  |  |  |  | }); | 
					
						
							| 
									
										
										
										
											2017-04-16 23:11:03 +02:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-04-16 19:11:32 +02:00
										 |  |  |  | $('#products-table').DataTable({ | 
					
						
							|  |  |  |  | 	'pageLength': 50, | 
					
						
							|  |  |  |  | 	'order': [[1, 'asc']], | 
					
						
							|  |  |  |  | 	'columnDefs': [ | 
					
						
							|  |  |  |  | 		{ 'orderable': false, 'targets': 0 } | 
					
						
							|  |  |  |  | 	], | 
					
						
							|  |  |  |  | 	'language': JSON.parse(L('datatables_localization')) | 
					
						
							| 
									
										
										
										
											2017-04-16 23:11:03 +02:00
										 |  |  |  | }); |