public function getKecamatan()
 {
     $dataInstansi = DataInstansi::find(1);
     $kabKotaId = $dataInstansi->kabkota_id;
     $data = ['list' => Districts::whereRegencyId($kabKotaId)->get()];
     return View::make('admin.option', $data);
 }
Esempio n. 2
0
 public function plot($vaccine)
 {
     // Initiate class
     $xml = new MY_Xml_writer();
     $xml->setRootName('markers');
     $xml->initiate();
     $year = date('U');
     $mapped_districts = Districts::getMappedDistricts();
     $mapped_regions = Regions::getAllRegions();
     foreach ($mapped_districts as $mapped_district) {
         //$stock = Disbursements::getDistrictStockAtHand($mapped_district->id,$vaccine);
         $stock = Disbursements::getDistrictPeriodBalance($mapped_district->id, $vaccine, $year);
         $xml->startBranch('marker', array('name' => $mapped_district->name . " District Store", 'lat' => $mapped_district->latitude, 'lng' => $mapped_district->longitude, 'facility_id' => $mapped_district->id, 'stock' => $stock));
         // start branch 1-1
         $xml->endBranch();
     }
     foreach ($mapped_regions as $mapped_region) {
         // $stock = Disbursements::getRegionalStockAtHand($mapped_region->id,$vaccine);
         $stock = Disbursements::getRegionalPeriodBalance($mapped_region->id, $vaccine, $year);
         $xml->startBranch('marker', array('name' => $mapped_region->name, 'lat' => $mapped_region->latitude, 'lng' => $mapped_region->longitude, 'facility_id' => $mapped_region->id, 'stock' => $stock));
         // start branch 1-1
         $xml->endBranch();
     }
     //$stock = Disbursements::getNationalStockAtHand($vaccine);
     $stock = Disbursements::getNationalPeriodBalance($vaccine, $year);
     $xml->startBranch('marker', array('name' => "Central Vaccine Store", 'lat' => "-1.304507", 'lng' => "36.806191", 'facility_id' => 0, 'stock' => $stock));
     // start branch 1-1
     $xml->endBranch();
     // Print the XML to screen
     $xml->getXml(true);
 }
Esempio n. 3
0
 public function facility_offline()
 {
     $identifier = $this->session->userdata('user_indicator');
     $user_type_id = $this->session->userdata('user_type_id');
     $district = $this->session->userdata('district_id');
     // echo $identifier;exit;
     $county = $this->session->userdata('county_id');
     // $data['facilities'] = isset($district) ? Facilities::get_facility_details($district) : Facilities::get_facilities_per_county($county);
     if ($identifier == "district") {
         $data['facilities'] = Facilities::get_facility_details($district);
         $data['identifier'] = $identifier;
     } elseif ($identifier == "county") {
         $data['facilities'] = Facilities::get_facility_details(NULL, $county);
         $data['identifier'] = $identifier;
         $data['district_info'] = Districts::get_districts($county);
     }
     $permissions = 'district_permissions';
     // $data['facilities']=Facilities::get_facility_details($district);
     // $data['facilities']=Facilities::get_facilities_per_county($county);
     // echo "<pre>";print_r($data['facilities']);echo "</pre>";exit;
     $data['title'] = "Offline Facility Setup";
     $data['banner_text'] = "Setup Facility Offline";
     $template = 'shared_files/template/template';
     // $data['sidebar'] = "shared_files/report_templates/side_bar_sub_county_v";
     $data['active_panel'] = 'system_usage';
     // $data['report_view'] = "shared_files/Facility_activation_v";
     $data['content_view'] = "shared_files/facility_offline";
     $this->load->view($template, $data);
 }
Esempio n. 4
0
 public function add_recipient($data = null)
 {
     $data['title'] = "District Stock Outs";
     $data['quick_link'] = "district_stock_out";
     $data['districts'] = Districts::getAllDistricts();
     $data['report'] = "add_stock_out_recipient_view";
     $this->base_params($data);
 }
Esempio n. 5
0
 public function init()
 {
     $this->states = States::model()->findAll('country_id=:country_id', array(':country_id' => 1));
     $this->districts = Districts::model()->findAll();
     $this->functionalAreas_models = FunctionalAreas::model()->findAll();
     $this->latest_posts = Post::model()->findAll(array('order' => 'id DESC', 'limit' => 5));
     $this->latest_resumes = User::model()->findAllByAttributes(array('showOnSearch' => 'Y'), array('order' => 'id DESC', 'limit' => 5));
 }
 public function edit($id)
 {
     $dataInstansi = DataInstansi::find(1);
     $kabKotaId = $dataInstansi->kabkota_id;
     $data['kecamatan'] = Districts::whereRegencyId($kabKotaId)->get();
     $data['datawartel'] = $this->wartel->tampilData($id);
     return View::make('admin.warteledit', $data);
 }
Esempio n. 7
0
 public function actionDistricts()
 {
     $districts = Districts::model()->findAll('state_id=:state_id', array(':state_id' => (int) $_POST[$_GET['form']]['state']));
     $districts = CHtml::listData($districts, 'id', 'district');
     echo CHtml::tag('option', array('value' => ''), CHtml::encode('Select District'), true);
     foreach ($districts as $value => $name) {
         echo CHtml::tag('option', array('value' => $value), CHtml::encode($name), true);
     }
 }
 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. 9
0
 public function edit($id)
 {
     $data['datatower'] = $this->tower_bts->tampilData($id);
     //kecamatan
     $dataInstansi = DataInstansi::find(1);
     $kabKotaId = $dataInstansi->kabkota_id;
     $data['kecamatan'] = Districts::whereRegencyId($kabKotaId)->get();
     $data['datapemilik'] = DataPemilik::all();
     return View::make('admin.toweredit', $data);
 }
Esempio n. 10
0
	public function edit_user($id) {
		$user = User::getUser($id);
		$data['user'] = $user;
		$data['title'] = "User Management::Edit " . $user -> Full_Name . "'s Details";
		$data['title'] = "User Management::Add New User";
		$data['module_view'] = "add_user_view";
		$data['groups'] = User_Groups::getAllGroups();
		$data['districts'] = Districts::getAllDistricts();
		$data['regions'] = Regions::getAllRegions();
		$this -> base_params($data);
	}
Esempio n. 11
0
 public function edit($id)
 {
     if (Auth::check() && (Auth::user()->id == $id || Auth::user()->access == 1)) {
         $tutor = Tutor::firstOrCreate(['id' => $id]);
         $subjects = Subjects::all();
         $levels = Subjects::getLevels();
         $districts = Districts::all();
         $subject = Input::get('sublevel');
         $district = Input::get('district');
         return View::make('edit_profile')->with(compact(['tutors', 'subjects', 'levels', 'districts']));
     }
     return View::make('login');
 }
Esempio n. 12
0
 public function manage_users()
 {
     $permissions = 'super_permissions';
     $data['title'] = "Users";
     $data['content_view'] = "Admin/users_v";
     $data['listing'] = Users::get_user_list_all();
     $data['counts'] = Users::get_users_count();
     $data['counties'] = Counties::getAll();
     $data['facilities'] = Facilities::getAll();
     $data['sub_counties'] = Districts::getAll();
     $data['user_types'] = Access_level::get_access_levels($permissions);
     $this->load->view("shared_files/template/dashboard_v", $data);
 }
Esempio n. 13
0
 public function getDistrict()
 {
     //for ajax
     $county = $_POST['county'];
     $districts = Districts::getDistrict($county);
     $list = "";
     foreach ($districts as $districts) {
         $list .= $districts->id;
         $list .= "*";
         $list .= $districts->district;
         $list .= "_";
     }
     echo $list;
 }
 public function district_potential_expiries($district = NULL)
 {
     $date = date('Y-m-d');
     $county = $this->session->userdata('county_id');
     $data['title'] = "Expired Products";
     $data['content_view'] = "county/district_potential_expiries_v";
     $data['banner_text'] = "Expired Products";
     $data['expired'] = Districts::get_district_expiries($date, $district);
     $data['potential_expiries'] = Counties::get_potential_expiry_summary($county);
     $data['link'] = "county/district_expiries_v";
     $data['quick_link'] = "county/district_expiries_v";
     $data['table_body'] = "";
     if (count($data['potential_expiries']) > 0) {
         foreach ($data['potential_expiries'] as $item) {
             $data['table_body'] .= "<tr><td>" . $item['facility_code'] . "</td>\n\t\t\t<td>" . $item['facility_name'] . "</td>\n\t\t\t<td>" . $item['balance'] . "</td>\n\t\t\t<td><a href=" . site_url('stock_expiry_management/county_potential_expiries/' . $item['facility_code']) . " class='link'>View</a></td>\n\t\t\t</tr>}";
         }
     } else {
         $data['table_body'] = "<div id='notification'>No records found</div>";
     }
     $this->load->view("county/district_potential_expiries_v", $data);
 }
Esempio n. 15
0
 public function rtk_allocation($msg = NULL)
 {
     $district = $this->session->userdata('district_id');
     $district_name = Districts::get_district_name($district)->toArray();
     $countyid = $this->session->userdata('county_id');
     $data['countyid'] = $countyid;
     $d_name = $district_name[0]['district'];
     $data['title'] = "Allocations";
     $data['content_view'] = "rtk/rtk/dpp/rtk_allocation_v";
     $data['banner_text'] = $d_name . "Allocation";
     //        $data['lab_order_list'] = Lab_Commodity_Orders::get_district_orders($district);
     ini_set('memory_limit', '-1');
     $start_date = date("Y-m-", strtotime("-3 Month "));
     $start_date .= '1';
     $end_date = date('Y-m-d', strtotime("last day of previous month"));
     $allocations = $this->_allocation(NULL, $county = NULL, $district, $facility = NULL, $sincedate = NULL, $enddate = NULL);
     $data['lab_order_list'] = $allocations;
     $data['all_orders'] = Lab_Commodity_Orders::get_district_orders($district);
     $myobj = Doctrine::getTable('districts')->find($district);
     $data['myClass'] = $this;
     $data['msg'] = $msg;
     $data['d_name'] = $d_name;
     $this->load->view("rtk/template", $data);
 }
Esempio n. 16
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. 17
0
 public function get_county_email($county_id)
 {
     !isset($county_id) ? exit : null;
     // added function on user
     $county = Districts::get_county_id($county_id);
     $county_email = Users::get_county_details($county[0]['county']);
     if ($this->test_mode) {
         return null;
     }
     //check to ensure the demo site wount start looking for county admin
     if ($county[0]['county'] == 1) {
         return 'kelvinmwas@gmail.com,';
     } else {
         if (count($county_email) > 0) {
             return $county_email[0]['email'] . ',';
         } else {
             return "";
         }
     }
 }
