$(document).ready(function() {
$("#proforma_delete").click(function() {
var fp_id = $("#fp_id").val();
var fp_number_id = $("#fp_number_id").val();
$.ajax({
type: "POST", data: "fp_id=" + fp_id + "&fp_number_id=" + fp_number_id, url: "../ins/delete_proforma.php",
success: function(value){
$("#delete_proforma_info2").css("display", "block");
$("#delete_proforma_info1").css("display", "none");
}
});
return false;
});
});
$(document).ready(function() {
$("#fp_services_delete").click(function() {
var show_fpo_id = $("#show_fpo_id").val();
var place = $('#tabela input[name*="id_fpo_edit"][value="'+show_fpo_id+'"]');
$.ajax({
type: "POST", data: "show_fpo_id=" + show_fpo_id, url: "../ins/delete_fp_services.php",
success: function(value){
$("#delete_fp_services_info2").css("display", "block");
$("#delete_fp_services_info1").css("display", "none");
place.closest('tr').remove();
$('#tabela > tbody > tr').each(function(i) {
$(this).find('td:first-child').text(i+1);
i=i+1;
$(this).closest('tr').attr('id','wiersz-'+i);
});
}
});
return false;
});
});
$(document).ready(function() {
$( "#dialog_delete_fp_services" ).dialog({
autoOpen: false,
modal: true,
title: "Usuń pozycję",
resizable: false,
width: 550
});
$( "#dialog_delete_proforma" ).dialog({
autoOpen: false,
modal: true,
title: "Usuń Fakturę",
resizable: false,
width: 550
});
});
$(document).ready(function() {
$( "#dialog_delete_proforma_open" ).click(function() { $( "#dialog_delete_proforma" ).dialog( "open" ); });
$( ".dialog_delete_proforma_zamknij" ).click(function() { $( "#dialog_delete_proforma" ).dialog( "close" ); });
$( ".dialog_delete_proforma_zamknij2" ).click(function() {
window.location='../main/proforma.php';
$( "#dialog_delete_proforma" ).dialog( "close" );
});
$( ".dialog_delete_fp_services_open" ).click(function(){
var show_fpo_id = $(this).closest('tr').find('input[name*=id_fpo_edit]').val();
var show_fpo_name = $(this).closest('tr').find('input[name*=fpo_name]').val();
$("#show_fpo_id").val(show_fpo_id);
$(".show_fpo_name").html(show_fpo_name);
$("#delete_fp_services_info2").css("display", "none");
$("#delete_fp_services_info1").css("display", "block");
$( "#dialog_delete_fp_services" ).dialog( "open" );
});
$( ".dialog_delete_fp_services_zamknij" ).click(function() { $( "#dialog_delete_fp_services" ).dialog( "close" ); });
});
$(document).ready(function() {
$('#dodajWiersz_proforma').click(function() {
//policz ile jest wierszy w tabeli
var liczba = $('#tabela tr').length;
if (liczba === 2 && $('input[name="fpo_name[1]"]').val() === '') {
$('input[name="fpo_name[1]"]').closest('tr').remove();
liczba=1;
}
var f1 = '
| ';
var f2 = ' | ';
var f3 = ' | ';
var f4 = ' | ';
var f5 = ' | ';
var f6 = ' | ';
var f7 = ' | '+liczba+' | '+f1+f2+f3+f4+f5+f6+f7+'';
//dołącz nowy wiersz na końcu tabeli
$('#tabela').find('tbody').append(row);
$('tr.none').removeClass('none');
$(document).on('click', '.delete', function(){
if ($('#tabela tr').length > 2){
$(this).closest('tr').remove();
}
$('#tabela > tbody > tr').each(function(i) {
$(this).find('td:first-child').text(i+1);
i=i+1;
$(this).closest('tr').attr('id','wiersz-'+i);
$(this).find('input[name*=fpo_name]').attr('name','fpo_name['+i+']');
$(this).find('input[name*=fpo_pkwiu]').attr('name','fpo_pkwiu['+i+']');
$(this).find('input[name*=fpo_quantity]').attr('name','fpo_quantity['+i+']');
$(this).find('input[name*=fpo_unit]').attr('name','fpo_unit['+i+']');
$(this).find('input[name*=fpo_price]').attr('name','fpo_price['+i+']');
$(this).find('select[name*=fpo_vat]').attr('name','fpo_vat['+i+']');
});
});
});
});
$(document).on('click', '#przelicz_proforma_b', function(){
// blokowanie komórek
var integer = /^[0-9]/;
var fpo_price = $("#tabela input[name*=fpo_price]");
var fpo_quantity = $("#tabela input[name*=fpo_quantity]");
var fpo_name = $("#tabela input[name*=fpo_name]");
var fpo_unit = $("#tabela input[name*=fpo_unit]");
count=$("#tabela tr").length;
count=count-1;
for(i=0;i value){
fp_data_exposed.addClass("error_button");
data_up.css("display", "block");
data_up_show.html(" "+value)
wartosc = false;
}
}
});
$.ajax({
type: "POST", data: "fp_number_id=" + fp_number_id, async : false, url: "../ins/fp_data_down_val.php",
success: function(value){
if (fp_data_exposed.val() < value){
fp_data_exposed.addClass("error_button");
data_down.css("display", "block");
data_down_show.html(" "+value)
wartosc = false;
}
}
});
return wartosc;
});
});
$(document).ready(function() {
$(document).on('click', '.services_selected_proforma', function(){
search_name = $(this).closest('tr').find('#search_name').html();
search_pkwiu = $(this).closest('tr').find('#search_pkwiu').html();
search_quantity = $(this).closest('tr').find('#search_quantity').html();
search_unit = $(this).closest('tr').find('#search_unit').html();
search_price = $(this).closest('tr').find('#search_price').html();
search_vat = $(this).closest('tr').find('#search_vat').html();
//policz ile jest wierszy w tabeli
var liczba = $('#tabela tr').length;
if (liczba === 2 && $('input[name="fpo_name[1]"]').val() === '') {
$('input[name="fpo_name[1]"]').closest('tr').remove();
liczba=1;
}
var f1 = ' | ';
var f2 = ' | ';
var f3 = ' | ';
var f4 = ' | ';
var f5 = ' | ';
var f6 = ' | ';
var f7 = ' | '+liczba+' | '+f1+f2+f3+f4+f5+f6+f7+'';
//dołącz nowy wiersz na końcu tabeli
$('#tabela').find('tbody').append(row);
$('tr.none').removeClass('none');
$(document).on('click', '.delete', function(){
if ($('#tabela tr').length > 2){
$(this).closest('tr').remove();
}
$('#tabela > tbody > tr').each(function(i) {
$(this).find('td:first-child').text(i+1);
i=i+1;
$(this).closest('tr').attr('id','wiersz-'+i);
$(this).find('input[name*=fpo_name]').attr('name','fpo_name['+i+']');
$(this).find('input[name*=fpo_pkwiu]').attr('name','fpo_pkwiu['+i+']');
$(this).find('input[name*=fpo_quantity]').attr('name','fpo_quantity['+i+']');
$(this).find('input[name*=fpo_unit]').attr('name','fpo_unit['+i+']');
$(this).find('input[name*=fpo_price]').attr('name','fpo_price['+i+']');
$(this).find('select[name*=fpo_vat]').attr('name','fpo_vat['+i+']');
});
});
$( "#dialog_services_search" ).dialog( "close" );
});
});