本文整理汇总了PHP中Facilities::get_facility_name2方法的典型用法代码示例。如果您正苦于以下问题:PHP Facilities::get_facility_name2方法的具体用法?PHP Facilities::get_facility_name2怎么用?PHP Facilities::get_facility_name2使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Facilities
的用法示例。
在下文中一共展示了Facilities::get_facility_name2方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: division_commodities_stock_level_graph
public function division_commodities_stock_level_graph($district_id = NULL, $county_id = NULL, $facility_code = NULL, $commodity_id = null, $division_id = NULL)
{
$county_id = $county_id == 'NULL' ? $this->session->userdata('user_indicator') == 'county' ? $this->session->userdata('county_id') : null : $county_id;
$district_id = $district_id == 'NULL' ? $this->session->userdata('user_indicator') == 'district' ? $this->session->userdata('district_id') : null : $district_id;
$facility_code = $facility_code == 'NULL' ? $this->session->userdata('user_indicator') == 'facility' ? $this->session->userdata('facility_code') : null : $facility_code;
$division_id = $division_id == 'NULL' ? null : $division_id;
$final_graph_data = facility_stocks_temp::get_division_commodities_stock($district_id, $county_id, $facility_code, $division_id);
$month = date('F Y');
if (isset($division_id)) {
$division_name = commodity_division_details::get_all_divisions($division_id)->toArray();
$title .= ' ' . @$division_name[0]['division_name'];
} else {
$division_name = null;
}
if (isset($county_id)) {
$county_name = counties::get_county_name($county_id);
$title .= ' ' . $county_name['county'] . " County ";
} else {
$county_name = null;
}
if (isset($district_id)) {
$district_name = districts::get_district_name_($district_id);
$title .= ' ' . $district_name['district'] . " Sub-County ";
} else {
$district_name = null;
}
if (isset($facility_code)) {
$facility_name = Facilities::get_facility_name2($facility_code);
$title .= ' ' . $facility_name['facility_name'];
} else {
$facility_name = null;
}
if (!isset($district_id) && !isset($facility_code) && !isset($division_id) && !isset($option)) {
$county_id = $this->session->userdata('county_id');
$county_name = counties::get_county_name($county_id);
$title .= ' ' . $county_name['county'] . " County ";
}
$graph_data = array();
$graph_data = array_merge($graph_data, array("graph_id" => 'default_graph_'));
$graph_data = array_merge($graph_data, array("graph_title" => "Months Of Stock For " . $title . ""));
$graph_data = array_merge($graph_data, array("graph_type" => 'bar'));
$graph_data = array_merge($graph_data, array("graph_yaxis_title" => 'Months of Stock'));
$graph_data = array_merge($graph_data, array("graph_categories" => array()));
$graph_data = array_merge($graph_data, array("series_data" => array("Stock" => array())));
foreach ($final_graph_data as $final_graph_data_) {
$graph_data['graph_categories'] = array_merge($graph_data['graph_categories'], array($final_graph_data_['commodity_name']));
$graph_data['series_data']['Stock'] = array_merge($graph_data['series_data']['Stock'], array((int) $final_graph_data_['total']));
}
$data['high_graph'] = $this->hcmp_functions->create_high_chart_graph($graph_data);
//echo $data['high_graph'];exit;
return $this->load->view("shared_files/report_templates/high_charts_template_v", $data);
}
示例2: pdfreport
public function pdfreport($report_type, $facility_code)
{
$facility_information = $report_data = $heading = $report_title = $data = '';
$facility_name = Facilities::get_facility_name2($facility_code);
$facility_obj = Facilities::get_facility_district_county_level($facility_code);
$facility_information = '<table class = "data-table"><thead><tr><th>Facility Code</th><th>Facility Name</th><th>County</th><th>District</th><th>Type</th></tr></thead>
<tbody><tr><td>' . $facility_code . '</td><td>' . $facility_name . '</td><td>' . $facility_obj['county'] . '</td><td>' . $facility_obj['district'] . '</td><td>' . $facility_obj['type'] . '</td></tr></tbody>';
$facility_information .= '</table>';
switch ($report_type) {
case 'malaria':
$heading = '<th>Drug Name</th>';
$report_title = 'Malaria Program Report For: ' . $facility_name;
$file_name = $facility_name . ' Malaria Report';
$data = $this->createmalariareport($facility_code);
break;
case 'rh':
$heading = '<th>Contraceptive</th>';
$report_title = 'Reproductive Health Program Report For: ' . $facility_name;
$file_name = $facility_name . ' RH Report';
$data = $this->createrhreport($facility_code);
break;
default:
break;
}
$report_table = '<table class = "data-table">
<thead>
<tr>' . $heading . '
<th>Unit Size</th>
<th>Unit Cost (Ksh)</th>
<th>Opening Balance (Units)</th>
<th>Total Receipts (Units)</th>
<th>Total issues (Units)</th>
<th>Adjustments(-ve) (Units)</th>
<th>Adjustments(+ve) (Units)</th>
<th>Losses (Units)</th>
<th>No days out of stock</th>
<th>Closing Stock(Units)</th>
</tr>
</thead>';
if (!$data) {
$data = '<tr><td colspan = "11"><center>There is no report for this facility</center></td></tr>';
}
$report_table .= $data;
$report_table .= '</table>';
$pdf_data['pdf_title'] = $report_title;
$pdf_data['file_name'] = $file_name;
$pdf_data['pdf_html_body'] = $facility_information . $report_table;
$this->hcmp_functions->create_pdf($pdf_data);
}
示例3: login_submit
public function login_submit()
{
$user = new Users();
$password = $this->input->post('password');
$username = $this->input->post('username');
$returned_user = $user->login($username, $password);
//If user successfully logs in, proceed here
if ($returned_user) {
//Create basic data to be saved in the session
$reply = Users::login($username, $password);
$user_data = $reply->toArray();
$access_typeid = $user_data['usertype_id'];
$fname = $user_data['fname'];
$user_id = $user_data['id'];
$lname = $user_data['lname'];
$district_id = $user_data['district'];
$facility_id = $user_data['facility'];
$phone = $user_data['telephone'];
$user_email = $user_data['email'];
$county_id = $user_data['county_id'];
$partner_id = $user_data['partner'];
$fullname = $fname . ' ' . $lname;
$banner_name = '';
$access_level = Access_level::get_access_level_name($access_typeid);
$user_indicator = $access_level['user_indicator'];
if ($user_indicator == 'district') {
//get county name
$district_name = districts::get_district_name_($district_id);
$banner_name = $district_name['district'] . " Sub-county";
} elseif ($user_indicator == 'county') {
//get county name
$county_name = Counties::get_county_name($county_id);
$banner_name = $county_name['county'] . " County";
} elseif ($user_indicator == 'facility' || $user_indicator == 'facility_admin') {
//get county name
$facility_name = Facilities::get_facility_name2($facility_id);
$banner_name = $facility_name['facility_name'];
}
$session_data = array('county_id' => $county_id, 'partner_id' => $partner_id, 'phone_no' => $phone, 'user_email' => $user_email, 'user_id' => $user_id, 'user_indicator' => $user_indicator, 'fname' => $fname, 'lname' => $lname, 'facility_id' => $facility_id, 'district_id' => $district_id, 'user_type_id' => $access_typeid, 'full_name' => $fullname, 'banner_name' => $banner_name);
$this->session->set_userdata($session_data);
//get menu items
$menu_items = Menu::getByUsertype($access_typeid);
//Create array that will hold all the accessible menus in the session
$menus = array();
$menuids = array();
$counter = 0;
foreach ($menu_items as $menu_item) {
$menus[$counter] = array("menu_text" => $menu_item->menu_text, "menu_url" => $menu_item->menu_url, "menu_id" => $menu_item->id, "parent_status" => $menu_item->parent_status);
$counter++;
$menuids[] = $menu_item->id;
}
$sub_menus = array();
foreach ($menuids as $parentid) {
$sub_items = Sub_menu::getByparent((int) $parentid);
foreach ($sub_items as $item) {
$sub_menus[] = array("submenu_text" => $item->subm_text, "submenu_url" => $item->subm_url, "menu_id" => $item->parent_id);
}
}
//Save this menus array in the session
$this->session->set_userdata("menus", $menus);
//Save this sub menus array in the session
$_SESSION["submenus"] = $sub_menus;
//creating a new log value
Log::update_log_out_action($this->session->userdata('user_id'));
$u1 = new Log();
$action = 'Logged In';
$u1->user_id = $this->session->userdata('user_id');
$u1->action = $action;
$u1->save();
redirect('home');
} else {
$data['popup'] = "errorpopup";
$data['title'] = "Login";
$this->load->view("shared_files/login_pages/login_v", $data);
}
}
示例4: add_more_stock_level_external
public function add_more_stock_level_external()
{
if ($this->input->post('facility_stock_id')) {
$facility_stock_id = $this->input->post('facility_stock_id');
$facility_code = $this->session->userdata('facility_id');
$commodity_id = array_values($this->input->post('commodity_id'));
$expiry_date = array_values($this->input->post('clone_datepicker'));
$batch_no = array_values($this->input->post('commodity_batch_no'));
$manu = array_values($this->input->post('commodity_manufacture'));
$total_unit_count = array_values($this->input->post('actual_quantity'));
$service_point = array_values($this->input->post('service_point'));
$source_of_item = array_values($this->input->post('source_of_item'));
$count = count($commodity_id);
$date_of_entry = date('y-m-d H:i:s');
//collect n set the data in the array
for ($i = 0; $i < $count; $i++) {
if ($total_unit_count[$i] > 0) {
//check if the balance is more than 0 ie they recieved something
if ($this->session->userdata('user_indicator') == 'district') {
//check if the user is district if so the facility which was given the item is not using HCMP
} else {
$mydata = array('facility_code' => $facility_code, 'commodity_id' => $commodity_id[$i], 'batch_no' => $batch_no[$i], 'manufacture' => $manu[$i], 'expiry_date' => date('y-m-d', strtotime(str_replace(",", " ", $expiry_date[$i]))), 'initial_quantity' => $total_unit_count[$i], 'current_balance' => $total_unit_count[$i], 'source_of_commodity' => $source_of_item[$i], 'date_added' => $date_of_entry);
//get the closing stock of the given item
$facility_stock = facility_stocks::get_facility_commodity_total($facility_code, $commodity_id[$i])->toArray();
//update the facility stock table
facility_stocks::update_facility_stock($mydata);
// save this infor in the issues table
$facility_name = isset($service_point[$i]) ? Facilities::get_facility_name2($service_point[$i]) : null;
$facility_name = isset($facility_name) ? $facility_name['facility_name'] : 'N/A';
$total_unit_count_ = $total_unit_count[$i] * -1;
$mydata = array('facility_code' => $facility_code, 's11_No' => '(+ve Adj) Stock Addition', 'commodity_id' => $commodity_id[$i], 'batch_no' => $batch_no[$i], 'expiry_date' => date('y-m-d', strtotime(str_replace(",", " ", $expiry_date[$i]))), 'balance_as_of' => $facility_stock[0]['commodity_balance'], 'date_issued' => date('y-m-d'), 'issued_to' => "inter-facility donation: " . $facility_name, 'qty_issued' => $total_unit_count_, 'issued_by' => $this->session->userdata('user_id'));
//$this -> session -> userdata('identity')
// update the issues table
facility_issues::update_issues_table($mydata);
//check
$facility_has_commodity = facility_transaction_table::get_if_commodity_is_in_table($facility_code, $commodity_id[$i]);
if ($facility_has_commodity > 0) {
//update the opening balance for the transaction table
$inserttransaction = Doctrine_Manager::getInstance()->getCurrentConnection();
$inserttransaction->execute("UPDATE `facility_transaction_table` SET `opening_balance` =`opening_balance`+{$total_unit_count[$i]}\n WHERE `commodity_id`= '{$commodity_id[$i]}' and status='1' and facility_code={$facility_code}");
} else {
//get the data to send to the facility_transaction_table
$mydata2 = array('facility_code' => $facility_code, 'commodity_id' => $commodity_id[$i], 'opening_balance' => $total_unit_count[$i], 'total_issues' => 0, 'total_receipts' => 0, 'adjustmentpve' => 0, 'adjustmentnve' => 0, 'date_added' => $date_of_entry, 'closing_stock' => $total_unit_count[$i], 'status' => 1);
//send the data to the facility_transaction_table
facility_transaction_table::update_facility_table($mydata2);
}
//update the redistribution data
$myobj = Doctrine::getTable('redistribution_data')->find($facility_stock_id[$i]);
$myobj->quantity_received = $total_unit_count[$i];
$myobj->receiver_id = $this->session->userdata('user_id');
$myobj->date_received = date('y-m-d');
$myobj->status = 1;
$myobj->save();
}
}
}
//set the notifications
//$this->hcmp_functions->send_stock_update_sms();
$this->session->set_flashdata('system_success_message', "Stock Levels Have Been Updated");
redirect('reports/facility_stock_data');
}
}
示例5: foreach
\t\t<td colspan = '2'>
\t\t\t<a href='{$link}' target="_blank">
\t\t \t<button type="button" class="btn btn-xs btn-primary">
\t\t \t<span class="glyphicon glyphicon-save"></span>Download Report pdf</button></a>
\t\t \t<a href='{$link_excel}' target="_blank">
\t\t\t<button type="button" class="btn btn-xs btn-primary">
\t\t\t<span class="glyphicon glyphicon-save"></span>Download Report excel</button></a>
\t\t
\t\t</td>
</tr>
HTML_DATA;
}
}
foreach ($TB as $TB_details1) {
foreach ($TB_details1 as $TB_details) {
$facilityname = Facilities::get_facility_name2($TB_details['facility_code']);
$facility = $facilityname['facility_name'];
$user = Users::get_user_names($TB_details['user']);
$username = $user[0]['fname'] . " " . $user[0]['lname'];
$report_date = $TB_details['report_date'];
$link = base_url('reports/get_facility_report_pdf/' . $TB_details['report_id'] . '/' . $TB_details['facility_code'] . '/TB');
$link_excel = base_url('reports/create_excel_facility_program_report/' . $TB_details['report_id'] . '/' . $TB_details['facility_code'] . '/TB');
$TB_report_details .= <<<HTML_DATA
\t <tr>
\t\t\t\t\t<td>{$facility}</td>
\t \t\t\t\t<td>{$username}</td>
\t \t\t<td>{$report_date}</td>
\t \t\t<td colspan = '2'>
\t\t\t<a href='{$link}' target="_blank">
\t\t \t<button type="button" class="btn btn-xs btn-primary">
示例6: external_issue
public function external_issue()
{
//security check
if ($this->input->post('mfl')) {
$facility_code = $this->session->userdata('facility_id');
$district_id = $this->session->userdata('district_id');
$service_point = array_values($this->input->post('mfl'));
$commodity_id = array_values($this->input->post('desc'));
$commodity_balance_before = array_values($this->input->post('commodity_balance'));
$facility_stock_id = array_values($this->input->post('facility_stock_id'));
$batch_no = array_values($this->input->post('batch_no'));
$expiry_date = array_values($this->input->post('expiry_date'));
$commodity_unit_of_issue = array_values($this->input->post('commodity_unit_of_issue'));
$quantity_issued = array_values($this->input->post('quantity_issued'));
$clone_datepicker_normal_limit_today = array_values($this->input->post('clone_datepicker_normal_limit_today'));
$manufacture = array_values($this->input->post('manufacture'));
$total_units = array_values($this->input->post('total_units'));
$total_items = count($facility_stock_id);
//var_dump($total_units);exit;
$data_array_issues_table = array();
$data_array_redistribution_table = array();
//loops through the data collected from the forms first
for ($i = 0; $i < $total_items; $i++) {
//compute the actual stock
$total_items_issues = $commodity_unit_of_issue[$i] == 'Pack_Size' ? $quantity_issued[$i] * $total_units[$i] : $quantity_issued[$i];
//prepare the issues data
$facility_name = isset($service_point[$i]) ? Facilities::get_facility_name2($service_point[$i]) : null;
$facility_name = isset($facility_name) ? $facility_name['facility_name'] : 'N/A';
$mydata = array('facility_code' => $facility_code, 's11_No' => '(-ve Adj) Stock Deduction', 'batch_no' => $batch_no[$i], 'commodity_id' => $commodity_id[$i], 'expiry_date' => date('y-m-d', strtotime($expiry_date[$i])), 'qty_issued' => $total_items_issues, 'issued_to' => "inter-facility donation:" . $facility_name, 'balance_as_of' => $commodity_balance_before[$i], 'date_issued' => date('y-m-d', strtotime($clone_datepicker_normal_limit_today[$i])), 'issued_by' => $this->session->userdata('user_id'));
$mydata_2 = array('manufacturer' => $manufacture[$i], 'source_district_id' => $district_id, 'source_facility_code' => $facility_code, 'batch_no' => $batch_no[$i], 'commodity_id' => $commodity_id[$i], 'expiry_date' => date('y-m-d', strtotime($expiry_date[$i])), 'quantity_sent' => $total_items_issues, 'receive_facility_code' => $service_point[$i], 'facility_stock_ref_id' => $facility_stock_id[$i], 'date_sent' => date('y-m-d'), 'sender_id' => $this->session->userdata('user_id'));
// update the issues table
array_push($data_array_issues_table, $mydata);
array_push($data_array_redistribution_table, $mydata_2);
// reduce the stock levels
//var_dump($mydata);exit;
$a = Doctrine_Manager::getInstance()->getCurrentConnection();
$a->execute("UPDATE `facility_stocks` SET `current_balance` = `current_balance`-{$total_items_issues} where id='{$facility_stock_id[$i]}'");
//update the transaction table here
$inserttransaction = Doctrine_Manager::getInstance()->getCurrentConnection();
$inserttransaction->execute("UPDATE `facility_transaction_table` SET `total_issues` = `total_issues`+{$total_items_issues},\n\t\t\t`closing_stock`=`closing_stock`-{$total_items_issues}\n WHERE `commodity_id`= '{$commodity_id[$i]}' and status='1' and facility_code='{$facility_code}';");
}
$user = $this->session->userdata('user_id');
$user_action = "redistribute";
//updates the log table accordingly based on the action carried out by the user involved
$update = Doctrine_Manager::getInstance()->getCurrentConnection();
$update->execute("update log set {$user_action} = 1 \n\t\t\twhere `user_id`= {$user} \n\t\t\tAND action = 'Logged In' \n\t\t\tand UNIX_TIMESTAMP( `end_time_of_event`) = 0");
$send_sms = $this->hcmp_functions->send_system_text($user_action);
$this->db->insert_batch('facility_issues', $data_array_issues_table);
$this->db->insert_batch('redistribution_data', $data_array_redistribution_table);
$this->session->set_flashdata('system_success_message', "You have issued {$total_items} item(s)");
// redirect(home);
}
redirect(home);
}
示例7: expiries_report
public function expiries_report()
{
//Set the current year
$year = date("Y");
//get the facilities in the district
$counties = Facilities::get_counties_all_using_HCMP();
foreach ($counties as $counties) {
//holds the dat for the entire county
//once it is done executing for one county it is reset to zero
$county_total = array();
//pick the county nae and county ID accordingly
$county_id = $counties['county'];
$county_name = $counties['county_name'];
//Get all the ddistricts in that particular county
$districts = Facilities::get_all_using_HCMP($county_id);
//holds the data for all the districts in a particular county
$district_total = array();
foreach ($districts as $districts) {
$district_id = $districts['district'];
$district_name = $districts['name'];
//get all facilities in that district
$facilities = Facilities::getFacilities_for_email($district_id);
//holds all the data for all facilities in a particular district
$facility_total = array();
foreach ($facilities as $facilities_) {
//holds the total value of expiries for that particular facility in that district
$facility_potential_expiries_total = 0;
//$facility_potential_expiries = array();
$facility_code = $facilities_->facility_code;
$facility_name = Facilities::get_facility_name2($facility_code);
$facility_name = $facility_name['facility_name'];
//$facility_potential_expiries = Facility_stocks::get_items_that_have_stock_out_in_facility(17401, 88, null);
$facility_potential_expiries = Facility_stocks::All_expiries_email($facility_code, 'all');
//get potential expiries in that particular facility
//$facility_potential_expiries = Facility_stocks::potential_expiries_email($district_id, $facility_code);
//push the result into another array that will be used by the distrct
array_key_exists($facility_name, $facility_total) ? $facility_total[$facility_name] = array_merge($facility_total[$facility_name], array($facility_potential_expiries)) : ($facility_total = array_merge($facility_total, array($facility_name => array($facility_potential_expiries))));
//Start buliding the excel file
$excel_data = array();
$excel_data = array('doc_creator' => $facility_name, 'doc_title' => 'facility expiries weekly report ', 'file_name' => 'facility weekly report');
$row_data = array();
$column_data = array("Facility Code", "Facility Name", "Commodity Code", "Commodity Name", "Expiry Date", "Batch No", "Manufacturer", "Unit Size", "Current Balance");
$excel_data['column_data'] = $column_data;
foreach ($facility_potential_expiries as $facility_potential_expiries) {
array_push($row_data, array($facility_potential_expiries["facility_code"], $facility_potential_expiries["facility_name"], $facility_potential_expiries["commodity_code"], $facility_potential_expiries["commodity_name"], $facility_potential_expiries["expiry_date"], $facility_potential_expiries["batch_no"], $facility_potential_expiries["manufacture"], $facility_potential_expiries["unit_size"], $facility_potential_expiries["current_balance"]));
}
if (empty($row_data)) {
//do nothing
} else {
$excel_data['row_data'] = $row_data;
$excel_data['report_type'] = "download_file";
$excel_data['file_name'] = $facility_name . "_Expiries_Report";
$message = "Find attached an excel sheet with the breakdown for the Expiries in the facility";
$this->hcmp_functions->create_excel($excel_data);
$handler = "./print_docs/excel/excel_files/" . $excel_data['file_name'] . ".xls";
$subject = "Expiries: " . $facility_name;
//$email_address = "collinsojenge2014@gmail.com";
$email_address = $this->get_facility_email($facility_code);
$this->hcmp_functions->send_email($email_address, $message, $subject, $handler);
}
//End foreach for facility
}
array_key_exists($district_name, $district_total) ? $district_total[$district_name] = array_merge($district_total[$district_name], array($facility_total)) : ($district_total = array_merge($district_total, array($district_name => array($facility_total))));
//Building the excel sheet to be sent to the district admin
$excel_data = array();
$excel_data = array('doc_creator' => $district_name, 'doc_title' => 'district stock outs weekly report ', 'file_name' => 'district weekly report');
$row_data = array();
$column_data = array("Facility Code", "Facility Name", "Commodity Code", "Commodity Name", "Expiry Date", "Batch No", "Manufacturer", "Unit Size", "Current Balance");
$excel_data['column_data'] = $column_data;
foreach ($facility_total as $facility_total_1) {
foreach ($facility_total_1 as $facility_total_2) {
foreach ($facility_total_2 as $facility_total1) {
array_push($row_data, array($facility_total1["facility_code"], $facility_total1["facility_name"], $facility_total1["commodity_code"], $facility_total1["commodity_name"], $facility_total1["expiry_date"], $facility_total1["batch_no"], $facility_total1["manufacture"], $facility_total1["unit_size"], $facility_total1["current_balance"]));
}
}
}
if (empty($row_data)) {
//do nothing
} else {
$excel_data['row_data'] = $row_data;
$excel_data['report_type'] = "download_file";
$excel_data['file_name'] = $district_name . "_Weekly_District_Stock_Outs_Report";
$this->hcmp_functions->create_excel($excel_data);
$handler = "./print_docs/excel/excel_files/" . $excel_data['file_name'] . ".xls";
$subject = "Expiries: " . $district_name . " Sub County";
$message = $district_name . "'s Weekly Expiries Report";
$message .= "Find attached an excel sheet with the breakdown for the Expiries for the district";
//$email_address = "collinsojenge2014@gmail.com";
$email_address = $this->get_ddp_email($district_id);
$this->hcmp_functions->send_email($email_address, $message, $subject, $handler);
}
}
//Building the excel sheet to be sent to the district admin
$excel_data = array();
$excel_data = array('doc_creator' => $district_name, 'doc_title' => 'district stock outs weekly report ', 'file_name' => 'district weekly report');
$row_data = array();
$column_data = array("Facility Code", "Facility Name", "Commodity Code", "Commodity Name", "Expiry Date", "Batch No", "Manufacturer", "Unit Size", "Current Balance");
$excel_data['column_data'] = $column_data;
foreach ($district_total as $facility_total_1) {
foreach ($facility_total_1 as $facility_total_2) {
//.........这里部分代码省略.........
示例8: stock_levels_report
public function stock_levels_report()
{
//Set the current year
$year = date("Y");
//$picurl = base_url() . 'assets/img/coat_of_arms-resized1.png';
//get the facilities in the district
$counties = Facilities::get_counties_all_using_HCMP();
foreach ($counties as $counties) {
//holds the data for the entire county
//once it is done executing for one county it is reset to zero
$county_total = array();
//pick the county nae and county ID accordingly
$county_id = $counties['county'];
$county_name = $counties['county_name'];
//Get all the districts in that particular county
$districts = Facilities::get_all_using_HCMP($county_id);
//holds the data for all the districts in a particular county
$district_total = array();
foreach ($districts as $districts) {
$district_id = $districts['district'];
$district_name = $districts['name'];
//get all facilities in that district
$facilities = Facilities::getFacilities_for_email($district_id);
//holds all the data for all facilities in a particular district
$facility_total = array();
foreach ($facilities as $facilities_) {
//holds the total value of expiries for that particular facility in that district
$facility_potential_expiries_total = 0;
//$facility_potential_expiries = array();
$facility_code = $facilities_->facility_code;
$facility_name = Facilities::get_facility_name2($facility_code);
$facility_name = $facility_name['facility_name'];
//get the stocking levels in that particular facility
$facility_consumption = facility_issues::get_consumption_report_facility($facility_code);
//push the result into another array that will be used by the distrct
array_key_exists($facility_name, $facility_total) ? $facility_total[$facility_name] = array_merge($facility_total[$facility_name], array($facility_consumption)) : ($facility_total = array_merge($facility_total, array($facility_name => array($facility_consumption))));
//Start buliding the excel file
$excel_data = array();
$excel_data = array('doc_creator' => $facility_name, 'doc_title' => 'facility stock level report ', 'file_name' => 'facility stock level report');
$row_data = array();
$column_data = array("Commodity Name", "Unit Size", "Quantity (units)", "Quantity (packs)", "Unit Cost(KSH)", "Total Cost(KSH)", "Supplier", "Facility Name", "MFL Code", "Sub County", "County");
$excel_data['column_data'] = $column_data;
foreach ($facility_consumption as $facility_consumption) {
array_push($row_data, array($facility_consumption["commodity_name"], $facility_consumption["unit_size"], $facility_consumption["total_units"], $facility_consumption["total_packs"], $facility_consumption["unit_cost"], $facility_consumption["total_cost"], $facility_consumption["source_name"], $facility_consumption["facility_name"], $facility_consumption["facility_code"], $facility_consumption["district"], $facility_consumption["county"]));
$facility_potential_expiries_total += $facility_consumption["total_cost"];
}
if (empty($row_data)) {
//do nothing
} else {
$excel_data['row_data'] = $row_data;
$excel_data['report_type'] = "download_file";
$excel_data['file_name'] = $facility_name . "_Stock_Level_Report";
$excel_data['excel_title'] = "Stock Levels Report for " . $facility_name . " for the month as at " . date("jS F Y");
$subject = "Stock Levels: " . $facility_name;
$message = "Dear " . $facility_name . ",\n\t \t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<p>Find attached an excel sheet with the " . $facility_name . " breakdown of Stock Levels.\n\t \t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t</p>\n\t \t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<p>You may log onto health-cmp.or.ke for follow up.</p>\n\n\t \t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<p>----</p>\n\n\t \t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<p>HCMP</p>\n\n\t \t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<p>This email was automatically generated. Please do not respond to this email address or it will be ignored.</p>";
$report_type = "stock_level";
$this->create_excel($excel_data, $report_type);
$handler = "./print_docs/excel/excel_files/" . $excel_data['file_name'] . ".xls";
//$email_address = $this->get_facility_email($facility_code);
//$this -> hcmp_functions -> send_email($email_address, $message, $subject, $handler);
}
//End foreach for facility
}
array_key_exists($district_name, $district_total) ? $district_total[$district_name] = array_merge($district_total[$district_name], array($facility_total)) : ($district_total = array_merge($district_total, array($district_name => array($facility_total))));
//Building the excel sheet to be sent to the district admin
$excel_data = array();
$excel_data = array('doc_creator' => $district_name, 'doc_title' => 'sub county stock level report ', 'file_name' => 'sub county stock level report');
$row_data = array();
$column_data = array("Commodity Name", "Unit Size", "Quantity (units)", "Quantity (packs)", "Unit Cost(KSH)", "Total Cost(KSH)", "Supplier", "Facility Name", "MFL Code", "Sub County", "County");
$excel_data['column_data'] = $column_data;
foreach ($facility_total as $facility_total_1) {
foreach ($facility_total_1 as $facility_total_2) {
foreach ($facility_total_2 as $facility_total1) {
array_push($row_data, array($facility_total1["commodity_name"], $facility_total1["unit_size"], $facility_total1["total_units"], $facility_total1["total_packs"], $facility_total1["unit_cost"], $facility_total1["total_cost"], $facility_total1["source_name"], $facility_total1["facility_name"], $facility_total1["facility_code"], $facility_total1["district"], $facility_total1["county"]));
}
}
}
if (empty($row_data)) {
//do nothing
} else {
$excel_data['row_data'] = $row_data;
$excel_data['report_type'] = "download_file";
$excel_data['file_name'] = $district_name . "_Sub_County_Stock_Level_Report";
$excel_data['excel_title'] = "Stock Levels Report for " . $district_name . " Sub County as at " . date("jS F Y");
//Create the excel file here
$report_type = "stock_level";
$this->create_excel($excel_data, $report_type);
//exit;
$handler = "./print_docs/excel/excel_files/" . $excel_data['file_name'] . ".xls";
$subject = "Stock Levels: " . $district_name . " Sub County";
$message = "<p>Dear " . $district_name . " Sub County,</p>\n\t \t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<p>Find attached an excel sheet with the " . $district_name . " Sub County's breakdown of Stock Levels.\n\t \t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t</p>\n\t \t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<p>You may log onto health-cmp.or.ke for follow up.</p>\n\n\t \t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<p>----</p>\n\n\t \t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<p>HCMP</p>\n\n\t \t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<p>This email was automatically generated. Please do not respond to this email address or it will be ignored.</p>";
//$email_address = $this -> get_ddp_email($district_id);
//$this -> hcmp_functions -> send_email($email_address, $message, $subject, $handler);
}
}
//Building the excel sheet to be sent to the County Admin
$excel_data = array();
$excel_data = array('doc_creator' => $county_name, 'doc_title' => 'county stock levels report ', 'file_name' => 'county stock levels report');
$row_data = array();
$column_data = array("Commodity Name", "Unit Size", "Quantity (units)", "Quantity (packs)", "Unit Cost(KSH)", "Total Cost(KSH)", "Supplier", "Facility Name", "MFL Code", "Sub County", "County");
//.........这里部分代码省略.........