cost center issues fixed
This commit is contained in:
parent
8728e50265
commit
f856dc734a
@ -183,14 +183,16 @@ class CostCenter extends BaseController
|
||||
|
||||
function GetBudgetForYear()
|
||||
{
|
||||
|
||||
//$id = $this->input->post('id');
|
||||
$BudYear = $_GET['BudYear'];
|
||||
$CostCenterID = $_GET['CostCode'];
|
||||
$result = $this->costcenter_model->GetCostCenterBudgetByYear($CostCenterID, $BudYear);
|
||||
$BudList = $this->costcenter_model->GetCostBudgetTypeByYear($CostCenterID,'C004', $BudYear);
|
||||
|
||||
$HTML="";
|
||||
$HTML2="";
|
||||
$index = 1;
|
||||
$index = 0;
|
||||
// $HTML2 = $BudList[0]['ConfigValue'];
|
||||
//if($BudList->num_rows() > 0){
|
||||
for ($j = 0; $j < count($BudList); $j++)
|
||||
@ -201,6 +203,7 @@ class CostCenter extends BaseController
|
||||
|
||||
for ($i = 0; $i < count($result); $i++)
|
||||
{
|
||||
$index = $index + 1;
|
||||
$BudgetType = $result[$i]['BudgetType'];
|
||||
$BudgetYear = $result[$i]['BudgetYear'];
|
||||
$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>
|
||||
";
|
||||
|
||||
$index = $index + 1;
|
||||
|
||||
|
||||
}
|
||||
$HTML.="<input type='hidden' name='txtRowCount' id='txtRowCount' value='".$index ."'/>";
|
||||
@ -293,20 +296,25 @@ class CostCenter extends BaseController
|
||||
}
|
||||
|
||||
$RowCount = $this->input->post('txtRowCount');
|
||||
//$BudgetType = $this->input->post('BudgetType2');
|
||||
//echo $BudgetType;
|
||||
|
||||
for ($i = 1; $i <= $RowCount; $i++)
|
||||
{
|
||||
$BudgetType = $this->input->post('BudgetType'.$i);
|
||||
$BudgetYear = $this->input->post('BudgetYear'.$i);
|
||||
$BudgetAmount = $this->input->post('BudgetAmount'.$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);
|
||||
//print_r($Budget);
|
||||
$this->costcenter_model->addBudget($Budget);
|
||||
//print_r( $BudgetType );
|
||||
$ExistYearBudget = $this->costcenter_model->CheckExistBudget($BudgetType,$BudgetYear,$CostCode);
|
||||
if($ExistYearBudget){
|
||||
$this->costcenter_model->updateBudget($Budget,$BudgetType,$BudgetYear,$CostCode);
|
||||
}
|
||||
else{
|
||||
$this->costcenter_model->addBudget($Budget);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
echo('Successfully Updated Cost details');
|
||||
|
||||
@ -356,5 +356,33 @@ function addNewcost($Cost)
|
||||
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;
|
||||
}
|
||||
}
|
||||
?>
|
||||
@ -93,9 +93,12 @@ $(function() {
|
||||
//});
|
||||
|
||||
$('#drpBudget').change(function() {
|
||||
|
||||
|
||||
|
||||
|
||||
var id = $('#drpBudget').val();
|
||||
var code = $('#CostCode').val();
|
||||
|
||||
if(id != '-1')
|
||||
{
|
||||
$('#content').loader('show');
|
||||
@ -106,8 +109,9 @@ $(function() {
|
||||
type:"POST",
|
||||
url:"<?php echo base_url();?>CostCenter/GetBudgetForYear?BudYear="+id+"&CostCode="+code,
|
||||
success:function(json) {
|
||||
|
||||
//alert('success');
|
||||
//alert(json);
|
||||
//alert(JSON.stringify(json));
|
||||
//alert(json.BudYear);
|
||||
$("#tempAppend").empty();
|
||||
$('#tempAppend').append(json.Html);
|
||||
@ -115,7 +119,9 @@ $(function() {
|
||||
$("#Addbudget").append(json.BudYear);
|
||||
//$("#Addbudget").append(json.BudYear);
|
||||
$('#content').loader('hide');
|
||||
//$("#Employee").append(result);
|
||||
//$("#Employee").append(result);
|
||||
index = $('#txtRowCount').val();
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
@ -181,7 +187,7 @@ $(function() {
|
||||
|
||||
<div class="form-group">
|
||||
<?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);
|
||||
?>
|
||||
</div>
|
||||
@ -380,7 +386,8 @@ $(function() {
|
||||
</div>
|
||||
<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>
|
||||
@ -439,6 +446,7 @@ $(function() {
|
||||
$index = 0;
|
||||
if(!empty($CostBudget))
|
||||
{
|
||||
|
||||
foreach($CostBudget as $record)
|
||||
{
|
||||
$index =$index + 1;
|
||||
@ -460,7 +468,7 @@ $(function() {
|
||||
|
||||
<td align="left"><?php echo $record->Remarks ?></td>
|
||||
<td>
|
||||
<a data-target='#Edit' data-id="<?php echo $index ?>" data-userid="<?php echo $index ?>" data-toggle="modal" href="#Edit"><i class="fa fa-pencil" data-toggle="tooltip" title="Click here to view/Edit the <?php echo $record->BudgetType ?> Budget details"></i> </a>
|
||||
<a data-target='#Edit' data-id="<?php echo $index ?>" data-userid="<?php echo $index ?>" data-toggle="modal" href="#Edit"><i class="fa fa-pencil" data-toggle="tooltip" title="Click here to view/Edit the <?php echo $record->BudgetType ?> Budget details"></i> </a>
|
||||
|
||||
|
||||
</td>
|
||||
@ -516,10 +524,13 @@ $(function() {
|
||||
Budget Year :
|
||||
</div>
|
||||
<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);
|
||||
?>
|
||||
?> -->
|
||||
|
||||
|
||||
</div>
|
||||
@ -639,6 +650,7 @@ var numbers = /^[0-9]+$/;
|
||||
var userid = '';
|
||||
|
||||
$("#Edit").on("shown.bs.modal", function(e) {
|
||||
|
||||
userid = $(e.relatedTarget).data('userid');
|
||||
|
||||
$('#Editbudget').val($('#BudgetTable tr:eq('+ userid +') td:eq(0)').text());
|
||||
@ -655,6 +667,7 @@ $("#Edit").on("shown.bs.modal", function(e) {
|
||||
});
|
||||
|
||||
$('.tempClick').click(function(){
|
||||
|
||||
|
||||
if ($("#Addbudget option:selected").val() =='-1' )
|
||||
{
|
||||
|
||||
Loading…
Reference in New Issue
Block a user