Esempio n. 18
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;
 }
 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. 20
0
 public function user_create_multiple($facility_code = null)
 {
     //get user details in session
     $identifier = $this->session->userdata('user_indicator');
     $user_type_id = $this->session->userdata('user_type_id');
     $district = $this->session->userdata('district_id');
     $county = $this->session->userdata('county_id');
     $facility = $this->session->userdata('facility_id');
     //query to get user listing by type of user
     switch ($identifier) {
         case 'moh':
             $permissions = 'moh_permissions';
             $template = 'shared_files/template/dashboard_template_v';
             break;
         case 'facility_admin':
             $permissions = 'facilityadmin_permissions';
             $data['listing'] = Users::get_user_list_facility($facility);
             $template = 'shared_files/template/template';
             break;
         case 'district':
             $permissions = 'district_permissions';
             $data['listing'] = Users::get_user_list_district($district);
             if ($facility_code == 0) {
                 $data['facilities'] = Facilities::getFacilities($district);
                 $facility_name = null;
                 $facility_banner_text = null;
                 $no_of_facilities = 0;
             } else {
                 $data['facilities'] = Facilities::getFacilities_from_facility_code($facility_code);
                 $facility_banner_text = ' to: ' . $data['facilities'][0]['facility_name'];
                 $facility_name = $data['facilities'][0]['facility_name'];
                 $no_of_facilities = 1;
             }
             $data['counts'] = Users::get_users_district($district);
             $template = 'shared_files/template/template';
             break;
         case 'moh_user':
             $data['listing'] = Users::get_user_list($user_type_id);
             $template = 'shared_files/template/dashboard_template_v';
             break;
         case 'district_tech':
             $data['listing'] = Users::get_user_list($user_type_id);
             $template = 'shared_files/template/template';
             break;
         case 'rtk_manager':
             $data['listing'] = Users::get_user_list($user_type_id);
             $template = 'shared_files/template/template';
             break;
         case 'super_admin':
             $permissions = 'super_permissions';
             $data['title'] = "Users";
             $data['content_view'] = "Admin/users_v";
             $data['listing'] = Users::get_user_list_all();
             $data['counts'] = Users::get_users_count();
             $data['counties'] = Counties::getAll();
             $template = 'shared_files/template/dashboard_v';
             break;
         case 'allocation_committee':
             $data['listing'] = Users::get_user_list($user_type_id);
             $template = 'shared_files/template/template';
             break;
         case 'county':
             $permissions = 'county_permissions';
             if ($facility_code == 0) {
                 $data['facilities'] = Facilities::getFacilities($district);
                 $facility_name = null;
                 $facility_banner_text = null;
                 $district_name = null;
                 $district_id = null;
                 $no_of_facilities = 0;
             } else {
                 $data['facilities'] = Facilities::getFacilities_from_facility_code($facility_code);
                 $facility_banner_text = ' to: ' . $data['facilities'][0]['facility_name'];
                 $facility_name = $data['facilities'][0]['facility_name'];
                 $district_id = $data['facilities'][0]['district'];
                 $district_data = Districts::get_district_name($district_id);
                 $district_name = $district_data[0]['district'];
                 $no_of_facilities = 1;
             }
             $data['listing'] = Users::get_user_list_county($county);
             $data['district_data'] = districts::getDistrict($county);
             $data['counts'] = Users::get_users_county($county);
             $template = 'shared_files/template/template';
             break;
     }
     $data['title'] = "Add Multiple Users";
     $data['user_types'] = Access_level::get_access_levels($permissions);
     $data['banner_text'] = "Multiple User Addition";
     $data['facility_name'] = $facility_name;
     $data['facility_code'] = $facility_code;
     $data['facility_banner_text'] = $facility_banner_text;
     $data['district_name'] = $district_name;
     $data['district_id'] = $district_id;
     $data['no_of_facilities'] = $no_of_facilities;
     $data['content_view'] = "shared_files/add_users_multiple";
     $this->load->view($template, $data);
 }
