public function getRegionCoverage($vaccine) {
		$months_of_stock = array();
		$region = $this -> session -> userdata('district_province_id'); 
		$year = date('Y');
		$now = date('U');
		$to = date("U", mktime(0, 0, 0, 1, 1, date("Y") + 1));
		$from = date("U", mktime(0, 0, 0, 1, 1, date('Y')));
		//Get National Data
		$population = regional_populations::getRegionalPopulation($region,$year);
		$population = str_replace(",", "", $population);
		$vaccine_object = Vaccines::getVaccine($vaccine);
		$yearly_requirement = ceil(($vaccine_object -> Doses_Required * $population * $vaccine_object -> Wastage_Factor));
		$stock_receipts =	Disbursements::getRegionalReceiptsTotals($region,$vaccine, $from, $to); 
		$percentage_coverage = ceil(($stock_receipts/$yearly_requirement)*100); 
		$chart = '
<chart caption="Estimated Coverage" palette="4" numberSuffix="%" decimals="0" enableSmartLabels="1" enableRotation="0"   bgAlpha="40,100" bgRatio="0,100" bgAngle="360" showBorder="0" startingAngle="70">
<set label="Covered" value="' . $percentage_coverage . '" isSliced="1"/>
<set label="Pending" value="' . (100-$percentage_coverage) . '"/>

</chart>';   
		echo $chart;
	}
Beispiel #2
0
public function get($type,$id,$vaccine)
{
$monthly_opening_stocks = array();
$year = date('Y');
$year_start = date("U", mktime(0, 0, 0, 1, 1, date('Y')));
$vaccine_object = Vaccines::getVaccine($vaccine); 

if($type == 0){
//Regional Store
$population = regional_populations::getRegionalPopulation($id,$year);
for($month = 1; $month<=12; $month++){
$to = date("U", mktime(0, 0, 0, $month, 1, date('Y')));
$monthly_opening_stocks[$month] = Disbursements::getRegionalReceiptsTotals($id, $vaccine,$year_start,$to);
}
}
else if($type == 1){
//District Store
$population = district_populations::getDistrictPopulation($id,$year);
for($month = 1; $month<=12; $month++){
$to = date("U", mktime(0, 0, 0, $month, 1, date('Y')));
$monthly_opening_stocks[$month] = Disbursements::getDistrictReceiptsTotals($id, $vaccine,$year_start,$to); 
}
} 
$population = str_replace(",","",$population);
$monthly_requirement =  ceil(($vaccine_object->Doses_Required*$population*$vaccine_object->Wastage_Factor)/12);
$upper_limit = $monthly_requirement*2;
$lower_limit = ceil($monthly_requirement/2); 
$chart =  '
<chart caption="Monthly Stock at Hand Summary" subcaption="For the year '.$year.'" xAxisName="Month" yAxisName="Quantity"  numberSuffix=" doses" showValues="0" alternateHGridColor="FCB541" alternateHGridAlpha="20" divLineColor="FCB541" divLineAlpha="50" canvasBorderColor="666666" baseFontColor="666666" lineColor="FCB541">
<categories>
<category label="Jan"/>
<category label="Feb"/>
<category label="Mar"/>
<category label="Apr"/>
<category label="May"/>
<category label="Jun"/>
<category label="Jul"/>
<category label="Aug"/>
<category label="Sep"/>
<category label="Oct"/>
<category label="Nov"/>
<category label="Dec"/>
</categories> 
<dataset seriesName="Upper Limit" color="269600" anchorBorderColor="269600" anchorBgColor="269600">';

for($x=1;$x<=12;$x++){
$cumulative_value = $x * $upper_limit;
$chart .= '<set value="'.$cumulative_value.'"/>';
}

$chart .= '</dataset>

<dataset seriesName="Receipts" color="0008FF" anchorBorderColor="0008FF" anchorBgColor="0008FF">
<set  value="'.$monthly_opening_stocks[1].'"/>
<set  value="'.$monthly_opening_stocks[2].'"/>
<set  value="'.$monthly_opening_stocks[3].'"/>
<set value="'.$monthly_opening_stocks[4].'"/>
<set  value="'.$monthly_opening_stocks[5].'"/>
<set value="'.$monthly_opening_stocks[6].'"/>
<set  value="'.$monthly_opening_stocks[7].'"/>
<set  value="'.$monthly_opening_stocks[8].'"/>
<set  value="'.$monthly_opening_stocks[9].'"/>
<set  value="'.$monthly_opening_stocks[10].'"/>
<set  value="'.$monthly_opening_stocks[11].'"/>
<set value="'.$monthly_opening_stocks[12].'"/>
</dataset>
<dataset seriesName="Lower Limit" color="FF0000" anchorBorderColor="FF0000" anchorBgColor="FF0000">';

for($x=1;$x<=12;$x++){
$cumulative_value = $x * $lower_limit;
$chart .= '<set value="'.$cumulative_value.'"/>';
}

$chart .= '</dataset>
<styles>
<definition>
<style name="Anim1" type="animation" param="_xscale" start="0" duration="1"/>
<style name="Anim2" type="animation" param="_alpha" start="0" duration="0.6"/>
<style name="DataShadow" type="Shadow" alpha="40"/>
</definition>
<application>
<apply toObject="DIVLINES" styles="Anim1"/>
<apply toObject="HGRID" styles="Anim2"/>
<apply toObject="DATALABELS" styles="DataShadow,Anim2"/>
</application>
</styles>
</chart>
';

echo $chart;
}
 function create_regional_reports($region)
 {
     $year = date('Y');
     $headers = "Summary Report for Vaccine Status in Kenya\n\t\nDepot: " . $region->name . "\tReporting Date: " . date("d/m/Y") . "\t\n";
     $data = "Analytical Areas\t";
     $vaccines = Vaccines::getAll();
     $from = date("U", mktime(0, 0, 0, 1, 1, date('Y')));
     //This sets the begining date as the 1st of january of that particular year
     $to = date('U');
     //This sets the end date as the current time when the report is being generated
     //Loop all vaccines and append the vaccine name in the excel sheet content.
     foreach ($vaccines as $vaccine) {
         $data .= $vaccine->Name . "\t";
     }
     $data .= "\n";
     //New Line!
     //Begin adding data for the areas being analysed!
     $data .= "Annual Needs Coverage\t";
     //Loop all vaccines and append the needs coverage for that particular vaccine in that store
     foreach ($vaccines as $vaccine) {
         $population = Regional_Populations::getRegionalPopulation($region->id, $year);
         $yearly_requirement = $population * $vaccine->Doses_Required * $vaccine->Wastage_Factor;
         $vaccine_totals = Disbursements::getRegionalReceiptsTotals($region->id, $vaccine->id, $from, $to);
         $coverage = ceil($vaccine_totals / $yearly_requirement * 100);
         $data .= $coverage . "%\t";
     }
     $data .= "\n";
     //New Line
     $data .= "Stock Availability (Stock at Hand)\t";
     //Loop all vaccines and append the stock at hand for that particular vaccine in that store
     foreach ($vaccines as $vaccine) {
         $stock_at_hand = Disbursements::getRegionalPeriodBalance($region->id, $vaccine->id, $to);
         $data .= $stock_at_hand . "\t";
     }
     $data .= "\n";
     //New Line
     $data .= "Stock at Hand Forecast (In Months)\t";
     //Loop all vaccines and append the stock at hand forecast for that particular vaccine in that store
     foreach ($vaccines as $vaccine) {
         $population = Regional_Populations::getRegionalPopulation($region->id, $year);
         $population = str_replace(",", "", $population);
         $monthly_requirement = ceil($vaccine->Doses_Required * $population * $vaccine->Wastage_Factor / 12);
         $stock_at_hand = Disbursements::getRegionalPeriodBalance($region->id, $vaccine->id, $to);
         $forecast = $stock_at_hand / $monthly_requirement;
         $data .= $forecast . "\t";
     }
     $data .= "\n";
     $result = $headers . $data;
     return $result;
 }
