Esempio n. 1
0
 public function save_vaccine()
 {
     $vaccine_id = $this->input->post('vaccine_id');
     //Check if we are in editing mode first; if so, retrieve the edited record. if not, create a new one!
     if (strlen($vaccine_id) > 0) {
         $vaccine = Vaccines::getVaccine($vaccine_id);
     } else {
         $vaccine = new Vaccines();
     }
     $vaccine->Name = $this->input->post("name");
     $vaccine->Doses_Required = $this->input->post("doses_required");
     $vaccine->Wastage_Factor = $this->input->post("wastage_factor");
     $vaccine->Designation = $this->input->post("designation");
     $vaccine->Formulation = $this->input->post("formulation");
     $vaccine->Administration = $this->input->post("administration");
     $vaccine->Presentation = $this->input->post("presentation");
     $vaccine->Vaccine_Packed_Volume = $this->input->post("vaccine_packed_volume");
     $vaccine->Diluents_Packed_Volume = $this->input->post("diluents_packed_volume");
     $vaccine->Vaccine_Vial_Price = $this->input->post("vaccine_vial_price");
     $vaccine->Vaccine_Dose_Price = $this->input->post("vaccine_dose_price");
     $vaccine->Fridge_Compartment = $this->input->post("fridge_compartment");
     $vaccine->Added_By = $this->session->userdata('user_id');
     $vaccine->Timestamp = date('U');
     $vaccine->Tray_Color = $this->input->post("tray_color");
     $vaccine->save();
     redirect("vaccine_management");
 }
Esempio n. 2
0
 public function getBalances($phones)
 {
     $this->load->database();
     $start_date = "";
     $data_buffer = "";
     $number = "";
     @$start_date == date('m/d/y', strtotime('-30 days'));
     @($end_date = date('m/d/y'));
     $population = 0;
     $closing_balance = 0;
     $sql_consumption = "";
     $vaccines = Vaccines::getAll_Minified();
     //gets consumption as per every vaccine
     foreach ($vaccines as $vaccine) {
         $population = Regional_Populations::getNationalPopulation(date('Y'));
         $closing_balance = Disbursements::getNationalPeriodBalance($vaccine->id, strtotime($end_date));
         $sql_consumption = "select (SELECT max(str_to_date(Date_Issued,'%m/%d/%Y'))  FROM `disbursements` where Owner = 'N0' and str_to_date(Date_Issued,'%m/%d/%Y') between str_to_date('" . $start_date . "','%m/%d/%Y') and str_to_date('" . $end_date . "','%m/%d/%Y') and Vaccine_Id = '" . $vaccine->id . "' and total_stock_balance>0)as last_stock_count,(SELECT sum(Quantity)FROM `disbursements` where Issued_By_National = '0' and Owner = 'N0' and str_to_date(Date_Issued,'%m/%d/%Y') between str_to_date('" . $start_date . "','%m/%d/%Y') and\n                    str_to_date('" . $end_date . "','%m/%d/%Y') and Vaccine_Id = '" . $vaccine->id . "')as total_issued,(SELECT sum(Quantity) FROM `disbursements` where Issued_To_National = '0' and Owner = 'N0' and str_to_date(Date_Issued,'%m/%d/%Y') between str_to_date('" . $start_date . "','%m/%d/%Y') and\n                    str_to_date('" . $end_date . "','%m/%d/%Y') and Vaccine_Id = '" . $vaccine->id . "')as total_received";
         $query = $this->db->query($sql_consumption);
         $vaccine_data = $query->row();
         $monthly_requirement = ceil($vaccine->Doses_Required * $population * $vaccine->Wastage_Factor / 12);
         $space1 = urldecode("++++");
         $space2 = urldecode("++");
         $newline = urldecode("%0A");
         $brace = urldecode('(');
         $brace2 = urldecode(')');
         $messsage = urlencode($data_buffer .= $newline . $vaccine->Name . $space2 . number_format($closing_balance + 0) . $space1 . $brace . number_format($closing_balance / $monthly_requirement, 1) . 'MOS' . $brace2);
     }
     $this->Send_Balanaces($phones, $messsage);
 }
Esempio n. 3
0
 public function dashboard($dashboard = "country_stock_view")
 {
     $year = date('Y');
     $data['title'] = "Home Page::Dashboards";
     $data['content_view'] = "home_view";
     $data['vaccines'] = Vaccines::getAll();
     $data['styles'] = array("jquery-ui.css", "tab.css");
     $data['script_urls'] = array("http://maps.google.com/maps/api/js?sensor=false");
     $data['scripts'] = array("FusionCharts/FusionCharts.js", "markerclusterer/src/markerclusterer.js", "markerclusterer/src/jsapi.js", "jquery-ui.js", "tab.js");
     $data['dashboard'] = $dashboard;
     $from = date('U');
     $national_balances = array();
     $regional_balances = array();
     $regional_stores = Regions::getAllRegions();
     //Get Statistics for each of the vaccines.
     foreach ($data['vaccines'] as $vaccine) {
         $national_balances[$vaccine->id] = array(Disbursements::getNationalPeriodBalance($vaccine->id, $from), Regional_Populations::getNationalPopulation(date('Y')));
         foreach ($regional_stores as $regional_store) {
             $regional_balances[$vaccine->id][$regional_store->id] = array(Disbursements::getRegionalPeriodBalance($regional_store->id, $vaccine->id, $from), Regional_Populations::getRegionalPopulation($regional_store->id, date('Y')));
         }
     }
     $data['national_stocks'] = $national_balances;
     $data['regional_stocks'] = $regional_balances;
     $data['regional_stores'] = $regional_stores;
     $data['link'] = "home";
     $this->load->view('template', $data);
 }
Esempio n. 4
0
	public function new_dashboard() 
	{
		$identifier = $this -> session -> userdata('user_identifier');
		
		if ($this -> session -> userdata('user_identifier') == 'national_officer') 
		{
			$data['content_view'] = "national_dashboard_view";
		}
		
		if ($this -> session -> userdata('user_identifier') == 'district_officer') 
		{
			$data['content_view'] = "district_dashboard_view";
		}
		
		if ($this -> session -> userdata('user_identifier') == 'provincial_officer') 
		{
			$data['content_view'] = "regional_dashboard_view";
		}
		
		if ($this -> session -> userdata('user_identifier') == 'general_user') 
		{
			$data['content_view'] = "general_dashboard_view";
		}

		$year = date('Y');
		$data['title'] = "System Dashboard";
		$data['vaccines'] = Vaccines::getAll_Minified();
		$data['styles'] = array("jquery-ui.css", "tab.css");
		$data['scripts'] = array("FusionCharts/FusionCharts.js","jquery-ui.js", "advanced_tabs.js");
		$data['link'] = "home";
		$this -> load -> view('template', $data);

	}
Esempio n. 5
0
	public function getBalances($from, $district_or_region, $region_name) #
	{
		$this -> load -> database();
		$start_date = "";
		$number = "";
		@$end_date = date('m/d/y');
		$closing_balance = 0;
		//calls the following function from the vaccines model.
		//the function c=selects data from the vaccines table then stores them in an array
		//the array is stored in the $vaccines variable
		$vaccines = Vaccines::getAll_Minified();

		//gets consumption as per every vaccine
		@$message = "";
		
		foreach ($vaccines as $vaccine) 
		{
			//$district_or_region is the regions id number
			$region_object = Regions::getRegion($district_or_region);
			$name = urlencode($vaccine['Name']);
			$store = urlencode($region_object -> name);
			$closing_balance = Disbursements::getRegionalPeriodBalance($district_or_region, $vaccine -> id, strtotime($end_date));
			$closing_balance_formatted = number_format($closing_balance);

			if ($closing_balance_formatted == 0) 
			{
				//	echo @$message.= "VACCINES+STOCK+OUTS++AT++%0A+*+DVI+-+SMT*";
				$this -> get_phones($name,$district_or_region,$store);

			}

		}

	}