Esempio n. 21
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. 22
0
 Route::get('admin-page/wartel/tambah', function () {
     $dataInstansi = DataInstansi::find(1);
     $kabKotaId = $dataInstansi->kabkota_id;
     $data['kecamatan'] = Districts::whereRegencyId($kabKotaId)->get();
     return View::make('admin.warteltambah', $data);
 });
 Route::post('admin-page/wartel/simpan', 'wartelController@simpan');
 Route::get('admin-page/wartel/edit/{id}', 'wartelController@edit');
 Route::post('admin-page/wartel/proses-edit', 'wartelController@prosesEdit');
 Route::get('admin-page/wartel/hapus/{id}', 'wartelController@hapus');
 //Warnet
 Route::get('admin-page/warnet', 'warnetController@admintampil');
 Route::get('admin-page/warnet/tambah', function () {
     $dataInstansi = DataInstansi::find(1);
     $kabKotaId = $dataInstansi->kabkota_id;
     $data['kecamatan'] = Districts::whereRegencyId($kabKotaId)->get();
     return View::make('admin.warnettambah', $data);
 });
 Route::post('admin-page/warnet/simpan', 'warnetController@simpan');
 Route::get('admin-page/warnet/edit/{id}', 'warnetController@edit');
 Route::post('admin-page/warnet/proses-edit', 'warnetController@prosesEdit');
 Route::get('admin-page/warnet/hapus/{id}', 'warnetController@hapus');
 //Radio
 Route::get('admin-page/radio', 'radioController@admintampil');
 Route::get('admin-page/radio/tambah', function () {
     return View::make('admin.radiotambah');
 });
 Route::post('admin-page/radio/simpan', 'radioController@simpan');
 Route::get('admin-page/radio/edit/{id}', 'radioController@edit');
 Route::post('admin-page/radio/proses-edit', 'radioController@prosesEdit');
 Route::get('admin-page/radio/hapus/{id}', 'radioController@hapus');
	public function view_ledger($type, $id, $paged_vaccine = null, $date_from = null, $date_to = null, $offset = 0, $default_offset = 0) {
		$data['type'] = $type;
		//get current district/region
		$district_or_province = $this -> session -> userdata('district_province_id');
		//get current level
		$identifier = $this -> session -> userdata('user_identifier');
		$dummy_identifier = "";
		//Determine if the user is trying to view the ledger for his/her own store
		//Type 0 means we are drilling down to a region
		if ($type == 0) {
			if ($identifier == "provincial_officer" && $district_or_province == $id) {
				redirect("disbursement_management/view_disbursements");
			}
			$dummy_identifier = "provincial_officer";
		}
		//Type 1 means we are drilling down to a district
		else if ($type == 1) {
			if ($identifier == "district_officer" && $district_or_province == $id) {
				redirect("disbursement_management/view_disbursements");
			}
			$dummy_identifier = "district_officer";
		}
		//Type 2 means we are drilling down to the whole country
		else if ($type == 2) {
			if ($identifier == "national_officer") {
				redirect("disbursement_management/view_disbursements");
			}
			$dummy_identifier = "national_officer";
		}
		$data['identifier'] = $dummy_identifier;
		$data['district_or_province'] = $id;

		$district_or_province = $id;
		//Now display the 'foreign' ledger
		$to = $this -> input -> post('to');
		$from = $this -> input -> post('from');
		$store = $this -> input -> post('selected_store_id');
		$order_by = $this -> input -> post('order_by');
		$order = $this -> input -> post('order');
		$per_page = $this -> input -> post('per_page');
		if ($to == false) {
			$to = date("U", mktime(0, 0, 0, 1, 1, date("Y") + 1));
		} else if ($to == true) {
			$to = strtotime($to);
		}
		if ($from == false) {
			$from = date("U", mktime(0, 0, 0, 1, 1, date('Y')));
		} else if ($from == true) {
			$from = strtotime($from);
		}

		if ($date_from != null) {
			$from = $date_from;
		} else if ($date_to != null) {
			$to = $date_to;
		}

		//Check if the user has specified how many items he/she wants per page. If not, default to 10 items per page.
		if ($per_page > 0) {
			$this -> session -> set_userdata(array("external_from" => $from, "external_to" => $to, "external_per_page" => $per_page, "external_order_by" => $order_by, "external_order" => $order));
		} else {
			$temp = $this -> session -> userdata('external_per_page');
			if ($temp == false) {
				$this -> session -> set_userdata(array("external_from" => $from, "external_to" => $to, "external_per_page" => 10, "external_order_by" => "Date_Issued_Timestamp", "external_order" => "DESC"));
			}
		}
		$items_per_page = $this -> session -> userdata('external_per_page');
		$order_by = $this -> session -> userdata('external_order_by');
		$order = $this -> session -> userdata('external_order');

		$region = 0;
		$district = 0;
		if ($store != null) {
			$split_parts = explode("_", $store);
			$type = $split_parts[0];
			$id = $split_parts[1];
			if ($type == "district") {
				$district = $id;
				$this -> session -> set_userdata(array("external_region" => ""));
				$this -> session -> set_userdata(array("external_district" => $district));
			} else if ($type == "region") {
				$region = $id;
				$this -> session -> set_userdata(array("external_district" => ""));
				$this -> session -> set_userdata(array("external_region" => $region));
			} else if ($type == "national") {
				$this -> session -> set_userdata(array("external_district" => ""));
				$this -> session -> set_userdata(array("external_region" => ""));
			}
		}
		$district = $this -> session -> userdata('external_district');
		$region = $this -> session -> userdata('external_region');
		$data['vaccines'] = Vaccines::getAll_Minified();
		$return_array = array();
		$balances = array();

		if ($type == 2) {//National Level
			$recipient = "Central Vaccines Store";
			foreach ($data['vaccines'] as $vaccine) {
				//skip the vaccine that is currently being browsed through
				if ($vaccine -> id == $paged_vaccine) {
					continue;
				}
				$total_disbursements = Disbursements::getTotalNationalDisbursements($vaccine -> id, $from, $to, $district, $region);

				if ($total_disbursements > $items_per_page) {
					$config['base_url'] = base_url() . "external_ledger_management/view_ledger/" . $type . "/" . $id . "/" . $vaccine -> id . "/" . $from . "/" . $to;
					$config['total_rows'] = $total_disbursements;
					$config['per_page'] = $items_per_page;
					$config['uri_segment'] = 9;
					$config['num_links'] = 5;
					$this -> pagination -> initialize($config);
					$data['pagination'][$vaccine -> id] = $this -> pagination -> create_links();
				}
				if ($order == "ASC") {
					$balances[$vaccine -> id] = Disbursements::getNationalPeriodBalance($vaccine -> id, $from);
				} else if ($order == "DESC") {
					$balances[$vaccine -> id] = Disbursements::getNationalPeriodBalance($vaccine -> id, $to);
				}

				$return_array[$vaccine -> id] = Disbursements::getNationalDisbursements($vaccine -> id, $from, $to, $default_offset, $items_per_page, $district, $region, $order_by, $order, $balances[$vaccine -> id]);

			}

			if ($paged_vaccine != null) {
				$data['paged_vaccine'] = $paged_vaccine;
				$total_disbursements = Disbursements::getTotalNationalDisbursements($paged_vaccine, $from, $to, $district, $region);

				if ($total_disbursements > $items_per_page) {
					$config['base_url'] = base_url() . "external_ledger_management/view_ledger/" . $type . "/" . $id . "/" . $paged_vaccine . "/" . $from . "/" . $to;
					$config['total_rows'] = $total_disbursements;
					$config['per_page'] = $items_per_page;
					$config['uri_segment'] = 8;
					$config['num_links'] = 5;
					$this -> pagination -> initialize($config);
					$data['pagination'][$paged_vaccine] = $this -> pagination -> create_links();
				}
				if ($order == "ASC") {
					$balances[$paged_vaccine] = Disbursements::getNationalPeriodBalance($paged_vaccine, $from);
				} else if ($order == "DESC") {
					$balances[$paged_vaccine] = Disbursements::getNationalPeriodBalance($paged_vaccine, $to);
				}
				$return_array[$paged_vaccine] = Disbursements::getNationalDisbursements($paged_vaccine, $from, $to, $offset, $items_per_page, $district, $region, $order_by, $order, $balances[$paged_vaccine]);

			}
		} else if ($type == 0) {//Regional Store Level
			$recipient = Regions::getRegionName($district_or_province);
			foreach ($data['vaccines'] as $vaccine) {
				if ($vaccine -> id == $paged_vaccine) {
					continue;
				}
				$total_disbursements = Disbursements::getTotalRegionalDisbursements($district_or_province, $vaccine -> id, $from, $to, $district, $region);

				if ($total_disbursements > $items_per_page) {
					$config['base_url'] = base_url() . "external_ledger_management/view_ledger/" . $type . "/" . $id . "/" . $vaccine -> id . "/" . $from . "/" . $to;
					$config['total_rows'] = $total_disbursements;
					$config['per_page'] = $items_per_page;
					$config['uri_segment'] = 9;
					$config['num_links'] = 5;
					$this -> pagination -> initialize($config);
					$data['pagination'][$vaccine -> id] = $this -> pagination -> create_links();
				}
				if ($order == "ASC") {
					$balances[$vaccine -> id] = Disbursements::getRegionalPeriodBalance($district_or_province, $vaccine -> id, $from);
				} else if ($order == "DESC") {
					$balances[$vaccine -> id] = Disbursements::getRegionalPeriodBalance($district_or_province, $vaccine -> id, $to);
				}
				$return_array[$vaccine -> id] = Disbursements::getRegionalDisbursements($district_or_province, $vaccine -> id, $from, $to, $default_offset, $items_per_page, $district, $region, $order_by, $order, $balances[$vaccine -> id]);

			}

			if ($paged_vaccine != null) {
				$data['paged_vaccine'] = $paged_vaccine;
				$total_disbursements = Disbursements::getTotalRegionalDisbursements($district_or_province, $paged_vaccine, $from, $to, $district, $region);

				if ($total_disbursements > $items_per_page) {
					$config['base_url'] = base_url() . "external_ledger_management/view_ledger/" . $type . "/" . $id . "/" . $paged_vaccine . "/" . $from . "/" . $to;
					$config['total_rows'] = $total_disbursements;
					$config['per_page'] = $items_per_page;
					$config['uri_segment'] = 8;
					$config['num_links'] = 5;
					$this -> pagination -> initialize($config);
					$data['pagination'][$paged_vaccine] = $this -> pagination -> create_links();
				}
				if ($order == "ASC") {
					$balances[$paged_vaccine] = Disbursements::getRegionalPeriodBalance($district_or_province, $paged_vaccine, $from);
				} else if ($order == "DESC") {
					$balances[$paged_vaccine] = Disbursements::getRegionalPeriodBalance($district_or_province, $paged_vaccine, $to);
				}
				$return_array[$paged_vaccine] = Disbursements::getRegionalDisbursements($district_or_province, $paged_vaccine, $from, $to, $offset, $items_per_page, $district, $region, $order_by, $order, $balances[$paged_vaccine]);

			}
		} else if ($type == 1) {//District Store Level
			$recipient = Districts::getDistrictName($district_or_province);
			foreach ($data['vaccines'] as $vaccine) {
				if ($vaccine -> id == $paged_vaccine) {
					continue;
				}
				$total_disbursements = Disbursements::getTotalDistrictDisbursements($district_or_province, $vaccine -> id, $from, $to, $district);

				if ($total_disbursements > $items_per_page) {
					$config['base_url'] = base_url() . "external_ledger_management/view_ledger/" . $type . "/" . $id . "/" . $vaccine -> id . "/" . $from . "/" . $to;
					$config['total_rows'] = $total_disbursements;
					$config['per_page'] = $items_per_page;
					$config['uri_segment'] = 9;
					$config['num_links'] = 5;
					$this -> pagination -> initialize($config);
					$data['pagination'][$vaccine -> id] = $this -> pagination -> create_links();
				}
				if ($order == "ASC") {
					$balances[$vaccine -> id] = Disbursements::getDistrictPeriodBalance($district_or_province, $vaccine -> id, $from);
				} else if ($order == "DESC") {
					$balances[$vaccine -> id] = Disbursements::getDistrictPeriodBalance($district_or_province, $vaccine -> id, $to);
				}
				$return_array[$vaccine -> id] = Disbursements::getDistrictDisbursements($district_or_province, $vaccine -> id, $from, $to, $default_offset, $items_per_page, $order_by, $order, $district, $balances[$vaccine -> id]);

			}

			if ($paged_vaccine != null) {
				$data['paged_vaccine'] = $paged_vaccine;
				$total_disbursements = Disbursements::getTotalDistrictDisbursements($district_or_province, $paged_vaccine, $from, $to, $district);

				if ($total_disbursements > $items_per_page) {
					$config['base_url'] = base_url() . "external_ledger_management/view_ledger/" . $type . "/" . $id . "/" . $paged_vaccine . "/" . $from . "/" . $to;
					$config['total_rows'] = $total_disbursements;
					$config['per_page'] = $items_per_page;
					$config['uri_segment'] = 8;
					$config['num_links'] = 5;
					$this -> pagination -> initialize($config);
					$data['pagination'][$paged_vaccine] = $this -> pagination -> create_links();
				}
				if ($order == "ASC") {
					$balances[$paged_vaccine] = Disbursements::getDistrictPeriodBalance($district_or_province, $paged_vaccine, $from);
				} else if ($order == "DESC") {
					$balances[$paged_vaccine] = Disbursements::getDistrictPeriodBalance($district_or_province, $paged_vaccine, $to);
				}
				$return_array[$paged_vaccine] = Disbursements::getDistrictDisbursements($district_or_province, $paged_vaccine, $from, $to, $offset, $items_per_page, $order_by, $order, $district, $balances[$paged_vaccine]);

			}
		}
		$data['title'] = $recipient . " Stock Ledger For The Period Between " . date('d/m/Y', $from) . " to " . date('d/m/Y', $to);
		$data['recipient'] = $recipient;
		$data['content_view'] = "view_external_ledger";

		$data['disbursements'] = $return_array;
		//$data['balances'] = $balances;
		$data['stylesheets'] = array("pagination.css");
		//Get all the districts and regions so as to enable drilling down to a particular store
		$data['districts'] = Districts::getAllDistricts();
		$data['regions'] = Regions::getAllRegions();
		$this -> base_params_min($data);
	}
