diff --git a/application/views/addCostCenter.php b/application/views/addCostCenter.php index c50e50d8..f0b0631c 100755 --- a/application/views/addCostCenter.php +++ b/application/views/addCostCenter.php @@ -518,6 +518,9 @@ $("#Edit").on("shown.bs.modal", function(e) { $('#EditRemarks').val($('#BudgetTable tr:eq('+ userid +') td:eq(3)').text()); }); +var typeArray = []; +var typeflag = 0; +var iflag = 0; $('.tempClick').click(function(){ @@ -548,22 +551,45 @@ $("#Edit").on("shown.bs.modal", function(e) { var BudType = $("#Addbudget option:selected").val(); var BudYear = $("#AddYear").val(); var BudAmount = $("#AddAmout").val(); - $('#Addbudget option[value='+BudType+']').remove(); + //$('#Addbudget option[value='+BudType+']').remove(); var BudRemarks = $('#AddRemarks').val(); $('#AddYear').val(''); $('#AddAmout').val(''); $('#AddRemarks').val(''); - index = parseInt(index)+1; - - + var str = (BudType.concat(BudYear)); + //alert('outsideeachfunction'+str); + $.each(typeArray,function(i,item){ + + //alert('each'+item+'input'+BudType); + //alert('str'+str); + if(str == item) + { + iflag=iflag+1; + //alert('iflag'+iflag); + } - var template = jQuery("#tempList").html(); - + }); + //alert('i value'+iflag); + //alert('array'+typeArray); + if(iflag == 0) + { + typeArray.push(str); + typeflag = 1; + index = parseInt(index)+1; + + var template = jQuery("#tempList").html(); - $('#tempAppend').append(_.template(template,{index:temp,BudgetType:BudType,BudgetYear:BudYear,BudgetAmount:BudAmount,Remarks:BudRemarks})); - + $('#tempAppend').append(_.template(template,{index:temp,BudgetType:BudType,BudgetYear:BudYear,BudgetAmount:BudAmount,Remarks:BudRemarks})); + + } + else + { + alert(" Budget Type and Budget Year values Already Exsits in our database!"); + iflag = 0; + } + var theForm = $(".addCost"); diff --git a/application/views/editOldcost.php b/application/views/editOldcost.php index aafdddb4..33f8dc0d 100755 --- a/application/views/editOldcost.php +++ b/application/views/editOldcost.php @@ -686,6 +686,10 @@ $("#Edit").on("shown.bs.modal", function(e) { }); +var typeArray = []; +var typeflag = 0; +var iflag = 0; + $('.tempClick').click(function(){ @@ -715,13 +719,32 @@ $("#Edit").on("shown.bs.modal", function(e) { var BudType = $("#Addbudget option:selected").val(); var BudYear = $("#drpBudget option:selected").val(); var BudAmount = $("#AddAmout").val(); - $('#Addbudget option[value='+BudType+']').remove(); + //$('#Addbudget option[value='+BudType+']').remove(); var BudRemarks = $('#AddRemarks').val(); //$('#AddYear').val(''); $('#AddAmout').val(''); $('#AddRemarks').val(''); - + var str = (BudType.concat(BudYear)); + //alert('outsideeachfunction'+str); + $.each(typeArray,function(i,item){ + + //alert('each'+item+'input'+BudType); + //alert('str'+str); + if(str == item) + { + iflag=iflag+1; + //alert('iflag'+iflag); + } + + }); + //alert('i value'+iflag); + //alert('array'+typeArray); + if(iflag == 0) + { + typeArray.push(str); + typeflag = 1; + index = parseInt(index)+1; var temp = index; @@ -730,7 +753,13 @@ $("#Edit").on("shown.bs.modal", function(e) { $('#tempAppend').append(_.template(template,{index:temp,BudgetType:BudType,BudgetYear:BudYear,BudgetAmount:BudAmount,Remarks:BudRemarks})); - + } + else + { + alert(" Budget Type and Budget Year values Already Exsits in our database!"); + iflag = 0; + } + //alert($('#txtRowCount').val()); //var theForm = $(".addCost");