Esempio n. 6
0
 private function base_params($data)
 {
     $data['vaccines'] = Vaccines::getAll_Minified();
     $data['scripts'] = array("jquery-ui.js", "tab.js");
     $data['styles'] = array("jquery-ui.css", "tab.css");
     $data['link'] = "alerts";
     $this->load->view('template', $data);
 }
 public function download()
 {
     $this->load->database();
     $valid = $this->validate_form();
     if ($valid) {
         $data_buffer = "\n\t\t\t<style>\n\t\t\ttable.data-table {\n\t\t\ttable-layout: fixed;\n\t\t\twidth: 700px;\n\t\t\tborder-collapse:collapse;\n\t\t\tborder:1px solid black;\n\t\t\t}\n\t\t\ttable.data-table td, th {\n\t\t\twidth: 100px;\n\t\t\tborder: 1px solid black;\n\t\t\t}\n\t\t\t.leftie{\n\t\t\t\ttext-align: left !important;\n\t\t\t}\n\t\t\t.right{\n\t\t\t\ttext-align: right !important;\n\t\t\t}\n\t\t\t.center{\n\t\t\t\ttext-align: center !important;\n\t\t\t}\n\t\t\t</style> \n\t\t\t";
         $start_date = $this->input->post("start_date");
         $end_date = $this->input->post("end_date");
         $data_buffer .= "<table class='data-table'>";
         $data_buffer .= $this->echoTitles();
         $district_or_region = $this->session->userdata('district_province_id');
         $identifier = $this->session->userdata('user_identifier');
         $population = 0;
         $opening_balance = 0;
         $closing_balance = 0;
         $sql_consumption = "";
         $store = "";
         $vaccines = Vaccines::getAll_Minified();
         foreach ($vaccines as $vaccine) {
             if ($identifier == 'provincial_officer') {
                 $region_object = Regions::getRegion($district_or_region);
                 $store = $region_object->name;
                 $population = Regional_Populations::getRegionalPopulation($district_or_region, date('Y'));
                 $opening_balance = Disbursements::getRegionalPeriodBalance($district_or_region, $vaccine->id, strtotime($start_date));
                 $closing_balance = Disbursements::getRegionalPeriodBalance($district_or_region, $vaccine->id, strtotime($end_date));
                 $owner = "R" . $district_or_region;
                 $sql_consumption = "select (SELECT date_format(max(str_to_date(Date_Issued,'%m/%d/%Y')),'%d-%b-%Y')  FROM `disbursements` where Owner = '" . $owner . "' and str_to_date(Date_Issued,'%m/%d/%Y') between str_to_date('" . $start_date . "','%m/%d/%Y') and str_to_date('" . $end_date . "','%m/%d/%Y') and Vaccine_Id = '" . $vaccine->id . "' and total_stock_balance>0)as last_stock_count,(SELECT sum(Quantity)FROM `disbursements` where Issued_By_Region = '" . $district_or_region . "' and Owner = '" . $owner . "' and str_to_date(Date_Issued,'%m/%d/%Y') between str_to_date('" . $start_date . "','%m/%d/%Y') and\nstr_to_date('" . $end_date . "','%m/%d/%Y') and Vaccine_Id = '" . $vaccine->id . "')as total_issued,(SELECT sum(Quantity) FROM `disbursements` where Issued_To_Region = '" . $district_or_region . "' and Owner = '" . $owner . "' and str_to_date(Date_Issued,'%m/%d/%Y') between str_to_date('" . $start_date . "','%m/%d/%Y') and\nstr_to_date('" . $end_date . "','%m/%d/%Y') and Vaccine_Id = '" . $vaccine->id . "')as total_received";
             } else {
                 if ($identifier == 'district_officer') {
                     $district_object = Districts::getDistrict($district_or_region);
                     $store = $district_object->name;
                     $population = District_Populations::getDistrictPopulation($district_or_region, date('Y'));
                     $opening_balance = Disbursements::getDistrictPeriodBalance($district_or_region, $vaccine->id, strtotime($start_date));
                     $closing_balance = Disbursements::getDistrictPeriodBalance($district_or_region, $vaccine->id, strtotime($end_date));
                     $owner = "D" . $district_or_region;
                     $sql_consumption = "select (SELECT date_format(max(str_to_date(Date_Issued,'%m/%d/%Y')),'%d-%b-%Y')  FROM `disbursements` where Owner = '" . $owner . "' and str_to_date(Date_Issued,'%m/%d/%Y') between str_to_date('" . $start_date . "','%m/%d/%Y') and str_to_date('" . $end_date . "','%m/%d/%Y') and Vaccine_Id = '" . $vaccine->id . "' and total_stock_balance>0)as last_stock_count,(SELECT sum(Quantity)FROM `disbursements` where Issued_By_District = '" . $district_or_region . "' and Owner = '" . $owner . "' and str_to_date(Date_Issued,'%m/%d/%Y') between str_to_date('" . $start_date . "','%m/%d/%Y') and\nstr_to_date('" . $end_date . "','%m/%d/%Y') and Vaccine_Id = '" . $vaccine->id . "')as total_issued,(SELECT sum(Quantity) FROM `disbursements` where Issued_To_District = '" . $district_or_region . "' and Owner = '" . $owner . "' and str_to_date(Date_Issued,'%m/%d/%Y') between str_to_date('" . $start_date . "','%m/%d/%Y') and\nstr_to_date('" . $end_date . "','%m/%d/%Y') and Vaccine_Id = '" . $vaccine->id . "')as total_received";
                 } else {
                     if ($identifier == 'national_officer') {
                         $store = "Central Vaccines Store";
                         $population = Regional_Populations::getNationalPopulation(date('Y'));
                         $opening_balance = Disbursements::getNationalPeriodBalance($vaccine->id, strtotime($start_date));
                         $closing_balance = Disbursements::getNationalPeriodBalance($vaccine->id, strtotime($end_date));
                         $sql_consumption = "select (SELECT date_format(max(str_to_date(Date_Issued,'%m/%d/%Y')),'%d-%b-%Y')  FROM `disbursements` where Owner = 'N0' and str_to_date(Date_Issued,'%m/%d/%Y') between str_to_date('" . $start_date . "','%m/%d/%Y') and str_to_date('" . $end_date . "','%m/%d/%Y') and Vaccine_Id = '" . $vaccine->id . "' and total_stock_balance>0)as last_stock_count,(SELECT sum(Quantity)FROM `disbursements` where Issued_By_National = '0' and Owner = 'N0' and str_to_date(Date_Issued,'%m/%d/%Y') between str_to_date('" . $start_date . "','%m/%d/%Y') and\nstr_to_date('" . $end_date . "','%m/%d/%Y') and Vaccine_Id = '" . $vaccine->id . "')as total_issued,(SELECT sum(Quantity) FROM `disbursements` where Issued_To_National = '0' and Owner = 'N0' and str_to_date(Date_Issued,'%m/%d/%Y') between str_to_date('" . $start_date . "','%m/%d/%Y') and\nstr_to_date('" . $end_date . "','%m/%d/%Y') and Vaccine_Id = '" . $vaccine->id . "')as total_received";
                     }
                 }
             }
             $query = $this->db->query($sql_consumption);
             $vaccine_data = $query->row();
             $monthly_requirement = ceil($vaccine->Doses_Required * $population * $vaccine->Wastage_Factor / 12);
             $data_buffer .= "<tr><td style='text-align:left;'>" . $vaccine->Name . "</td><td class='right'>" . number_format($opening_balance + 0) . "</td><td  class='right'>" . number_format($vaccine_data->total_received + 0) . "</td><td class='right'>" . number_format($vaccine_data->total_issued + 0) . "</td><td class='right'>" . number_format($closing_balance - ($opening_balance + $vaccine_data->total_received - $vaccine_data->total_issued) + 0) . "</td><td class='right'>" . number_format($closing_balance + 0) . "</td><td class='center'>" . number_format($closing_balance / $monthly_requirement, 1) . "</td><td class='center'>" . $vaccine_data->last_stock_count . "</td></tr>";
         }
         $data_buffer .= "</table>";
         $this->generatePDF($data_buffer, $start_date, $end_date, $store);
     } else {
         $this->view_transactions_interface();
     }
 }
Esempio n. 8
0
	public function save_vaccine() {
		$vaccine = new Vaccines();
		$vaccine -> Name = $this -> input -> post("name");
		$vaccine -> Doses_Required = $this -> input -> post("doses_required");
		$vaccine -> Wastage_Factor = $this -> input -> post("wastage_factor");
		$vaccine -> Designation = $this -> input -> post("designation");
		$vaccine -> Formulation = $this -> input -> post("formulation");
		$vaccine -> Administration = $this -> input -> post("administration");
		$vaccine -> Presentation = $this -> input -> post("presentation");
		$vaccine -> Vaccine_Packed_Volume = $this -> input -> post("vaccine_packed_volume");
		$vaccine -> Diluents_Packed_Volume = $this -> input -> post("diluents_packed_volume");
		$vaccine -> Vaccine_Vial_Price = $this -> input -> post("vaccine_vial_price");
		$vaccine -> Vaccine_Dose_Price = $this -> input -> post("vaccine_dose_price");
		$vaccine -> Added_By = $this -> session -> userdata('user_id');
		$vaccine -> Timestamp = date('U');
		$vaccine -> Tray_Color = $this -> input -> post("tray_color");
		$vaccine -> save();
		redirect("vaccine_management");
	}
Esempio n. 9
0
	public function task_Management()
	
	 {
	 	$data['task'] = Tasks::getThemAll();		
		$data['vaccine'] = Vaccines::getThemAll();	
		$data['content_view'] = "add_task_view";
		$data['title'] = "New task";
		$this -> base_params($data);
		
		//$this->load->view("add_task_view");
	 }
Esempio n. 10
0
 public function flag_out($math, $ID)
 {
     $vnames = Vaccines::getVaccineName($ID);
     foreach ($vnames as $vname) {
         $flaged = urlencode($vname['Name']);
         @($message .= "VACCINES+STOCK+OUTS+%0A+{$flaged}");
         //determines which type of sms to send
     }
     $smslevel = Emails::getSmslevel();
     foreach ($smslevel as $levels) {
         $phones = $levels['number'];
         $this->send_sms($phones, $message, $math);
     }
 }
Esempio n. 11
0
	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;
	}
Esempio n. 12
0
 public function getBalances($from, $district_or_region, $region_name)
 {
     $this->load->database();
     $start_date = "";
     $number = "";
     @($end_date = date('m/d/y'));
     $closing_balance = 0;
     $vaccines = Vaccines::getAll_Minified();
     //gets consumption as per every vaccine
     @($message = "");
     foreach ($vaccines as $vaccine) {
         $region_object = Regions::getRegion($district_or_region);
         $name = urlencode($vaccine['Name']);
         $store = urlencode($region_object->name);
         $closing_balance = Disbursements::getRegionalPeriodBalance($district_or_region, $vaccine->id, strtotime($end_date));
         $closing_balance_formatted = number_format($closing_balance);
         if ($closing_balance_formatted == 0) {
             //	echo @$message.= "VACCINES+STOCK+OUTS++AT++%0A+*+DVI+-+SMT*";
             $this->get_phones($name, $district_or_region, $store);
         }
     }
 }
Esempio n. 13
0
	function download($national = "", $region = "", $district = "") {
		$title = "";
		if ($national > 0) {
			$title = "MOS Available at Central Vaccine Store";
		}
		if ($region > 0) {
			$region_object = Regions::getRegion($region);
			$title = "MOS Available at " . $region_object -> name;
		}
		if ($district > 0) {
			$district_object = Districts::getDistrict($district);
			$title = "MOS Available at " . $district_object -> name . " District Store";
		}
		$vaccines = Vaccines::getAll_Minified();
		$date = date("m/d/Y");
		$months_required = array();
		$data_buffer = "
			<style>
			table.data-table {
			table-layout: fixed;
			width: 700px;
			border-collapse:collapse;
			border:1px solid black;
			}
			table.data-table td, th {
			width: 100px;
			border: 1px solid black;
			}
			.leftie{
				text-align: left !important;
			}
			.right{
				text-align: right !important;
			}
			.center{
				text-align: center !important;
			}
			</style> 
			";
		$data_buffer .= "<table class='data-table'>";
		$data_buffer .= $this -> echoTitles();

		foreach ($vaccines as $vaccine_object) {
			$months_of_stock = array();
			$year = date('Y');
			$now = date('U');
			$population = 0;
			$stock_balance = 0;
			if ($national > 0) {
				$population = Regional_Populations::getNationalPopulation($year);
				$stock_balance = Disbursements::getNationalPeriodBalance($vaccine_object -> id, $now);
			}
			if ($region > 0) {
				$population = Regional_Populations::getRegionalPopulation($region, $year);
				$stock_balance = Disbursements::getRegionalPeriodBalance($region, $vaccine_object -> id, $now);
			}
			if ($district > 0) {
				$population = District_Populations::getDistrictPopulation($district, $year);
				$stock_balance = Disbursements::getDistrictPeriodBalance($district, $vaccine_object -> id, $now);
			}
			$population = str_replace(",", "", $population);
			$monthly_requirement = ceil(($vaccine_object -> Doses_Required * $population * $vaccine_object -> Wastage_Factor) / 12);
			$months_till_shipment = 0;
			if ($national > 0) {
				$months_of_stock = array();
				$year = date('Y');
				$now = date('U');
				$expected_delivery = Provisional_Plan::getNextDelivery($vaccine_object -> id);

				if (isset($expected_delivery[0])) {
					$next_shipment = $expected_delivery[0]['next_shipment'];
					$days_till_shipment = $expected_delivery[0]['difference'];
					if (isset($days_till_shipment)) {
						$months_till_shipment = number_format(($days_till_shipment / 30), 1);
					}
				}
			}
			if ($region > 0) {
				$months_till_shipment = 3;
				$next_shipment = "N/A";
			}
			if ($district > 0) {
				$months_till_shipment = 3;
				$next_shipment = "N/A";
			}

			$doses_needed = "N/A";
			if ($stock_balance > 0) {
				$months_left = number_format(($stock_balance / $monthly_requirement), 1);
			}
			if ($months_left > $months_till_shipment) {
				$doses_needed = "None";
			} else {
				$doses_needed = number_format((($months_till_shipment - $months_left) * $monthly_requirement), 2);
			}

			$monthly_requirement = number_format($monthly_requirement + 0);
			$data_buffer .= "<tr><td class='leftie'>" . $vaccine_object -> Name . "</td><td class='right'>" . number_format($stock_balance) . "</td><td class='center'>" . $months_left . "</td><td class='center'>" . $next_shipment . "</td><td class='center'>" . $months_till_shipment . "</td><td class='right'>" . $monthly_requirement . "</td><td class='right'>" . $doses_needed . "</td></tr>";

		}
		$data_buffer .= "</table>";
		$this -> generatePDF($data_buffer, $title);
		//echo $data_buffer;
	}