Esempio n. 24
0
 public function stocking_levels($county_id = NULL, $district_id = NULL, $facility_code = NULL, $commodity_id = NULL, $tracer_item = NULL, $division = NULL, $graph_type = NULL)
 {
     /*function does not take county if you give district,neither does it take district if you give facility. purpose: query optimisation*/
     // $commodity_id = 456;
     // echo $tracer_item;exit;
     $county_id = $county_id == "NULL" ? null : $county_id;
     $district_id = $district_id == "NULL" ? null : $district_id;
     $graph_type = $graph_type == "NULL" ? null : $graph_type;
     $facility_code = $facility_code == "NULL" ? null : $facility_code;
     $tracer_item = $tracer_item == "NULL" ? null : $tracer_item;
     $commodity_id = $commodity_id == "ALL" || $commodity_id == "NULL" ? null : $commodity_id;
     $division_details = Dashboard_model::get_division_details($division);
     // echo "<pre>";print_r($tracer_commodities);exit;
     if (isset($division) && $division > 0) {
         $page_title = $division_details[0]['division_name'];
         $tracer = "NULL";
     } else {
         $tracer = 1;
         $page_title = "Tracer Item";
     }
     $page_title = trim($page_title);
     $graph_title = $page_title . ' National Stock Level';
     if ($county_id > 0) {
         $county_name = Counties::get_county_name($county_id);
         $graph_title = $page_title . ' ' . $county_name['county'] . ' County Stock Level';
     }
     if ($district_id > 0) {
         $district_name = Districts::get_district_name_($district_id);
         $graph_title = $page_title . ' ' . $district_name['district'] . ' Sub-County Stock Level';
     }
     // echo $tracer_item;exit;
     // echo is_null($district_id);
     $filter = '';
     $filter .= $county_id > 0 && is_null($district_id) ? " AND counties.id = {$county_id}" : NULL;
     $filter .= $district_id > 0 && is_null($county_id) ? " AND districts.id = {$district_id}" : NULL;
     $filter .= $facility_code > 0 && is_null($county_id) && is_null($district_id) ? " AND facilities.facility_code = {$facility_code}" : NULL;
     $filter .= $commodity_id > 0 ? " AND commodities.id = {$commodity_id} " : NULL;
     $filter .= $tracer_item > 0 ? " AND commodities.tracer_item = 1 " : NULL;
     if ($division != 5) {
         $filter .= $division > 0 ? " AND commodities.commodity_division = {$division}" : NULL;
     }
     // echo $filter;exit;
     /*echo "SELECT 
     		    commodities.id,
     		    commodities.commodity_name,
     		    SUM(facility_stocks.current_balance) AS unit_balance,
     		    SUM(facility_stocks.current_balance) / commodities.total_commodity_units AS pack_balance,
     		    commodities.total_commodity_units
     		FROM
     		    hcmp_rtk.facility_stocks
     		        INNER JOIN
     		    facilities ON facility_stocks.facility_code = facilities.facility_code
     		        INNER JOIN
     		    districts ON facilities.district = districts.id
     		        INNER JOIN
     		    counties ON districts.county = counties.id
     		        INNER JOIN
     		    commodities ON facility_stocks.commodity_id = commodities.id
     		WHERE
     		    commodities.status = 1
     		         $filter
     		GROUP BY commodities.id ORDER BY commodities.commodity_name ASC";exit;*/
     $stocking_levels = $this->db->query("\n\t\t\tSELECT \n\t\t\t    commodities.id,\n\t\t\t    commodities.commodity_name,\n\t\t\t    SUM(facility_stocks.current_balance) AS unit_balance,\n\t\t\t    SUM(facility_stocks.current_balance) / commodities.total_commodity_units AS pack_balance,\n\t\t\t    commodities.total_commodity_units\n\t\t\tFROM\n\t\t\t    hcmp_rtk.facility_stocks\n\t\t\t        INNER JOIN\n\t\t\t    facilities ON facility_stocks.facility_code = facilities.facility_code\n\t\t\t        INNER JOIN\n\t\t\t    districts ON facilities.district = districts.id\n\t\t\t        INNER JOIN\n\t\t\t    counties ON districts.county = counties.id\n\t\t\t        INNER JOIN\n\t\t\t    commodities ON facility_stocks.commodity_id = commodities.id\n\t\t\tWHERE\n\t\t\t    commodities.status = 1\n\t\t\t         {$filter}\n\t\t\tGROUP BY commodities.id ORDER BY commodities.commodity_name ASC\n\t\t")->result_array();
     // echo "<pre>"; print_r($stocking_levels); exit;
     /*			
     $category_data = array();
     $series_data = $series_data_ = array();
     $temp_array = $temp_array_ = array();
     $graph_data = array();
     $graph_type = '';
     foreach ($stocking_levels as $data) :
     	$series_data = array_merge($series_data, array($data["commodity_name"] => (int)$data['cur_bal_packs']/(int)$data['amc_packs']));
     	$category_data = array_merge($category_data, array($data["commodity_name"]));
     endforeach;
     */
     /*CODE FOR MULTI BAR COLUMN*/
     $graph_data = array();
     $graph_data = array_merge($graph_data, array("graph_id" => 'dem_graph_mos'));
     $graph_data = array_merge($graph_data, array("graph_title" => $graph_title));
     $graph_data = array_merge($graph_data, array("color" => "['#7CB5EC', '#434348']"));
     $graph_data = array_merge($graph_data, array("graph_type" => 'bar'));
     // $graph_data=array_merge($graph_data,array("graph_yaxis_title"=>'National Stock Level (Units and Packs)'));
     $graph_data = array_merge($graph_data, array("graph_categories" => array()));
     // $graph_data=array_merge($graph_data,array("series_data"=>array("Pack Balance"=>array(),"Unit Balance"=>array())));
     $graph_data = array_merge($graph_data, array("series_data" => array("Pack Balance" => array())));
     $graph_data['stacking'] = 'normal';
     foreach ($stocking_levels as $stock_level) {
         // $category_name = $stock_level['commodity_name'].' ('.$facility_stock_['source_name'].')';
         $category_name = $stock_level['commodity_name'];
         $graph_data['graph_categories'] = array_merge($graph_data['graph_categories'], array($category_name));
         // $graph_data['series_data']['Unit Balance']=array_merge($graph_data['series_data']['Unit Balance'],array((float) $stock_level['unit_balance']));
         $graph_data['series_data']['Pack Balance'] = array_merge($graph_data['series_data']['Pack Balance'], array((double) $stock_level['pack_balance']));
     }
     // echo "<pre>";print_r($graph_data);exit;
     /*END OF THAT TITLE OVER THERE*/
     // echo "<pre>";print_r($graph_data);echo "</pre>";exit;
     /*
     $graph_type = 'bar';
     $graph_data = array_merge($graph_data, array("graph_id" => 'dem_graph_mos'));
     $graph_data = array_merge($graph_data, array("graph_title" => "$title Stock Level in Months of Stock (MOS)"));
     $graph_data = array_merge($graph_data, array("graph_type" => $graph_type));
     $graph_data = array_merge($graph_data, array("color" => "['#4572A7','#FFF263', '#6AF9C4']"));
     $graph_data = array_merge($graph_data, array("graph_yaxis_title" => "MOS"));
     $graph_data = array_merge($graph_data, array("graph_categories" => $category_data));
     // $graph_data = array_merge($graph_data, array("series_data" => array('total' => $series_data)));
     $graph_data=array_merge($graph_data,array("series_data"=>array("Unit Balance"=>array(),"Pack Balance"=>array())));
     $data = array();
     */
     $data['high_graph'] = $this->hcmp_functions->create_high_chart_graph($graph_data);
     // echo "<pre>";print_r($data['high_graph']);exit;
     $data['graph_id'] = 'dem_graph_mos';
     if ($graph_type == "excel") {
         // print_r($_GET); exit;
         // echo "<pre>"; print_r($stocking_levels); exit;
         $excel_data = array('doc_creator' => "HCMP", 'doc_title' => $page_title, 'file_name' => $page_title);
         $row_data = array();
         $column_data = array("Commoidity Name", "Unit Balance", "Pack Balance", "Total Commodity Units");
         foreach ($stocking_levels as $stocking_levels) {
             array_push($row_data, array($stocking_levels['commodity_name'], $stocking_levels['unit_balance'], $stocking_levels['pack_balance'], $stocking_levels['total_commodity_units']));
         }
         $excel_data['column_data'] = $column_data;
         $excel_data['row_data'] = $row_data;
         $this->hcmp_functions->create_excel($excel_data);
     }
     return $this->load->view("shared_files/report_templates/high_charts_template_v_national", $data);
     /*END OF THIS OLD SH!T*/
 }
 public function RH_report($facility = NULL)
 {
     //Used to pick the kemsa code and assign it to elements displayed on the report
     $rhtable = '';
     if ($facility == NULL) {
         $facility = $this->session->userdata('facility_id');
     }
     $user_id = $this->session->userdata('user_id');
     $facility_info = tb_data::get_facility_name($facility);
     $district_name_ = Districts::get_district_name_($facility_district);
     $district_name = $this->session->userdata('district');
     $data['facility_code'] = $facility_info['facility_code'];
     $data['district_region_name'] = $district_name_['district'];
     $data['facility_name'] = $facility_info['facility_name'];
     $data['facility_type_'] = $facility_info['owner'];
     $data['rh_data'] = $this->createrhreport($facility);
     $data['content_view'] = "facility/facility_reports/facility_reports_RH_reports_v";
     $data['sidebar'] = "shared_files/report_templates/side_bar_v";
     $data['title'] = "RH Report";
     $data['banner_text'] = "Facility RH Commodities Order";
     // $view = 'shared_files/template/template';
     $this->load->view($data['content_view'], $data);
 }
<?php

$attributes = array('name' => 'myform', 'id' => 'myform');
foreach ($facilities as $facility) {
    $facility_name = $facility['facility_name'];
    $district = $facility['district'];
    $county_id = Districts::get_county_id($district);
    $district_name = Districts::get_district_name($district);
    $county_name = Counties::get_county_name($county_id['county']);
}
$facility_code = $this->session->userdata('facility_id');
$fname = $this->session->userdata('fname');
$lname = $this->session->userdata('lname');
$username = $fname . ' ' . $lname;
?>
		<div style="width: 65%; margin-left: auto; margin-right: auto; font-size: 14px;">
<div id="dialog-form" title="Enter the evaluation information here.">
	<h4>Kindly provide information in all the fields indicated for proper analysis and assessment to be performed. This evaluation will take at least 15 minutes.</h4>
	<form>
		<table id="eval"  width="100%" class="table table-bordered">
		<input type="hidden" name="facility_name" colspan = "3" style = "color:#000; border:none" value="<?php 
echo $facility_name;
?>
"></td>
		<input type="hidden" name="facility_code" colspan = "2" style = "color:#000; border:none" value="<?php 
echo $facility_code;
?>
"></td>
		<input type="hidden" name="district_name" colspan = "2" style = "color:#000; border:none" value="<?php 
