public function getBalances($from, $district_or_region, $region_name) # { $this -> load -> database(); $start_date = ""; $number = ""; @$end_date = date('m/d/y'); $closing_balance = 0; //calls the following function from the vaccines model. //the function c=selects data from the vaccines table then stores them in an array //the array is stored in the $vaccines variable $vaccines = Vaccines::getAll_Minified(); //gets consumption as per every vaccine @$message = ""; foreach ($vaccines as $vaccine) { //$district_or_region is the regions id number $region_object = Regions::getRegion($district_or_region); $name = urlencode($vaccine['Name']); $store = urlencode($region_object -> name); $closing_balance = Disbursements::getRegionalPeriodBalance($district_or_region, $vaccine -> id, strtotime($end_date)); $closing_balance_formatted = number_format($closing_balance); if ($closing_balance_formatted == 0) { // echo @$message.= "VACCINES+STOCK+OUTS++AT++%0A+*+DVI+-+SMT*"; $this -> get_phones($name,$district_or_region,$store); } } }
public function getBalances($phones) { $this->load->database(); $start_date = ""; $data_buffer = ""; $number = ""; @$start_date == date('m/d/y', strtotime('-30 days')); @($end_date = date('m/d/y')); $population = 0; $closing_balance = 0; $sql_consumption = ""; $vaccines = Vaccines::getAll_Minified(); //gets consumption as per every vaccine foreach ($vaccines as $vaccine) { $population = Regional_Populations::getNationalPopulation(date('Y')); $closing_balance = Disbursements::getNationalPeriodBalance($vaccine->id, strtotime($end_date)); $sql_consumption = "select (SELECT max(str_to_date(Date_Issued,'%m/%d/%Y')) FROM `disbursements` where Owner = 'N0' and str_to_date(Date_Issued,'%m/%d/%Y') between str_to_date('" . $start_date . "','%m/%d/%Y') and str_to_date('" . $end_date . "','%m/%d/%Y') and Vaccine_Id = '" . $vaccine->id . "' and total_stock_balance>0)as last_stock_count,(SELECT sum(Quantity)FROM `disbursements` where Issued_By_National = '0' and Owner = 'N0' and str_to_date(Date_Issued,'%m/%d/%Y') between str_to_date('" . $start_date . "','%m/%d/%Y') and\n str_to_date('" . $end_date . "','%m/%d/%Y') and Vaccine_Id = '" . $vaccine->id . "')as total_issued,(SELECT sum(Quantity) FROM `disbursements` where Issued_To_National = '0' and Owner = 'N0' and str_to_date(Date_Issued,'%m/%d/%Y') between str_to_date('" . $start_date . "','%m/%d/%Y') and\n str_to_date('" . $end_date . "','%m/%d/%Y') and Vaccine_Id = '" . $vaccine->id . "')as total_received"; $query = $this->db->query($sql_consumption); $vaccine_data = $query->row(); $monthly_requirement = ceil($vaccine->Doses_Required * $population * $vaccine->Wastage_Factor / 12); $space1 = urldecode("++++"); $space2 = urldecode("++"); $newline = urldecode("%0A"); $brace = urldecode('('); $brace2 = urldecode(')'); $messsage = urlencode($data_buffer .= $newline . $vaccine->Name . $space2 . number_format($closing_balance + 0) . $space1 . $brace . number_format($closing_balance / $monthly_requirement, 1) . 'MOS' . $brace2); } $this->Send_Balanaces($phones, $messsage); }
public function new_dashboard() { $identifier = $this -> session -> userdata('user_identifier'); if ($this -> session -> userdata('user_identifier') == 'national_officer') { $data['content_view'] = "national_dashboard_view"; } if ($this -> session -> userdata('user_identifier') == 'district_officer') { $data['content_view'] = "district_dashboard_view"; } if ($this -> session -> userdata('user_identifier') == 'provincial_officer') { $data['content_view'] = "regional_dashboard_view"; } if ($this -> session -> userdata('user_identifier') == 'general_user') { $data['content_view'] = "general_dashboard_view"; } $year = date('Y'); $data['title'] = "System Dashboard"; $data['vaccines'] = Vaccines::getAll_Minified(); $data['styles'] = array("jquery-ui.css", "tab.css"); $data['scripts'] = array("FusionCharts/FusionCharts.js","jquery-ui.js", "advanced_tabs.js"); $data['link'] = "home"; $this -> load -> view('template', $data); }
private function base_params($data) { $data['vaccines'] = Vaccines::getAll_Minified(); $data['scripts'] = array("jquery-ui.js", "tab.js"); $data['styles'] = array("jquery-ui.css", "tab.css"); $data['link'] = "alerts"; $this->load->view('template', $data); }
public function download() { $this->load->database(); $valid = $this->validate_form(); if ($valid) { $data_buffer = "\n\t\t\t<style>\n\t\t\ttable.data-table {\n\t\t\ttable-layout: fixed;\n\t\t\twidth: 700px;\n\t\t\tborder-collapse:collapse;\n\t\t\tborder:1px solid black;\n\t\t\t}\n\t\t\ttable.data-table td, th {\n\t\t\twidth: 100px;\n\t\t\tborder: 1px solid black;\n\t\t\t}\n\t\t\t.leftie{\n\t\t\t\ttext-align: left !important;\n\t\t\t}\n\t\t\t.right{\n\t\t\t\ttext-align: right !important;\n\t\t\t}\n\t\t\t.center{\n\t\t\t\ttext-align: center !important;\n\t\t\t}\n\t\t\t</style> \n\t\t\t"; $start_date = $this->input->post("start_date"); $end_date = $this->input->post("end_date"); $data_buffer .= "<table class='data-table'>"; $data_buffer .= $this->echoTitles(); $district_or_region = $this->session->userdata('district_province_id'); $identifier = $this->session->userdata('user_identifier'); $population = 0; $opening_balance = 0; $closing_balance = 0; $sql_consumption = ""; $store = ""; $vaccines = Vaccines::getAll_Minified(); foreach ($vaccines as $vaccine) { if ($identifier == 'provincial_officer') { $region_object = Regions::getRegion($district_or_region); $store = $region_object->name; $population = Regional_Populations::getRegionalPopulation($district_or_region, date('Y')); $opening_balance = Disbursements::getRegionalPeriodBalance($district_or_region, $vaccine->id, strtotime($start_date)); $closing_balance = Disbursements::getRegionalPeriodBalance($district_or_region, $vaccine->id, strtotime($end_date)); $owner = "R" . $district_or_region; $sql_consumption = "select (SELECT date_format(max(str_to_date(Date_Issued,'%m/%d/%Y')),'%d-%b-%Y') FROM `disbursements` where Owner = '" . $owner . "' and str_to_date(Date_Issued,'%m/%d/%Y') between str_to_date('" . $start_date . "','%m/%d/%Y') and str_to_date('" . $end_date . "','%m/%d/%Y') and Vaccine_Id = '" . $vaccine->id . "' and total_stock_balance>0)as last_stock_count,(SELECT sum(Quantity)FROM `disbursements` where Issued_By_Region = '" . $district_or_region . "' and Owner = '" . $owner . "' and str_to_date(Date_Issued,'%m/%d/%Y') between str_to_date('" . $start_date . "','%m/%d/%Y') and\nstr_to_date('" . $end_date . "','%m/%d/%Y') and Vaccine_Id = '" . $vaccine->id . "')as total_issued,(SELECT sum(Quantity) FROM `disbursements` where Issued_To_Region = '" . $district_or_region . "' and Owner = '" . $owner . "' and str_to_date(Date_Issued,'%m/%d/%Y') between str_to_date('" . $start_date . "','%m/%d/%Y') and\nstr_to_date('" . $end_date . "','%m/%d/%Y') and Vaccine_Id = '" . $vaccine->id . "')as total_received"; } else { if ($identifier == 'district_officer') { $district_object = Districts::getDistrict($district_or_region); $store = $district_object->name; $population = District_Populations::getDistrictPopulation($district_or_region, date('Y')); $opening_balance = Disbursements::getDistrictPeriodBalance($district_or_region, $vaccine->id, strtotime($start_date)); $closing_balance = Disbursements::getDistrictPeriodBalance($district_or_region, $vaccine->id, strtotime($end_date)); $owner = "D" . $district_or_region; $sql_consumption = "select (SELECT date_format(max(str_to_date(Date_Issued,'%m/%d/%Y')),'%d-%b-%Y') FROM `disbursements` where Owner = '" . $owner . "' and str_to_date(Date_Issued,'%m/%d/%Y') between str_to_date('" . $start_date . "','%m/%d/%Y') and str_to_date('" . $end_date . "','%m/%d/%Y') and Vaccine_Id = '" . $vaccine->id . "' and total_stock_balance>0)as last_stock_count,(SELECT sum(Quantity)FROM `disbursements` where Issued_By_District = '" . $district_or_region . "' and Owner = '" . $owner . "' and str_to_date(Date_Issued,'%m/%d/%Y') between str_to_date('" . $start_date . "','%m/%d/%Y') and\nstr_to_date('" . $end_date . "','%m/%d/%Y') and Vaccine_Id = '" . $vaccine->id . "')as total_issued,(SELECT sum(Quantity) FROM `disbursements` where Issued_To_District = '" . $district_or_region . "' and Owner = '" . $owner . "' and str_to_date(Date_Issued,'%m/%d/%Y') between str_to_date('" . $start_date . "','%m/%d/%Y') and\nstr_to_date('" . $end_date . "','%m/%d/%Y') and Vaccine_Id = '" . $vaccine->id . "')as total_received"; } else { if ($identifier == 'national_officer') { $store = "Central Vaccines Store"; $population = Regional_Populations::getNationalPopulation(date('Y')); $opening_balance = Disbursements::getNationalPeriodBalance($vaccine->id, strtotime($start_date)); $closing_balance = Disbursements::getNationalPeriodBalance($vaccine->id, strtotime($end_date)); $sql_consumption = "select (SELECT date_format(max(str_to_date(Date_Issued,'%m/%d/%Y')),'%d-%b-%Y') FROM `disbursements` where Owner = 'N0' and str_to_date(Date_Issued,'%m/%d/%Y') between str_to_date('" . $start_date . "','%m/%d/%Y') and str_to_date('" . $end_date . "','%m/%d/%Y') and Vaccine_Id = '" . $vaccine->id . "' and total_stock_balance>0)as last_stock_count,(SELECT sum(Quantity)FROM `disbursements` where Issued_By_National = '0' and Owner = 'N0' and str_to_date(Date_Issued,'%m/%d/%Y') between str_to_date('" . $start_date . "','%m/%d/%Y') and\nstr_to_date('" . $end_date . "','%m/%d/%Y') and Vaccine_Id = '" . $vaccine->id . "')as total_issued,(SELECT sum(Quantity) FROM `disbursements` where Issued_To_National = '0' and Owner = 'N0' and str_to_date(Date_Issued,'%m/%d/%Y') between str_to_date('" . $start_date . "','%m/%d/%Y') and\nstr_to_date('" . $end_date . "','%m/%d/%Y') and Vaccine_Id = '" . $vaccine->id . "')as total_received"; } } } $query = $this->db->query($sql_consumption); $vaccine_data = $query->row(); $monthly_requirement = ceil($vaccine->Doses_Required * $population * $vaccine->Wastage_Factor / 12); $data_buffer .= "<tr><td style='text-align:left;'>" . $vaccine->Name . "</td><td class='right'>" . number_format($opening_balance + 0) . "</td><td class='right'>" . number_format($vaccine_data->total_received + 0) . "</td><td class='right'>" . number_format($vaccine_data->total_issued + 0) . "</td><td class='right'>" . number_format($closing_balance - ($opening_balance + $vaccine_data->total_received - $vaccine_data->total_issued) + 0) . "</td><td class='right'>" . number_format($closing_balance + 0) . "</td><td class='center'>" . number_format($closing_balance / $monthly_requirement, 1) . "</td><td class='center'>" . $vaccine_data->last_stock_count . "</td></tr>"; } $data_buffer .= "</table>"; $this->generatePDF($data_buffer, $start_date, $end_date, $store); } else { $this->view_transactions_interface(); } }
public function getBalances($from, $district_or_region, $region_name) { $this->load->database(); $start_date = ""; $number = ""; @($end_date = date('m/d/y')); $closing_balance = 0; $vaccines = Vaccines::getAll_Minified(); //gets consumption as per every vaccine @($message = ""); foreach ($vaccines as $vaccine) { $region_object = Regions::getRegion($district_or_region); $name = urlencode($vaccine['Name']); $store = urlencode($region_object->name); $closing_balance = Disbursements::getRegionalPeriodBalance($district_or_region, $vaccine->id, strtotime($end_date)); $closing_balance_formatted = number_format($closing_balance); if ($closing_balance_formatted == 0) { // echo @$message.= "VACCINES+STOCK+OUTS++AT++%0A+*+DVI+-+SMT*"; $this->get_phones($name, $district_or_region, $store); } } }
private function base_params($data) { $data['vaccines'] = Vaccines::getAll_Minified(); $data['scripts'] = array("jquery-ui.js", "tab.js", "FusionCharts/FusionCharts.js"); $data['styles'] = array("jquery-ui.css", "tab.css"); $data['link'] = "batch_management"; $this->load->view('template', $data); }
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(); } }
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; }
<div class="dashboard_menu"> <a href="<?php echo site_url()."task_Management/add_new"?>" class="quick_menu_link">Add new task</a> <?php $access_level = $this -> session -> userdata('user_group'); if($access_level == "1" || $access_level == "2"){?> <a href="<?php echo site_url()."task_management/view_task";?>" class="quick_menu_link <?php if($quick_link == "edit_task"){echo "quick_menu_active";}?>">Edit Task</a> <?php } ?> <a class="quick_menu_link <?php if($quick_link == "all_tasks") {echo "quick_menu_active";}?>" href="<?php echo site_url("task_management");?>">All Tasks</a> <div id="tabs" class="htabs"> <?php $vaccines = Vaccines::getAll_Minified(); foreach($vaccines as $vaccine){?> <?php?> <a href="<?php echo base_url()."task_Management/vaccine/".$vaccine->id?>" id="vaccine_<?php echo $vaccine->id ?>" tab="#<?php echo $vaccine->id ?>" class="vaccine_name" name="<?php echo $vaccine->Name?>" style="background-color: <?php echo '#'.$vaccine->Tray_Color;?>"><?php echo $vaccine->Name?></a> <?php } ?> <?php if(isset($gantt_data)){ ?> <script type="text/javascript"> $(function() { var _id=<?php echo $gantt_data; ?>; $(".vaccine_name").removeClass(); $("#vaccine_"+_id).addClass('selected'); }); </script>
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 }
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; }
function download_forecast($vaccine = 0, $year = "0", $national = 0, $region = 0, $district = 0) { $population = 0; if ($year == "0") { $year = date('Y'); } $title = ""; if ($national > 0) { $title = "Consumption vs. Forecast at Central Vaccine Store"; $population = regional_populations::getNationalPopulation($year); } if ($region > 0) { $region_object = Regions::getRegion($region); $title = "Consumption vs. Forecast at " . $region_object->name; $population = Regional_Populations::getRegionalPopulation($region, $year); } if ($district > 0) { $district_object = Districts::getDistrict($district); $title = "Consumption vs. Forecast at " . $district_object->name . " District Store"; $population = District_Populations::getDistrictPopulation($district, $year); } $population = str_replace(",", "", $population); $vaccines = Vaccines::getAll_Minified(); $date = date("m/d/Y"); $months_required = array(); $data_buffer = "\n\t\t\t<style>\n\t\t\ttable.data-table {\n\t\t\ttable-layout: fixed;\n\t\t\twidth: 700px;\n\t\t\tborder-collapse:collapse;\n\t\t\tborder:1px solid black;\n\t\t\t}\n\t\t\ttable.data-table td, th {\n\t\t\twidth: 100px;\n\t\t\tborder: 1px solid black;\n\t\t\t}\n\t\t\t.leftie{\n\t\t\t\ttext-align: left !important;\n\t\t\t}\n\t\t\t.center{\n\t\t\t\ttext-align: center !important;\n\t\t\t}\n\t\t\t.right{\n\t\t\t\ttext-align: right !important;\n\t\t\t}\n\t\t\t</style> \n\t\t\t"; $data_buffer .= "<table class='data-table'>"; $data_buffer .= $this->echoTitles(); //Get the start and end dates for all the quarters $quarter_one_start = date("U", mktime(0, 0, 0, 1, 1, $year)); $quarter_one_end = date("U", mktime(0, 0, 0, 3, 31, $year)); $quarter_two_start = date("U", mktime(0, 0, 0, 4, 1, $year)); $quarter_two_end = date("U", mktime(0, 0, 0, 6, 30, $year)); $quarter_three_start = date("U", mktime(0, 0, 0, 7, 1, $year)); $quarter_three_end = date("U", mktime(0, 0, 0, 9, 30, $year)); $quarter_four_start = date("U", mktime(0, 0, 0, 10, 1, $year)); $quarter_four_end = date("U", mktime(0, 0, 0, 12, 31, $year)); foreach ($vaccines as $vaccine_object) { $months_of_stock = array(); $now = date('U'); //Get the consumption for each of the quarters //Set the maximum value $max_value = 0; //Get the consumption for each of the quarters if ($national > 0) { $quarter_one_consumption = Disbursements::getNationalIssuesTotals($vaccine_object->id, $quarter_one_start, $quarter_one_end); $quarter_two_consumption = Disbursements::getNationalIssuesTotals($vaccine_object->id, $quarter_two_start, $quarter_two_end); $quarter_three_consumption = Disbursements::getNationalIssuesTotals($vaccine_object->id, $quarter_three_start, $quarter_three_end); $quarter_four_consumption = Disbursements::getNationalIssuesTotals($vaccine_object->id, $quarter_four_start, $quarter_four_end); } if ($region > 0) { $quarter_one_consumption = Disbursements::getRegionalIssuesTotals($vaccine_object->id, $quarter_one_start, $quarter_one_end, $region); $quarter_two_consumption = Disbursements::getRegionalIssuesTotals($vaccine_object->id, $quarter_two_start, $quarter_two_end, $region); $quarter_three_consumption = Disbursements::getRegionalIssuesTotals($vaccine_object->id, $quarter_three_start, $quarter_three_end, $region); $quarter_four_consumption = Disbursements::getRegionalIssuesTotals($vaccine_object->id, $quarter_four_start, $quarter_four_end, $region); } if ($district > 0) { $quarter_one_consumption = Disbursements::getDistrictIssuesTotals($district, $vaccine_object->id, $quarter_one_start, $quarter_one_end); $quarter_two_consumption = Disbursements::getDistrictIssuesTotals($district, $vaccine_object->id, $quarter_two_start, $quarter_two_end); $quarter_three_consumption = Disbursements::getDistrictIssuesTotals($district, $vaccine_object->id, $quarter_three_start, $quarter_three_end); $quarter_four_consumption = Disbursements::getDistrictIssuesTotals($district, $vaccine_object->id, $quarter_four_start, $quarter_four_end); } $monthly_requirement = ceil($vaccine_object->Doses_Required * $population * $vaccine_object->Wastage_Factor / 12); $quarterly_consumption = $monthly_requirement * 3; $data_buffer .= "<tr><td class='leftie'>" . $vaccine_object->Name . "</td><td class='right'>" . number_format($quarterly_consumption) . "</td><td class='right'>" . number_format($quarter_one_consumption) . "</td><td class='right'>" . number_format($quarterly_consumption - $quarter_one_consumption) . "</td><td class='right'>" . number_format($quarter_two_consumption) . "</td><td class='right'>" . number_format($quarterly_consumption - $quarter_two_consumption) . "</td><td class='right'>" . number_format($quarter_three_consumption) . "</td><td class='right'>" . number_format($quarterly_consumption - $quarter_three_consumption) . "</td><td class='right'>" . number_format($quarter_four_consumption) . "</td><td class='right'>" . number_format($quarterly_consumption - $quarter_four_consumption) . "</td></tr>"; } $data_buffer .= "</table>"; $this->generatePDF($data_buffer, $year, $title); echo $data_buffer; }
function nyeri_dashboard() { $data['link'] = "region_view"; $year = date('Y'); $data['province_id'] = 8; $data['title'] = "System Dashboard :: Nyeri"; $data['vaccines'] = Vaccines::getAll_Minified(); $data['styles'] = array("jquery-ui.css", "tab.css"); $data['scripts'] = array("FusionCharts/FusionCharts.js", "jquery-ui.js", "advanced_tabs.js"); $data['content_view'] = "general_specific"; $data['quick_link'] = "nyeri"; $data['dashboard_active'] = 1; $data['text'] = "Regional Dashboard :: Nyeri"; $this->load->view('template_regional_dashboard', $data); }