Esempio n. 14
0
<div class="dashboard_menu">
	<a href="<?php echo site_url()."task_Management/add_new"?>" class="quick_menu_link">Add new task</a>
<?php 
$access_level = $this -> session -> userdata('user_group');
if($access_level == "1" || $access_level == "2"){?>
<a href="<?php echo site_url()."task_management/view_task";?>" class="quick_menu_link <?php if($quick_link == "edit_task"){echo "quick_menu_active";}?>">Edit Task</a> 
<?php
}
?>
<a  class="quick_menu_link <?php if($quick_link == "all_tasks") {echo "quick_menu_active";}?>" href="<?php echo site_url("task_management");?>">All Tasks</a>
 

<div id="tabs" class="htabs">
<?php

$vaccines = Vaccines::getAll_Minified();
foreach($vaccines as $vaccine){?>
	<?php?>
<a href="<?php echo base_url()."task_Management/vaccine/".$vaccine->id?>" id="vaccine_<?php echo $vaccine->id ?>" tab="#<?php echo $vaccine->id ?>" class="vaccine_name" name="<?php echo $vaccine->Name?>" style="background-color: <?php echo '#'.$vaccine->Tray_Color;?>"><?php echo $vaccine->Name?></a> 
<?php } ?>

<?php
if(isset($gantt_data)){
	?>
	<script type="text/javascript">
	$(function() {
	var _id=<?php echo $gantt_data; ?>;
	$(".vaccine_name").removeClass();
	$("#vaccine_"+_id).addClass('selected');
	}); 
	</script>
Esempio n. 15
0
 public function printReport($from, $to)
 {
     @$this->load->database();
     @($user_groups = User_groups::getAllGroups());
     foreach ($user_groups as $user_group) {
         @($identifier = $user_group["Identifier"]);
         @($population = 0);
         @($opening_balance = 0);
         @($closing_balance = 0);
         @($sql_consumption = "");
         @($store = "");
         @($vaccines = Vaccines::getAll_Minified());
         if ($identifier == 'provincial_officer') {
             @($provinces = Provinces::getAllProvinces());
             foreach ($provinces as $province) {
                 @($data_buffer = "\n\t\t\t   <style>\n\t\t\ttable.data-table {\n\t\t\ttable-layout: fixed;\n\t\t\twidth: 700px;\n\t\t\tborder-collapse:collapse;\n\t\t\tborder:1px solid black;\n\t\t\t}\n\t\t\ttable.data-table td, th {\n\t\t\twidth: 100px;\n\t\t\tborder: 1px solid black;\n\t\t\t}\n\t\t\t.leftie{\n\t\t\t\ttext-align: left !important;\n\t\t\t}\n\t\t\t.right{\n\t\t\t\ttext-align: right !important;\n\t\t\t}\n\t\t\t.center{\n\t\t\t\ttext-align: center !important;\n\t\t\t}\n\t\t\t</style>\n\t\t\t  ");
                 @($start_date = $from);
                 @($end_date = $to);
                 @($data_buffer .= "<table class='data-table'>");
                 @($data_buffer .= $this->echoTitles());
                 foreach ($vaccines as $vaccine) {
                     @($district_or_region = $province["id"]);
                     @($region_object = Regions::getRegion($district_or_region));
                     @($store = $region_object->name);
                     @($population = Regional_Populations::getRegionalPopulation($district_or_region, date('Y')));
                     @($opening_balance = Disbursements::getRegionalPeriodBalance($district_or_region, $vaccine->id, strtotime($start_date)));
                     @($closing_balance = Disbursements::getRegionalPeriodBalance($district_or_region, $vaccine->id, strtotime($end_date)));
                     @($owner = "R" . $district_or_region);
                     @($sql_consumption = "select (SELECT max(str_to_date(Date_Issued,'%m/%d/%Y'))  FROM `disbursements` where Owner = '" . $owner . "' and str_to_date(Date_Issued,'%m/%d/%Y') between str_to_date('" . $start_date . "','%m/%d/%Y') and str_to_date('" . $end_date . "','%m/%d/%Y') and Vaccine_Id = '" . $vaccine->id . "' and total_stock_balance>0)as last_stock_count,(SELECT sum(Quantity)FROM `disbursements` where Issued_By_Region = '" . $district_or_region . "' and Owner = '" . $owner . "' and str_to_date(Date_Issued,'%m/%d/%Y') between str_to_date('" . $start_date . "','%m/%d/%Y') and\n  str_to_date('" . $end_date . "','%m/%d/%Y') and Vaccine_Id = '" . $vaccine->id . "')as total_issued,(SELECT sum(Quantity) FROM `disbursements` where Issued_To_Region = '" . $district_or_region . "' and Owner = '" . $owner . "' and str_to_date(Date_Issued,'%m/%d/%Y') between str_to_date('" . $start_date . "','%m/%d/%Y') and\n  str_to_date('" . $end_date . "','%m/%d/%Y') and Vaccine_Id = '" . $vaccine->id . "')as total_received");
                     @($query = $this->db->query($sql_consumption));
                     @($vaccine_data = $query->row());
                     @($monthly_requirement = ceil($vaccine->Doses_Required * $population * $vaccine->Wastage_Factor / 12));
                     @($data_buffer .= "<tr><td>" . $vaccine->Name . "</td><td>" . number_format($opening_balance + 0) . "</td><td>" . number_format($vaccine_data->total_received + 0) . "</td><td>" . number_format($vaccine_data->total_issued + 0) . "</td><td>" . number_format($closing_balance - ($opening_balance + $vaccine_data->total_received - $vaccine_data->total_issued) + 0) . "</td><td>" . number_format($closing_balance + 0) . "</td><td>" . number_format($closing_balance / $monthly_requirement, 1) . "</td><td>" . $vaccine_data->last_stock_count . "</td></tr>");
                 }
                 //end of foreach vaccines
                 @($vals = 1);
                 @($data_buffer .= "</table>");
                 @$this->generatePDF($data_buffer, $start_date, $end_date, $store, $district_or_region, $vals, $store);
                 @($data_buffer = "");
             }
         }
         if ($identifier == 'district_officer') {
             @($districts = Districts::getAllDistricts());
             foreach ($districts as $district) {
                 @($data_buffer = "\n\t\t\t    <style>\n\t\t\ttable.data-table {\n\t\t\ttable-layout: fixed;\n\t\t\twidth: 700px;\n\t\t\tborder-collapse:collapse;\n\t\t\tborder:1px solid black;\n\t\t\t}\n\t\t\ttable.data-table td, th {\n\t\t\twidth: 100px;\n\t\t\tborder: 1px solid black;\n\t\t\t}\n\t\t\t.leftie{\n\t\t\t\ttext-align: left !important;\n\t\t\t}\n\t\t\t.right{\n\t\t\t\ttext-align: right !important;\n\t\t\t}\n\t\t\t.center{\n\t\t\t\ttext-align: center !important;\n\t\t\t}\n\t\t\t</style>\n\t\t\t  ");
                 @($start_date = $from);
                 @($end_date = $to);
                 @($data_buffer .= "<table class='data-table'>");
                 @($data_buffer .= $this->echoTitles());
                 foreach ($vaccines as $vaccine) {
                     @($district_or_region = $district["id"]);
                     @($district_object = Districts::getDistrict($district_or_region));
                     @($store = $district_object->name);
                     @($population = District_Populations::getDistrictPopulation($district_or_region, date('Y')));
                     @($opening_balance = Disbursements::getDistrictPeriodBalance($district_or_region, $vaccine->id, strtotime($start_date)));
                     @($closing_balance = Disbursements::getDistrictPeriodBalance($district_or_region, $vaccine->id, strtotime($end_date)));
                     @($owner = "D" . $district_or_region);
                     @($sql_consumption = "select (SELECT max(str_to_date(Date_Issued,'%m/%d/%Y'))  FROM `disbursements` where Owner = '" . $owner . "' and str_to_date(Date_Issued,'%m/%d/%Y') between str_to_date('" . $start_date . "','%m/%d/%Y') and str_to_date('" . $end_date . "','%m/%d/%Y') and Vaccine_Id = '" . $vaccine->id . "' and total_stock_balance>0)as last_stock_count,(SELECT sum(Quantity)FROM `disbursements` where Issued_By_District = '" . $district_or_region . "' and Owner = '" . $owner . "' and str_to_date(Date_Issued,'%m/%d/%Y') between str_to_date('" . $start_date . "','%m/%d/%Y') and\n  str_to_date('" . $end_date . "','%m/%d/%Y') and Vaccine_Id = '" . $vaccine->id . "')as total_issued,(SELECT sum(Quantity) FROM `disbursements` where Issued_To_District = '" . $district_or_region . "' and Owner = '" . $owner . "' and str_to_date(Date_Issued,'%m/%d/%Y') between str_to_date('" . $start_date . "','%m/%d/%Y') and\n  str_to_date('" . $end_date . "','%m/%d/%Y') and Vaccine_Id = '" . $vaccine->id . "')as total_received");
                     @($query = $this->db->query($sql_consumption));
                     @($vaccine_data = $query->row());
                     @($monthly_requirement = ceil($vaccine->Doses_Required * $population * $vaccine->Wastage_Factor / 12));
                     @($data_buffer .= "<tr><td>" . $vaccine->Name . "</td><td>" . number_format($opening_balance + 0) . "</td><td>" . number_format($vaccine_data->total_received + 0) . "</td><td>" . number_format($vaccine_data->total_issued + 0) . "</td><td>" . number_format($closing_balance - ($opening_balance + $vaccine_data->total_received - $vaccine_data->total_issued) + 0) . "</td><td>" . number_format($closing_balance + 0) . "</td><td>" . number_format($closing_balance / $monthly_requirement, 1) . "</td><td>" . $vaccine_data->last_stock_count . "</td></tr>");
                 }
                 //end of foreach vaccines
                 @($vals = 2);
                 @($data_buffer .= "</table>");
                 @$this->generatePDF($data_buffer, $start_date, $end_date, $store, $district_or_region, $vals, $store);
                 @($data_buffer = "");
             }
         }
         if ($identifier == 'national_officer') {
             @($data_buffer = "\n\t\t\t    <style>\n\t\t\ttable.data-table {\n\t\t\ttable-layout: fixed;\n\t\t\twidth: 700px;\n\t\t\tborder-collapse:collapse;\n\t\t\tborder:1px solid black;\n\t\t\t}\n\t\t\ttable.data-table td, th {\n\t\t\twidth: 100px;\n\t\t\tborder: 1px solid black;\n\t\t\t}\n\t\t\t.leftie{\n\t\t\t\ttext-align: left !important;\n\t\t\t}\n\t\t\t.right{\n\t\t\t\ttext-align: right !important;\n\t\t\t}\n\t\t\t.center{\n\t\t\t\ttext-align: center !important;\n\t\t\t}\n\t\t\t</style>\n\t\t\t  ");
             @($start_date = $from);
             @($end_date = $to);
             @($data_buffer .= "<table class='data-table'>");
             @($data_buffer .= $this->echoTitles());
             @($store = "Central Vaccines Store");
             foreach ($vaccines as $vaccine) {
                 @($population = Regional_Populations::getNationalPopulation(date('Y')));
                 @($opening_balance = Disbursements::getNationalPeriodBalance($vaccine->id, strtotime($start_date)));
                 @($closing_balance = Disbursements::getNationalPeriodBalance($vaccine->id, strtotime($end_date)));
                 @($sql_consumption = "select (SELECT max(str_to_date(Date_Issued,'%m/%d/%Y'))  FROM `disbursements` where Owner = 'N0' and str_to_date(Date_Issued,'%m/%d/%Y') between str_to_date('" . $start_date . "','%m/%d/%Y') and str_to_date('" . $end_date . "','%m/%d/%Y') and Vaccine_Id = '" . $vaccine->id . "' and total_stock_balance>0)as last_stock_count,(SELECT sum(Quantity)FROM `disbursements` where Issued_By_National = '0' and Owner = 'N0' and str_to_date(Date_Issued,'%m/%d/%Y') between str_to_date('" . $start_date . "','%m/%d/%Y') and\n  str_to_date('" . $end_date . "','%m/%d/%Y') and Vaccine_Id = '" . $vaccine->id . "')as total_issued,(SELECT sum(Quantity) FROM `disbursements` where Issued_To_National = '0' and Owner = 'N0' and str_to_date(Date_Issued,'%m/%d/%Y') between str_to_date('" . $start_date . "','%m/%d/%Y') and\n  str_to_date('" . $end_date . "','%m/%d/%Y') and Vaccine_Id = '" . $vaccine->id . "')as total_received");
                 @($query = $this->db->query($sql_consumption));
                 @($vaccine_data = $query->row());
                 @($monthly_requirement = ceil($vaccine->Doses_Required * $population * $vaccine->Wastage_Factor / 12));
                 @($data_buffer .= "<tr><td>" . $vaccine->Name . "</td><td>" . number_format($opening_balance + 0) . "</td><td>" . number_format($vaccine_data->total_received + 0) . "</td><td>" . number_format($vaccine_data->total_issued + 0) . "</td><td>" . number_format($closing_balance - ($opening_balance + $vaccine_data->total_received - $vaccine_data->total_issued) + 0) . "</td><td>" . number_format($closing_balance + 0) . "</td><td>" . number_format($closing_balance / $monthly_requirement, 1) . "</td><td>" . $vaccine_data->last_stock_count . "</td></tr>");
             }
             //end of foreach vaccines
             @($vals = 3);
             @($data_buffer .= "</table>");
             @($district_or_region = "");
             @$this->generatePDF($data_buffer, $start_date, $end_date, $store, $district_or_region, $vals, $store);
             @($data_buffer = "");
         }
     }
     //end of foreach user_group
 }
Esempio n. 16
0
					
				 }		
				?>
				
			</select></td>
	
			
		</tr>
		<tr>
			<td><span class="mandatory">*</span>Vaccine</td>
					
			<td>
			<select id="combo2" name="combo2">
				<option value="chose">Choose One</option>
				<?php
							$vaccine= Vaccines::getThemAll();	
				foreach ($vaccine as $vaccines)
				 {
					
		            echo '<option  value="'. $vaccines['id'].'">'. $vaccines['Name'].'</option>';
					
				 }		
				?>
				
			</select></td>
	
			
		</tr>
		<tr>
			<td><span class="mandatory">*</span>Initiator name</td>
			<td>
