$(document).ready(function(){
 
    // Show Input element
    $('.edit').click(function(){
        $('.txtedit').hide();
        $(this).next('.txtedit').show().focus();
        $(this).hide();
    });

    // Save data
    $(".txtedit").on('focusout',function(){
        
        // Get edit id, field name and value
        var id = this.id;
        var split_id = id.split("_");
        var field_name = split_id[0];
        var edit_id = split_id[1];
        var value = $(this).val();
        
        // Hide Input element
        $(this).hide();

        // Hide and Change Text of the container with input elmeent
        $(this).prev('.edit').show();
        $(this).prev('.edit').text(value);

        // Sending AJAX request
        $.ajax({
            url: 'https://www.tiarabakery.com/cab1/modules/stokgudang/updatestokg.php',
            type: 'post',
            data: { field:field_name, value:value, id:edit_id },
            success:function(response){
                if(response == 1){ 
                    console.log('Save successfully'); 
                    
                }else{ 
                    console.log("Not saved."); 
                    
                }  
            }
        });
    
    });
	
	
	
	
	
	
	
	// Show Input element
    $('.edit2').click(function(){
        $('.txtedit2').hide();
        $(this).next('.txtedit2').show().focus();
        $(this).hide();
    });

    // Save data
    $(".txtedit2").on('focusout',function(){
        
        // Get edit id, field name and value
        var id = this.id;
        var split_id = id.split("_");
        var field_name = split_id[0];
        var edit_id = split_id[1];
        var value = $(this).val();
        
        // Hide Input element
        $(this).hide();

        // Hide and Change Text of the container with input elmeent
        $(this).prev('.edit2').show();
        $(this).prev('.edit2').text(value);

        // Sending AJAX request
        $.ajax({
            url: 'https://www.miausion.com/spring/modules/penjualan/updatepenjualan.php',
            type: 'post',
            data: { field:field_name, value:value, id:edit_id },
            success:function(response){
                if(response == 1){ 
                    console.log('Save successfully'); 
                    
                }else{ 
                    console.log("Not saved."); 
                    
                }  
            }
        });
    
    });
	
	
	
	
	
	
	
	// Show Input element
    $('.edit3').click(function(){
        $('.txtedit3').hide();
        $(this).next('.txtedit3').show().focus();
        $(this).hide();
    });

    // Save data
    $(".txtedit3").on('focusout',function(){
        
        // Get edit id, field name and value
        var id = this.id;
        var split_id = id.split("_");
        var field_name = split_id[0];
        var edit_id = split_id[1];
        var value = $(this).val();
        
        // Hide Input element
        $(this).hide();

        // Hide and Change Text of the container with input elmeent
        $(this).prev('.edit3').show();
        $(this).prev('.edit3').text(value);

        // Sending AJAX request
        $.ajax({
			
            url: 'https://www.miausion.com/spring/modules/penjualan/updatepenjualandetail.php',
            type: 'post',
            data: { field:field_name, value:value, id:edit_id },
            success:function(response){
                if(response == 1){ 
                    console.log('Save successfully'); 
                    
                }else{ 
                    console.log("Not saved."); 
                    
                }  
            }
        });
    
    });








	// Show Input element
    $('.edit4').click(function(){
        $('.txtedit4').hide();
        $(this).next('.txtedit4').show().focus();
        $(this).hide();
    });

    // Save data
    $(".txtedit4").on('focusout',function(){
        
        // Get edit id, field name and value
        var id = this.id;
        var split_id = id.split("_");
        var field_name = split_id[0];
        var edit_id = split_id[1];
        var value = $(this).val();
        
        // Hide Input element
        $(this).hide();

        // Hide and Change Text of the container with input elmeent
        $(this).prev('.edit4').show();
        $(this).prev('.edit4').text(value);

        // Sending AJAX request
        $.ajax({
            url: 'https://www.www.miausion.com/spring/modules/pembelian/updatepembelian.php',
            type: 'post',
            data: { field:field_name, value:value, id:edit_id },
            success:function(response){
                if(response == 1){ 
                    console.log('Save successfully'); 
                    
                }else{ 
                    console.log("Not saved."); 
                    
                }  
            }
        });
    
    });
	
	
	
	
	
	
	
	// Show Input element
    $('.edit5').click(function(){
        $('.txtedit5').hide();
        $(this).next('.txtedit5').show().focus();
        $(this).hide();
    });

    // Save data
    $(".txtedit5").on('focusout',function(){
        
        // Get edit id, field name and value
        var id = this.id;
        var split_id = id.split("_");
        var field_name = split_id[0];
        var edit_id = split_id[1];
        var value = $(this).val();
        
        // Hide Input element
        $(this).hide();

        // Hide and Change Text of the container with input elmeent
        $(this).prev('.edit5').show();
        $(this).prev('.edit5').text(value);

        // Sending AJAX request
        $.ajax({
            url: 'https://www.www.miausion.com/spring/modules/pembelian/updatepembeliandetail.php',
            type: 'post',
            data: { field:field_name, value:value, id:edit_id },
            success:function(response){
                if(response == 1){ 
                    console.log('Save successfully'); 
                    
                }else{ 
                    console.log("Not saved."); 
                    
                }  
            }
        });
    
    });
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	











	
	
	

});