<?php

function all_borrowings_graph_display(&$pg0, $from_month_id, $to_month_id)
{
    all_borrowings_graph_set_values($pg0, $from_month_id, $to_month_id);

    $random_id = 'abg_'.$from_month_id."_".$to_month_id."_".time();
    
    $pg0->axis_value_names_angle = -30;
    
    $data = array();
    $data['title'] = "Active Loans & LCs";
    $data['x_axis_name'] = "Month";
    $data['y_axis_name'] = "Value";
    $data['graph1_name'] = "New Loans";
    $data['graph2_name'] = "LCs";
    $data['graph3_name'] = "";

    
    
    //echo "<a href='".$path_to_root."/admin/dashboard_uda_level_1.php?month_id=".$month_id."&division_code=UDA_0001&level=".$level."'>";
    display_graph($pg0, $data, 1, $random_id);//line graph = 4
//    source_graphic($today, $title, , $pg0, "Target", _("Achievement"), 1, $random_id, "Trend");
    //echo "</a>";
}

function all_borrowings_graph_set_values(&$pg0, $from_month_id, $to_month_id) 
{
    $title = "";

        $result = get_months_range($from_month_id, $to_month_id);
        $i = 0;
        $early_loans_value = 0;
        while ($myrow = db_fetch($result)) {

            $name = $myrow["description"];
            if ($pg0 != null) {
                $pg0->x[$i] = $name;

//                $loans = get_month_loans_total($myrow['id']);
//                    if($loans == 0){
//                        $loans = $early_loans_value;
//                    }else{
//                        $early_loans_value = $loans;
//                    }
 
                $new_loans = get_month_new_loans_total($myrow['id'], $myrow['month_begin_date'], $myrow['month_end_date']);
                $new_lcs = get_month_new_lcs_total($myrow['id'], $myrow['month_begin_date'], $myrow['month_end_date']);
//                $closed_loans = get_month_closed_loans_total($myrow['id'], $myrow['month_begin_date'], $myrow['month_end_date']);
//                $interest = get_month_interest_total($myrow['id']);       

                $pg0->y[$i] = $new_loans;
                $pg0->z[$i] = $new_lcs;
//                $pg0->z1[$i] = $closed_loans;
//                $pg0->y[$i] = $myrow['target'];
//                $pg0->z1[$i] = $pg0->z[$i]; // for trend calculation
                $pg0->colour_type[$i] = set_bar_colour_type($new_loans);
                
                
//                $pg0->y[$i] = $myrow['achievement'];
//                $pg0->z[$i] = $myrow['target'];
//                $pg0->z1[$i] = $myrow['target'];
//                $pg0->colour_type[$i] = set_bar_colour_type($myrow['achievement']);
            }
            
            
            $i++;
            
//            if($i == 1 && $myrow['achievement'] == null){
//                $title = "No data for ".$myrow['division_name'];
//            }
//            else{
//                $title = $myrow['division_name'];
//            }
        }

        return $title;

}





?>












































































































































































































































