Esempio n. 17
0
 public function send_emails()
 {
     $this->load->helper(array('file'));
     $config['protocol'] = 'smtp';
     $config['smtp_host'] = 'ssl://smtp.googlemail.com';
     $config['smtp_port'] = 465;
     $config['smtp_user'] = stripslashes('*****@*****.**');
     $config['smtp_pass'] = stripslashes('projectDVI');
     $this->load->library('email', $config);
     $this->load->database();
     $period = 'Jun-12';
     //First, retrieve all the districts that have recipients
     $sql = "select distinct district, d.name as district_name from stock_out_recipient s left join districts d on district = d.id where s.disabled = '0'";
     $query = $this->db->query($sql);
     $district_array = $query->result_array();
     //get the total number of vaccines that report dhis data
     $vaccine_number = Vaccines::getTotalDHIS();
     $vaccine_number++;
     //Get the vaccines wiith dhis data
     $vaccines = Vaccines::getDHIS();
     $months = array();
     foreach ($district_array as $district) {
         $data_buffer = "\n\t\t\t<style>\n\t\t\ttable.data-table {\n\t\t\ttable-layout: fixed;\n\t\t\twidth: 1000px;\n\t\t\tborder-collapse:collapse;\n\t\t\tborder:1px solid black;\n\t\t\tmargin-top:20px;\n\t\t\t}\n\t\t\ttable.data-table td, th {\n\t\t\twidth: 100px;\n\t\t\tborder: 1px solid black;\n\t\t\t}\n\t\t\t.leftie{\n\t\t\t\ttext-align: left !important;\n\t\t\t}\n\t\t\t.right{\n\t\t\t\ttext-align: right !important;\n\t\t\t}\n\t\t\t.center{\n\t\t\t\ttext-align: center !important;\n\t\t\t}\n\t\t\t</style> \n\t\t\t";
         $data_buffer .= "<table class='data-table'>";
         $data_buffer .= $this->echoTitles();
         $data_buffer .= "<tr>";
         //loop through all the months in the season
         for ($x = 1; $x <= 12; $x++) {
             //get the month name
             $text = "2012-" . $x . "-1";
             $period = date("M-y", strtotime($text));
             $months[$x] = $period;
             $data_buffer .= "<td>" . $period . "</td>";
         }
         $data_buffer .= "</tr>";
         //Loop through the returned districts, generating a report for each
         $district_name = $district['district_name'];
         $district = $district['district'];
         //get all facilities for this district
         $facilities = Facilities::getDistrictFacilities($district);
         //loop through all the facilities to return immunization data
         foreach ($facilities as $facility) {
             $data_buffer .= "<tr><td rowspan='{$vaccine_number}'>" . $facility->name . "</td>";
             $data_buffer .= "<td>Children Immunized</td>";
             //get the total number of children immunized in this facility
             foreach ($months as $month) {
                 $sql_children = "select fully_immunized_children from dhis_data where facility_code = '{$facility->facilitycode}' and reporting_period = '{$month}'";
                 $query_children = $this->db->query($sql_children);
                 $immunized_children = $query_children->row_array();
                 if (isset($immunized_children['fully_immunized_children'])) {
                     $data_buffer .= "<td>" . $immunized_children['fully_immunized_children'] . "</td>";
                 } else {
                     $data_buffer .= "<td>N/A</td>";
                 }
             }
             $data_buffer .= "</tr>";
             foreach ($vaccines as $vaccine) {
                 $data_buffer .= "<tr><td>" . $vaccine->Name . "</td>";
                 $dhis_remaining = $vaccine->Dhis_Remaining;
                 $dhis_received = $vaccine->Dhis_Received;
                 $dhis_stock = $vaccine->Dhis_Stock;
                 foreach ($months as $month) {
                     //For each vaccine, create a query to get its dhis data
                     $sql_remaining = "select {$dhis_remaining}, {$dhis_received}, {$dhis_stock} from dhis_data where facility_code = '{$facility->facilitycode}' and reporting_period = '{$month}'";
                     $query_remaining = $this->db->query($sql_remaining);
                     $remaining_stock = $query_remaining->row_array();
                     //var_dump($query_remaining);
                     if (!empty($remaining_stock)) {
                         if (strlen($remaining_stock[$dhis_received]) > 0 || strlen($remaining_stock[$dhis_remaining]) > 0 || strlen($remaining_stock[$dhis_stock]) > 0) {
                             if ($remaining_stock[$dhis_remaining] == "0" || $remaining_stock[$dhis_remaining] == "" || $remaining_stock[$dhis_remaining] == null) {
                                 $data_buffer .= "<td style='background-color: red;'>" . $remaining_stock[$dhis_remaining] . "</td>";
                             } else {
                                 $data_buffer .= "<td>" . $remaining_stock[$dhis_remaining] . "</td>";
                             }
                         } else {
                             $data_buffer .= "<td style='text-align:center'>-</td>";
                         }
                     } else {
                         $data_buffer .= "<td style='text-align:center'>-</td>";
                     }
                 }
             }
             $data_buffer .= "</tr>";
         }
         $data_buffer .= "</table>";
         //echo $data_buffer;
         $this->generatePDF($data_buffer, $district_name);
     }
 }