echo $district;
?>
Esempio n. 27
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. 28
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. 29
0
    public function create_program_report_pdf_template($report_id, $facility_code, $report_type)
    {
        if ($report_type == "malaria") {
            //$report_time= strtotime($report_time);
            $from_malaria_data_table = Malaria_Data::get_facility_report($report_id, $facility_code);
            $from_malaria_data_table_count = count(Malaria_Data::get_facility_report($report_id, $facility_code));
            foreach ($from_malaria_data_table as $report_details) {
                $mfl = $report_details['facility_id'];
                $commodity_code = $report_details['Kemsa_Code'];
                $mydrug_name = Doctrine::getTable('Malaria_drugs')->findOneBykemsa_code($commodity_code);
                $commodityname = $mydrug_name->drug_name;
                $report_date = $report_details['Report_Date'];
                $myobj = Doctrine::getTable('Facilities')->findOneByfacility_code($mfl);
                $sub_county_id = $myobj->district;
                $facility_name = $myobj->facility_name;
                // get the order form details here
                $myobj1 = Doctrine::getTable('Districts')->find($sub_county_id);
                $sub_county_name = $myobj1->district;
                $county = $myobj1->county;
                $myobj2 = Doctrine::getTable('Counties')->find($county);
                $county_name = $myobj2->county;
                $myobj_order = Doctrine::getTable('users')->find($report_details['user_id']);
                $creator_email = $myobj_order->email;
                $creator_name1 = $myobj_order->fname;
                $creator_name2 = $myobj_order->lname;
                $creator_telephone = $myobj_order->telephone;
            }
            //create the table for displaying the order details
            $html_body = "<table class='data-table' width=100%>\n\t\t\t<tr>\n\t\t\t\t<td>MFL No: {$mfl}</td> \n\t\t\t\t<td>Health Facility Name:<br/> {$facility_name}</td>\n\t\t\t\t<td>Level:</td>\n\t\t\t\t<td>Dispensary</td>\n\t\t\t\t<td>Health Centre</td>\n\t\t\t</tr>\n\t\t\t<tr>\n\t\t\t\t<td>County: {$county_name}</td> \n\t\t\t\t<td> District: {$sub_county_name}</td>\n\t\t\t\t<td >Reporting Period <br/>\n\t\t\t\t\tStart Date:  <br/>  End Date: " . date('d M, Y', strtotime($report_date)) . "\n\t\t\t\t</td>\n\t\t\t</tr>\n\t\t</table>";
            $html_body .= "\n\t\t<table class='data-table'>\n\t\t\t<thead>\n\t\t\t\t<tr>\n\t\t\t\t\t<th><b>KEMSA Code</b></th>\n\t\t\t\t\t<th><b>Commodity Name</b></th>\n\t\t\t\t\t<th ><b>Beginning Balance</b></th>\n\t\t\t\t\t<th ><b>Quantity Received</b></th>\n\t\t\t\t\t<th ><b>Quantity Dispensed</b></th>\n\t\t\t\t\t<th ><b>Losses Excluding Expiries</b></th>\n\t\t\t\t\t<th ><b>Adjustments</b></th>\n\t\t\t\t\t<th ><b>Physical Count</b></th>\n\t\t\t\t\t<th ><b>Expired Drugs</b></th>\n\t\t\t\t\t<th ><b>Days Out of Stock</b></th>\n\t\t\t\t\t<th ><b>Report Total</b></th>\n\t\t\t\t</tr> \n\t\t\t</thead>\n\t\t\t<tbody>";
            $html_body .= '<ol type="a">';
            for ($i = 0; $i < $from_malaria_data_table_count; $i++) {
                $mydrug_name = Doctrine::getTable('Malaria_drugs')->findOneBykemsa_code($from_malaria_data_table[$i]['Kemsa_Code']);
                //$commodityname[$i] = $mydrug_name -> drug_name;
                $adjs = $from_malaria_data_table[$i]['Positive_Adjustments'] + $from_malaria_data_table[$i]['Negative_Adjustments'];
                $html_body .= "<tr>";
                $html_body .= "<td>" . $from_malaria_data_table[$i]['Kemsa_Code'] . "</td>";
                $html_body .= "<td>" . ($commodityname = $mydrug_name->drug_name . "</td>");
                $html_body .= "<td>" . $from_malaria_data_table[$i]['Beginning_Balance'] . "</td>";
                $html_body .= "<td>" . $from_malaria_data_table[$i]['Quantity_Received'] . "</td>";
                $html_body .= "<td>" . $from_malaria_data_table[$i]['Quantity_Dispensed'] . "</td>";
                $html_body .= "<td>" . $from_malaria_data_table[$i]['Losses_Excluding_Expiries'] . "</td>";
                $html_body .= "<td>" . $adjs . "</td>";
                $html_body .= "<td>" . $from_malaria_data_table[$i]['Physical_Count'] . "</td>";
                $html_body .= "<td>" . $from_malaria_data_table[$i]['Expired_Drugs'] . "</td>";
                $html_body .= "<td>" . $from_malaria_data_table[$i]['Days_Out_Stock'] . "</td>";
                $html_body .= "<td>" . $from_malaria_data_table[$i]['Report_Total'] . "</td>";
                $html_body .= "</tr>";
            }
            $html_body .= '</tbody></table></ol>';
        } elseif ($report_type == "RH") {
            $from_RH_data_table = RH_Drugs_Data::get_facility_report($report_id, $facility_code);
            $from_RH_data_table_count = count(RH_Drugs_Data::get_facility_report($report_id, $facility_code));
            foreach ($from_RH_data_table as $report_details) {
                $mfl = $report_details['facility_id'];
                $report_date = $report_details['Report_Date'];
                $myobj = Doctrine::getTable('Facilities')->findOneByfacility_code($mfl);
                $sub_county_id = $myobj->district;
                $facility_name = $myobj->facility_name;
                $myobj1 = Doctrine::getTable('Districts')->find($sub_county_id);
                $sub_county_name = $myobj1->district;
                $county = $myobj1->county;
                $myobj2 = Doctrine::getTable('Counties')->find($county);
                $county_name = $myobj2->county;
                $myobj_order = Doctrine::getTable('users')->find($report_details['user_id']);
                $creator_email = $myobj_order->email;
                $creator_name1 = $myobj_order->fname;
                $creator_name2 = $myobj_order->lname;
                $creator_telephone = $myobj_order->telephone;
            }
            //create the table for displaying the order details
            $html_body = "<table class='data-table' width=100%>\n\t\t\t\t<tr>\n\t\t\t\t\t<td>MFL No: {$mfl}</td> \n\t\t\t\t\t<td>Health Facility Name:<br/> {$facility_name}</td>\n\t\t\t\t\t<td>Level:</td>\n\t\t\t\t\t<td>Dispensary</td>\n\t\t\t\t\t<td>Health Centre</td>\n\t\t\t\t</tr>\n\t\t\t\t<tr>\n\t\t\t\t\t<td>County: {$county_name}</td> \n\t\t\t\t\t<td> District: {$sub_county_name}</td>\n\t\t\t\t\t<td >Reporting Period <br/>\n\t\t\t\t\t\tStart Date:  <br/>  End Date: " . date('d M, Y', strtotime($report_date)) . "\n\t\t\t\t\t</td>\n\t\t\t\t</tr>\n\t\t\t</table>";
            $html_body .= "\n\t\t\t<table class='data-table'>\n\t\t\t\t<thead>\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<th ><b>Beginning Balance</b></th>\n\t\t\t\t\t\t<th ><b>Quantity Received This Month</b></th>\n\t\t\t\t\t\t<th ><b>Quantity Dispensed</b></th>\n\t\t\t\t\t\t<th ><b>Losses</b></th>\n\t\t\t\t\t\t<th ><b>Adjustments</b></th>\n\t\t\t\t\t\t<th ><b>Ending Balance</b></th>\n\t\t\t\t\t\t<th ><b>Quantity Requested</b></th>\n\t\t\t\t\t</tr> \n\t\t\t\t</thead>\n\t\t\t\t<tbody>";
            $html_body .= '<ol type="a">';
            for ($i = 0; $i < $from_RH_data_table_count; $i++) {
                $html_body .= "<tr>";
                $html_body .= "<td>" . $from_RH_data_table[$i]['Beginning_Balance'] . "</td>";
                $html_body .= "<td>" . $from_RH_data_table[$i]['Received_This_Month'] . "</td>";
                $html_body .= "<td>" . $from_RH_data_table[$i]['Dispensed'] . "</td>";
                $html_body .= "<td>" . $from_RH_data_table[$i]['Losses'] . "</td>";
                $html_body .= "<td>" . $from_RH_data_table[$i]['Adjustments'] . "</td>";
                $html_body .= "<td>" . $from_RH_data_table[$i]['Ending_Balance'] . "</td>";
                $html_body .= "<td>" . $from_RH_data_table[$i]['Quantity_Requested'] . "</td>";
                $html_body .= "</tr>";
            }
            $html_body .= '</tbody></table></ol>';
        } elseif ($report_type == "TB") {
            $from_TB_data_table = tb_data::get_all_other($report_id);
            $from_TB_data_table_s2 = tb_data::get_all_other_2($report_id);
            $from_TB_data_table_count = count(tb_data::get_all_other($report_id));
            $tb_drug_names = tb_data::get_tb_drug_names();
            foreach ($from_TB_data_table as $report_details) {
                $mfl = $report_details['facility_code'];
                $report_date = $report_details['report_date'];
                $myobj = Doctrine::getTable('Facilities')->findOneByfacility_code($mfl);
                $sub_county_id = $myobj->district;
                $facility_name = $myobj->facility_name;
                $myobj1 = Doctrine::getTable('Districts')->find($sub_county_id);
                $sub_county_name = $myobj1->district;
                $county = $myobj1->county;
                $myobj2 = Doctrine::getTable('Counties')->find($county);
                $county_name = $myobj2->county;
                $myobj_order = Doctrine::getTable('users')->find($report_details['user_id']);
                $creator_email = $myobj_order->email;
                $creator_name1 = $myobj_order->fname;
                $creator_name2 = $myobj_order->lname;
                $creator_telephone = $myobj_order->telephone;
            }
            //create the table for displaying the order details
            $html_body = "<table class='data-table' width=100%>\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td>MFL No: {$mfl}</td> \n\t\t\t\t\t\t<td>Health Facility Name:<br/> {$facility_name}</td>\n\t\t\t\t\t\t<td>Level:</td>\n\t\t\t\t\t\t<td>Dispensary</td>\n\t\t\t\t\t\t<td>Health Centre</td>\n\t\t\t\t\t</tr>\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td>County: {$county_name}</td> \n\t\t\t\t\t\t<td> District: {$sub_county_name}</td>\n\t\t\t\t\t\t<td >Reporting Period <br/>\n\t\t\t\t\t\t\tStart Date:  <br/>  End Date: " . date('d M, Y', strtotime($report_date)) . "\n\t\t\t\t\t\t</td>\n\t\t\t\t\t</tr>\n\t\t\t\t</table>";
            $html_body .= "\n\t\t\t\t<table class='data-table'>\n\t\t\t\t\t<thead>\n\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t<th ><b>Drug Name</b></th>\n\t\t\t\t\t\t\t<th ><b>Pack</b></th>\n\t\t\t\t\t\t\t<th ><b>Beginning Date</b></th>\n\t\t\t\t\t\t\t<th ><b>Quantity Received This Month</b></th>\n\t\t\t\t\t\t\t<th ><b>Ending Date</b></th>\n\t\t\t\t\t\t\t<th ><b>Beginning Balance</b></th>\n\t\t\t\t\t\t\t<th ><b>Quantity Dispensed</b></th>\n\t\t\t\t\t\t\t<th ><b>Positive_Adjustments</b></th>\n\t\t\t\t\t\t\t<th ><b>Negative_Adjustments</b></th>\n\t\t\t\t\t\t\t<th ><b>Losses</b></th>\n\t\t\t\t\t\t\t<th ><b>Physical Count</b></th>\n\t\t\t\t\t\t\t<th ><b>Earliest Expiry</b></th>\n\t\t\t\t\t\t\t<th ><b>Quantity Requested</b></th>\n\t\t\t\t\t\t\t<th ><b>Report Date</b></th>\n\t\t\t\t\t\t</tr> \n\t\t\t\t\t</thead>\n\t\t\t\t\t<tbody>";
            $html_body .= '<ol type="a">';
            for ($i = 0; $i < $from_TB_data_table_count; $i++) {
                $html_body .= "<tr>";
                $html_body .= "<td>" . $tb_drug_names[$i]['drug_name'] . "</td>";
                $html_body .= "<td>" . $tb_drug_names[$i]['unit_size'] . "</td>";
                $html_body .= "<td>" . $from_TB_data_table[$i]['beginning_date'] . "</td>";
                $html_body .= "<td>" . $from_TB_data_table[$i]['currently_recieved'] . "</td>";
                $html_body .= "<td>" . $from_TB_data_table[$i]['ending_date'] . "</td>";
                $html_body .= "<td>" . $from_TB_data_table[$i]['beginning_balance'] . "</td>";
                $html_body .= "<td>" . $from_TB_data_table[$i]['quantity_dispensed'] . "</td>";
                $html_body .= "<td>" . $from_TB_data_table[$i]['positive_adjustment'] . "</td>";
                $html_body .= "<td>" . $from_TB_data_table[$i]['negative_adjustment'] . "</td>";
                $html_body .= "<td>" . $from_TB_data_table[$i]['losses'] . "</td>";
                $html_body .= "<td>" . $from_TB_data_table[$i]['physical_count'] . "</td>";
                $html_body .= "<td>" . $from_TB_data_table[$i]['earliest_expiry'] . "</td>";
                $html_body .= "<td>" . $from_TB_data_table[$i]['quantity_needed'] . "</td>";
                $html_body .= "<td>" . $from_TB_data_table[$i]['report_date'] . "</td>";
                $html_body .= "</tr>";
            }
            $html_body .= '</tbody></table></ol>';
        } elseif ($report_type == "expiries") {
            $years = array();
            $month_names[] = array();
            $year1 = $years[0] = date('Y');
            $year2 = $years[1] = date('Y') + 1;
            $year3 = $years[2] = date('Y') + 2;
            $month_names[0] = 'January';
            $month_names[1] = 'February';
            $month_names[2] = 'March';
            $month_names[3] = 'April';
            $month_names[4] = 'May';
            $month_names[5] = 'June';
            $month_names[6] = 'July';
            $month_names[7] = 'August';
            $month_names[8] = 'September';
            $month_names[9] = 'October';
            $month_names[10] = 'November';
            $month_names[11] = 'December';
            $facility_code = isset($facility_code) ? $facility_code : $this->session->userdata('facility_id');
            $expiry_data = Facility_stocks::expiries_report($facility_code);
            $facility = $this->session->userdata('facility_id');
            $user_id = $this->session->userdata('user_id');
            $user_names = Users::get_user_names($user_id);
            $data['user_names'] = $user_names[0]['fname'] . " " . $user_names[0]['lname'];
            $expiry_data_ = Facility_stocks::expiries_report($facility_code);
            $facility_info = tb_data::get_facility_name($facility_code);
            $facility_name = $facility_info['facility_name'];
            $facility_code_ = $facility_info['facility_code'];
            $facility_district = $facility_info['district'];
            $district_name_ = Districts::get_district_name_($facility_district);
            $district_name = $this->session->userdata('district');
            $data['facility_code'] = $facility_info['facility_code'];
            $district_region_name = $district_name_['district'];
            $data['facility_name'] = $facility_info['facility_name'];
            $data['facility_type_'] = $facility_info['owner'];
            // echo "<pre>";print_r($years);echo "</pre>";exit;
            //$data['expiry_data'] = Facility_stocks::expiries_report($facility_code);
            $facility_name = Facilities::get_facility_name_($facility_code)->toArray();
            $data['facility_name'] = $facility_name[0]['facility_name'];
            $yrs_no = count($years);
            $months_no = count($month_names);
            for ($i = 0; $i < $yrs_no; $i++) {
                for ($j = 0; $j < $months_no; $j++) {
                    $final_date[] = $month_names[$j] . " " . $years[$i];
                }
            }
            $html_body = '
						<body>
							<div>
								<table width="100%"  class="data-table">
									<tbody>
										<tr>
											<th>Expiries Report</th>
										</tr>
										
									</table>
								</div>
								<table width="100%"  class="data-table">
									<tbody style = "display: table-row-group;vertical-align: middle;border-color: inherit;">
										<form class ="form-control" id="tb_form" name="tb_form_">
											<div>
												<tr style = "display: table-row;vertical-align: inherit;border-color: inherit;">
													<thead>
														<th style = "border: 1px solid #ddd;" >Commodity</th>
														<th style = "border: 1px solid #ddd;" >Batch No</th>
														<th style = "border: 1px solid #ddd;" >Expiry Date</th>
														<th colspan="12" style="text-align: center;border: 1px solid #ddd;">' . $year1 . '
														</th>
														<th colspan="12" style="text-align: center;border: 1px solid #ddd;">' . $year2 . '
														</th>
														<th colspan="12" style="text-align: center;border: 1px solid #ddd;">' . $year3 . '
														</th>
													</thead>
												</tr>
												<tr>
													<thead>
														<th style = "border: 1px solid #ddd;"></th>
														<th style = "border: 1px solid #ddd;"></th>
														<th style = "border: 1px solid #ddd;"></th>
														
														<th style = "border: 1px solid #ddd;">J</th>
														<th style = "border: 1px solid #ddd;">F</th>
														<th style = "border: 1px solid #ddd;">M</th>
														<th style = "border: 1px solid #ddd;">A</th>
														<th style = "border: 1px solid #ddd;">M</th>
														<th style = "border: 1px solid #ddd;">J</th>
														<th style = "border: 1px solid #ddd;">J</th>
														<th style = "border: 1px solid #ddd;" >A</th>
														<th style = "border: 1px solid #ddd;" >S</th>
														<th style = "border: 1px solid #ddd;" >O</th>
														<th style = "border: 1px solid #ddd;" >N</th>
														<th style = "border: 1px solid #ddd;" >D</th>
														
														<th style = "border: 1px solid #ddd;" >J</th>
														<th style = "border: 1px solid #ddd;" >F</th>
														<th style = "border: 1px solid #ddd;" >M</th>
														<th style = "border: 1px solid #ddd;" >A</th>
														<th style = "border: 1px solid #ddd;" >M</th>
														<th style = "border: 1px solid #ddd;" >J</th>
														<th style = "border: 1px solid #ddd;" >J</th>
														<th style = "border: 1px solid #ddd;" >A</th>
														<th style = "border: 1px solid #ddd;" >S</th>
														<th style = "border: 1px solid #ddd;" >O</th>
														<th style = "border: 1px solid #ddd;" >N</th>
														<th style = "border: 1px solid #ddd;" >D</th>
														
														<th style = "border: 1px solid #ddd;" >J</th>
														<th style = "border: 1px solid #ddd;" >F</th>
														<th style = "border: 1px solid #ddd;" >M</th>
														<th style = "border: 1px solid #ddd;" >A</th>
														<th style = "border: 1px solid #ddd;" >M</th>
														<th style = "border: 1px solid #ddd;" >J</th>
														<th style = "border: 1px solid #ddd;" >J</th>
														<th style = "border: 1px solid #ddd;" >A</th>
														<th style = "border: 1px solid #ddd;" >S</th>
														<th style = "border: 1px solid #ddd;" >O</th>
														<th style = "border: 1px solid #ddd;" >N</th>
														<th style = "border: 1px solid #ddd;" >D</th>
													</thead>
												</tr>
												';
            foreach ($expiry_data_ as $data) {
                $checked = '<td><input type="checkbox"  checked = "checked" disabled ></td>';
                $unchecked = '<td><input type="checkbox" disabled ></td>';
                $jan14 = $feb14 = $march14 = $april14 = $may14 = $june14 = $july14 = $aug14 = $sept14 = $oct14 = $nov14 = $dec14 = $unchecked;
                $jan15 = $feb15 = $march15 = $april15 = $may15 = $june15 = $july15 = $aug15 = $sept15 = $oct15 = $nov15 = $dec15 = $unchecked;
                $jan16 = $feb16 = $march16 = $april16 = $may16 = $june16 = $july16 = $aug16 = $sept16 = $oct16 = $nov16 = $dec16 = $unchecked;
                $commodity = $data['commodity_name'];
                $batch = $data['batch_no'];
                $month = $data['expiry_month'];
                // echo "<pre>";print_r($month);echo " </pre>";
                // echo "<pre>";print_r($final_date);echo " </pre>";exit;
                $html_body .= '
												<tr>
													<td>' . $commodity . '</td>
													<td>' . $batch . '</td>
													<td>
														' . $data['expiry_date'] . '			
													</td>';
                switch ($month) {
                    // 2014 SWITCH
                    case NULL:
                        $html_body .= $jan14 . $feb14 . $march14 . $april14 . $may14 . $june14 . $july14 . $aug14 . $sept14 . $oct14 . $nov14 . $dec14;
                        $html_body .= $jan15 . $feb15 . $march15 . $april15 . $may15 . $june15 . $july15 . $aug15 . $sept15 . $oct15 . $nov15 . $dec15;
                        $html_body .= $jan16 . $feb16 . $march16 . $april16 . $may16 . $june16 . $july16 . $aug16 . $sept16 . $oct16 . $nov16 . $dec16;
                        break;
                    case $final_date[0]:
                        $jan14 = $checked;
                        $html_body .= $jan14 . $feb14 . $march14 . $april14 . $may14 . $june14 . $july14 . $aug14 . $sept14 . $oct14 . $nov14 . $dec14;
                        $html_body .= $jan15 . $feb15 . $march15 . $april15 . $may15 . $june15 . $july15 . $aug15 . $sept15 . $oct15 . $nov15 . $dec15;
                        $html_body .= $jan16 . $feb16 . $march16 . $april16 . $may16 . $june16 . $july16 . $aug16 . $sept16 . $oct16 . $nov16 . $dec16;
                        break;
                    case $final_date[1]:
                        $feb14 = $checked;
                        $html_body .= $jan14 . $feb14 . $march14 . $april14 . $may14 . $june14 . $july14 . $aug14 . $sept14 . $oct14 . $nov14 . $dec14;
                        $html_body .= $jan15 . $feb15 . $march15 . $april15 . $may15 . $june15 . $july15 . $aug15 . $sept15 . $oct15 . $nov15 . $dec15;
                        $html_body .= $jan16 . $feb16 . $march16 . $april16 . $may16 . $june16 . $july16 . $aug16 . $sept16 . $oct16 . $nov16 . $dec16;
                        break;
                    case $final_date[2]:
                        $march14 = $checked;
                        $html_body .= $jan14 . $feb14 . $march14 . $april14 . $may14 . $june14 . $july14 . $aug14 . $sept14 . $oct14 . $nov14 . $dec14;
                        $html_body .= $jan15 . $feb15 . $march15 . $april15 . $may15 . $june15 . $july15 . $aug15 . $sept15 . $oct15 . $nov15 . $dec15;
                        $html_body .= $jan16 . $feb16 . $march16 . $april16 . $may16 . $june16 . $july16 . $aug16 . $sept16 . $oct16 . $nov16 . $dec16;
                        break;
                    case $final_date[3]:
                        $april14 = $checked;
                        $html_body .= $jan14 . $feb14 . $march14 . $april14 . $may14 . $june14 . $july14 . $aug14 . $sept14 . $oct14 . $nov14 . $dec14;
                        $html_body .= $jan15 . $feb15 . $march15 . $april15 . $may15 . $june15 . $july15 . $aug15 . $sept15 . $oct15 . $nov15 . $dec15;
                        $html_body .= $jan16 . $feb16 . $march16 . $april16 . $may16 . $june16 . $july16 . $aug16 . $sept16 . $oct16 . $nov16 . $dec16;
                        break;
                    case $final_date[4]:
                        $may14 = $checked;
                        $html_body .= $jan14 . $feb14 . $march14 . $april14 . $may14 . $june14 . $july14 . $aug14 . $sept14 . $oct14 . $nov14 . $dec14;
                        $html_body .= $jan15 . $feb15 . $march15 . $april15 . $may15 . $june15 . $july15 . $aug15 . $sept15 . $oct15 . $nov15 . $dec15;
                        $html_body .= $jan16 . $feb16 . $march16 . $april16 . $may16 . $june16 . $july16 . $aug16 . $sept16 . $oct16 . $nov16 . $dec16;
                        break;
                    case $final_date[5]:
                        $june14 = $checked;
                        $html_body .= $jan14 . $feb14 . $march14 . $april14 . $may14 . $june14 . $july14 . $aug14 . $sept14 . $oct14 . $nov14 . $dec14;
                        $html_body .= $jan15 . $feb15 . $march15 . $april15 . $may15 . $june15 . $july15 . $aug15 . $sept15 . $oct15 . $nov15 . $dec15;
                        $html_body .= $jan16 . $feb16 . $march16 . $april16 . $may16 . $june16 . $july16 . $aug16 . $sept16 . $oct16 . $nov16 . $dec16;
                        break;
                    case $final_date[6]:
                        $july14 = $checked;
                        $html_body .= $jan14 . $feb14 . $march14 . $april14 . $may14 . $june14 . $july14 . $aug14 . $sept14 . $oct14 . $nov14 . $dec14;
                        $html_body .= $jan15 . $feb15 . $march15 . $april15 . $may15 . $june15 . $july15 . $aug15 . $sept15 . $oct15 . $nov15 . $dec15;
                        $html_body .= $jan16 . $feb16 . $march16 . $april16 . $may16 . $june16 . $july16 . $aug16 . $sept16 . $oct16 . $nov16 . $dec16;
                        break;
                    case $final_date[7]:
                        $aug14 = $checked;
                        $html_body .= $jan14 . $feb14 . $march14 . $april14 . $may14 . $june14 . $july14 . $aug14 . $sept14 . $oct14 . $nov14 . $dec14;
                        $html_body .= $jan15 . $feb15 . $march15 . $april15 . $may15 . $june15 . $july15 . $aug15 . $sept15 . $oct15 . $nov15 . $dec15;
                        $html_body .= $jan16 . $feb16 . $march16 . $april16 . $may16 . $june16 . $july16 . $aug16 . $sept16 . $oct16 . $nov16 . $dec16;
                        break;
                    case $final_date[8]:
                        $sept14 = $checked;
                        $html_body .= $jan14 . $feb14 . $march14 . $april14 . $may14 . $june14 . $july14 . $aug14 . $sept14 . $oct14 . $nov14 . $dec14;
                        $html_body .= $jan15 . $feb15 . $march15 . $april15 . $may15 . $june15 . $july15 . $aug15 . $sept15 . $oct15 . $nov15 . $dec15;
                        $html_body .= $jan16 . $feb16 . $march16 . $april16 . $may16 . $june16 . $july16 . $aug16 . $sept16 . $oct16 . $nov16 . $dec16;
                        break;
                    case $final_date[9]:
                        $oct14 = $checked;
                        $html_body .= $jan14 . $feb14 . $march14 . $april14 . $may14 . $june14 . $july14 . $aug14 . $sept14 . $oct14 . $nov14 . $dec14;
                        $html_body .= $jan15 . $feb15 . $march15 . $april15 . $may15 . $june15 . $july15 . $aug15 . $sept15 . $oct15 . $nov15 . $dec15;
                        $html_body .= $jan16 . $feb16 . $march16 . $april16 . $may16 . $june16 . $july16 . $aug16 . $sept16 . $oct16 . $nov16 . $dec16;
                        break;
                    case $final_date[10]:
                        $nov14 = $checked;
                        $html_body .= $jan14 . $feb14 . $march14 . $april14 . $may14 . $june14 . $july14 . $aug14 . $sept14 . $oct14 . $nov14 . $dec14;
                        $html_body .= $jan15 . $feb15 . $march15 . $april15 . $may15 . $june15 . $july15 . $aug15 . $sept15 . $oct15 . $nov15 . $dec15;
                        $html_body .= $jan16 . $feb16 . $march16 . $april16 . $may16 . $june16 . $july16 . $aug16 . $sept16 . $oct16 . $nov16 . $dec16;
                        break;
                    case $final_date[11]:
                        $dec14 = $checked;
                        $html_body .= $jan14 . $feb14 . $march14 . $april14 . $may14 . $june14 . $july14 . $aug14 . $sept14 . $oct14 . $nov14 . $dec14;
                        $html_body .= $jan15 . $feb15 . $march15 . $april15 . $may15 . $june15 . $july15 . $aug15 . $sept15 . $oct15 . $nov15 . $dec15;
                        $html_body .= $jan16 . $feb16 . $march16 . $april16 . $may16 . $june16 . $july16 . $aug16 . $sept16 . $oct16 . $nov16 . $dec16;
                        break;
                        // 2015
                    // 2015
                    case $final_date[12]:
                        $jan15 = $checked;
                        $html_body .= $jan14 . $feb14 . $march14 . $april14 . $may14 . $june14 . $july14 . $aug14 . $sept14 . $oct14 . $nov14 . $dec14;
                        $html_body .= $jan15 . $feb15 . $march15 . $april15 . $may15 . $june15 . $july15 . $aug15 . $sept15 . $oct15 . $nov15 . $dec15;
                        $html_body .= $jan16 . $feb16 . $march16 . $april16 . $may16 . $june16 . $july16 . $aug16 . $sept16 . $oct16 . $nov16 . $dec16;
                        break;
                    case $final_date[13]:
                        $feb15 = $checked;
                        $html_body .= $jan14 . $feb14 . $march14 . $april14 . $may14 . $june14 . $july14 . $aug14 . $sept14 . $oct14 . $nov14 . $dec14;
                        $html_body .= $jan15 . $feb15 . $march15 . $april15 . $may15 . $june15 . $july15 . $aug15 . $sept15 . $oct15 . $nov15 . $dec15;
                        $html_body .= $jan16 . $feb16 . $march16 . $april16 . $may16 . $june16 . $july16 . $aug16 . $sept16 . $oct16 . $nov16 . $dec16;
                        break;
                    case $final_date[14]:
                        $march15 = $checked;
                        $html_body .= $jan14 . $feb14 . $march14 . $april14 . $may14 . $june14 . $july14 . $aug14 . $sept14 . $oct14 . $nov14 . $dec14;
                        $html_body .= $jan15 . $feb15 . $march15 . $april15 . $may15 . $june15 . $july15 . $aug15 . $sept15 . $oct15 . $nov15 . $dec15;
                        $html_body .= $jan16 . $feb16 . $march16 . $april16 . $may16 . $june16 . $july16 . $aug16 . $sept16 . $oct16 . $nov16 . $dec16;
                        break;
                    case $final_date[15]:
                        $april15 = $checked;
                        $html_body .= $jan14 . $feb14 . $march14 . $april14 . $may14 . $june14 . $july14 . $aug14 . $sept14 . $oct14 . $nov14 . $dec14;
                        $html_body .= $jan15 . $feb15 . $march15 . $april15 . $may15 . $june15 . $july15 . $aug15 . $sept15 . $oct15 . $nov15 . $dec15;
                        $html_body .= $jan16 . $feb16 . $march16 . $april16 . $may16 . $june16 . $july16 . $aug16 . $sept16 . $oct16 . $nov16 . $dec16;
                        break;
                    case $final_date[16]:
                        $may15 = $checked;
                        $html_body .= $jan14 . $feb14 . $march14 . $april14 . $may14 . $june14 . $july14 . $aug14 . $sept14 . $oct14 . $nov14 . $dec14;
                        $html_body .= $jan15 . $feb15 . $march15 . $april15 . $may15 . $june15 . $july15 . $aug15 . $sept15 . $oct15 . $nov15 . $dec15;
                        $html_body .= $jan16 . $feb16 . $march16 . $april16 . $may16 . $june16 . $july16 . $aug16 . $sept16 . $oct16 . $nov16 . $dec16;
                        break;
                    case $final_date[17]:
                        $june15 = $checked;
                        $html_body .= $jan14 . $feb14 . $march14 . $april14 . $may14 . $june14 . $july14 . $aug14 . $sept14 . $oct14 . $nov14 . $dec14;
                        $html_body .= $jan15 . $feb15 . $march15 . $april15 . $may15 . $june15 . $july15 . $aug15 . $sept15 . $oct15 . $nov15 . $dec15;
                        $html_body .= $jan16 . $feb16 . $march16 . $april16 . $may16 . $june16 . $july16 . $aug16 . $sept16 . $oct16 . $nov16 . $dec16;
                        break;
                    case $final_date[18]:
                        $july15 = $checked;
                        $html_body .= $jan14 . $feb14 . $march14 . $april14 . $may14 . $june14 . $july14 . $aug14 . $sept14 . $oct14 . $nov14 . $dec14;
                        $html_body .= $jan15 . $feb15 . $march15 . $april15 . $may15 . $june15 . $july15 . $aug15 . $sept15 . $oct15 . $nov15 . $dec15;
                        $html_body .= $jan16 . $feb16 . $march16 . $april16 . $may16 . $june16 . $july16 . $aug16 . $sept16 . $oct16 . $nov16 . $dec16;
                        break;
                    case $final_date[19]:
                        $aug15 = $checked;
                        $html_body .= $jan14 . $feb14 . $march14 . $april14 . $may14 . $june14 . $july14 . $aug14 . $sept14 . $oct14 . $nov14 . $dec14;
                        $html_body .= $jan15 . $feb15 . $march15 . $april15 . $may15 . $june15 . $july15 . $aug15 . $sept15 . $oct15 . $nov15 . $dec15;
                        $html_body .= $jan16 . $feb16 . $march16 . $april16 . $may16 . $june16 . $july16 . $aug16 . $sept16 . $oct16 . $nov16 . $dec16;
                        break;
                    case $final_date[20]:
                        $sept15 = $checked;
                        $html_body .= $jan14 . $feb14 . $march14 . $april14 . $may14 . $june14 . $july14 . $aug14 . $sept14 . $oct14 . $nov14 . $dec14;
                        $html_body .= $jan15 . $feb15 . $march15 . $april15 . $may15 . $june15 . $july15 . $aug15 . $sept15 . $oct15 . $nov15 . $dec15;
                        $html_body .= $jan16 . $feb16 . $march16 . $april16 . $may16 . $june16 . $july16 . $aug16 . $sept16 . $oct16 . $nov16 . $dec16;
                        break;
                    case $final_date[21]:
                        $oct15 = $checked;
                        $html_body .= $jan14 . $feb14 . $march14 . $april14 . $may14 . $june14 . $july14 . $aug14 . $sept14 . $oct14 . $nov14 . $dec14;
                        $html_body .= $jan15 . $feb15 . $march15 . $april15 . $may15 . $june15 . $july15 . $aug15 . $sept15 . $oct15 . $nov15 . $dec15;
                        $html_body .= $jan16 . $feb16 . $march16 . $april16 . $may16 . $june16 . $july16 . $aug16 . $sept16 . $oct16 . $nov16 . $dec16;
                        break;
                    case $final_date[22]:
                        $nov15 = $checked;
                        $html_body .= $jan14 . $feb14 . $march14 . $april14 . $may14 . $june14 . $july14 . $aug14 . $sept14 . $oct14 . $nov14 . $dec14;
                        $html_body .= $jan15 . $feb15 . $march15 . $april15 . $may15 . $june15 . $july15 . $aug15 . $sept15 . $oct15 . $nov15 . $dec15;
                        $html_body .= $jan16 . $feb16 . $march16 . $april16 . $may16 . $june16 . $july16 . $aug16 . $sept16 . $oct16 . $nov16 . $dec16;
                        break;
                    case $final_date[23]:
                        $dec15 = $checked;
                        $html_body .= $jan14 . $feb14 . $march14 . $april14 . $may14 . $june14 . $july14 . $aug14 . $sept14 . $oct14 . $nov14 . $dec14;
                        $html_body .= $jan15 . $feb15 . $march15 . $april15 . $may15 . $june15 . $july15 . $aug15 . $sept15 . $oct15 . $nov15 . $dec15;
                        $html_body .= $jan16 . $feb16 . $march16 . $april16 . $may16 . $june16 . $july16 . $aug16 . $sept16 . $oct16 . $nov16 . $dec16;
                        break;
                        // 2016
                    // 2016
                    case $final_date[24]:
                        $jan16 = $checked;
                        $html_body .= $jan14 . $feb14 . $march14 . $april14 . $may14 . $june14 . $july14 . $aug14 . $sept14 . $oct14 . $nov14 . $dec14;
                        $html_body .= $jan15 . $feb15 . $march15 . $april15 . $may15 . $june15 . $july15 . $aug15 . $sept15 . $oct15 . $nov15 . $dec15;
                        $html_body .= $jan16 . $feb16 . $march16 . $april16 . $may16 . $june16 . $july16 . $aug16 . $sept16 . $oct16 . $nov16 . $dec16;
                        break;
                    case $final_date[25]:
                        $feb16 = $checked;
                        $html_body .= $jan14 . $feb14 . $march14 . $april14 . $may14 . $june14 . $july14 . $aug14 . $sept14 . $oct14 . $nov14 . $dec14;
                        $html_body .= $jan15 . $feb15 . $march15 . $april15 . $may15 . $june15 . $july15 . $aug15 . $sept15 . $oct15 . $nov15 . $dec15;
                        $html_body .= $jan16 . $feb16 . $march16 . $april16 . $may16 . $june16 . $july16 . $aug16 . $sept16 . $oct16 . $nov16 . $dec16;
                        break;
                    case $final_date[26]:
                        $march16 = $checked;
                        $html_body .= $jan14 . $feb14 . $march14 . $april14 . $may14 . $june14 . $july14 . $aug14 . $sept14 . $oct14 . $nov14 . $dec14;
                        $html_body .= $jan15 . $feb15 . $march15 . $april15 . $may15 . $june15 . $july15 . $aug15 . $sept15 . $oct15 . $nov15 . $dec15;
                        $html_body .= $jan16 . $feb16 . $march16 . $april16 . $may16 . $june16 . $july16 . $aug16 . $sept16 . $oct16 . $nov16 . $dec16;
                        break;
                    case $final_date[27]:
                        $april16 = $checked;
                        $html_body .= $jan14 . $feb14 . $march14 . $april14 . $may14 . $june14 . $july14 . $aug14 . $sept14 . $oct14 . $nov14 . $dec14;
                        $html_body .= $jan15 . $feb15 . $march15 . $april15 . $may15 . $june15 . $july15 . $aug15 . $sept15 . $oct15 . $nov15 . $dec15;
                        $html_body .= $jan16 . $feb16 . $march16 . $april16 . $may16 . $june16 . $july16 . $aug16 . $sept16 . $oct16 . $nov16 . $dec16;
                        break;
                    case $final_date[28]:
                        $may16 = $checked;
                        $html_body .= $jan14 . $feb14 . $march14 . $april14 . $may14 . $june14 . $july14 . $aug14 . $sept14 . $oct14 . $nov14 . $dec14;
                        $html_body .= $jan15 . $feb15 . $march15 . $april15 . $may15 . $june15 . $july15 . $aug15 . $sept15 . $oct15 . $nov15 . $dec15;
                        $html_body .= $jan16 . $feb16 . $march16 . $april16 . $may16 . $june16 . $july16 . $aug16 . $sept16 . $oct16 . $nov16 . $dec16;
                        break;
                    case $final_date[29]:
                        $june16 = $checked;
                        $html_body .= $jan14 . $feb14 . $march14 . $april14 . $may14 . $june14 . $july14 . $aug14 . $sept14 . $oct14 . $nov14 . $dec14;
                        $html_body .= $jan15 . $feb15 . $march15 . $april15 . $may15 . $june15 . $july15 . $aug15 . $sept15 . $oct15 . $nov15 . $dec15;
                        $html_body .= $jan16 . $feb16 . $march16 . $april16 . $may16 . $june16 . $july16 . $aug16 . $sept16 . $oct16 . $nov16 . $dec16;
                        break;
                    case $final_date[30]:
                        $july16 = $checked;
                        $html_body .= $jan14 . $feb14 . $march14 . $april14 . $may14 . $june14 . $july14 . $aug14 . $sept14 . $oct14 . $nov14 . $dec14;
                        $html_body .= $jan15 . $feb15 . $march15 . $april15 . $may15 . $june15 . $july15 . $aug15 . $sept15 . $oct15 . $nov15 . $dec15;
                        $html_body .= $jan16 . $feb16 . $march16 . $april16 . $may16 . $june16 . $july16 . $aug16 . $sept16 . $oct16 . $nov16 . $dec16;
                        break;
                    case $final_date[31]:
                        $aug16 = $checked;
                        $html_body .= $jan14 . $feb14 . $march14 . $april14 . $may14 . $june14 . $july14 . $aug14 . $sept14 . $oct14 . $nov14 . $dec14;
                        $html_body .= $jan15 . $feb15 . $march15 . $april15 . $may15 . $june15 . $july15 . $aug15 . $sept15 . $oct15 . $nov15 . $dec15;
                        $html_body .= $jan16 . $feb16 . $march16 . $april16 . $may16 . $june16 . $july16 . $aug16 . $sept16 . $oct16 . $nov16 . $dec16;
                        break;
                    case $final_date[32]:
                        $sept16 = $checked;
                        $html_body .= $jan14 . $feb14 . $march14 . $april14 . $may14 . $june14 . $july14 . $aug14 . $sept14 . $oct14 . $nov14 . $dec14;
                        $html_body .= $jan15 . $feb15 . $march15 . $april15 . $may15 . $june15 . $july15 . $aug15 . $sept15 . $oct15 . $nov15 . $dec15;
                        $html_body .= $jan16 . $feb16 . $march16 . $april16 . $may16 . $june16 . $july16 . $aug16 . $sept16 . $oct16 . $nov16 . $dec16;
                        break;
                    case $final_date[33]:
                        $oct16 = $checked;
                        $html_body .= $jan14 . $feb14 . $march14 . $april14 . $may14 . $june14 . $july14 . $aug14 . $sept14 . $oct14 . $nov14 . $dec14;
                        $html_body .= $jan15 . $feb15 . $march15 . $april15 . $may15 . $june15 . $july15 . $aug15 . $sept15 . $oct15 . $nov15 . $dec15;
                        $html_body .= $jan16 . $feb16 . $march16 . $april16 . $may16 . $june16 . $july16 . $aug16 . $sept16 . $oct16 . $nov16 . $dec16;
                        break;
                    case $final_date[34]:
                        $nov16 = $checked;
                        $html_body .= $jan14 . $feb14 . $march14 . $april14 . $may14 . $june14 . $july14 . $aug14 . $sept14 . $oct14 . $nov14 . $dec14;
                        $html_body .= $jan15 . $feb15 . $march15 . $april15 . $may15 . $june15 . $july15 . $aug15 . $sept15 . $oct15 . $nov15 . $dec15;
                        $html_body .= $jan16 . $feb16 . $march16 . $april16 . $may16 . $june16 . $july16 . $aug16 . $sept16 . $oct16 . $nov16 . $dec16;
                        break;
                    case $final_date[35]:
                        $dec16 = $checked;
                        $html_body .= $jan14 . $feb14 . $march14 . $april14 . $may14 . $june14 . $july14 . $aug14 . $sept14 . $oct14 . $nov14 . $dec14;
                        $html_body .= $jan15 . $feb15 . $march15 . $april15 . $may15 . $june15 . $july15 . $aug15 . $sept15 . $oct15 . $nov15 . $dec15;
                        $html_body .= $jan16 . $feb16 . $march16 . $april16 . $may16 . $june16 . $july16 . $aug16 . $sept16 . $oct16 . $nov16 . $dec16;
                        break;
                    default:
                        $html_body .= $jan14 . $feb14 . $march14 . $april14 . $may14 . $june14 . $july14 . $aug14 . $sept14 . $oct14 . $nov14 . $dec14;
                        $html_body .= $jan15 . $feb15 . $march15 . $april15 . $may15 . $june15 . $july15 . $aug15 . $sept15 . $oct15 . $nov15 . $dec15;
                        $html_body .= $jan16 . $feb16 . $march16 . $april16 . $may16 . $june16 . $july16 . $aug16 . $sept16 . $oct16 . $nov16 . $dec16;
                        break;
                }
            }
            $html_body .= '</tr></div>
												</form>
											</tbody>
										</table>
										';
            $pdf_data = array("pdf_title" => "Expiry Tracking Chart For {$facility_name}", 'pdf_html_body' => $pdf_body, 'pdf_view_option' => 'download', 'file_name' => $file_name);
            $html_body['title'] = $pdf_data;
        }
        // echo "<pre>";print_r($html_body);echo "</pre>";exit;
        return $html_body;
    }
Esempio n. 30
0
 public function edit_district($code)
 {
     $district = Districts::getDistrict($code);
     $data['district_populations'] = District_Populations::getAllForDistrict($code);
     $data['district'] = $district;
     $data['title'] = "District Management::Edit " . $district->name . " District";
     $data['module_view'] = "add_district_view";
     $data['quick_link'] = "new_district";
     $data['provinces'] = Provinces::getAllProvinces();
     $this->base_params($data);
 }