diff --git a/application/controllers/CostCenter.php b/application/controllers/CostCenter.php index b67f906f..0d891262 100755 --- a/application/controllers/CostCenter.php +++ b/application/controllers/CostCenter.php @@ -234,7 +234,7 @@ class CostCenter extends BaseController */ function editcost() { - + $this->form_validation->set_rules('CostCode','CostCode','trim|required'); $this->form_validation->set_rules('CostName','CostName','trim|required'); @@ -249,16 +249,18 @@ class CostCenter extends BaseController $updatedBy = $this->session->userdata ( 'userId' ); $SelectedDepartment = $this->input->post('txtSelectedDepartment'); //echo $SelectedDepartment; + //die(); $ApproverName = $this->input->post('ApprovedBy'); $comma_separated = ""; //print_r(strlen($SelectedDepartment)); if(strlen($SelectedDepartment)>0) { + $comma_separated = explode(':', $SelectedDepartment); } - //print_r($comma_separated); + //die(); //echo count($comma_separated); $dt = new DateTime('now', new DateTimeZone('Asia/Kolkata')); @@ -271,13 +273,11 @@ class CostCenter extends BaseController $Cost = array( 'CostCenterName'=>$CostName,'ApprovedBy'=>$ApproverName,'UpdatedBy'=>$updatedBy,'UpdatedDate'=>$updateddt); $this->costcenter_model->EditCost($Cost,$CostCode); } - //echo count($comma_separated); - - if(count($comma_separated)> 0) + + if(count($comma_separated)>= 1) { - - //echo "scs"; - //die(); + + for ($j = 0; $j < count($comma_separated); $j++) { $DeptCode = $comma_separated[$j]; @@ -313,6 +313,72 @@ class CostCenter extends BaseController } } + + + function DeleteCostDepartment() + { + // echo "dasf"; + // die(); + $CostCode = strtoupper(trim($this->input->post('CostCode'))); + $CostName = strtoupper(trim($this->input->post('CostName'))); + $updatedBy = $this->session->userdata ( 'userId' ); + $SelectedDepartment = $this->input->post('txtSelectedDepartment'); + $this->costcenter_model->DeleteDepartment($SelectedDepartment,$CostCode); + echo ("Department Removed Successfully"); + } + + + // function AddCostDepartment() + // { + // // echo "343"; + // // die(); + // $CostCode = strtoupper(trim($this->input->post('CostCode'))); + // $CostName = strtoupper(trim($this->input->post('CostName'))); + // $updatedBy = $this->session->userdata ( 'userId' ); + // $SelectedDepartment = $this->input->post('txtSelectedDepartment'); + // //echo $SelectedDepartment; + // //die(); + + // $ApproverName = $this->input->post('ApprovedBy'); + // $comma_separated = ""; + // //print_r(strlen($SelectedDepartment)); + // if(strlen($SelectedDepartment)>0) + // { + + // $comma_separated = explode(':', $SelectedDepartment); + // } + + // //die(); + // //echo count($comma_separated); + // $dt = new DateTime('now', new DateTimeZone('Asia/Kolkata')); + + // $updateddt = $dt->format('Y-m-d H:i:s'); + + + // if(count($comma_separated)>= 1) + // { + + + // for ($j = 0; $j < count($comma_separated); $j++) + // { + // $DeptCode = $comma_separated[$j]; + + // $this->costcenter_model->DeleteDepartment( $DeptCode,$CostCode); + + // $Dept = array('CostCenterCode'=>$CostCode, 'DEPCode'=>$DeptCode,'CreatedBy'=>$updatedBy,'createdDate'=>$updateddt,'UpdatedBy'=>$updatedBy,'UpdatedDate'=>$updateddt); + + // //print_r($Dept); + // $this->costcenter_model->addCostCenterDepartment($Dept); + + // } + // echo "Updated"; + // } + + + + // } + + function viewcost($CostCenterID = NULL) { diff --git a/application/models/costcenter_model.php b/application/models/costcenter_model.php index 97a7e293..e54f44ab 100755 --- a/application/models/costcenter_model.php +++ b/application/models/costcenter_model.php @@ -270,6 +270,9 @@ function addNewcost($Cost) function DeleteDepartment($DepCode='',$CostCode='') { + + // echo "fsds"; + // die(); $this->db->where("DEPCode", $DepCode); $this->db->where("CostCenterCode", $CostCode); $this->db->delete('T_CostCenter_Departments'); diff --git a/application/views/editOldcost.php b/application/views/editOldcost.php index 27e3ed8b..32d41e53 100755 --- a/application/views/editOldcost.php +++ b/application/views/editOldcost.php @@ -761,6 +761,7 @@ $('.tempClickEdit').click(function(){ var o = new Option(tempText,tempSelect); var hidval = tempSelect; var orgVal = $('#txtSelectedDepartment').val(); + alert(orgVal); var Selectedval = '' if(orgVal != '') @@ -784,7 +785,14 @@ $('.tempClickEdit').click(function(){ tempSelect = ''; tempText = ''; Selectedval = ''; - } else { + + + + + + } + + else { alert("Before add please select any position."); } }); @@ -797,8 +805,42 @@ $('.tempClickEdit').click(function(){ $("#distriList").attr('selectedIndex', '-1').find("option:selected").removeAttr("selected"); $("#distriList").val(tempSelect); + $('#txtSelectedDepartment').val(tempSelect); tempSelect = ''; - } else { + + + + if(validate()) + { + $('#content').loader('show'); + $.ajax({ + data:$('.EditCost').serialize(), + type:"POST", + url:"CostCenter/DeleteCostDepartment", + success:function(data) { + if(data) + { + $('#content').loader('hide'); + alert(data); + $('#txtSelectedDepartment').val(''); + $('#txtRowCount').val(''); + + //window.location = baseurl + 'CostCenter/CostListing'; + } + + } + }); + //$('#content').loader('hide'); + } + + + + + + } + + else + { alert("Before remove please select any position."); } });