Esempio n. 18
0
 public function index()
 {
     //Get the Earliest Disbursement Date and the Earliest Archive Date. Do the neccesary!
     $earliest_disbursement_date = Disbursements::getEarliestDisbursement();
     $earliest_archive_date = Archive_Logs::getEarliestArchive();
     if ($earliest_archive_date == null) {
         $earliest_archive_date = date('m/d/Y');
     }
     $split_disbursement_date = explode('/', $earliest_disbursement_date);
     $split_archive_date = explode('/', $earliest_archive_date);
     var_dump($split_disbursement_date);
     var_dump($split_archive_date);
     $total_months = $split_archive_date[0] - $split_disbursement_date[0] + ($split_archive_date[2] - $split_disbursement_date[2]) * 12;
     $dates_to_archive = array();
     for ($archive_month = 0; $archive_month < $total_months; $archive_month++) {
         $expected_month = $archive_month + $split_disbursement_date[0];
         $year = $split_disbursement_date[2];
         //echo $expected_month." and ".$year;
         if ($expected_month > 12) {
             $year += ceil(($expected_month - 12) / 12);
             $expected_month -= 12;
         }
         $archive_date = $expected_month . "/15/" . $year;
         $dates_to_archive[$archive_month] = $archive_date;
     }
     var_dump($dates_to_archive);
     //foreach($dates_to_archive as $date_to_archive){
     //Check if this date's archive has been done. If not do it now!
     $expected_archive_date = "6/15/2011";
     $expected_archive_timestamp = strtotime($expected_archive_date);
     $archive_exists = Archive_Logs::archiveExists($expected_archive_date);
     if (!$archive_exists) {
         echo "Creating Archive!";
         //Loop through all vaccines
         $vaccines = Vaccines::getAll();
         $regions = Regions::getAllRegions();
         $districts = Districts::getAllDistricts();
         foreach ($vaccines as $vaccine) {
             //National Archive First
             $national_archive = new Archives();
             $national_archive->National_Store = "0";
             $national_archive->Stock_At_Hand = Disbursements::getNationalStockAtHand($vaccine->id, $expected_archive_timestamp);
             $national_archive->Date_Of_Archive = $expected_archive_date;
             $national_archive->Vaccine_Id = $vaccine->id;
             $national_archive->save();
             //Do archives for all the regions
             foreach ($regions as $region) {
                 $regional_archive = new Archives();
                 $regional_archive->Regional_Store_Id = $region->id;
                 $regional_archive->Stock_At_Hand = Disbursements::getRegionalStockAtHand($region->id, $vaccine->id, $expected_archive_timestamp);
                 $regional_archive->Date_Of_Archive = $expected_archive_date;
                 $regional_archive->Vaccine_Id = $vaccine->id;
                 $regional_archive->save();
             }
             //Do archives for all the districts. :-(
             foreach ($districts as $district) {
                 $district_archive = new Archives();
                 $district_archive->District_Store_Id = $district->id;
                 $district_archive->Stock_At_Hand = Disbursements::getDistrictStockAtHand($district->id, $vaccine->id, $expected_archive_timestamp);
                 $district_archive->Date_Of_Archive = $expected_archive_date;
                 $district_archive->Vaccine_Id = $vaccine->id;
                 $district_archive->save();
             }
         }
         $archive_log = new Archive_Logs();
         $archive_log->Archive_Date = $expected_archive_date;
         $archive_log->Timestamp = date('U');
         $archive_log->Save();
     } else {
         echo "This archive already exists!";
     }
     //}
 }
Esempio n. 19
0
 public function download_mos_trend($selected_year = 0, $national = "", $region = "", $district = "")
 {
     $year = date('Y');
     if ($selected_year != "0") {
         $year = $selected_year;
     }
     $counter = 2;
     $vaccine_objects = Vaccines::getAll();
     $population = 0;
     $title = "";
     if ($national > 0) {
         $title = "MOS Balance Trend at Central Vaccine Store";
         $population = Regional_Populations::getNationalPopulation($year);
     }
     if ($region > 0) {
         $region_object = Regions::getRegion($region);
         $title = "MOS Balance Trend at " . $region_object->name;
         $population = Regional_Populations::getRegionalPopulation($region, $year);
     }
     if ($district > 0) {
         $district_object = Districts::getDistrict($district);
         $title = "MOS Balance Trend at " . $district_object->name . " District Store";
         $population = District_Populations::getDistrictPopulation($district, $year);
     }
     $population = str_replace(",", "", $population);
     foreach ($vaccine_objects as $vaccine_object) {
         $monthly_requirement = ceil($vaccine_object->Doses_Required * $population * $vaccine_object->Wastage_Factor / 12);
         for ($month = 1; $month <= 36; $month++) {
             $mos_balance = 0;
             //Get the month
             $month_number = ceil($month / 3);
             //If it is an even number, get values for the 21st, if it's odd, get values for the 7th
             if ($month % 3 == 0) {
                 $month_date = 28;
             } else {
                 if ($month % 3 == 1) {
                     $month_date = 7;
                 } else {
                     if ($month % 3 == 2) {
                         $month_date = 21;
                     }
                 }
             }
             $to = date("U", mktime(0, 0, 0, $month_number, $month_date, $year));
             $stock_balance = 0;
             if ($national > 0) {
                 $stock_balance = Disbursements::getNationalPeriodBalance($vaccine_object->id, $to);
             }
             if ($region > 0) {
                 $stock_balance = Disbursements::getRegionalPeriodBalance($region, $vaccine_object->id, $to);
             }
             if ($district > 0) {
                 $stock_balance = Disbursements::getDistrictPeriodBalance($district, $vaccine_object->id, $to);
             }
             //$stock_balance = 0;
             if ($stock_balance > 0) {
                 $mos_balance = number_format($stock_balance / $monthly_requirement, 2);
             }
             $monthly_opening_stocks[$month][$vaccine_object->id]['stock_balance'] = number_format($stock_balance + 0);
             $monthly_opening_stocks[$month][$vaccine_object->id]['mos_balance'] = $mos_balance;
             $counter += 2;
         }
     }
     $data_buffer = "\n\t\t\t<style>\n\t\t\ttable.data-table {\n\t\t\ttable-layout: fixed;\n\t\t\twidth: 1000px;\n\t\t\tborder-collapse:collapse;\n\t\t\tborder:1px solid black;\n\t\t\t}\n\t\t\ttable.data-table td, th {\n\t\t\twidth: 100px;\n\t\t\tborder: 1px solid black;\n\t\t\t}\n\t\t\t.leftie{\n\t\t\t\ttext-align: left !important;\n\t\t\t}\n\t\t\t.center{\n\t\t\t\ttext-align: center !important;\n\t\t\t}\n\t\t\t.right{\n\t\t\t\ttext-align: right !important;\n\t\t\t}\n\t\t\t</style> \n\t\t\t";
     $data_buffer .= "<table class='data-table'>";
     $counter = 2;
     $data_buffer .= $this->echoTitles($vaccine_objects);
     for ($month = 1; $month <= 36; $month++) {
         $data_buffer .= "<tr>";
         $month_number = ceil($month / 3);
         //If it is an even number, get values for the 21st, if it's odd, get values for the 7th
         if ($month % 3 == 0) {
             $month_date = 28;
         } else {
             if ($month % 3 == 1) {
                 $month_date = 7;
             } else {
                 if ($month % 3 == 2) {
                     $month_date = 21;
                 }
             }
         }
         $date = date("M-d", mktime(0, 0, 0, $month_number, $month_date, $year));
         $data_buffer .= "<td>" . $date . "</td>";
         foreach ($vaccine_objects as $vaccine_object) {
             $data_buffer .= "<td class='center'>" . $monthly_opening_stocks[$month][$vaccine_object->id]['mos_balance'] . "</td><td class='right'>" . $monthly_opening_stocks[$month][$vaccine_object->id]['stock_balance'] . "</td>";
         }
         $data_buffer .= "</tr>";
         $counter += 2;
     }
     $data_buffer .= "</table>";
     $this->generatePDF($data_buffer, $year, $title);
     //	var_dump($monthly_opening_stocks);
 }
Esempio n. 20
0
 function vaccine($id)
 {
     $data['gantt_data'] = $id;
     $vacc_name = Vaccines::get_Name($id);
     $vacc = $vacc_name["Name"];
     $data['link'] = "task_management";
     $data['content_view'] = "gant_menu_view";
     $data['title'] = "Task Management for " . $vacc;
     $data['report'] = "task_gantt_vaccine";
     $data['scripts'] = array("jquery-ui.js", "tab.js", "FusionWidgets/FusionCharts.js");
     $data['styles'] = array("jquery-ui.css", "tab.css");
     $this->load->view('template', $data);
 }
Esempio n. 21
0
 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;
 }
