public function get_stock_status_ajax($option = NULL, $facility_code = NULL, $year = NULL) { $facility_code = $facility_code; $district = $this->session->userdata('district1'); $county_id = $this->session->userdata('county_id'); $width = "100%"; $height = "100%"; if ($option == NULL) { $commodity_array = facility_stock::get_district_stock_level($district); } elseif ($option == "ajax-request_facility") { $district_name = facilities::get_facility_name_($facility_code); $title = $district_name["facility_name"]; $commodity_array = facility_stock::get_facility_stock_level($facility_code); if (count($commodity_array) < 20) { $width = "100%"; $height = "50%"; } if (count($commodity_array) > 20 && count($commodity_array) < 40) { $width = "100%"; $height = "100%"; } if (count($commodity_array) > 50) { $width = "100%"; $height = "400%"; } $commodity_name = array(); $current_values = array(); $monthly_values = array(); foreach ($commodity_array as $data) { array_push($commodity_name, $data['drug_name']); array_push($current_values, isset($data['total']) ? (int) $data['total'] : (int) 0); array_push($monthly_values, isset($data['consumption_level']) ? (int) $data['consumption_level'] : (int) 0); } $data['width'] = $width; $data['height'] = $height; $data['title_1'] = "Current Balance"; $data['title_2'] = "Average Monthly Consumption"; $data['commodity_name'] = stripslashes(json_encode($commodity_name)); $data['current_values'] = json_encode($current_values); $data['monthly_values'] = json_encode($monthly_values); return $this->load->view("facility/facility_reports/facility_commodity_stock_level_v", $data); } elseif ($option == "ajax-request_county") { $commodity_array = isset($facility_code) ? facility_stock::get_county_drug_stock_level($county_id, $facility_code) : facility_stock::get_county_drug_stock_level($county_id); } elseif ($option == "ajax-request_drug") { $commodity_array = facility_stock::get_district_drug_stock_level($district, $facility_code); } elseif ($option == "consumption") { $commodity_array = facility_stock::get_county_drug_consumption_level($county_id, $facility_code, $year); } if (count($commodity_array) < 20) { $width = "100%"; $height = "50%"; } if (count($commodity_array) > 20 && count($commodity_array) < 50) { $width = "100%"; $height = "100%"; } if (count($commodity_array) > 50) { $width = "100%"; $height = "300%"; } $data['width'] = $width; $data['height'] = $height; $data['facilities'] = Facilities::getFacilities($district); $data['option'] = $option; $data['facility_code'] = $facility_code; $data['year_selection'] = $year; $this->load->view("district/ajax_view/stock_status_v", $data); }