diff --git a/application/controllers/CostCenter.php b/application/controllers/CostCenter.php index 0d891262..d449fd58 100755 --- a/application/controllers/CostCenter.php +++ b/application/controllers/CostCenter.php @@ -280,14 +280,14 @@ class CostCenter extends BaseController for ($j = 0; $j < count($comma_separated); $j++) { - $DeptCode = $comma_separated[$j]; + // $DeptCode = $comma_separated[$j]; - $this->costcenter_model->DeleteDepartment( $DeptCode,$CostCode); + // $this->costcenter_model->DeleteDepartment( $DeptCode,$CostCode); - $Dept = array('CostCenterCode'=>$CostCode, 'DEPCode'=>$DeptCode,'CreatedBy'=>$updatedBy,'createdDate'=>$updateddt,'UpdatedBy'=>$updatedBy,'UpdatedDate'=>$updateddt); + //$Dept = array('CostCenterCode'=>$CostCode, 'DEPCode'=>$DeptCode,'CreatedBy'=>$updatedBy,'createdDate'=>$updateddt,'UpdatedBy'=>$updatedBy,'UpdatedDate'=>$updateddt); //print_r($Dept); - $this->costcenter_model->addCostCenterDepartment($Dept); + //$this->costcenter_model->addCostCenterDepartment($Dept); } } @@ -304,6 +304,7 @@ class CostCenter extends BaseController $this->costcenter_model->DeleteBudget( $BudgetType,$BudgetYear,$CostCode); $Budget = array('CostCenterCode'=>$CostCode, 'BudgetType'=>$BudgetType,'BudgetYear'=>$BudgetYear,'BudgetAmount'=>$BudgetAmount,'Remarks'=>$Remarks,'CreatedBy'=>$updatedBy,'createdDate'=>$updateddt,'UpdatedBy'=>$updatedBy,'UpdatedDate'=>$updateddt); + //print_r($Budget); $this->costcenter_model->addBudget($Budget); //print_r( $BudgetType ); } @@ -328,6 +329,22 @@ class CostCenter extends BaseController } + function AddCostDepartment() + { + $CostCode = strtoupper(trim($this->input->post('CostCode'))); + $CostName = strtoupper(trim($this->input->post('CostName'))); + $updatedBy = $this->session->userdata ( 'userId' ); + $SelectedDepartment = $this->input->post('txtSelectedDepartment'); + // $updatedBy = $this->session->userdata ( 'userId' ); + $dt = new DateTime('now', new DateTimeZone('Asia/Kolkata')); + $updateddt = $dt->format('Y-m-d H:i:s'); + + $Dept = array('CostCenterCode'=>$CostCode, 'DEPCode'=>$SelectedDepartment,'CreatedBy'=>$updatedBy,'createdDate'=>$updateddt,'UpdatedBy'=>$updatedBy,'UpdatedDate'=>$updateddt); + $this->costcenter_model->addCostCenterDepartment($Dept); + echo ("Department Added Successfully"); + } + + // function AddCostDepartment() // { // // echo "343"; diff --git a/application/views/editOldcost.php b/application/views/editOldcost.php index 7c9a7958..79f0ed29 100755 --- a/application/views/editOldcost.php +++ b/application/views/editOldcost.php @@ -11,15 +11,18 @@ $FYEnd =''; $FYear = ''; //print_r($opt); -$Budget=''; +$a=0; -foreach ($CostBudget as $BUD) -{ - $Budget=$BUD->BudgetType; + +$BudgetTypeAdd=[]; +foreach ($CostBudget as $record) +{ + $a=+1; + $BudgetTypeAdd[$a]=$record->BudgetType; + //print_r($BudgetTypeAdd); } -//echo $Budget; - +//print_r($BudgetTypeAdd); if(!empty($CostMaster)) { @@ -297,8 +300,13 @@ $(function() {
- -   Add Budget + + + +   Add Budget + + +
@@ -333,19 +341,27 @@ $(function() { $Budget = array("-1"=>'Select Budget Type'); //print_r( $options); - + $i=0; if(!empty($BudType)) { - + //print_r($BudgetTypeAdd); + //print_r($BudType); foreach ($BudType as $SID): - //print_r($Budget); - if($SID->ConfigValue!=$Budget) + + foreach ($BudgetTypeAdd as $BUD) + { + + + if($SID->ConfigValue!=$BUD) { + //print_r($BUD); $Budget[$SID->ConfigValue] = $SID->ConfigValue; } + } endforeach; + $i=+1; } @@ -426,6 +442,9 @@ $(function() { foreach($CostBudget as $record) { $index =$index + 1; + // $BudgetTypeAdd=[]; + // $BudgetTypeAdd[$index]=$record->BudgetType; + // print_r($BudgetTypeAdd); ?> @@ -688,7 +707,12 @@ $("#Edit").on("shown.bs.modal", function(e) { // addHidden(theForm,"BudgetAmount"+temp,BudAmount); //addHidden(theForm,"Remarks"+temp,BudRemarks); - $('#txtRowCount').val(temp); + $('#txtRowCount').val(temp); + + CountRows(); + + // var a= CountRowsbutton(); + // alert(a); } @@ -777,7 +801,7 @@ $('.tempClickEdit').click(function(){ var o = new Option(tempText,tempSelect); var hidval = tempSelect; var orgVal = $('#txtSelectedDepartment').val(); - alert(orgVal); + //alert(orgVal); var Selectedval = '' if(orgVal != '') @@ -797,6 +821,31 @@ $('.tempClickEdit').click(function(){ $('#distriList option:selected').remove(); $("#distriList").attr('selectedIndex', '-1').find("option:selected").removeAttr("selected"); $("#selectDistriList").attr('selectedIndex', '-1').find("option:selected").removeAttr("selected"); + + + if(validate()) + { + $('#content').loader('show'); + $.ajax({ + data:$('.EditCost').serialize(), + type:"POST", + url:"CostCenter/AddCostDepartment", + success:function(data) { + if(data) + { + $('#content').loader('hide'); + alert(data); + $('#txtSelectedDepartment').val(''); + $('#txtRowCount').val(''); + + //window.location = baseurl + 'CostCenter/CostListing'; + } + + } + }); + //$('#content').loader('hide'); + } + tempSelect = ''; tempText = ''; @@ -892,6 +941,57 @@ $('.tempClickEdit').click(function(){ }); + + var totalRowCount = 0; + var rowCount = 0; + var table = document.getElementById("BudgetTable"); + var rows = table.getElementsByTagName("tr"); + //console.log(rows.length); + + +if(rows.length>=5) +{ + + $('#ButtonAdd').hide(); + +} +else +{ + $('#ButtonAdd').show(); +} + +function CountRows() +{ + + totalRowCount = 0; + rowCount = 0; + table = document.getElementById("BudgetTable"); + rows = table.getElementsByTagName("tr") + for (var i = 0; i < rows.length; i++) { + totalRowCount++; + if (rows[i].getElementsByTagName("td").length > 0) { + rowCount++; + } + } + + + var message = "Total Row Count: " + totalRowCount; + message += "\nRow Count: " + rowCount; + //alert(message); + if(totalRowCount>"4") + { + $("#addbudgetmodel").modal('hide'); + } + else + { + return false; + } + + } + + + + function validate() { /* if($("#txtSelectedDepartment").val().length < 1)