Esempio n. 22
0
 function nyeri_dashboard()
 {
     $data['link'] = "region_view";
     $year = date('Y');
     $data['province_id'] = 8;
     $data['title'] = "System Dashboard :: Nyeri";
     $data['vaccines'] = Vaccines::getAll_Minified();
     $data['styles'] = array("jquery-ui.css", "tab.css");
     $data['scripts'] = array("FusionCharts/FusionCharts.js", "jquery-ui.js", "advanced_tabs.js");
     $data['content_view'] = "general_specific";
     $data['quick_link'] = "nyeri";
     $data['dashboard_active'] = 1;
     $data['text'] = "Regional Dashboard :: Nyeri";
     $this->load->view('template_regional_dashboard', $data);
 }
 public function download()
 {
     $this->load->database();
     $valid = $this->validate_form();
     if ($valid) {
         $data_buffer = "\n\t\t\t<style>\n\t\t\ttable.data-table {\n\t\t\ttable-layout: fixed;\n\t\t\twidth: 700px;\n\t\t\tborder-collapse:collapse;\n\t\t\tborder:1px solid black;\n\t\t\t}\n\t\t\ttable.data-table td, th {\n\t\t\twidth: 100px;\n\t\t\tborder: 1px solid black;\n\t\t\t}\n\t\t\t.leftie{\n\t\t\t\ttext-align: left !important;\n\t\t\t}\n\t\t\t.center{\n\t\t\t\ttext-align: center !important;\n\t\t\t}\n\t\t\t.right{\n\t\t\t\ttext-align: right !important;\n\t\t\t}\n\t\t\t</style> \n\t\t\t";
         $start_date = $this->input->post("start_date");
         $end_date = $this->input->post("end_date");
         $data_buffer .= "<table class='data-table'>";
         $vaccines = Vaccines::getAll_Minified();
         $data_buffer .= $this->echoTitles($vaccines);
         $population = 0;
         $store = "";
         $district_or_region = $this->session->userdata('district_province_id');
         $identifier = $this->session->userdata('user_identifier');
         $sql_issues = "";
         if ($identifier == 'provincial_officer') {
             $region_object = Regions::getRegion($district_or_region);
             $store = $region_object->name;
             $owner = "R" . $district_or_region;
             $sql_issues = "select vaccine_summaries.*,group_concat(vaccine_id,'-',quantity) as vaccine_issues from (SELECT vaccine_id,sum(Quantity) as quantity,issued_to_region,issued_to_district,issued_to_facility FROM `disbursements` where owner = '" . $owner . "' and Issued_By_Region = '" . $district_or_region . "'  and vaccine_id != '' and str_to_date(date_issued,'%m/%d/%Y') between str_to_date('" . $start_date . "','%m/%d/%Y') and str_to_date('" . $end_date . "','%m/%d/%Y')  group by vaccine_id,issued_to_region,issued_to_district,issued_to_facility) vaccine_summaries group by issued_to_region,issued_to_district,issued_to_facility";
         } else {
             if ($identifier == 'district_officer') {
                 $district_object = Districts::getDistrict($district_or_region);
                 $store = $district_object->name;
                 $owner = "D" . $district_or_region;
                 $sql_issues = "select vaccine_summaries.*,group_concat(vaccine_id,'-',quantity) as vaccine_issues from (SELECT vaccine_id,sum(Quantity) as quantity,issued_to_region,issued_to_district,issued_to_facility FROM `disbursements` where owner = '" . $owner . "' and Issued_By_Region = '" . $district_or_region . "'  and vaccine_id != '' and str_to_date(date_issued,'%m/%d/%Y') between str_to_date('" . $start_date . "','%m/%d/%Y') and str_to_date('" . $end_date . "','%m/%d/%Y')  group by vaccine_id,issued_to_region,issued_to_district,issued_to_facility) vaccine_summaries group by issued_to_region,issued_to_district,issued_to_facility";
             } else {
                 if ($identifier == 'national_officer') {
                     $store = "Central Vaccines Store";
                     $sql_issues = "select vaccine_summaries.*,group_concat(vaccine_id,'-',quantity) as vaccine_issues from (SELECT vaccine_id,sum(Quantity) as quantity,issued_to_region,issued_to_district,issued_to_facility FROM `disbursements` where owner = 'N0' and Issued_By_National = '0'  and vaccine_id != '' and str_to_date(date_issued,'%m/%d/%Y') between str_to_date('" . $start_date . "','%m/%d/%Y') and str_to_date('" . $end_date . "','%m/%d/%Y')  group by vaccine_id,issued_to_region,issued_to_district,issued_to_facility) vaccine_summaries group by issued_to_region,issued_to_district,issued_to_facility";
                 }
             }
         }
         $query = $this->db->query($sql_issues);
         $issues_data = $query->result_array();
         foreach ($issues_data as $recipient_data) {
             $population = 0;
             $recipient = "";
             if (isset($recipient_data['issued_to_region'])) {
                 $population = Regional_Populations::getRegionalPopulation($recipient_data['issued_to_region'], date('Y'));
                 $recipient = Regions::getRegionName($recipient_data['issued_to_region']);
             } else {
                 if (isset($recipient_data['issued_to_district'])) {
                     $population = District_Populations::getDistrictPopulation($recipient_data['issued_to_district'], date('Y'));
                     $recipient = Districts::getDistrictName($recipient_data['issued_to_district']);
                 } else {
                     if (isset($recipient_data['issued_to_facility'])) {
                         $recipient = $recipient_data['issued_to_facility'];
                     }
                 }
             }
             $data_buffer .= "<tr><td style='text-align:left;'>" . $recipient . "</td><td class='right'>" . number_format($population + 0) . "</td>";
             //Get the vaccine data
             $vaccine_data = $recipient_data['vaccine_issues'];
             $separated_data = explode(',', $vaccine_data);
             $final_vaccine_data = array();
             foreach ($separated_data as $vaccine_issue) {
                 $further_separation = explode("-", $vaccine_issue);
                 $final_vaccine_data[$further_separation[0]] = $further_separation[1];
             }
             foreach ($vaccines as $vaccine) {
                 $doses = 0;
                 $mos = 0;
                 $population = str_replace(',', '', $population);
                 if (isset($final_vaccine_data[$vaccine->id])) {
                     $doses = $final_vaccine_data[$vaccine->id];
                 }
                 if ($population != 0 && $doses != 0) {
                     $monthly_requirement = ceil($vaccine->Doses_Required * $population * $vaccine->Wastage_Factor / 12);
                     $mos = number_format($doses / $monthly_requirement, 1);
                 }
                 $data_buffer .= "<td class='right'>" . number_format($doses + 0) . "</td><td class='center'>" . $mos . "</td>";
             }
             $data_buffer .= "</tr>";
         }
         $data_buffer .= "</table>";
         $this->generatePDF($data_buffer, $start_date, $end_date, $store);
     } else {
         $this->view_transactions_interface();
     }
 }
Esempio n. 24
0
 function download($national = "", $region = "", $district = "")
 {
     $title = "";
     $store_fridges = "";
     if ($national > 0) {
         $title = "Cold Chain Utilization at Central Vaccine Store";
         $store_fridges = National_Fridges::getNationalFridges();
     }
     if ($region > 0) {
         $region_object = Regions::getRegion($region);
         $title = "Cold Chain Utilization at " . $region_object->name;
         $store_fridges = Regional_Fridges::getRegionFridges($region);
     }
     if ($district > 0) {
         $district_object = Districts::getDistrict($district);
         $title = "Cold Chain Utilization at " . $district_object->name . " District Store";
         $store_fridges = District_Fridges::getDistrictFridges($district);
     }
     $freezer_vaccines = Fridge_Compartments::getCompartmentVaccines("freezer");
     $fridge_vaccines = Fridge_Compartments::getCompartmentVaccines("fridge");
     $all_vaccines = Vaccines::getAll_Minified();
     $freezer_stock = array();
     $fridge_stock = array();
     $freezer_capacities = array();
     $fridge_capacities = array();
     $now = date("U");
     $total_net_volume_4deg = 0;
     $total_net_volume_minus_20deg = 0;
     $data_buffer = "\n\t\t\t<style>\n\t\t\ttable.data-table {\n\t\t\ttable-layout: fixed;\n\t\t\twidth: 700px;\n\t\t\tborder-collapse:collapse;\n\t\t\tborder:1px solid black;\n\t\t\t}\n\t\t\ttable.data-table td, th {\n\t\t\twidth: 100px;\n\t\t\tborder: 1px solid black;\n\t\t\t}\n\t\t\t.leftie{\n\t\t\t\ttext-align: left !important;\n\t\t\t}\n\t\t\t.right{\n\t\t\t\ttext-align: right !important;\n\t\t\t}\n\t\t\t.center{\n\t\t\t\ttext-align: center !important;\n\t\t\t}\n\t\t\t</style> \n\t\t\t";
     $data_buffer .= "<table class='data-table'>";
     $data_buffer .= $this->echoTitles();
     //Get the total Capacities of all the fridges
     foreach ($store_fridges as $fridge) {
         $total_net_volume_4deg += $fridge->Fridge_Equipment->Net_Vol_4deg;
         $total_net_volume_minus_20deg += $fridge->Fridge_Equipment->Net_Vol_Minus_20deg;
     }
     $freezer_capacity = $total_net_volume_minus_20deg;
     $fridge_capacity = $total_net_volume_4deg;
     //Get the stock balances for each of the vaccines at this point in time
     foreach ($freezer_vaccines as $vaccine) {
         if ($vaccine->Active == "0") {
             continue;
         }
         $volume = $vaccine->Vaccine_Packed_Volume;
         $stock_balance = 0;
         if ($national > 0) {
             $stock_balance = Disbursements::getNationalPeriodBalance($vaccine->id, $now);
         }
         if ($region > 0) {
             $stock_balance = Disbursements::getRegionalPeriodBalance($region, $vaccine->id, $now);
         }
         if ($district > 0) {
             $stock_balance = Disbursements::getDistrictPeriodBalance($district, $vaccine->id, $now);
         }
         $freezer_stock[$vaccine->id] = $stock_balance;
         $volume_occupied = $volume * $stock_balance;
         if ($volume_occupied > 0) {
             $volume_occupied = $volume_occupied / 1000;
             $freezer_capacities[$vaccine->id] = $volume_occupied;
             $total_net_volume_minus_20deg -= $volume_occupied;
         } else {
             $freezer_capacities[$vaccine->id] = 0;
         }
     }
     //Get the stock balances for each of the vaccines at this point in time
     foreach ($fridge_vaccines as $vaccine) {
         if ($vaccine->Active == "0") {
             continue;
         }
         $volume = $vaccine->Vaccine_Packed_Volume;
         $stock_balance = 0;
         if ($national > 0) {
             $stock_balance = Disbursements::getNationalPeriodBalance($vaccine->id, $now);
         }
         if ($region > 0) {
             $stock_balance = Disbursements::getRegionalPeriodBalance($region, $vaccine->id, $now);
         }
         if ($district > 0) {
             $stock_balance = Disbursements::getDistrictPeriodBalance($district, $vaccine->id, $now);
         }
         $volume_occupied = $volume * $stock_balance;
         if ($volume_occupied > 0) {
             $volume_occupied = $volume_occupied / 1000;
             $fridge_capacities[$vaccine->id] = $volume_occupied;
             $total_net_volume_4deg -= $volume_occupied;
         } else {
             $fridge_capacities[$vaccine->id] = 0;
         }
         $fridge_stock[$vaccine->id] = $stock_balance;
     }
     $fridge_totals = 0;
     $freezer_totals = 0;
     foreach ($all_vaccines as $vaccine) {
         $data_buffer .= "<tr><td style='text-align: left;'>" . $vaccine->Name . "</td>";
         if (isset($fridge_capacities[$vaccine->id])) {
             $data_buffer .= "<td class='right'>" . number_format($fridge_stock[$vaccine->id] + 0) . "</td><td  class='right'>" . number_format($fridge_capacities[$vaccine->id] + 0) . "</td><td  class='right'>N/A</td>";
             $fridge_totals += $fridge_capacities[$vaccine->id];
         }
         if (isset($freezer_capacities[$vaccine->id])) {
             $data_buffer .= "<td  class='right'>" . number_format($freezer_stock[$vaccine->id] + 0) . "</td><td  class='right'>N/A</td><td  class='right'>" . number_format($freezer_capacities[$vaccine->id] + 0) . "</td>";
             $freezer_totals += $freezer_capacities[$vaccine->id];
         }
         $data_buffer .= "</tr>";
     }
     $data_buffer .= "<tr><td style='text-align: left;'>Totals</td><td>-</td><td class='right'>" . number_format($fridge_totals + 0) . "</td><td class='right'>" . number_format($freezer_totals + 0) . "</td></tr>";
     $data_buffer .= "</table>";
     $data_buffer .= "<table class='data-table' style='margin-top:50px;'><tr><th>Statistic</th><th>(+2 to +8)</th><th>(-15 to -25)</th></tr>";
     $data_buffer .= "<tr><td style='text-align: left;'>Total Net Volume (Litres)</th><td  class='right'>" . number_format($fridge_capacity, 2) . "</td><td  class='right'>" . number_format($freezer_capacity, 2) . "</td></tr>";
     $data_buffer .= "<tr><td style='text-align: left;'>Total Occupied Capacity (Litres)</td><td  class='right'>" . number_format($fridge_capacity - $total_net_volume_4deg, 2) . "</td><td  class='right'>" . number_format($freezer_capacity - $total_net_volume_minus_20deg, 2) . "</td></tr>";
     $data_buffer .= "<tr><td style='text-align: left;'>Available Capacity (Litres)</td><td  class='right'>" . number_format($total_net_volume_4deg, 2) . "</td><td  class='right'>" . number_format($total_net_volume_minus_20deg, 2) . "</td></tr></table>";
     $this->generatePDF($data_buffer, $title);
     //echo $data_buffer;
 }
