2019-04-22 22:16:35 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
										 
							
							
								 $ ( '#save-product-button' ) . on ( 'click' ,  function ( e )  
						 
					
						
							
								
									
										
										
										
											2017-04-15 23:16:20 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									e . preventDefault ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2018-04-18 19:03:39 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									var  redirectDestination  =  U ( '/products' ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2018-04-14 11:10:38 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									var  returnTo  =  GetUriParam ( 'returnto' ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-04-20 22:01:14 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									if  ( returnTo  !==  undefined ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									{ 
							 
						 
					
						
							
								
									
										
										
										
											2019-05-03 20:22:48 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										redirectDestination  =  U ( returnTo )  +  '?createdproduct='  +  encodeURIComponent ( $ ( '#name' ) . val ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-04-20 22:01:14 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2019-01-26 14:17:02 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									var  jsonData  =  $ ( '#product-form' ) . serializeJSON ( {  checkboxUncheckedValue :  "0"  } ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2019-09-14 17:34:36 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									var  parentProductId  =  jsonData . product _id ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									delete  jsonData . product _id ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									jsonData . parent _product _id  =  parentProductId ; 
							 
						 
					
						
							
								
									
										
										
										
											2018-11-24 19:40:50 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									Grocy . FrontendHelpers . BeginUiBusy ( "product-form" ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2019-09-14 17:34:36 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									if  ( jsonData . parent _product _id . toString ( ) . isEmpty ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									{ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										jsonData . parent _product _id  =  null ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2018-09-30 23:22:17 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									if  ( $ ( "#product-picture" ) [ 0 ] . files . length  >  0 ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									{ 
							 
						 
					
						
							
								
									
										
										
										
											2018-10-01 20:20:50 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										var  someRandomStuff  =  Math . random ( ) . toString ( 36 ) . substring ( 2 ,  100 )  +  Math . random ( ) . toString ( 36 ) . substring ( 2 ,  100 ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										jsonData . picture _file _name  =  someRandomStuff  +  $ ( "#product-picture" ) [ 0 ] . files [ 0 ] . name ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									if  ( Grocy . DeleteProductPictureOnSave ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									{ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										jsonData . picture _file _name  =  null ; 
							 
						 
					
						
							
								
									
										
										
										
											2018-09-30 23:22:17 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2017-04-15 23:16:20 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									if  ( Grocy . EditMode  ===  'create' ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									{ 
							 
						 
					
						
							
								
									
										
										
										
											2019-01-19 14:51:51 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										Grocy . Api . Post ( 'objects/products' ,  jsonData , 
							 
						 
					
						
							
								
									
										
										
										
											2019-04-22 22:16:35 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											function ( result ) 
							 
						 
					
						
							
								
									
										
										
										
											2017-04-15 23:16:20 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											{ 
							 
						 
					
						
							
								
									
										
										
										
											2019-04-22 22:16:35 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												Grocy . EditObjectId  =  result . created _object _id ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												Grocy . Components . UserfieldsForm . Save ( function ( ) 
							 
						 
					
						
							
								
									
										
										
										
											2018-09-30 23:22:17 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												{ 
							 
						 
					
						
							
								
									
										
										
										
											2019-04-22 22:16:35 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
													if  ( jsonData . hasOwnProperty ( "picture_file_name" )  &&  ! Grocy . DeleteProductPictureOnSave ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
													{ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
														Grocy . Api . UploadFile ( $ ( "#product-picture" ) [ 0 ] . files [ 0 ] ,  'productpictures' ,  jsonData . picture _file _name , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
															function ( result ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
															{ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
																window . location . href  =  redirectDestination ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
															} , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
															function  ( xhr ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
															{ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
																Grocy . FrontendHelpers . EndUiBusy ( "product-form" ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
																Grocy . FrontendHelpers . ShowGenericError ( 'Error while saving, probably this item already exists' ,  xhr . response ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
															} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
														) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
													} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
													else 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
													{ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
														window . location . href  =  redirectDestination ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
													} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												} ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-04-15 23:16:20 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											} , 
							 
						 
					
						
							
								
									
										
										
										
											2018-10-01 20:20:50 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											function  ( xhr ) 
							 
						 
					
						
							
								
									
										
										
										
											2017-04-15 23:16:20 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											{ 
							 
						 
					
						
							
								
									
										
										
										
											2018-11-24 19:40:50 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												Grocy . FrontendHelpers . EndUiBusy ( "product-form" ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2018-09-08 09:26:12 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												Grocy . FrontendHelpers . ShowGenericError ( 'Error while saving, probably this item already exists' ,  xhr . response ) 
							 
						 
					
						
							
								
									
										
										
										
											2017-04-15 23:16:20 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									else 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									{ 
							 
						 
					
						
							
								
									
										
										
										
											2018-10-01 20:20:50 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										if  ( Grocy . DeleteProductPictureOnSave ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										{ 
							 
						 
					
						
							
								
									
										
										
										
											2019-01-19 14:51:51 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											Grocy . Api . DeleteFile ( Grocy . ProductPictureFileName ,  'productpictures' ,  { } , 
							 
						 
					
						
							
								
									
										
										
										
											2018-10-01 20:20:50 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												function ( result ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												{ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
													// Nothing to do
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												} , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												function ( xhr ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												{ 
							 
						 
					
						
							
								
									
										
										
										
											2018-11-24 19:40:50 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
													Grocy . FrontendHelpers . EndUiBusy ( "product-form" ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2018-10-01 20:20:50 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
													Grocy . FrontendHelpers . ShowGenericError ( 'Error while saving, probably this item already exists' ,  xhr . response ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										} ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2019-01-19 14:51:51 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										Grocy . Api . Put ( 'objects/products/'  +  Grocy . EditObjectId ,  jsonData , 
							 
						 
					
						
							
								
									
										
										
										
											2017-04-15 23:16:20 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											function ( result ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											{ 
							 
						 
					
						
							
								
									
										
										
										
											2019-04-22 22:16:35 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												Grocy . Components . UserfieldsForm . Save ( function ( ) 
							 
						 
					
						
							
								
									
										
										
										
											2018-09-30 23:22:17 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												{ 
							 
						 
					
						
							
								
									
										
										
										
											2019-04-22 22:16:35 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
													if  ( jsonData . hasOwnProperty ( "picture_file_name" )  &&  ! Grocy . DeleteProductPictureOnSave ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
													{ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
														Grocy . Api . UploadFile ( $ ( "#product-picture" ) [ 0 ] . files [ 0 ] ,  'productpictures' ,  jsonData . picture _file _name , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
															function ( result ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
															{ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
																window . location . href  =  redirectDestination ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
															} , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
															function ( xhr ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
															{ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
																Grocy . FrontendHelpers . EndUiBusy ( "product-form" ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
																Grocy . FrontendHelpers . ShowGenericError ( 'Error while saving, probably this item already exists' ,  xhr . response ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
															} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
														) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
													} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
													else 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
													{ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
														window . location . href  =  redirectDestination ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
													} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												} ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-04-15 23:16:20 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											} , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											function ( xhr ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											{ 
							 
						 
					
						
							
								
									
										
										
										
											2018-11-24 19:40:50 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												Grocy . FrontendHelpers . EndUiBusy ( "product-form" ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2018-09-08 09:26:12 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												Grocy . FrontendHelpers . ShowGenericError ( 'Error while saving, probably this item already exists' ,  xhr . response ) 
							 
						 
					
						
							
								
									
										
										
										
											2017-04-15 23:16:20 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								} ) ;  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2018-04-16 19:11:32 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								$ ( '#barcode-taginput' ) . tagsManager ( {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									'hiddenTagListName' :  'barcode' , 
							 
						 
					
						
							
								
									
										
										
										
											2018-10-03 13:34:38 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									'tagsContainer' :  '#barcode-taginput-container' , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									'tagClass' :  'badge badge-secondary' 
							 
						 
					
						
							
								
									
										
										
										
											2018-04-16 19:11:32 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								} ) ;  
						 
					
						
							
								
									
										
										
										
											2017-04-18 21:15:45 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2018-04-16 19:11:32 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								if  ( Grocy . EditMode  ===  'edit' )  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
									
										
										
										
											2019-01-19 14:51:51 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									Grocy . Api . Get ( 'objects/products/'  +  Grocy . EditObjectId , 
							 
						 
					
						
							
								
									
										
										
										
											2018-04-16 19:11:32 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										function  ( product ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										{ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											if  ( product . barcode  !==  null  &&  product . barcode . length  >  0 ) 
							 
						 
					
						
							
								
									
										
										
										
											2017-04-18 21:15:45 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											{ 
							 
						 
					
						
							
								
									
										
										
										
											2018-04-16 19:11:32 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												product . barcode . split ( ',' ) . forEach ( function ( item ) 
							 
						 
					
						
							
								
									
										
										
										
											2017-04-18 21:15:45 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												{ 
							 
						 
					
						
							
								
									
										
										
										
											2018-04-16 19:11:32 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
													$ ( '#barcode-taginput' ) . tagsManager ( 'pushTag' ,  item ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												} ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-04-18 21:15:45 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											} 
							 
						 
					
						
							
								
									
										
										
										
											2018-04-16 19:11:32 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										} , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										function ( xhr ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										{ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											console . error ( xhr ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
									
										
										
										
											2017-04-18 21:15:45 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2018-04-16 19:11:32 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								var  prefillName  =  GetUriParam ( 'prefillname' ) ;  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								if  ( prefillName  !==  undefined )  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									$ ( '#name' ) . val ( prefillName ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-04-15 23:16:20 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									$ ( '#name' ) . focus ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2018-04-16 19:11:32 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
									
										
										
										
											2017-04-20 22:01:14 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2018-04-16 19:11:32 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								var  prefillBarcode  =  GetUriParam ( 'prefillbarcode' ) ;  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								if  ( prefillBarcode  !==  undefined )  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									$ ( '#barcode-taginput' ) . tagsManager ( 'pushTag' ,  prefillBarcode ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									$ ( '#name' ) . focus ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
									
										
										
										
											2017-04-17 16:51:49 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2019-06-09 09:21:56 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								$ ( "#barcode-taginput" ) . on ( "blur" ,  function ( e )  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									$ ( "#barcode-taginput" ) . tagsManager ( "pushTag" ,  $ ( "#barcode-taginput" ) . val ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								} ) ;  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2017-04-18 19:54:51 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								$ ( '.input-group-qu' ) . on ( 'change' ,  function ( e )  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
									
										
										
										
											2018-10-03 13:27:36 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									var  quIdPurchase  =  $ ( "#qu_id_purchase" ) . val ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									var  quIdStock  =  $ ( "#qu_id_stock" ) . val ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-04-18 19:54:51 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									var  factor  =  $ ( '#qu_factor_purchase_to_stock' ) . val ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2018-10-03 13:27:36 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									if  ( quIdPurchase  !=  quIdStock ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									{ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										$ ( '#qu_factor_purchase_to_stock' ) . attr ( "min" ,  2 ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2019-05-01 20:19:18 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										$ ( "#qu_factor_purchase_to_stock" ) . parent ( ) . find ( ".invalid-feedback" ) . text ( _ _t ( 'The amount cannot be lower than %s' ,  '2' ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2018-10-03 13:27:36 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									else 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									{ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										$ ( '#qu_factor_purchase_to_stock' ) . attr ( "min" ,  1 ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2019-05-01 20:19:18 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										$ ( "#qu_factor_purchase_to_stock" ) . parent ( ) . find ( ".invalid-feedback" ) . text ( _ _t ( 'The amount cannot be lower than %s' ,  '1' ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2018-10-03 13:27:36 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2017-04-18 19:54:51 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									if  ( factor  >  1 ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									{ 
							 
						 
					
						
							
								
									
										
										
										
											2019-05-05 14:13:50 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										$ ( '#qu-conversion-info' ) . text ( _ _t ( 'This means 1 %1$s purchased will be converted into %2$s %3$s in stock' ,  $ ( "#qu_id_purchase option:selected" ) . text ( ) ,  ( 1  *  factor ) . toString ( ) ,  $ ( "#qu_id_stock option:selected" ) . text ( ) ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2018-07-11 19:43:05 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										$ ( '#qu-conversion-info' ) . removeClass ( 'd-none' ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-04-18 19:54:51 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									else 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									{ 
							 
						 
					
						
							
								
									
										
										
										
											2018-07-11 19:43:05 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										$ ( '#qu-conversion-info' ) . addClass ( 'd-none' ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2018-10-03 13:27:36 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2019-03-05 17:51:50 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									$ ( "#tare_weight_qu_info" ) . text ( $ ( "#qu_id_stock option:selected" ) . text ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2018-10-03 13:27:36 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									Grocy . FrontendHelpers . ValidateForm ( 'product-form' ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2018-07-11 19:43:05 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								} ) ;  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								$ ( '#product-form input' ) . keyup ( function ( event )  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									Grocy . FrontendHelpers . ValidateForm ( 'product-form' ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								} ) ;  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2019-01-26 13:13:38 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								$ ( '#location_id' ) . change ( function ( event )  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									Grocy . FrontendHelpers . ValidateForm ( 'product-form' ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								} ) ;  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2018-07-11 19:43:05 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								$ ( '#product-form input' ) . keydown ( function ( event )  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									if  ( event . keyCode  ===  13 )  //Enter
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									{ 
							 
						 
					
						
							
								
									
										
										
										
											2018-09-29 13:41:56 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										event . preventDefault ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2019-01-19 00:37:21 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2018-07-11 19:43:05 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										if  ( document . getElementById ( 'product-form' ) . checkValidity ( )  ===  false )  //There is at least one validation error
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										{ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											return  false ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										else 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										{ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											$ ( '#save-product-button' ) . click ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										} 
							 
						 
					
						
							
								
									
										
										
										
											2017-04-18 19:54:51 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								} ) ;  
						 
					
						
							
								
									
										
										
										
											2018-04-16 19:11:32 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2019-03-05 17:51:50 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								$ ( "#enable_tare_weight_handling" ) . on ( "click" ,  function ( )  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									if  ( this . checked ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									{ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										$ ( "#tare_weight" ) . removeAttr ( "disabled" ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									else 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									{ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										$ ( "#tare_weight" ) . attr ( "disabled" ,  "" ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									Grocy . FrontendHelpers . ValidateForm ( "product-form" ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								} ) ;  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2019-04-06 15:27:00 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								$ ( "#allow_partial_units_in_stock" ) . on ( "click" ,  function ( )  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									if  ( this . checked ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									{ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										$ ( "#min_stock_amount" ) . attr ( "min" ,  "0.00" ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										$ ( "#min_stock_amount" ) . attr ( "step" ,  "0.01" ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									else 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									{ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										$ ( "#min_stock_amount" ) . attr ( "min" ,  "0" ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										$ ( "#min_stock_amount" ) . attr ( "step" ,  "1" ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									Grocy . FrontendHelpers . ValidateForm ( "product-form" ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								} ) ;  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2018-10-01 20:20:50 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								Grocy . DeleteProductPictureOnSave  =  false ;  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								$ ( '#delete-current-product-picture-button' ) . on ( 'click' ,  function  ( e )  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									Grocy . DeleteProductPictureOnSave  =  true ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									$ ( "#current-product-picture" ) . addClass ( "d-none" ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									$ ( "#delete-current-product-picture-on-save-hint" ) . removeClass ( "d-none" ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									$ ( "#delete-current-product-picture-button" ) . addClass ( "disabled" ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								} ) ;  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2018-10-20 14:55:49 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								if  ( Grocy . EditMode  ===  'create' )  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									if  ( Grocy . UserSettings . product _presets _location _id . toString ( )  !==  '-1' ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									{ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										$ ( "#location_id" ) . val ( Grocy . UserSettings . product _presets _location _id ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									if  ( Grocy . UserSettings . product _presets _product _group _id . toString ( )  !==  '-1' ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									{ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										$ ( "#product_group_id" ) . val ( Grocy . UserSettings . product _presets _product _group _id ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									if  ( Grocy . UserSettings . product _presets _qu _id . toString ( )  !==  '-1' ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									{ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										$ ( "select.input-group-qu" ) . val ( Grocy . UserSettings . product _presets _qu _id ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2019-04-22 22:16:35 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								Grocy . Components . UserfieldsForm . Load ( ) ;  
						 
					
						
							
								
									
										
										
										
											2018-04-16 19:11:32 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								$ ( '#name' ) . focus ( ) ;  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								$ ( '.input-group-qu' ) . trigger ( 'change' ) ;  
						 
					
						
							
								
									
										
										
										
											2018-07-11 19:43:05 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								Grocy . FrontendHelpers . ValidateForm ( 'product-form' ) ;  
						 
					
						
							
								
									
										
										
										
											2019-04-06 15:27:00 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								// Click twice to trigger on-click but not change the actual checked state
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								$ ( "#allow_partial_units_in_stock" ) . click ( ) ;  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								$ ( "#allow_partial_units_in_stock" ) . click ( ) ;