Beispiel #4
0
 function create_regional_reports($region)
 {
     $year = date('Y');
     $total_vaccines = Vaccines::getTotalNumber();
     $html = "<table border='2px solid black' class='regionals'>";
     $html .= "<tr ><th rowspan=3>Analytical Areas</th><th style='text-align: center' colspan=" . $total_vaccines . ">Summary Report for Vaccine Status in Kenya</th></tr>";
     $html .= "<tr ><th style='text-align: center' colspan=" . $total_vaccines . ">Depot: " . $region->name . " Reporting Date: " . date("d/m/Y") . "</th></tr>";
     $headers = "Summary Report for Vaccine Status in Kenya\n\t\nDepot: National Store\tReporting Date: " . date("d/m/Y") . "\t\n";
     $data = "Analytical Areas\t";
     $vaccines = Vaccines::getAll();
     $from = date("U", mktime(0, 0, 0, 1, 1, date('Y')));
     //This sets the begining date as the 1st of january of that particular year
     $to = date('U');
     //This sets the end date as the current time when the report is being generated
     //Loop all vaccines and append the vaccine name in the excel sheet content.
     $html .= "<tr>";
     foreach ($vaccines as $vaccine) {
         $html .= "<td  style='background-color:#" . $vaccine->Tray_Color . "'>" . $vaccine->Name . "</td>";
     }
     $html .= "</tr>";
     //New Line!
     //Begin adding data for the areas being analysed!
     $html .= "<tr><td class='title'>Annual Needs Coverage</td>";
     //Loop all vaccines and append the needs coverage for that particular vaccine in that store
     foreach ($vaccines as $vaccine) {
         $population = Regional_Populations::getRegionalPopulation($region->id, $year);
         $yearly_requirement = $population * $vaccine->Doses_Required * $vaccine->Wastage_Factor;
         $vaccine_totals = Disbursements::getRegionalReceiptsTotals($region->id, $vaccine->id, $from, $to);
         $coverage = ceil($vaccine_totals / $yearly_requirement * 100);
         $html .= "<td >" . $coverage . "%</td>";
     }
     $html .= "</tr>";
     //New Line
     $html .= "<tr><td class='title'>Stock Availability (Stock at Hand)</td>";
     //Loop all vaccines and append the stock at hand for that particular vaccine in that store
     foreach ($vaccines as $vaccine) {
         $stock_at_hand = Disbursements::getRegionalPeriodBalance($region->id, $vaccine->id, $to);
         $html .= "<td >" . $stock_at_hand . "</td>";
     }
     $html .= "</tr>";
     //New Line
     $html .= "<tr><td class='title'>Stock at Hand Forecast (In Months)</td>";
     //Loop all vaccines and append the stock at hand forecast for that particular vaccine in that store
     foreach ($vaccines as $vaccine) {
         $population = Regional_Populations::getRegionalPopulation($region->id, $year);
         $population = str_replace(",", "", $population);
         $monthly_requirement = ceil($vaccine->Doses_Required * $population * $vaccine->Wastage_Factor / 12);
         $stock_at_hand = Disbursements::getRegionalPeriodBalance($region->id, $vaccine->id, $to);
         $forecast = $stock_at_hand / $monthly_requirement;
         $forecast = number_format($forecast, 2, '.', '');
         $html .= "<td>" . $forecast . "</td>";
     }
     $html .= "</tr></table>";
     return $html;
 }