public function national_allocation_chart() { $str_xml_body = ''; // $title=""; $strXML = "<chart caption='National Allocation' yAxisName='Allocation' alternateVGridColor='AFD8F8' baseFontColor='114B78' toolTipBorderColor='114B78' toolTipBgColor='E7EFF6' useRoundEdges='1' showBorder='0' bgColor='FFFFFF,FFFFFF'>"; $allocations = rtk_stock_status::get_national_allocation(); $counties = counties::getAllcounties(); foreach ($counties as $counties_data) { $counties_data_id = $counties_data["id"]; } $districts = districts::getDistrict(2); // Gets districts within county id 2 foreach ($districts as $districts_data) { $districts_data_id = $districts_data["id"]; $districts_data_name = $districts_data["district"]; // echo $districts_data_id; //echo $districts_data_name."<br /><br />"; $facilities = facilities::getFacilities($districts_data_id); foreach ($facilities as $facilities_data) { $facilities_data_id = $facilities_data["id"]; $facilities_data_code = $facilities_data["facility_code"]; $allocations = rtk_stock_status::get_county_allocation($facilities_data_code); $sum_determine = 0; $sum_unigold = 0; $sum_syphillis = 0; $commodity = ""; foreach ($allocations as $allocations_data) { if ($allocations_data["commodity_id"] == 1) { $commodity = "Colloidal"; $sum_unigold += $allocations_data["qty"]; } if ($allocations_data["commodity_id"] == 2) { $commodity = "First Response"; $sum_determine += $allocations_data["qty"]; } if ($allocations_data["commodity_id"] == 3) { $commodity = "Unigold"; $sum_syphillis += $allocations_data["qty"]; } $allocations_data_commodity_id = $allocations_data["commodity_id"]; } } $str_xml_body .= "<set value='{$sum_determine}' label='Total Determine {$districts_data_name}'/>"; $str_xml_body .= "<set value='{$sum_unigold}' label='Reporting Unigold {$districts_data_name}'/>"; $str_xml_body .= "<set value='{$sum_syphillis}' label='Sum Syphillis {$districts_data_name}'/>"; } echo $str_xml_body; $strXML .= "{$str_xml_body}</chart>"; echo $strXML; }
public function get_district_facility_mapping_($district_id) { $facility_data = facilities::getFacilities($district_id); $dpp_details = Users::get_dpp_details($district_id)->toArray(); $district_name = districts::getDistrict(null, $district_id)->toArray(); $table_body = ""; $dpp_fname = ''; $dpp_lname = ''; $dpp_phone = ''; $dpp_email = ''; $indicator = "SubCounty"; $no_of_facility_users = 0; $no_of_facility_users_online = 0; $no_of_facilities = 0; $no_of_facilities_using = 0; $no_of_facilities_using_targetted = 0; $series_data = $graph_data = array(); if (count($dpp_details) > 0) { $dpp_fname = $dpp_details[0]['fname']; $dpp_lname = $dpp_details[0]['lname']; $dpp_phone = $dpp_details[0]['telephone']; $dpp_email = $dpp_details[0]['email']; } foreach ($facility_data as $facility_detail) { $facility_code = $facility_detail->facility_code; $facility_extra_data = facilities::get_facility_status_no_users_status($facility_code); $no_of_facility_users = $no_of_facility_users + $facility_extra_data[0]['number_of_users']; $no_of_facility_users_online = $no_of_facility_users_online + $facility_extra_data[0]['number_of_users_online']; $no_of_facilities = $no_of_facilities + 1; $using = $facility_detail->using_hcmp; $status_radio = $facility_detail->targetted == 1 ? 'checked="true"' : null; $using == 1 ? $no_of_facilities_using = $no_of_facilities_using + 1 : ($status = null); $temp = $facility_extra_data[0]['status']; $status_using = $using == 1 ? 'checked="true"' : null; $a_date = strtotime($facility_detail->date_of_activation) ? date('d M, Y', strtotime($facility_detail->date_of_activation)) : "N/A"; $using == 1 ? $status = "<span class='label label-success'>Active</span>" : ($status = "<span class='label label-warning'>Inactive</span>"); $facility_detail->targetted == 1 ? $no_of_facilities_using_targetted = $no_of_facilities_using_targetted + 1 : null; array_push($series_data, array($district_name[0]['district'], $facility_detail->facility_name, $facility_code, $facility_detail->owner, $status, "<input id='{$facility_detail->id}' type='checkbox' name='targetted' class='checkbox' {$status_radio}/>", "<input id='{$facility_detail->id}' name='using_hcmp' type='checkbox' class='checkbox' {$status_using}/>", $a_date, $facility_extra_data[0]['number_of_users'])); } $stats_data = ' <table style="float:left"> <tr> <td><label style=" font-weight: ">' . $district_name[0]['district'] . ' ' . $indicator . ' Pharmacist :</label></td> <td><a class="badge">' . $dpp_fname . ' ' . $dpp_lname . '</a></td> </tr> <tr> <td><label style="font-weight: ">Phone No.</label></td> <td><a class="badge">' . $dpp_phone . '</a></td> </tr> <tr> <td><label style="font-weight: ">Email Address</label></td> <td><a class="badge">' . $dpp_email . '</a></td> </tr> </table> <table style="float:left"> <tr> <td><label style=" font-weight: ">Total No of Facilities</label></td> <td><a class="badge" >' . $no_of_facilities . '</a></td> </tr> <tr> <td><label style="font-weight: ">Total No of Facilities Targeted</label></td> <td> <a class="badge">' . $no_of_facilities_using_targetted . '</a></td> </tr> <tr> <td><label style="font-weight: ">Total No of Facilities Using HCMP </label></td> <td> <a class="badge">' . $no_of_facilities_using . '</a></td> </tr> <tr> <td><label style="font-weight: ">Total No of Users</label></td> <td><a class="badge" >' . $no_of_facility_users . '</a></td> </tr> </table> </br><p>'; $category_data = array(array("Sub County", 'Facility Name', "MLF No", "Owner", "Facility Status", "Targeted For Roll Out", "Using HCMP", "Date Activated", "No. Facility Users")); $graph_data = array_merge($graph_data, array("table_id" => 'dem_graph_1')); $graph_data = array_merge($graph_data, array("table_header" => $category_data)); $graph_data = array_merge($graph_data, array("table_body" => $series_data)); $data['table'] = $this->hcmp_functions->create_data_table($graph_data); $data['table_id'] = "dem_graph_1"; $data['stats_data'] = $stats_data; return $this->load->view("shared_files/report_templates/data_table_template_v", $data); }
public function get_district_facility_mapping_($district_id) { $facility_data = facilities::getFacilities($district_id); $table_body = ""; $dpp_details = user::get_dpp_details($district_id)->toArray(); $district_name = districts::get_district_name($district_id)->toArray(); $dpp_fname = ''; $dpp_lname = ''; $dpp_phone = ''; $dpp_email = ''; if (count($dpp_details) > 0) { $dpp_fname = $dpp_details[0]['fname']; $dpp_lname = $dpp_details[0]['lname']; $dpp_phone = $dpp_details[0]['telephone']; $dpp_email = $dpp_details[0]['email']; } $indicator = "District"; $no_of_facility_users = 0; $no_of_facility_users_online = 0; $no_of_facilities = 0; $no_of_facilities_using = 0; foreach ($facility_data as $facility_detail) { $facility_code = $facility_detail->facility_code; $facility_extra_data = facilities::get_facility_status_no_users_status($facility_code); $no_of_facility_users = $no_of_facility_users + $facility_extra_data[0]['number_of_users']; $no_of_facility_users_online = $no_of_facility_users_online + $facility_extra_data[0]['number_of_users_online']; $no_of_facilities = $no_of_facilities + 1; if ($facility_extra_data[0]['number_of_users'] > 0) { $no_of_facilities_using = $no_of_facilities_using + 1; } $table_body .= "<tr>"; $status = null; $temp = $facility_extra_data[0]['status']; $temp == "Active" ? $status = "<span class='label label-success'>{$temp}</span>" : ($status = "<span class='label label-important'>{$temp}</span>"); $table_body .= "<td>{$facility_code}</td>\n\t <td>{$facility_detail->facility_name}</td>\n\t <td>{$facility_detail->owner}</td>\n\t <td>{$status}</td>\n\t <td>" . $facility_extra_data[0]['number_of_users'] . "</td>\n\t <td>" . $facility_extra_data[0]['number_of_users_online'] . "</td>"; $table_body .= "</tr>"; } $stats_data = ' <table style="float:left"> <tr> <td><label style=" font-weight: ">' . $district_name[0]['district'] . ' ' . $indicator . ' Pharmacist :</label></td> <td><a class="badge">' . $dpp_fname . ' ' . $dpp_lname . '</a></td> </tr> <tr> <td><label style="font-weight: ">Phone No.</label></td> <td><a class="badge">' . $dpp_phone . '</a></td> </tr> <tr> <td><label style="font-weight: ">Email Address</label></td> <td><a class="badge">' . $dpp_email . '</a></td> </tr> </table> <table style="float:left"> <tr> <td><label style=" font-weight: ">Total No of Facilities in The ' . $indicator . ' </label></td> <td><a class="badge" >' . $no_of_facilities . '</a></td> </tr> <tr> <td><label style="font-weight: ">Total No of Facilities in The ' . $indicator . ' Using HCMP </label></td> <td> <a class="badge">' . $no_of_facilities_using . '</a></td> </tr> </table> <table style="float:left"> <tr> <td><label style="font-weight: ">Total No of Users in The ' . $indicator . ' </label></td> <td><a class="badge" >' . $no_of_facility_users . '</a></td> </tr> <tr> <td><label style="font-weight: ">Users online in The ' . $indicator . '</label></td> <td><a class="badge" >' . $no_of_facility_users_online . '</a></td> </tr> </table> '; $data['stats_data'] = $stats_data; $data['table_body'] = $table_body; $this->load->view("county/ajax_view/facility_mapping_v", $data); }