Esempio n. 25
0
 public function download_recipients($selected_year = 0, $selected_quarter = 0, $national = 0, $region = 0, $district = 0)
 {
     $title = "";
     if ($national > 0) {
         $title = "Antigen Recipients at Central Vaccine Store";
     }
     if ($region > 0) {
         $region_object = Regions::getRegion($region);
         $title = "Antigen Recipients at " . $region_object->name;
     }
     if ($district > 0) {
         $district_object = Districts::getDistrict($district);
         $title = "Antigen Recipients at " . $district_object->name . " District Store";
     }
     $this->load->database();
     $year = date('Y');
     $quarter = 1;
     $quarter_start_date = 0;
     $quarter_end_date = 0;
     $periods = array(1 => "Jan - Mar", 2 => "Apr - Jun", 3 => "Jul - Sep", 4 => "Oct - Dec");
     if ($selected_year != "0") {
         $year = $selected_year;
     }
     if ($selected_quarter != "0") {
         $quarter = $selected_quarter;
     }
     $vaccines = Vaccines::getAll_Minified();
     //Figure out which quarter has been selected and get the start and end dates for that quarter
     if ($quarter == 1) {
         $quarter_start_date = date("U", mktime(0, 0, 0, 1, 1, $year));
         $quarter_end_date = date("U", mktime(0, 0, 0, 3, 31, $year));
     }
     if ($quarter == 2) {
         $quarter_start_date = date("U", mktime(0, 0, 0, 4, 1, $year));
         $quarter_end_date = date("U", mktime(0, 0, 0, 6, 30, $year));
     }
     if ($quarter == 3) {
         $quarter_start_date = date("U", mktime(0, 0, 0, 7, 1, $year));
         $quarter_end_date = date("U", mktime(0, 0, 0, 9, 30, $year));
     }
     if ($quarter == 4) {
         $quarter_start_date = date("U", mktime(0, 0, 0, 10, 1, $year));
         $quarter_end_date = date("U", mktime(0, 0, 0, 12, 31, $year));
     }
     $data_buffer = "\n\t\t\t<style>\n\t\t\ttable.data-table {\n\t\t\ttable-layout: fixed;\n\t\t\twidth: 700px;\n\t\t\tborder-collapse:collapse;\n\t\t\tborder:1px solid black;\n\t\t\t}\n\t\t\ttable.data-table td, th {\n\t\t\twidth: 100px;\n\t\t\tborder: 1px solid black;\n\t\t\t}\n\t\t\t.leftie{\n\t\t\t\ttext-align: left !important;\n\t\t\t}\n\t\t\t.center{\n\t\t\t\ttext-align: center !important;\n\t\t\t}\n\t\t\t.right{\n\t\t\t\ttext-align: right !important;\n\t\t\t}\n\t\t\t</style> \n\t\t\t";
     $data_buffer .= "<table class='data-table'>";
     $data_buffer .= $this->echoTitles($vaccines);
     $district_data = array();
     foreach ($vaccines as $vaccine_object) {
         $sql_recipients = "";
         //query to get all the districts that received vaccines from the selected store in that period
         if ($national > 0) {
             $sql_recipients = "select districts_issued.*,sum(quantity) as total_received,d2.name as district_name  from (select distinct issued_to_district as district_id from disbursements where owner = 'N0' and issued_to_district>0 and date_issued_timestamp between '" . $quarter_start_date . "' and '" . $quarter_end_date . "') districts_issued left join disbursements d on district_id  = d.issued_to_district left join districts d2 on district_id = d2.ID where date_issued_timestamp between '" . $quarter_start_date . "' and '" . $quarter_end_date . "' and owner != concat('D',district_id) and vaccine_id = '" . $vaccine_object->id . "' group by district_id order by d2.name";
         }
         if ($region > 0) {
             $sql_recipients = "select districts_issued.*,sum(quantity) as total_received,d2.name as district_name  from (select distinct issued_to_district as district_id from disbursements where owner = 'R" . $region . "' and issued_to_district>0 and date_issued_timestamp between '" . $quarter_start_date . "' and '" . $quarter_end_date . "') districts_issued left join disbursements d on district_id  = d.issued_to_district left join districts d2 on district_id = d2.ID where date_issued_timestamp between '" . $quarter_start_date . "' and '" . $quarter_end_date . "' and owner != concat('D',district_id) and vaccine_id = '" . $vaccine_object->id . "' group by district_id order by d2.name";
         }
         if ($district > 0) {
             $sql_recipients = "select districts_issued.*,sum(quantity) as total_received,d2.name as district_name  from (select distinct issued_to_district as district_id from disbursements where owner = 'D" . $district . "' and issued_to_district>0 and date_issued_timestamp between '" . $quarter_start_date . "' and '" . $quarter_end_date . "') districts_issued left join disbursements d on district_id  = d.issued_to_district left join districts d2 on district_id = d2.ID where date_issued_timestamp between '" . $quarter_start_date . "' and '" . $quarter_end_date . "' and owner != concat('D',district_id) and vaccine_id = '" . $vaccine_object->id . "' group by district_id order by d2.name";
         }
         $query = $this->db->query($sql_recipients);
         $recipients_data = $query->result_array();
         $consumption = array();
         $forecast = array();
         $districts = array();
         $counter = 0;
         $max_forecast = 0;
         foreach ($recipients_data as $recipient_district) {
             $population = District_Populations::getDistrictPopulation($recipient_district['district_id'], date('Y'));
             $monthly_requirement = 0;
             if ($population > 0) {
                 $monthly_requirement = ceil($vaccine_object->Doses_Required * $population * $vaccine_object->Wastage_Factor / 12);
             }
             $monthly_requirement *= 3;
             if ($monthly_requirement > $max_forecast) {
                 $max_forecast = $monthly_requirement;
             }
             $forecast[$counter] = $monthly_requirement;
             $consumption[$counter] = $recipient_district['total_received'];
             $districts[$counter] = $recipient_district['district_name'];
             $district_data[$recipient_district['district_id']]['district'] = $recipient_district['district_name'];
             $district_data[$recipient_district['district_id']][$vaccine_object->id] = array('vaccine' => $vaccine_object->id, 'forecast' => $monthly_requirement, 'consumption' => $recipient_district['total_received']);
             $counter++;
         }
     }
     //var_dump($district_data);
     foreach ($district_data as $row_data) {
         $data_buffer .= "<tr><td class='leftie'>" . $row_data['district'] . "</td>";
         foreach ($vaccines as $vaccine_object) {
             if (isset($row_data[$vaccine_object->id])) {
                 $data_buffer .= "<td class='right'>" . number_format($row_data[$vaccine_object->id]['forecast'] + 0) . "</td><td class='right'>" . number_format($row_data[$vaccine_object->id]['consumption'] + 0) . "</td>";
             } else {
                 $data_buffer .= "<td class='center'>-</td><td class='center'>-</td>";
             }
         }
         $data_buffer .= "</tr>";
     }
     $data_buffer .= "</table>";
     $this->generatePDF($data_buffer, $periods[$quarter], $year, $title);
     //echo $data_buffer;
 }
Esempio n. 26
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;
}
Esempio n. 27
0
 public function provisional_plan($vaccine)
 {
     $plan = Provisional_Plan::getCurrentPlan($vaccine);
     $data['plans'] = $plan;
     $data['vaccine'] = Vaccines::getVaccine($vaccine);
     $data['title'] = "Stock Management:: " . date('Y') . " Provisional Plan For " . $data['vaccine']->Name;
     $data['content_view'] = "plan_view";
     $this->base_params($data);
 }
