cost center issues fixed
This commit is contained in:
parent
8728e50265
commit
f856dc734a
@ -183,14 +183,16 @@ class CostCenter extends BaseController
|
|||||||
|
|
||||||
function GetBudgetForYear()
|
function GetBudgetForYear()
|
||||||
{
|
{
|
||||||
|
|
||||||
//$id = $this->input->post('id');
|
//$id = $this->input->post('id');
|
||||||
$BudYear = $_GET['BudYear'];
|
$BudYear = $_GET['BudYear'];
|
||||||
$CostCenterID = $_GET['CostCode'];
|
$CostCenterID = $_GET['CostCode'];
|
||||||
$result = $this->costcenter_model->GetCostCenterBudgetByYear($CostCenterID, $BudYear);
|
$result = $this->costcenter_model->GetCostCenterBudgetByYear($CostCenterID, $BudYear);
|
||||||
$BudList = $this->costcenter_model->GetCostBudgetTypeByYear($CostCenterID,'C004', $BudYear);
|
$BudList = $this->costcenter_model->GetCostBudgetTypeByYear($CostCenterID,'C004', $BudYear);
|
||||||
|
|
||||||
$HTML="";
|
$HTML="";
|
||||||
$HTML2="";
|
$HTML2="";
|
||||||
$index = 1;
|
$index = 0;
|
||||||
// $HTML2 = $BudList[0]['ConfigValue'];
|
// $HTML2 = $BudList[0]['ConfigValue'];
|
||||||
//if($BudList->num_rows() > 0){
|
//if($BudList->num_rows() > 0){
|
||||||
for ($j = 0; $j < count($BudList); $j++)
|
for ($j = 0; $j < count($BudList); $j++)
|
||||||
@ -201,6 +203,7 @@ class CostCenter extends BaseController
|
|||||||
|
|
||||||
for ($i = 0; $i < count($result); $i++)
|
for ($i = 0; $i < count($result); $i++)
|
||||||
{
|
{
|
||||||
|
$index = $index + 1;
|
||||||
$BudgetType = $result[$i]['BudgetType'];
|
$BudgetType = $result[$i]['BudgetType'];
|
||||||
$BudgetYear = $result[$i]['BudgetYear'];
|
$BudgetYear = $result[$i]['BudgetYear'];
|
||||||
$BudgetAmount = $result[$i]['BudgetAmount'];
|
$BudgetAmount = $result[$i]['BudgetAmount'];
|
||||||
@ -221,7 +224,7 @@ class CostCenter extends BaseController
|
|||||||
<a data-target='#Edit' data-id=".$index." data-userid=".$index." data-toggle='modal' href='#Edit'><i class='fa fa-pencil' data-toggle='tooltip' title='Click here to view/Edit the ".$BudgetType." Budget details'></i> </a> </td></tr>
|
<a data-target='#Edit' data-id=".$index." data-userid=".$index." data-toggle='modal' href='#Edit'><i class='fa fa-pencil' data-toggle='tooltip' title='Click here to view/Edit the ".$BudgetType." Budget details'></i> </a> </td></tr>
|
||||||
";
|
";
|
||||||
|
|
||||||
$index = $index + 1;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
$HTML.="<input type='hidden' name='txtRowCount' id='txtRowCount' value='".$index ."'/>";
|
$HTML.="<input type='hidden' name='txtRowCount' id='txtRowCount' value='".$index ."'/>";
|
||||||
@ -293,20 +296,25 @@ class CostCenter extends BaseController
|
|||||||
}
|
}
|
||||||
|
|
||||||
$RowCount = $this->input->post('txtRowCount');
|
$RowCount = $this->input->post('txtRowCount');
|
||||||
//$BudgetType = $this->input->post('BudgetType2');
|
|
||||||
//echo $BudgetType;
|
|
||||||
for ($i = 1; $i <= $RowCount; $i++)
|
for ($i = 1; $i <= $RowCount; $i++)
|
||||||
{
|
{
|
||||||
$BudgetType = $this->input->post('BudgetType'.$i);
|
$BudgetType = $this->input->post('BudgetType'.$i);
|
||||||
$BudgetYear = $this->input->post('BudgetYear'.$i);
|
$BudgetYear = $this->input->post('BudgetYear'.$i);
|
||||||
$BudgetAmount = $this->input->post('BudgetAmount'.$i);
|
$BudgetAmount = $this->input->post('BudgetAmount'.$i);
|
||||||
$Remarks = $this->input->post('Remarks'.$i);
|
$Remarks = $this->input->post('Remarks'.$i);
|
||||||
$this->costcenter_model->DeleteBudget( $BudgetType,$BudgetYear,$CostCode);
|
// $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);
|
$Budget = array('CostCenterCode'=>$CostCode, 'BudgetType'=>$BudgetType,'BudgetYear'=>$BudgetYear,'BudgetAmount'=>$BudgetAmount,'Remarks'=>$Remarks,'CreatedBy'=>$updatedBy,'createdDate'=>$updateddt,'UpdatedBy'=>$updatedBy,'UpdatedDate'=>$updateddt);
|
||||||
//print_r($Budget);
|
$ExistYearBudget = $this->costcenter_model->CheckExistBudget($BudgetType,$BudgetYear,$CostCode);
|
||||||
|
if($ExistYearBudget){
|
||||||
|
$this->costcenter_model->updateBudget($Budget,$BudgetType,$BudgetYear,$CostCode);
|
||||||
|
}
|
||||||
|
else{
|
||||||
$this->costcenter_model->addBudget($Budget);
|
$this->costcenter_model->addBudget($Budget);
|
||||||
//print_r( $BudgetType );
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
echo('Successfully Updated Cost details');
|
echo('Successfully Updated Cost details');
|
||||||
|
|||||||
@ -356,5 +356,33 @@ function addNewcost($Cost)
|
|||||||
return $this->db->get('T_CostCenter_Master as bud')->result_array();
|
return $this->db->get('T_CostCenter_Master as bud')->result_array();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
//get exist budget year details
|
||||||
|
function CheckExistBudget($BudgetType,$BudgetYear,$CostCode){
|
||||||
|
$this->db->select('CostCenterCode');
|
||||||
|
$this->db->from('T_CostCenter_Budget');
|
||||||
|
$this->db->where('CostCenterCode',$CostCode);
|
||||||
|
$this->db->where('BudgetType',$BudgetType);
|
||||||
|
$this->db->where('BudgetYear',$BudgetYear);
|
||||||
|
|
||||||
|
$query = $this->db->get();
|
||||||
|
|
||||||
|
if ($query->num_rows > 0) {
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//update budget
|
||||||
|
function updateBudget($Budget,$BudgetType,$BudgetYear,$CostCode)
|
||||||
|
{
|
||||||
|
$this->db->where('CostCenterCode',$CostCode);
|
||||||
|
$this->db->where('BudgetType',$BudgetType);
|
||||||
|
$this->db->where('BudgetYear',$BudgetYear);
|
||||||
|
|
||||||
|
$this->db->update('T_CostCenter_Budget', $Budget);
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
@ -94,8 +94,11 @@ $(function() {
|
|||||||
|
|
||||||
$('#drpBudget').change(function() {
|
$('#drpBudget').change(function() {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
var id = $('#drpBudget').val();
|
var id = $('#drpBudget').val();
|
||||||
var code = $('#CostCode').val();
|
var code = $('#CostCode').val();
|
||||||
|
|
||||||
if(id != '-1')
|
if(id != '-1')
|
||||||
{
|
{
|
||||||
$('#content').loader('show');
|
$('#content').loader('show');
|
||||||
@ -106,8 +109,9 @@ $(function() {
|
|||||||
type:"POST",
|
type:"POST",
|
||||||
url:"<?php echo base_url();?>CostCenter/GetBudgetForYear?BudYear="+id+"&CostCode="+code,
|
url:"<?php echo base_url();?>CostCenter/GetBudgetForYear?BudYear="+id+"&CostCode="+code,
|
||||||
success:function(json) {
|
success:function(json) {
|
||||||
|
|
||||||
//alert('success');
|
//alert('success');
|
||||||
//alert(json);
|
//alert(JSON.stringify(json));
|
||||||
//alert(json.BudYear);
|
//alert(json.BudYear);
|
||||||
$("#tempAppend").empty();
|
$("#tempAppend").empty();
|
||||||
$('#tempAppend').append(json.Html);
|
$('#tempAppend').append(json.Html);
|
||||||
@ -116,6 +120,8 @@ $(function() {
|
|||||||
//$("#Addbudget").append(json.BudYear);
|
//$("#Addbudget").append(json.BudYear);
|
||||||
$('#content').loader('hide');
|
$('#content').loader('hide');
|
||||||
//$("#Employee").append(result);
|
//$("#Employee").append(result);
|
||||||
|
index = $('#txtRowCount').val();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
@ -181,7 +187,7 @@ $(function() {
|
|||||||
|
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<?php
|
<?php
|
||||||
$data = array('name' => 'CostCode','value' => set_value( 'CostCode',$CostCenterCode ),'id'=>'c', 'class' => 'form-control' ,'readonly' => 'true' );
|
$data = array('name' => 'CostCode','value' => set_value( 'CostCode',$CostCenterCode ),'id'=>'CostCode', 'class' => 'form-control' ,'readonly' => 'true' );
|
||||||
echo form_input($data);
|
echo form_input($data);
|
||||||
?>
|
?>
|
||||||
</div>
|
</div>
|
||||||
@ -380,7 +386,8 @@ $(function() {
|
|||||||
</div>
|
</div>
|
||||||
<div class="col-md-5">
|
<div class="col-md-5">
|
||||||
|
|
||||||
<?php echo form_dropdown('AddYear', $optYear,set_value('AddYear'),'id="AddYear"' ,'class="form-control required"','required="true"'); ?>
|
<input name="AddYear" class="form-control required" id="AddYear" type="text" ,'required="true"'>
|
||||||
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -439,6 +446,7 @@ $(function() {
|
|||||||
$index = 0;
|
$index = 0;
|
||||||
if(!empty($CostBudget))
|
if(!empty($CostBudget))
|
||||||
{
|
{
|
||||||
|
|
||||||
foreach($CostBudget as $record)
|
foreach($CostBudget as $record)
|
||||||
{
|
{
|
||||||
$index =$index + 1;
|
$index =$index + 1;
|
||||||
@ -516,10 +524,13 @@ $(function() {
|
|||||||
Budget Year :
|
Budget Year :
|
||||||
</div>
|
</div>
|
||||||
<div class="col-md-5">
|
<div class="col-md-5">
|
||||||
<?php
|
|
||||||
$data = array('name' => 'EditYear', 'value' => set_value('EditYear'),'id'=>'EditYear', 'class' => 'form-control','onkeypress'=>'return isNumberKey(event);','onkeypress'=>'return false;');
|
<input name="EditYear" class="form-control required" id="EditYear" type="text" ,'required="true"'>
|
||||||
|
|
||||||
|
<!-- <?php
|
||||||
|
$data = array('name' => '', 'value' => set_value(''),'id'=>'EditYear', 'class' => 'form-control',);
|
||||||
echo form_input($data);
|
echo form_input($data);
|
||||||
?>
|
?> -->
|
||||||
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
@ -639,6 +650,7 @@ var numbers = /^[0-9]+$/;
|
|||||||
var userid = '';
|
var userid = '';
|
||||||
|
|
||||||
$("#Edit").on("shown.bs.modal", function(e) {
|
$("#Edit").on("shown.bs.modal", function(e) {
|
||||||
|
|
||||||
userid = $(e.relatedTarget).data('userid');
|
userid = $(e.relatedTarget).data('userid');
|
||||||
|
|
||||||
$('#Editbudget').val($('#BudgetTable tr:eq('+ userid +') td:eq(0)').text());
|
$('#Editbudget').val($('#BudgetTable tr:eq('+ userid +') td:eq(0)').text());
|
||||||
@ -656,6 +668,7 @@ $("#Edit").on("shown.bs.modal", function(e) {
|
|||||||
|
|
||||||
$('.tempClick').click(function(){
|
$('.tempClick').click(function(){
|
||||||
|
|
||||||
|
|
||||||
if ($("#Addbudget option:selected").val() =='-1' )
|
if ($("#Addbudget option:selected").val() =='-1' )
|
||||||
{
|
{
|
||||||
alert('Please Select the Budget Type ');
|
alert('Please Select the Budget Type ');
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user