<?php
/**********************************************************************
***********************************************************************/
include_once($path_to_root . "/includes/date_functions.inc");

//$pcs = "";

function get_salary_component_program_result(&$salary, $employee_code, $payroll_run_id, $salary_component, $payroll_days_factor, $table_source_value = null)
{    
//        get_salary_totals_array($payroll_run_id, $employee_code);
//        return format_salary_totals_result(true, 999, 'Test value');
        
        $process_code = $salary_component['process_code']; 
        
        switch ($process_code) {
            case "BROGHT_FORWRD_DEDUCT":
                $bfd_msg = get_BROGHT_FORWRD_DEDUCT_value($process_code, $payroll_run_id, $employee_code);
                return format_salary_totals_result($bfd_msg, '', true); 
                
            default:
                break;
        }
                

        $default = array('success' => true, 'calculated_value' => 0, 'full_value' => 0, 'message' => '');
        return format_salary_totals_result($default, '', true);  
    
}
function get_BROGHT_FORWRD_DEDUCT_value($process_code, $payroll_run_id, $employee_code){
    
        $payroll_run = get_payroll_run_details($payroll_run_id);
        $linked_payroll_run_id = $payroll_run['linked_payroll_run_id'];
        if($linked_payroll_run_id == 0){
            $BROGHT_FORWRD_DEDUCT = 0;
        
        }else{
             $calculated_salary_component = get_calculated_payroll_db_value($process_code, $employee_code, $payroll_run_id);  
             if(isset($calculated_salary_component['id']) && $calculated_salary_component['id'] > 0){
                $BROGHT_FORWRD_DEDUCT = $calculated_salary_component['value'];
             }else{
                $BROGHT_FORWRD_DEDUCT = 0;
             }
        }
            
        return array('success' => true, 
                'calculated_value' => $BROGHT_FORWRD_DEDUCT, 
                'full_value' => $BROGHT_FORWRD_DEDUCT,
                'message' => '');
}


//function format_salary_component_program_result($success = false, $message = 0, $comment = ''){
//    $r['success'] = $success;
//    $r['message'] = $message;
//    $r['comment'] = $comment;
//    
//    return $r;
//}

?>