Esempio n. 28
0
 <?php 
 foreach($tasks as $task){?>
 <tr>
 	<td>
 		<?php
 			$task_id = $task->task_id;
			$task_name = Tasks::get_task_name($task_id);
			echo ($task_name[0]["name"]) ;
 		?>
 		
 	</td>
 	<td>
 		<?php
 			
 			$vacc_id = $task->vaccine_id;
			$vacc_name = Vaccines::get_Name($vacc_id);
			echo($vacc_name["Name"]) ;
 		?>
 		
 	</td>
 <td>
 <?php echo $task->Initiate_date;?>
 </td> 
   <td>
 <?php echo $task->expected_end_date;?>
 </td>
    <td>
 <?php echo $task->end_date;?>
 </td>
  <td>
 <?php echo $task->Initiator_name;?>
Esempio n. 29
0
    public function get($type, $id, $vaccine, $year = "")
    {
        $monthly_opening_stocks = array();
        if ($year == "") {
            $year = date('Y');
        }
        $year_start = date("U", mktime(0, 0, 0, 1, 1, $year));
        $vaccine_object = Vaccines::getVaccine($vaccine);
        $counter = 2;
        if ($type == 0) {
            //Regional Store
            $population = regional_populations::getRegionalPopulation($id, $year);
            $population = str_replace(",", "", $population);
            $monthly_requirement = ceil($vaccine_object->Doses_Required * $population * $vaccine_object->Wastage_Factor / 12);
            for ($month = 1; $month <= 36; $month++) {
                //Get the month
                $month_number = $counter / 3;
                //If it is an even number, get values for the 21st, if it's odd, get values for the 7th
                if ($month % 3 == 0) {
                    $month_date = 7;
                } else {
                    if ($month % 3 == 1) {
                        $month_date = 21;
                    } else {
                        if ($month % 3 == 2) {
                            $month_date = 28;
                        }
                    }
                }
                $to = date("U", mktime(0, 0, 0, $month_number, $month_date, $year));
                $monthly_opening_stocks[$month] = Disbursements::getRegionalPeriodBalance($id, $vaccine, $to);
                $counter += 3;
            }
            $upper_limit = $monthly_requirement * 4;
            $lower_limit = $monthly_requirement;
        } else {
            if ($type == 1) {
                //District Store
                $population = district_populations::getDistrictPopulation($id, $year);
                $population = str_replace(",", "", $population);
                $monthly_requirement = ceil($vaccine_object->Doses_Required * $population * $vaccine_object->Wastage_Factor / 12);
                for ($month = 1; $month <= 36; $month++) {
                    //Get the month
                    $month_number = $counter / 2;
                    //If it is an even number, get values for the 21st, if it's odd, get values for the 7th
                    if ($month % 3 == 0) {
                        $month_date = 7;
                    } else {
                        if ($month % 3 == 1) {
                            $month_date = 21;
                        } else {
                            if ($month % 3 == 2) {
                                $month_date = 28;
                            }
                        }
                    }
                    $to = date("U", mktime(0, 0, 0, $month_number, $month_date, $year));
                    $monthly_opening_stocks[$month] = Disbursements::getDistrictPeriodBalance($id, $vaccine, $to);
                    $counter += 2;
                }
                $upper_limit = $monthly_requirement * 2;
                $lower_limit = ceil($monthly_requirement / 2);
            } else {
                if ($type == 2) {
                    //National Store
                    $population = regional_populations::getNationalPopulation($year);
                    $population = str_replace(",", "", $population);
                    $monthly_requirement = ceil($vaccine_object->Doses_Required * $population * $vaccine_object->Wastage_Factor / 12);
                    for ($month = 1; $month <= 36; $month++) {
                        //Get the month
                        $month_number = $counter / 2;
                        //If it is an even number, get values for the 21st, if it's odd, get values for the 7th
                        if ($month % 3 == 0) {
                            $month_date = 7;
                        } else {
                            if ($month % 3 == 1) {
                                $month_date = 21;
                            } else {
                                if ($month % 3 == 2) {
                                    $month_date = 28;
                                }
                            }
                        }
                        $to = date("U", mktime(0, 0, 0, $month_number, $month_date, $year));
                        $monthly_opening_stocks[$month] = Disbursements::getNationalPeriodBalance($vaccine, $to);
                        $counter += 2;
                    }
                    $upper_limit = $monthly_requirement * 4;
                    $lower_limit = $monthly_requirement;
                }
            }
        }
        $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=""/>
<category label=""/>
<category label="Feb"/>
<category label=""/>
<category label=""/>
<category label="Mar"/>
<category label=""/>
<category label=""/>
<category label="Apr"/>
<category label=""/>
<category label=""/>
<category label="May"/>
<category label=""/>
<category label=""/>
<category label="Jun"/>
<category label=""/>
<category label=""/>
<category label="Jul"/>
<category label=""/>
<category label=""/>
<category label="Aug"/>
<category label=""/>
<category label=""/>
<category label="Sep"/>
<category label=""/>
<category label=""/>
<category label="Oct"/>
<category label=""/>
<category label=""/>
<category label="Nov"/>
<category label=""/>
<category label=""/>
<category label="Dec"/>
<category label=""/>
<category label=""/>
</categories> 
<dataset seriesName="Upper Limit" color="269600" anchorBorderColor="269600" anchorBgColor="269600">';
        for ($x = 1; $x <= 36; $x++) {
            $cumulative_value = $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] . '"/>
<set  value="' . $monthly_opening_stocks[13] . '"/>
<set  value="' . $monthly_opening_stocks[14] . '"/>
<set  value="' . $monthly_opening_stocks[15] . '"/>
<set value="' . $monthly_opening_stocks[16] . '"/>
<set  value="' . $monthly_opening_stocks[17] . '"/>
<set value="' . $monthly_opening_stocks[18] . '"/>
<set  value="' . $monthly_opening_stocks[19] . '"/>
<set  value="' . $monthly_opening_stocks[20] . '"/>
<set  value="' . $monthly_opening_stocks[21] . '"/>
<set  value="' . $monthly_opening_stocks[22] . '"/>
<set  value="' . $monthly_opening_stocks[23] . '"/>
<set value="' . $monthly_opening_stocks[24] . '"/>
<set value="' . $monthly_opening_stocks[25] . '"/>
<set  value="' . $monthly_opening_stocks[26] . '"/>
<set  value="' . $monthly_opening_stocks[27] . '"/>
<set  value="' . $monthly_opening_stocks[28] . '"/>
<set value="' . $monthly_opening_stocks[29] . '"/>
<set  value="' . $monthly_opening_stocks[30] . '"/>
<set value="' . $monthly_opening_stocks[31] . '"/>
<set  value="' . $monthly_opening_stocks[32] . '"/>
<set  value="' . $monthly_opening_stocks[33] . '"/>
<set  value="' . $monthly_opening_stocks[34] . '"/>
<set  value="' . $monthly_opening_stocks[35] . '"/>
<set  value="' . $monthly_opening_stocks[36] . '"/> 
</dataset>
<dataset seriesName="Lower Limit" color="FF0000" anchorBorderColor="FF0000" anchorBgColor="FF0000">';
        for ($x = 1; $x <= 36; $x++) {
            $cumulative_value = $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;
    }
Esempio n. 30
0
 function download_forecast($vaccine = 0, $year = "0", $national = 0, $region = 0, $district = 0)
 {
     $population = 0;
     if ($year == "0") {
         $year = date('Y');
     }
     $title = "";
     if ($national > 0) {
         $title = "Consumption vs. Forecast at Central Vaccine Store";
         $population = regional_populations::getNationalPopulation($year);
     }
     if ($region > 0) {
         $region_object = Regions::getRegion($region);
         $title = "Consumption vs. Forecast at " . $region_object->name;
         $population = Regional_Populations::getRegionalPopulation($region, $year);
     }
     if ($district > 0) {
         $district_object = Districts::getDistrict($district);
         $title = "Consumption vs. Forecast at " . $district_object->name . " District Store";
         $population = District_Populations::getDistrictPopulation($district, $year);
     }
     $population = str_replace(",", "", $population);
     $vaccines = Vaccines::getAll_Minified();
     $date = date("m/d/Y");
     $months_required = array();
     $data_buffer = "\n\t\t\t<style>\n\t\t\ttable.data-table {\n\t\t\ttable-layout: fixed;\n\t\t\twidth: 700px;\n\t\t\tborder-collapse:collapse;\n\t\t\tborder:1px solid black;\n\t\t\t}\n\t\t\ttable.data-table td, th {\n\t\t\twidth: 100px;\n\t\t\tborder: 1px solid black;\n\t\t\t}\n\t\t\t.leftie{\n\t\t\t\ttext-align: left !important;\n\t\t\t}\n\t\t\t.center{\n\t\t\t\ttext-align: center !important;\n\t\t\t}\n\t\t\t.right{\n\t\t\t\ttext-align: right !important;\n\t\t\t}\n\t\t\t</style> \n\t\t\t";
     $data_buffer .= "<table class='data-table'>";
     $data_buffer .= $this->echoTitles();
     //Get the start and end dates for all the quarters
     $quarter_one_start = date("U", mktime(0, 0, 0, 1, 1, $year));
     $quarter_one_end = date("U", mktime(0, 0, 0, 3, 31, $year));
     $quarter_two_start = date("U", mktime(0, 0, 0, 4, 1, $year));
     $quarter_two_end = date("U", mktime(0, 0, 0, 6, 30, $year));
     $quarter_three_start = date("U", mktime(0, 0, 0, 7, 1, $year));
     $quarter_three_end = date("U", mktime(0, 0, 0, 9, 30, $year));
     $quarter_four_start = date("U", mktime(0, 0, 0, 10, 1, $year));
     $quarter_four_end = date("U", mktime(0, 0, 0, 12, 31, $year));
     foreach ($vaccines as $vaccine_object) {
         $months_of_stock = array();
         $now = date('U');
         //Get the consumption for each of the quarters
         //Set the maximum value
         $max_value = 0;
         //Get the consumption for each of the quarters
         if ($national > 0) {
             $quarter_one_consumption = Disbursements::getNationalIssuesTotals($vaccine_object->id, $quarter_one_start, $quarter_one_end);
             $quarter_two_consumption = Disbursements::getNationalIssuesTotals($vaccine_object->id, $quarter_two_start, $quarter_two_end);
             $quarter_three_consumption = Disbursements::getNationalIssuesTotals($vaccine_object->id, $quarter_three_start, $quarter_three_end);
             $quarter_four_consumption = Disbursements::getNationalIssuesTotals($vaccine_object->id, $quarter_four_start, $quarter_four_end);
         }
         if ($region > 0) {
             $quarter_one_consumption = Disbursements::getRegionalIssuesTotals($vaccine_object->id, $quarter_one_start, $quarter_one_end, $region);
             $quarter_two_consumption = Disbursements::getRegionalIssuesTotals($vaccine_object->id, $quarter_two_start, $quarter_two_end, $region);
             $quarter_three_consumption = Disbursements::getRegionalIssuesTotals($vaccine_object->id, $quarter_three_start, $quarter_three_end, $region);
             $quarter_four_consumption = Disbursements::getRegionalIssuesTotals($vaccine_object->id, $quarter_four_start, $quarter_four_end, $region);
         }
         if ($district > 0) {
             $quarter_one_consumption = Disbursements::getDistrictIssuesTotals($district, $vaccine_object->id, $quarter_one_start, $quarter_one_end);
             $quarter_two_consumption = Disbursements::getDistrictIssuesTotals($district, $vaccine_object->id, $quarter_two_start, $quarter_two_end);
             $quarter_three_consumption = Disbursements::getDistrictIssuesTotals($district, $vaccine_object->id, $quarter_three_start, $quarter_three_end);
             $quarter_four_consumption = Disbursements::getDistrictIssuesTotals($district, $vaccine_object->id, $quarter_four_start, $quarter_four_end);
         }
         $monthly_requirement = ceil($vaccine_object->Doses_Required * $population * $vaccine_object->Wastage_Factor / 12);
         $quarterly_consumption = $monthly_requirement * 3;
         $data_buffer .= "<tr><td class='leftie'>" . $vaccine_object->Name . "</td><td class='right'>" . number_format($quarterly_consumption) . "</td><td class='right'>" . number_format($quarter_one_consumption) . "</td><td class='right'>" . number_format($quarterly_consumption - $quarter_one_consumption) . "</td><td class='right'>" . number_format($quarter_two_consumption) . "</td><td class='right'>" . number_format($quarterly_consumption - $quarter_two_consumption) . "</td><td class='right'>" . number_format($quarter_three_consumption) . "</td><td class='right'>" . number_format($quarterly_consumption - $quarter_three_consumption) . "</td><td class='right'>" . number_format($quarter_four_consumption) . "</td><td class='right'>" . number_format($quarterly_consumption - $quarter_four_consumption) . "</td></tr>";
     }
     $data_buffer .= "</table>";
     $this->generatePDF($data_buffer, $year, $title);
     echo $data_buffer;
 }