Пример #1
0
 public function Header()
 {
     // Logo
     $siteLogo = site_path . '/logo.png';
     $image_file = file_exists($siteLogo) ? $siteLogo : ROOT . '/resources/images/gaiaehr_small_white.png';
     $y = 16;
     $x = 70;
     $f = new Facilities();
     $facility = $f->getCurrentFacility(true);
     $address1 = $facility['address'];
     $address2 = $facility['address_cont'];
     $address3 = $facility['city'] . ', ' . $facility['state'] . ' ' . $facility['postal_code'];
     $phone1 = '';
     $phone2 = 'Tel. ' . $facility['phone'];
     $phone3 = 'Fax ' . $facility['fax'];
     // Logo
     $this->Image($image_file, 10, 13, '', '', 'PNG', '', 'T', false, 1200, '', false, false, 0, false, false, false);
     // Address
     $this->SetFont('helvetica', '', 9);
     $this->SetY($y);
     $this->SetX($x);
     if ($address1 != '') {
         $this->Cell(95, 0, $address1, '', false, 'L', 0, '', 0, false, 'M', 'M');
     }
     $this->SetY($y + 4);
     $this->SetX($x);
     if ($address2 != '') {
         $this->Cell(95, 0, $address2, '', false, 'L', 0, '', 0, false, 'M', 'M');
     }
     $this->SetY($y + 8);
     $this->SetX($x);
     if ($address3 != '') {
         $this->Cell(95, 0, $address3, '', false, 'L', 0, '', 0, false, 'M', 'M');
     }
     // set phones
     $this->SetY($y);
     $this->SetX(165);
     if ($phone1 != '') {
         $this->Cell(0, 0, $phone1, '', false, 'R', 0, '', 0, false, 'M', 'M');
     }
     $this->SetY($y + 4);
     $this->SetX(165);
     if ($phone2 != '') {
         $this->Cell(0, 0, $phone2, '', false, 'R', 0, '', 0, false, 'M', 'M');
     }
     $this->SetY($y + 8);
     $this->SetX(165);
     if ($phone3 != '') {
         $this->Cell(0, 0, $phone3, '', false, 'R', 0, '', 0, false, 'M', 'M');
     }
     $this->Line(10, 30, 200, 30, array('color' => array(0, 0, 0)));
 }
Пример #2
0
 public function new_disbursement($id = null)
 {
     if ($id != null) {
         $disbursement = Disbursements::getDisbursement($id);
         $data['disbursement'] = $disbursement[0];
         $data['edit'] = true;
         $data['id'] = $id;
     }
     $districts = new Districts();
     $regions = new Regions();
     $facilities = new Facilities();
     $additional_facilities = new Additional_Facilities();
     $data['vaccines'] = Vaccines::getAll_Minified();
     $archive_date = date('U');
     $data['stock_balance'] = array();
     $district_or_region = $this->session->userdata('district_province_id');
     //Retrieve the user identifier from the session
     $identifier = $this->session->userdata('user_identifier');
     //Check if it's a provincial officer
     if ($identifier == 'provincial_officer') {
         foreach ($data['vaccines'] as $vaccine) {
             $data['stock_balance'][$vaccine->id] = Disbursements::getRegionalPeriodBalance($district_or_region, $vaccine->id, $archive_date);
         }
         $data['districts'] = $districts->getAllDistricts();
         $data['regions'] = $regions->getAllRegions();
     } else {
         if ($identifier == 'district_officer') {
             foreach ($data['vaccines'] as $vaccine) {
                 $data['stock_balance'][$vaccine->id] = Disbursements::getDistrictPeriodBalance($district_or_region, $vaccine->id, $archive_date);
             }
             $district_province = $districts->getDistrictProvince($district_or_region);
             $data['districts'] = $districts->getProvinceDistricts($district_province['province']);
             $data['facilities'] = $facilities->getDistrictFacilities($district_or_region);
             $data['additional_facilities'] = $additional_facilities->getExtraFacilities($district_or_region);
         } else {
             if ($identifier == 'national_officer') {
                 foreach ($data['vaccines'] as $vaccine) {
                     $data['stock_balance'][$vaccine->id] = Disbursements::getNationalPeriodBalance($vaccine->id, $archive_date);
                 }
                 $data['districts'] = $districts->getAllDistricts();
                 $data['regions'] = $regions->getAllRegions();
             }
         }
     }
     $data['title'] = "Disbursement Management::Disburse Vaccines";
     $data['content_view'] = "add_disbursement_view";
     $data['quick_link'] = "new_disbursement";
     $this->base_params($data);
 }
Пример #3
0
 public function facility_dash()
 {
     $identifier = $this->session->userdata('user_indicator');
     $user_type_id = $this->session->userdata('user_type_id');
     $district = $this->session->userdata('district_id');
     // echo $identifier;exit;
     $county = $this->session->userdata('county_id');
     // $data['facilities'] = isset($district) ? Facilities::get_facility_details($district) : Facilities::get_facilities_per_county($county);
     if ($identifier == "district") {
         $data['facilities'] = Facilities::get_facility_details($district);
         $data['identifier'] = $identifier;
     } elseif ($identifier == "county") {
         $data['facilities'] = Facilities::get_facility_details(NULL, $county);
         $data['identifier'] = $identifier;
         $data['district_info'] = Districts::get_districts($county);
         // echo "<pre>";print_r($districts);echo "</pre>";exit;
     }
     $permissions = 'district_permissions';
     // $data['facilities']=Facilities::get_facility_details($district);
     // $data['facilities']=Facilities::get_facilities_per_county($county);
     // echo "<pre>";print_r($data['facilities']);echo "</pre>";exit;
     $data['title'] = "Facility Management";
     $data['banner_text'] = "Facility Management";
     $template = 'shared_files/template/template';
     // $data['sidebar'] = "shared_files/report_templates/side_bar_sub_county_v";
     $data['active_panel'] = 'system_usage';
     // $data['report_view'] = "shared_files/Facility_activation_v";
     $data['content_view'] = "shared_files/facility_activation_v";
     $this->load->view($template, $data);
 }
Пример #4
0
	public function search() {
		$search_term = $this -> input -> post('search');
		$data['facilities'] = Facilities::search($search_term);
		$data['search_term'] = $search_term;
		$data['title'] = "Facility Management::Click on a Facility";
		$data['content_view'] = "search_facilities_result_view";
		$this -> base_params($data);
	}
 public function show($id)
 {
     $facility = Facilities::where('ID_Facility', '=', $id)->firstOrFail();
     $faciList = Facilities::where('Status', '=', 'Active')->get();
     $data['room'] = Rooms::select('roomtype.RoomType_Name', 'roomtype.ID_RoomType', 'roomtype_pic.Picture')->join('roomtype_pic', 'roomtype.ID_RoomType', '=', 'roomtype_pic.ID_RoomType')->where('roomtype_pic.Main_Pic', '=', 'YES')->where('roomtype.Status', '=', 'Active')->take(40)->get()->all();
     $data['offer'] = Offer::where('Status', '=', 'Active')->take(40)->get()->all();
     $data['about'] = About::get()->all();
     return View::make('Facilities.show', compact('facility', 'listFaci'))->with('faci_active', 'active')->with('faciList', $faciList)->with('data', $data);
 }
Пример #6
0
 public function get_facility_stock_details($facility_code)
 {
     $facility_name = Facilities::get_facility_name($facility_code);
     $msg = "Stock levels for :" . $facility_name['facility_name'] . " as of " . date("d M, Y");
     $data['msg'] = $msg;
     $data['facility_order'] = Facility_Transaction_Table::get_all($facility_code);
     $data['content_view'] = "district/district_report/facility_stock_level_v";
     $data['quick_link'] = "actions";
     $data['banner_text'] = "Stock Level";
     $data['title'] = "Stock Level ";
     $this->load->view("template", $data);
 }
Пример #7
0
 private function get_ClinicTokensData($allNeededInfo, $tokens)
 {
     $facilityInfo = $this->facility->getActiveFacilitiesById($_SESSION['facilities']['id']);
     $clinicInformation = array('[FACILITY_NAME]' => $facilityInfo['name'], '[FACILITY_PHONE]' => $facilityInfo['phone'], '[FACILITY_FAX]' => $facilityInfo['fax'], '[FACILITY_STREET]' => $facilityInfo['street'], '[FACILITY_CITY]' => $facilityInfo['city'], '[FACILITY_STATE]' => $facilityInfo['state'], '[FACILITY_POSTALCODE]' => $facilityInfo['postal_code'], '[FACILITY_COUNTRYCODE]' => $facilityInfo['country_code'], '[FACILITY_FEDERAL_EIN]' => $facilityInfo['federal_ein'], '[FACILITY_SERVICE_LOCATION]' => $facilityInfo['service_location'], '[FACILITY_BILLING_LOCATION]' => $facilityInfo['billing_location'], '[FACILITY_FACILITY_NPI]' => $facilityInfo['facility_npi']);
     $pos = 0;
     foreach ($tokens as $tok) {
         if ($allNeededInfo[$pos] == '' || $allNeededInfo[$pos] == null) {
             $allNeededInfo[$pos] = $clinicInformation[$tok];
         }
         $pos = $pos + 1;
     }
     return $allNeededInfo;
 }
Пример #8
0
 public function manage_users()
 {
     $permissions = 'super_permissions';
     $data['title'] = "Users";
     $data['content_view'] = "Admin/users_v";
     $data['listing'] = Users::get_user_list_all();
     $data['counts'] = Users::get_users_count();
     $data['counties'] = Counties::getAll();
     $data['facilities'] = Facilities::getAll();
     $data['sub_counties'] = Districts::getAll();
     $data['user_types'] = Access_level::get_access_levels($permissions);
     $this->load->view("shared_files/template/dashboard_v", $data);
 }
Пример #9
0
 public function get_facility_user_data($facility_code)
 {
     // $facility_code = $_POST['facility_code'];
     $facility_data = Facilities::get_facilities_user_activation_data($facility_code);
     // echo "<pre>";print_r($facility_data);echo "</pre>";exit;
     foreach ($facility_data as $key => $value) {
         $name = $value['fname'] . ' ' . $value['lname'];
         $created_at = $value['created_at'];
         $last_login = $value['end_time_of_event'];
         $created = date('d F Y', strtotime($created_at));
         $last_login = date('d F Y', strtotime($last_login));
         $output[] = array($name, $created, $last_login);
     }
     echo json_encode($output);
 }
Пример #10
0
 public function addSatellite()
 {
     $results = Facilities::getSatellites($this->session->userdata("facility"));
     $dyn_table = "<table border='1' id='patient_listing'  cellpadding='5' class='dataTables'>";
     $dyn_table .= "<thead><tr><th>Facility Code</th><th>Facility Name</th><th>Options</th></tr></thead><tbody>";
     if ($results) {
         foreach ($results as $result) {
             $option = "<a href='" . base_url() . "admin_management/remove/" . $result['facilitycode'] . "'' class='red'>Remove</a>";
             $dyn_table .= "<tr><td>" . $result['facilitycode'] . "</td><td>" . $result['name'] . "</td><td>" . $option . "</td></tr>";
         }
     }
     $dyn_table .= "</tbody></table>";
     $data['label'] = 'Satellite';
     $data['table'] = 'facilities';
     $data['actual_page'] = 'View Satellites';
     $data['dyn_table'] = $dyn_table;
     $this->base_params($data);
 }
 public function add($data = array())
 {
     $access_level = $this->session->userdata('user_indicator');
     if ($access_level == "district_clerk") {
         $district = $this->session->userdata('district_province_id');
         $data['facilities'] = Facilities::getDistrictFacilities($district);
     }
     $provinces = Province::getAll();
     $districts = District::getAll();
     $diseases = Disease::getAllObjects();
     $data['provinces'] = $provinces;
     $data['districts'] = $districts;
     $data['diseases'] = $diseases;
     $data['editing'] = false;
     $data['prediction'] = Surveillance::getPrediction();
     $data['scripts'] = array("special_date_picker.js", "validationEngine-en.js", "validator.js");
     $data["styles"] = array("validator.css");
     $this->base_params($data);
 }
 public function add()
 {
     $provinces = Province::getAll();
     $districts = District::getAll();
     $facilities = Facilities::getAll();
     $diseases = Disease::getAllObjects();
     $data['provinces'] = $provinces;
     $data['districts'] = $districts;
     $data['facilities'] = $facilities;
     $data['diseases'] = $diseases;
     $data['scripts'] = array("jquery.ui.core.js", "jquery.ui.datepicker.js", "jquery.ui.widget.js");
     $data['styles'] = array("jquery.ui.all.css");
     $data['title'] = "Line List Data";
     $data['content_view'] = "linelist_data_add_v";
     $data['banner_text'] = "Linelist Data";
     $data['link'] = "submissions_management";
     $data['quick_link'] = "linelisted_data_management";
     $this->base_params($data);
     //$this -> load -> view("template", $data);
 }
Пример #13
0
    public function create_order_delivery_color_coded_table($order_id)
    {
        // get the order and order details here
        $detail_list = facility_order_details::get_order_details($order_id, true);
        $dates = facility_orders::get_order_($order_id)->toArray();
        $facility_name = Facilities::get_facility_name_($dates[0]['facility_code'])->toArray();
        $facility_name = $facility_name[0]['facility_name'];
        //set up the details
        $table_body = "";
        $total_fill_rate = 0;
        $order_value = 0;
        //get the lead time
        $ts1 = strtotime(date($dates[0]["order_date"]));
        $ts2 = strtotime(date($dates[0]["deliver_date"]));
        $seconds_diff = $ts2 - $ts1;
        //strtotime($a_date) ? date('d M, Y', strtotime($a_date)) : "N/A";
        $date_diff = strtotime($dates[0]["deliver_date"]) ? floor($seconds_diff / 3600 / 24) : "N/A";
        $order_date = strtotime($dates[0]["order_date"]) ? date('D j M, Y', $ts1) : "N/A";
        $deliver_date = strtotime($dates[0]["deliver_date"]) ? date('D j M, Y', $ts2) : "N/A";
        $kemsa_order_no = $dates[0]['kemsa_order_id'];
        $order_total = number_format($dates[0]['order_total'], 2, '.', ',');
        $actual_order_total = number_format($date[0]['deliver_total'], 2, '.', ',');
        $tester = count($detail_list);
        if ($tester == 0) {
        } else {
            foreach ($detail_list as $rows) {
                //setting the values to display
                $received = $rows['quantity_recieved'];
                $price = $rows['unit_cost'];
                $ordered = $rows['quantity_ordered_unit'];
                $code = $rows['commodity_id'];
                $drug_name = $rows['commodity_name'];
                $kemsa_code = $rows['commodity_code'];
                $unit_size = $rows['unit_size'];
                $total_units = $rows['total_commodity_units'];
                $cat_name = $rows['sub_category_name'];
                $received = round(@$received / $total_units);
                $fill_rate = round(@($received / $ordered) * 100);
                $total = $price * $ordered;
                $total_ = $price * $received;
                $total_fill_rate = $total_fill_rate + $fill_rate;
                switch (true) {
                    case $fill_rate == 0:
                        $table_body .= "<tr style='background-color: #FBBBB9;'>";
                        $table_body .= "<td>{$cat_name}</td>";
                        $table_body .= '<td>' . $drug_name . '</td><td>' . $kemsa_code . '</td>' . '<td>' . $unit_size . '</td>';
                        $table_body .= '<td>' . $price . '</td>';
                        $table_body .= '<td>' . $ordered . '</td>';
                        $table_body .= '<td>' . number_format($total, 2, '.', ',') . '</td>';
                        $table_body .= '<td>' . $received . '</td>';
                        $table_body .= '<td>' . number_format($total_, 2, '.', ',') . '</td>';
                        $table_body .= '<td>' . $fill_rate . '% ' . '</td>';
                        $table_body .= '</tr>';
                        break;
                    case $fill_rate <= 60:
                        $table_body .= "<tr style=' background-color: #FAF8CC;'>";
                        $table_body .= "<td>{$cat_name}</td>";
                        $table_body .= '<td>' . $drug_name . '</td><td>' . $kemsa_code . '</td>' . '<td>' . $unit_size . '</td>';
                        $table_body .= '<td>' . $price . '</td>';
                        $table_body .= '<td>' . $ordered . '</td>';
                        $table_body .= '<td>' . number_format($total, 2, '.', ',') . '</td>';
                        $table_body .= '<td>' . $received . '</td>';
                        $table_body .= '<td>' . number_format($total_, 2, '.', ',') . '</td>';
                        $table_body .= '<td>' . $fill_rate . '% ' . '</td>';
                        $table_body .= '</tr>';
                        break;
                    case $fill_rate > 100.01:
                    case $fill_rate == 100.01:
                        $table_body .= "<tr style='background-color: #ea1e17'>";
                        $table_body .= "<td>{$cat_name}</td>";
                        $table_body .= '<td>' . $drug_name . '</td><td>' . $kemsa_code . '</td>' . '<td>' . $unit_size . '</td>';
                        $table_body .= '<td>' . $price . '</td>';
                        $table_body .= '<td>' . $ordered . '</td>';
                        $table_body .= '<td>' . number_format($total, 2, '.', ',') . '</td>';
                        $table_body .= '<td>' . $received . '</td>';
                        $table_body .= '<td>' . number_format($total_, 2, '.', ',') . '</td>';
                        $table_body .= '<td>' . $fill_rate . '% ' . '</td>';
                        $table_body .= '</tr>';
                        break;
                    case $fill_rate == 100:
                        $table_body .= "<tr style=' background-color: #C3FDB8;'>";
                        $table_body .= "<td>{$cat_name}</td>";
                        $table_body .= '<td>' . $drug_name . '</td><td>' . $kemsa_code . '</td>' . '<td>' . $unit_size . '</td>';
                        $table_body .= '<td>' . $price . '</td>';
                        $table_body .= '<td>' . $ordered . '</td>';
                        $table_body .= '<td>' . number_format($total, 2, '.', ',') . '</td>';
                        $table_body .= '<td>' . $received . '</td>';
                        $table_body .= '<td>' . number_format($total_, 2, '.', ',') . '</td>';
                        $table_body .= '<td>' . $fill_rate . '% ' . '</td>';
                        $table_body .= '</tr>';
                        break;
                    default:
                        $table_body .= "<tr>";
                        $table_body .= "<td>{$cat_name}</td>";
                        $table_body .= '<td>' . $drug_name . '</td><td>' . $kemsa_code . '</td>' . '<td>' . $unit_size . '</td>';
                        $table_body .= '<td>' . $price . '</td>';
                        $table_body .= '<td>' . $ordered . '</td>';
                        $table_body .= '<td>' . number_format($total, 2, '.', ',') . '</td>';
                        $table_body .= '<td>' . $received . '</td>';
                        $table_body .= '<td>' . number_format($total_, 2, '.', ',') . '</td>';
                        $table_body .= '<td>' . $fill_rate . '% ' . '</td>';
                        $table_body .= '</tr>';
                        break;
                }
            }
            $order_value = round($total_fill_rate / count($detail_list), 0, PHP_ROUND_HALF_UP);
        }
        $message = <<<HTML_DATA
\t<table>
\t\t\t<tr>
\t\t<th colspan='11'>
\t\t<p>{$facility_name}</p>
\t\t<p>Fill rate(Quantity Ordered/Quantity Received)</p>
         <p style="letter-spacing: 1px;font-weight: bold;text-shadow: 0 1px rgba(0, 0, 0, 0.1);">
Facility Order No {$order_id}| KEMSA Order No {$kemsa_order_no} | Total ordered value(ksh) {$order_total} | Total recieved order value(ksh) {$actual_order_total} |Date Ordered {$order_date}| Date Delivered {$deliver_date}| Order lead Time {$date_diff}; day(s)</p>
\t\t</th>
\t\t</tr>
\t\t<tr>
\t\t<th width="50px" style="background-color: #C3FDB8; "></th>
\t\t<th>Full Delivery 100%</th>
\t\t<th width="50px" style="background-color:#FFFFFF"></th>
\t\t<th>Ok Delivery 60%-less than 100%</th>
\t\t<th width="50px" style="background-color:#FAF8CC;"></th> 
\t\t<th>Partial Delivery less than 60% </th>
\t\t<th width="50px" style="background-color:#FBBBB9;"></th>
\t\t<th>Problematic Delivery 0% </th>
\t\t<th width="50px" style="background-color:#ea1e17;"></th>
\t\t<th>Problematic Delivery over 100%</th>
\t\t</tr></table> </br></n>
<table id="main1" width="100%" class="row-fluid table table-bordered">
\t<thead>
\t\t<tr>
\t\t<th><strong>Category</strong></th>
\t\t<th><strong>Description</strong></th>
\t\t<th><strong>Commodity Code</strong></th>
\t\t<th><strong>Unit Size</strong></th>
\t\t<th><strong>Unit Cost Ksh</strong></th>
\t\t<th><strong>Quantity Ordered</strong></th>
\t\t<th><strong>Total Cost</strong></th>
\t\t<th><strong>Quantity Received</strong></th>
\t\t<th><strong>Total Cost</strong></th>
\t\t<th><strong>Fill rate</strong></th>\t
\t\t</tr>
\t</thead>
\t<tbody>\t
\t\t {$table_body}\t
\t</tbody>
</table>
<br></n>
HTML_DATA;
        return array('table' => $message, 'date_ordered' => $order_date, 'date_received' => $deliver_date, 'order_total' => $order_total, 'actual_order_total' => $actual_order_total, 'lead_time' => $date_diff, 'facility_name' => $facility_name);
    }
 public function save_details()
 {
     $district = $this->session->userdata("district_province_id");
     $facility_id = $this->input->post('facility_id');
     //Check if we are in editing mode first; if so, retrieve the edited record. if not, create a new one!
     if (strlen($facility_id) > 0) {
         $facility = Facilities::getFacility($facility_id);
         //Retrieve the fridges for this facility
         $fridges = Facility_Fridges::getFacilityFridges($facility_id);
         //Delete all these existing facility-fridge combinations
         foreach ($fridges as $fridge) {
             $fridge->delete();
         }
     } else {
         $facility = new Facilities();
     }
     $facility->facilitycode = $this->input->post('facilitycode');
     $facility->name = $this->input->post('name');
     $facility->facilitytype = $this->input->post('type');
     $facility->district = $district;
     $facility->email = $this->input->post('email');
     $facility->phone = $this->input->post('phone');
     $facility->save();
     $facility_id = $facility->id;
     $fridges = $this->input->post('fridges');
     $counter = 0;
     foreach ($fridges as $fridge) {
         if ($fridge > 0) {
             $facility_fridge = new Facility_Fridges();
             $facility_fridge->Facility = $facility_id;
             $facility_fridge->Fridge = $fridge;
             $facility_fridge->Timestamp = date('U');
             $facility_fridge->save();
             $counter++;
         } else {
             $counter++;
             continue;
         }
     }
     redirect("facility_management/district_list");
 }
Пример #15
0
 public function dist_manage($pop_up_msg = NULL)
 {
     $district = $this->session->userdata('district1');
     $id = $this->session->userdata('user_db_id');
     $data['user_type'] = Access_level::getAll1();
     $data['facilities'] = Facilities::getFacilities($district);
     $data['title'] = "User Management";
     $data['content_view'] = "district/user_management/users_district_v";
     $data['banner_text'] = "User Management";
     $data['pop_up_msg'] = $pop_up_msg;
     $data['result'] = User::getAll5($district, $id);
     $data['counties'] = Counties::getAll();
     $this->load->view("template", $data);
 }
Пример #16
0
 public function user_create()
 {
     //get user details in session
     $identifier = $this->session->userdata('user_indicator');
     $user_type_id = $this->session->userdata('user_type_id');
     $district = $this->session->userdata('district_id');
     $county = $this->session->userdata('county_id');
     $facility = $this->session->userdata('facility_id');
     //query to get user listing by type of user
     switch ($identifier) {
         case 'moh':
             $permissions = 'moh_permissions';
             $template = 'shared_files/template/dashboard_template_v';
             break;
         case 'facility_admin':
             $permissions = 'facilityadmin_permissions';
             $data['listing'] = Users::get_user_list_facility($facility);
             $template = 'shared_files/template/template';
             break;
         case 'district':
             $permissions = 'district_permissions';
             $data['listing'] = Users::get_user_list_district($district);
             $data['facilities'] = Facilities::getFacilities($district);
             $data['counts'] = Users::get_users_district($district);
             $template = 'shared_files/template/template';
             break;
         case 'moh_user':
             $data['listing'] = Users::get_user_list($user_type_id);
             $template = 'shared_files/template/dashboard_template_v';
             break;
         case 'district_tech':
             $data['listing'] = Users::get_user_list($user_type_id);
             $template = 'shared_files/template/template';
             break;
         case 'rtk_manager':
             $data['listing'] = Users::get_user_list($user_type_id);
             $template = 'shared_files/template/template';
             break;
         case 'super_admin':
             $permissions = 'super_permissions';
             $data['title'] = "Users";
             $data['content_view'] = "Admin/users_v";
             $data['listing'] = Users::get_user_list_all();
             $data['counts'] = Users::get_users_count();
             $data['counties'] = Counties::getAll();
             $template = 'shared_files/template/dashboard_v';
             break;
         case 'allocation_committee':
             $data['listing'] = Users::get_user_list($user_type_id);
             $template = 'shared_files/template/template';
             break;
         case 'county':
             $permissions = 'county_permissions';
             $data['listing'] = Users::get_user_list_county($county);
             $data['district_data'] = districts::getDistrict($county);
             $data['counts'] = Users::get_users_county($county);
             $template = 'shared_files/template/template';
             break;
     }
     $data['title'] = "User Management";
     $data['user_types'] = Access_level::get_access_levels($permissions);
     $data['banner_text'] = "User Management";
     $data['content_view'] = "shared_files/user_creation_v";
     $this->load->view($template, $data);
 }
Пример #17
0
    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);
    }
Пример #18
0
    public function decommission()
    {
        //Change status of commodities to decommissioned
        $date = date('y-m-d');
        $facility_code = $this->session->userdata('facility_id');
        $user_id = $this->session->userdata('user_id');
        $facility_name_array = Facilities::get_facility_name_($facility_code)->toArray();
        $facility_name = $facility_name_array[0]['facility_name'];
        $myobj1 = Doctrine::getTable('Districts')->find($facility_name_array[0]['district']);
        $disto_name = $myobj1->district;
        $county = $myobj1->county;
        $myobj2 = Doctrine::getTable('Counties')->find($county);
        $county_name = $myobj2->county;
        $total = 0;
        //Create PDF of Expired Drugs that are to be decommisioned. check here
        $decom = Facility_stocks::get_facility_expired_stuff($facility_code);
        /*****************************setting up the report*******************************************/
        if (count($decom) > 0) {
            $body = '';
            $body .= "<style> table {\n    border-collapse: collapse;\n}td,th{\n\tpadding: 12px;\n\ttext-align:center;\n}\n\n*{margin:0;padding:0}*{font-family:'Helvetica Neue',Helvetica,Helvetica,Arial,sans-serif}img{max-width:100%}.collapse{padding:0}body{-webkit-font-smoothing:antialiased;-webkit-text-size-adjust:none;width:100%!important;height:100%}a{color:#2BA6CB}.btn{text-decoration:none;color:#FFF;background-color:#666;padding:10px 16px;font-weight:700;margin-right:10px;text-align:center;cursor:pointer;display:inline-block}p.callout{padding:15px;background-color:#ECF8FF;margin-bottom:15px}.callout a{font-weight:700;color:#2BA6CB}table.social{background-color:#ebebeb}.social .soc-btn{padding:3px 7px;font-size:12px;margin-bottom:10px;text-decoration:none;color:#FFF;font-weight:700;display:block;text-align:center}a.fb{background-color:#3B5998!important}a.tw{background-color:#1daced!important}a.gp{background-color:#DB4A39!important}a.ms{background-color:#000!important}.sidebar .soc-btn{display:block;width:100%}table.head-wrap{width:100%}.header.container table td.logo{padding:15px}.header.container table td.label{padding:15px 15px 15px 0}table.body-wrap{width:100%}table.footer-wrap{width:100%;clear:both!important}.footer-wrap .container td.content p{border-top:1px solid #d7d7d7;padding-top:15px;font-size:9px;font-weight:500}h1,h2,h3,h4,h5,h6{font-family:HelveticaNeue-Light,'Helvetica Neue Light','Helvetica Neue',Helvetica,Arial,'Lucida Grande',sans-serif;line-height:1.1;margin-bottom:15px;color:#000}h1 small,h2 small,h3 small,h4 small,h5 small,h6 small{font-size:60%;color:#6f6f6f;line-height:0;text-transform:none}h1{font-weight:200;font-size:44px}h2{font-weight:200;font-size:37px}h3{font-weight:500;font-size:27px}h4{font-weight:500;font-size:23px}h5{font-weight:900;font-size:17px}h6{font-weight:900;font-size:14px;text-transform:uppercase;color:#444}.collapse{margin:0!important}p,ul{margin-bottom:10px;font-weight:400;font-size:14px;line-height:1.6}p.lead{font-size:17px}p.last{margin-bottom:0}ul li{margin-left:5px;list-style-position:inside}ul.sidebar{background:#ebebeb;display:block;list-style-type:none}ul.sidebar li{display:block;margin:0}ul.sidebar li a{text-decoration:none;color:#666;padding:10px 16px;cursor:pointer;border-bottom:1px solid #777;border-top:1px solid #FFF;display:block;margin:0}ul.sidebar li a.last{border-bottom-width:0}ul.sidebar li a h1,ul.sidebar li a h2,ul.sidebar li a h3,ul.sidebar li a h4,ul.sidebar li a h5,ul.sidebar li a h6,ul.sidebar li a p{margin-bottom:0!important}.container{display:block!important;max-width:100%!important;margin:0 auto!important;clear:both!important}.content{padding:15px;max-width:80%px;margin:0 auto;display:block}.content table{width:100%}.column{width:300px;float:left}.column tr td{padding:15px}.column-wrap{padding:0!important;margin:0 auto;max-width:600px!important}.column table{width:100%}.social .column{width:280px;min-width:279px;float:left}.clear{display:block;clear:both}@media only screen and (max-width:600px){a[class=btn]{display:block!important;margin-bottom:10px!important;background-image:none!important;margin-right:0!important}div[class=column]{width:auto!important;float:none!important}table.social div[class=column]{width:auto!important}}</style>";
            $body .= "<table class='' style='background-color: #ECF8FF;' >\n<tr>\n<td>MFL No: <strong>{$facility_code}</strong> </td>\n<td>Health Facility Name: <strong>{$facility_name}</strong></td>\n<td>County: <strong>{$county_name}</strong></td>\n<td>Subcounty: <strong>{$disto_name}</strong></td>\n</tr>\n</table>" . '
<table class="" style="margin:8px;word-wrap: break-word;">
<thead style="font-size:12px">
			<tr><th><strong>Source</strong></th>
			<th><strong>Description</strong></th>
			<th><strong>Commodity Code</strong></th>

			<th><strong>Unit Cost(Ksh)</strong></th>
			<th><strong>Batch Affected</strong></th>
			<th><strong>Manufacturer</strong></th>
			<th><strong>Expiry Date</strong></th>
			<th><strong>Expiry Days</strong></th>
			<th><strong>Expired(Pack Size)</strong></th>
			<th><strong>Expired(Unit Size)</strong></th>
			<th><strong>Cost of Expired (Ksh)</strong></th>
</tr> </thead><tbody>';
            /*******************************begin adding data to the report*****************************************/
            foreach ($decom as $drug) {
                $commodity_id = $drug['commodity_id'];
                $batch = $drug['batch_no'];
                $mau = $drug['manufacture'];
                $commodity_name = $drug['commodity_name'];
                $commodity_code = $drug['commodity_code'];
                $unit_size = $drug['unit_size'];
                $unit_cost = str_replace(",", '', $drug['unit_cost']);
                $current_balance = $drug['current_balance'];
                $total_commodity_units = $drug['total_commodity_units'];
                $expiry_date = $drug['expiry_date'];
                $current_balance_pack = round($current_balance / $total_commodity_units, 1);
                $cost = $current_balance_pack * $unit_cost;
                $formatme = new DateTime($expiry_date);
                $newdate = $formatme->format('d M Y');
                $facility_stock_id = $drug['facility_stock_id'];
                $total = $total + $cost;
                $source = $drug['source_name'];
                //get the current balance of the commodity
                $facility_stock = Facility_Stocks::get_facility_commodity_total($facility, $commodity_id)->toArray();
                $mydata3 = array('facility_code' => $facility_code, 's11_No' => '(Loss) Expiry', 'commodity_id' => $commodity_id, 'batch_no' => $batch, 'expiry_date' => date('y-m-d', strtotime(str_replace(",", " ", $expiry_date))), 'balance_as_of' => $facility_stock[0]['commodity_balance'], 'date_issued' => date('y-m-d'), 'qty_issued' => 0, 'adjustmentnve' => $current_balance * -1, 'issued_to' => 'N/A', 'issued_by' => $this->session->userdata('user_id'));
                $seconds_diff = strtotime(date("y-m-d")) - strtotime($expiry_date);
                $date_diff = floor($seconds_diff / 3600 / 24);
                Facility_Issues::update_issues_table($mydata3);
                $inserttransaction = Doctrine_Manager::getInstance()->getCurrentConnection()->execute("UPDATE `facility_transaction_table` SET losses =losses+{$current_balance}, closing_stock=closing_stock-{$current_balance}\n              WHERE `commodity_id`= '{$commodity_id}' and status='1' and facility_code={$facility_code} ");
                /// update the facility issues and set the commodity to expired
                $inserttransaction = Doctrine_Manager::getInstance()->getCurrentConnection()->execute("UPDATE `facility_stocks` SET status =2 WHERE `id`= '{$facility_stock_id}'");
                if ($current_balance_pack > 0) {
                    $body .= '<tr style="font-size:12px;padding:4px"><td>' . $source . '</td>
							<td>' . $commodity_name . '</td>
							<td>' . $commodity_code . '</td>

							<td>' . $unit_cost . '(' . $unit_size . ')' . '</td>
							<td>' . $batch . '</td>
							<td>' . $mau . '</td>
							<td>' . $newdate . '</td>
							<td>' . $date_diff . '</td>
							<td>' . $current_balance_pack . '</td>
							<td>' . $current_balance . '</td>
							<td>' . number_format($cost, 2, '.', ',') . '</td>
							</tr>';
                }
            }
            $body .= '
		<tr>
		<td colspan="12">
		<b style="float: right; margin:1.0em;font-size:14px">TOTAL cost(Ksh) of Expiries: &nbsp; ' . number_format($total, 2, '.', ',') . '</b>
		</tr>
		</tbody>
		</table>';
            $html_body .= "<!-- BODY -->\n<table class='body-wrap'>\n\t<tr>\n\t\t<td></td>\n\t\t<td class='container' bgcolor='#FFFFFF'>\n\n\t\t\t<div class='content'>\n\t\t\t<table>\n\t\t\t\t<tr>\n\t\t\t\t\t<td>\n\t\t\t\t\t\t<h3>Hello,</h3>\n\t\t\t\t\t\t<p class='lead'>Find attached decommissioned commodities for {$facility_name} ({$facility_code}).</p>\n\t\t\t\t\t\t<p>{$body}</p>\n\t\t\t\t\t\t<!-- Callout Panel -->\n\t\t\t\t\t\t<p class='callout'>\n\t\t\t\t\t\t\t<a href='health-cmp.or.ke'>Click here! &raquo;</a> to follow up.\n\t\t\t\t\t\t</p><!-- /Callout Panel -->\n\n\t\t\t\t\t\t<!-- social & contact -->\n\t\t\t\t\t\t<table class='social' width='100%'>\n\t\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t\t<td>\n\n\t\t\t\t\t\t\t\t\t<!-- column 1 -->\n\t\t\t\t\t\t\t\t\t<table align='left' class='column'>\n\n\t\t\t\t\t\t\t\t\t</table><!-- /column 1 -->\n\n\t\t\t\t\t\t\t\t\t<!-- column 2 -->\n\t\t\t\t\t\t\t\t\t<table align='left' class='column'>\n\t\t\t\t\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t\t\t\t\t<td>\n\n\t\t\t\t\t\t\t\t\t\t\t\t<h5 class=''>Contact Info:</h5>\n\t\t\t\t\t\t\t\t\t\t\t\t<p>Phone: <strong>+254720167245</strong><br/>\n                Email: <strong><a href='emailto:hcmpkenya@gmail.com'>hcmpkenya@gmail.com</a></strong></p>\n\n\t\t\t\t\t\t\t\t\t\t\t</td>\n\t\t\t\t\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t\t\t\t</table><!-- /column 2 -->\n\n\t\t\t\t\t\t\t\t\t<span class='clear'></span>\n\n\t\t\t\t\t\t\t\t</td>\n\t\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t</table><!-- /social & contact -->\n\n\t\t\t\t\t</td>\n\t\t\t\t</tr>\n\t\t\t</table>\n\t\t\t</div><!-- /content -->\n\n\t\t</td>\n\t\t<td></td>\n\t</tr>\n</table><!-- /BODY -->";
            $file_name = 'Facility_Expired_Commodities_' . $facility_name . "_" . $facility_code . "_" . $date;
            $pdf_data = array("pdf_title" => "Facility Expired Commodities For {$facility_name}", 'pdf_html_body' => $body, 'pdf_view_option' => 'save_file', 'file_name' => $file_name);
            $this->hcmp_functions->create_pdf($pdf_data);
            if ($this->hcmp_functions->send_stock_decommission_email($html_body, 'Decommission Report For ' . $facility_name, './pdf/' . $file_name . '.pdf')) {
                delete_files('./pdf/' . $file_name . '.pdf');
                $this->session->set_flashdata('system_success_message', 'Stocks Have Been Decommissioned');
            }
            //updates the log tables with the action
            $user = $this->session->userdata('user_id');
            $user_action = "decommissioned";
            //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");
        }
        redirect('reports/facility_stock_data');
    }
Пример #19
0
 public function user_create_multiple($facility_code = null)
 {
     //get user details in session
     $identifier = $this->session->userdata('user_indicator');
     $user_type_id = $this->session->userdata('user_type_id');
     $district = $this->session->userdata('district_id');
     $county = $this->session->userdata('county_id');
     $facility = $this->session->userdata('facility_id');
     //query to get user listing by type of user
     switch ($identifier) {
         case 'moh':
             $permissions = 'moh_permissions';
             $template = 'shared_files/template/dashboard_template_v';
             break;
         case 'facility_admin':
             $permissions = 'facilityadmin_permissions';
             $data['listing'] = Users::get_user_list_facility($facility);
             $template = 'shared_files/template/template';
             break;
         case 'district':
             $permissions = 'district_permissions';
             $data['listing'] = Users::get_user_list_district($district);
             if ($facility_code == 0) {
                 $data['facilities'] = Facilities::getFacilities($district);
                 $facility_name = null;
                 $facility_banner_text = null;
                 $no_of_facilities = 0;
             } else {
                 $data['facilities'] = Facilities::getFacilities_from_facility_code($facility_code);
                 $facility_banner_text = ' to: ' . $data['facilities'][0]['facility_name'];
                 $facility_name = $data['facilities'][0]['facility_name'];
                 $no_of_facilities = 1;
             }
             $data['counts'] = Users::get_users_district($district);
             $template = 'shared_files/template/template';
             break;
         case 'moh_user':
             $data['listing'] = Users::get_user_list($user_type_id);
             $template = 'shared_files/template/dashboard_template_v';
             break;
         case 'district_tech':
             $data['listing'] = Users::get_user_list($user_type_id);
             $template = 'shared_files/template/template';
             break;
         case 'rtk_manager':
             $data['listing'] = Users::get_user_list($user_type_id);
             $template = 'shared_files/template/template';
             break;
         case 'super_admin':
             $permissions = 'super_permissions';
             $data['title'] = "Users";
             $data['content_view'] = "Admin/users_v";
             $data['listing'] = Users::get_user_list_all();
             $data['counts'] = Users::get_users_count();
             $data['counties'] = Counties::getAll();
             $template = 'shared_files/template/dashboard_v';
             break;
         case 'allocation_committee':
             $data['listing'] = Users::get_user_list($user_type_id);
             $template = 'shared_files/template/template';
             break;
         case 'county':
             $permissions = 'county_permissions';
             if ($facility_code == 0) {
                 $data['facilities'] = Facilities::getFacilities($district);
                 $facility_name = null;
                 $facility_banner_text = null;
                 $district_name = null;
                 $district_id = null;
                 $no_of_facilities = 0;
             } else {
                 $data['facilities'] = Facilities::getFacilities_from_facility_code($facility_code);
                 $facility_banner_text = ' to: ' . $data['facilities'][0]['facility_name'];
                 $facility_name = $data['facilities'][0]['facility_name'];
                 $district_id = $data['facilities'][0]['district'];
                 $district_data = Districts::get_district_name($district_id);
                 $district_name = $district_data[0]['district'];
                 $no_of_facilities = 1;
             }
             $data['listing'] = Users::get_user_list_county($county);
             $data['district_data'] = districts::getDistrict($county);
             $data['counts'] = Users::get_users_county($county);
             $template = 'shared_files/template/template';
             break;
     }
     $data['title'] = "Add Multiple Users";
     $data['user_types'] = Access_level::get_access_levels($permissions);
     $data['banner_text'] = "Multiple User Addition";
     $data['facility_name'] = $facility_name;
     $data['facility_code'] = $facility_code;
     $data['facility_banner_text'] = $facility_banner_text;
     $data['district_name'] = $district_name;
     $data['district_id'] = $district_id;
     $data['no_of_facilities'] = $no_of_facilities;
     $data['content_view'] = "shared_files/add_users_multiple";
     $this->load->view($template, $data);
 }
Пример #20
0
 public function facility_order_($facility_code = null)
 {
     // hack to ensure that when you are ordering for a facility that is not using hcmp they have all the items
     $checker = $this->session->userdata('facility_id') ? null : 1;
     if (isset($_FILES['file']) && $_FILES['file']['size'] > 0) {
         $more_data = $this->hcmp_functions->kemsa_excel_order_uploader($_FILES["file"]["tmp_name"]);
         $data['order_details'] = $data['facility_order'] = $more_data['row_data'];
         $facility_data = Facilities::get_facility_name($more_data['facility_code'])->toArray();
         $facility_code = $facility_data[0]['facility_code'];
         if (count($facility_data) == 0) {
             $this->session->set_flashdata('system_error_message', "Kindly upload a file with correct facility MFL code ");
             redirect("reports/order_listing/subcounty");
         }
         if ($facility_data[0]['using_hcmp'] == 1) {
             //$this -> session -> set_flashdata('system_error_message', "You cannot order for a" . " facility that is already using HCMP, they need to place their order using their accounts");
             //redirect("reports/order_listing/subcounty");
         }
     } else {
         $data['order_details'] = $data['facility_order'] = Facility_Transaction_Table::get_commodities_for_ordering($facility_code, $checker);
         $facility_data = Facilities::get_facility_name($facility_code)->toArray();
     }
     $data['content_view'] = "facility/facility_orders/facility_order_from_kemsa_v";
     $data['title'] = "Facility New Order";
     $data['system_error_message'] = "You are ordering for " . $facility_data[0]['facility_name'];
     $data['facility_code'] = $facility_code;
     $data['banner_text'] = "Facility New Order";
     $data['drawing_rights'] = $facility_data[0]['drawing_rights'];
     $data['facility_commodity_list'] = Commodities::get_all_from_supllier(1);
     $this->load->view('shared_files/template/template', $data);
 }
Пример #21
0
 public function generate_fcdrr_Report_pdf($report_name, $title, $html_data)
 {
     $current_year = date('Y');
     $current_month = date('F');
     $facility_code = $this->session->userdata('news');
     $facility_name_array = Facilities::get_facility_name($facility_code)->toArray();
     $facility_name = $facility_name_array['facility_name'];
     //if ($display_type == "Download PDF") {
     /*         * ******************************************setting the report title******************** */
     $html_title = "<div ALIGN=CENTER><img src='" . base_url() . "Images/coat_of_arms.png' height='70' width='70'style='vertical-align: top;' > </img></div>\n    <div style='text-align:center; font-family: arial,helvetica,clean,sans-serif; font-size: 14px; display: block; font-weight: bold;'>Division of Reproductive Health Report</div>\n    <div style='text-align:center; font-family: arial,helvetica,clean,sans-serif; font-size: 14px; display: block; font-weight: bold; '>\n        Ministry of Public Health and Sanitation/Ministry of Medical Services</div>\n        <div style='text-align:center; font-family: arial,helvetica,clean,sans-serif;display: block; font-weight: bold;display: block; font-size: 13px;'>Health Commodities Management Platform</div>\n        <div style='text-align:center; font-family: arial,helvetica,clean,sans-serif; font-size: 12px; display: block; font-weight: bold;'>" . $current_month . " " . $current_year . "</h2>\n            <hr />   ";
     $css_path = base_url() . 'CSS/style.css';
     /*         * ********************************initializing the report ********************* */
     $this->load->library('mpdf');
     $this->mpdf = new mPDF('', 'A4-L', 0, '', 15, 15, 16, 16, 9, 9, '');
     //$stylesheet = file_get_contents("$css_path");
     //$this->mpdf->WriteHTML($stylesheet,1);    // The parameter 1 tells that this is css/style only and no body/html/text
     $this->mpdf->SetTitle($title);
     $this->mpdf->WriteHTML($html_title);
     $this->mpdf->simpleTables = true;
     $this->mpdf->WriteHTML('<br/>');
     $this->mpdf->WriteHTML($html_data);
     $reportname = $report_name . ".pdf";
     $this->mpdf->Output($reportname, 'D');
 }
Пример #22
0
           \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">
Пример #23
0
 public function data_upload()
 {
     if ($_POST['btn_save']) {
         $objReader = new PHPExcel_Reader_Excel2007();
         if ($_FILES['file']['tmp_name']) {
             $objPHPExcel = $objReader->load($_FILES['file']['tmp_name']);
         } else {
             $this->session->set_userdata('upload_counter', '1');
             redirect("fcdrr_management/index");
         }
         $arr = $objPHPExcel->getActiveSheet()->toArray(null, true, true, true);
         $highestColumm = $objPHPExcel->setActiveSheetIndex(0)->getHighestColumn();
         $highestRow = $objPHPExcel->setActiveSheetIndex(0)->getHighestRow();
         //Top Details
         $facility_name = $arr[5]['B'] . $arr[5]['C'] . $arr[5]['D'] . $arr[5]['E'];
         $province = $arr[6]['B'] . $arr[6]['C'] . $arr[6]['D'] . $arr[6]['E'];
         $facility_code = $arr[5]['R'] . $arr[5]['S'] . $arr[5]['T'];
         $district = $arr[6]['R'] . $arr[6]['S'] . $arr[6]['T'];
         $type_of_service_art = $arr[8]['C'];
         $type_of_service_pmtct = $arr[8]['E'];
         $type_of_service_pep = $arr[8]['H'];
         if ($type_of_service_art && $type_of_service_pmtct && $type_of_service_pep) {
             $services_offered = "ART,PMTCT,PEP";
         } else {
             if ($type_of_service_pmtct && $type_of_service_art) {
                 $services_offered = "ART,PMTCT";
             } else {
                 if ($type_of_service_pep && $type_of_service_art) {
                     $services_offered = "ART,PEP";
                 } else {
                     if ($type_of_service_pmtct && $type_of_service_pep) {
                         $services_offered = "PMTCT,PEP";
                     } else {
                         if ($type_of_service_art) {
                             $services_offered = "ART";
                         }
                         if ($type_of_service_pmtct) {
                             $services_offered = "PMTCT";
                         }
                         if ($type_of_service_pep) {
                             $services_offered = "PEP";
                         }
                     }
                 }
             }
         }
         @$services_offered;
         $programme_sponsor_gok = $arr[4]['D'];
         $programme_sponsor_pepfar = $arr[4]['G'];
         $programme_sponsor_msf = $arr[4]['L'];
         $programme_sponsor = "";
         if ($programme_sponsor_gok) {
             $programme_sponsor = "GOK";
         }
         if ($programme_sponsor_pepfar) {
             $programme_sponsor = "PEPFAR";
         }
         if ($programme_sponsor_msf) {
             $programme_sponsor = "MSF";
         }
         $updated_on = date("U");
         //Reporting Period
         @($beginning = trim($arr[10]['D'] . $arr[10]['E']));
         @($ending = $arr[10]['R'] . $arr[10]['S'] . $arr[10]['T']);
         $start = explode("-", $beginning);
         $day = $start[0];
         $month = $start[1];
         $year = $start[2];
         $beginning = "20" . $year . "-" . $month . "-" . $day;
         $beginning = date('Y-m-d', strtotime($beginning));
         $ending = str_replace('/', '-', $ending);
         $old_ending = strtotime($ending);
         $ending = date('Y-m-d', $old_ending);
         $central_facility = $this->session->userdata('facility');
         $parent = Facilities::getParent($central_facility);
         $central_site = $parent->parent;
         //Comments
         for ($i = 105; $i <= 109; $i++) {
             for ($j = 1; $j <= $highestColumm; $j++) {
             }
             @($comments .= $arr[$i]['A'] . $arr[$i]['B'] . $arr[$i]['C'] . $arr[$i]['D'] . $arr[$i]['E'] . $arr[$i]['G'] . $arr[$i]['H'] . $arr[$i]['L']);
         }
         $unique_id = 0;
         $this->load->database();
         $facility_order_query = $this->db->query("SELECT MAX(id) AS id FROM facility_order");
         $facility_order_results = $facility_order_query->result_array();
         $facility_id = $facility_order_results[0]['id'];
         $order_number = $facility_id + 1;
         $unique_id = md5($order_number . $facility_code);
         $query = $this->db->query("INSERT INTO facility_order (`id`, `status`, `created`, `updated`, `code`, `period_begin`, `period_end`, `comments`, `reports_expected`, `reports_actual`, `services`, `sponsors`, `delivery_note`, `order_id`, `facility_id`,`central_facility`,`unique_id`) VALUES ('{$order_number}', '0', CURDATE(), '{$updated_on}', '2', '{$beginning}', '{$ending}', '{$comments}', NULL, NULL, '{$services_offered}', '{$programme_sponsor}', NULL, NULL, '{$facility_code}','{$central_site}','{$unique_id}');");
         $facility_id = $unique_id;
         $user_id = $this->session->userdata('full_name');
         $query = $this->db->query("SELECT MAX(id) AS id FROM order_comment");
         $results = $query->result_array();
         $last_id = $results[0]['id'];
         $last_id = $last_id + 1;
         $last_id = md5($last_id . $facility_code);
         //Adding comments
         $order_comment = new Order_Comment();
         $order_comment->Order_Number = $facility_id;
         $order_comment->Timestamp = date('U');
         $order_comment->User = $user_id;
         $order_comment->Comment = $comments;
         $order_comment->Unique_Id = $last_id;
         $order_comment->save();
         //Adult ARV Preparations
         for ($i = 18; $i <= 42; $i++) {
             for ($j = 1; $j <= $highestColumm; $j++) {
             }
             $quantity_required_for_supply = $arr[$i]['L'];
             $drug_name = $arr[$i]['A'];
             if ($quantity_required_for_supply != 0) {
                 $drug_id = $drug_name;
                 $basic_unit = $arr[$i]['B'];
                 $beginning_balance = $arr[$i]['C'];
                 $quantity_received_in_period = $arr[$i]['D'];
                 $quantity_dispensed_in_period = $arr[$i]['E'];
                 $adjustments_to_other_facilities = $arr[$i]['G'];
                 $end_of_month_physical_count = $arr[$i]['H'];
                 $quantity_required_for_supply = $arr[$i]['L'];
                 $query = $this->db->query("SELECT MAX(id) AS id FROM cdrr_item");
                 $results = $query->result_array();
                 $last_id = $results[0]['id'];
                 $last_id++;
                 $last_id = md5($last_id . $facility_code);
                 $cdrr_query = $this->db->query("INSERT INTO cdrr_item (`id`, `balance`, `received`, `dispensed_units`, `dispensed_packs`, `losses`, `adjustments`, `count`, `resupply`, `aggr_consumed`, `aggr_on_hand`, `publish`, `cdrr_id`, `drug_id`,`unique_id`) VALUES (NULL, '{$beginning_balance}', '{$quantity_received_in_period}', '{$quantity_dispensed_in_period}', NULL, NULL, '{$adjustments_to_other_facilities}', '{$end_of_month_physical_count}', '{$quantity_required_for_supply}', NULL, NULL, '0', '{$facility_id}', '{$drug_id}','{$last_id}');");
             }
         }
         //Paediatric Preparations
         for ($i = 44; $i <= 76; $i++) {
             for ($j = 1; $j <= $highestColumm; $j++) {
             }
             $quantity_required_for_supply = $arr[$i]['L'];
             $drug_name = $arr[$i]['A'];
             if ($quantity_required_for_supply != 0) {
                 $drug_id = $drug_name;
                 $basic_unit = $arr[$i]['B'];
                 $beginning_balance = $arr[$i]['C'];
                 $quantity_received_in_period = $arr[$i]['D'];
                 $quantity_dispensed_in_period = $arr[$i]['E'];
                 $adjustments_to_other_facilities = $arr[$i]['G'];
                 $end_of_month_physical_count = $arr[$i]['H'];
                 $quantity_required_for_supply = $arr[$i]['L'];
                 $query = $this->db->query("SELECT MAX(id) AS id FROM cdrr_item");
                 $results = $query->result_array();
                 $last_id = $results[0]['id'];
                 $last_id++;
                 $last_id = md5($last_id . $facility_code);
                 $cdrr_query = $this->db->query("INSERT INTO cdrr_item (`id`, `balance`, `received`, `dispensed_units`, `dispensed_packs`, `losses`, `adjustments`, `count`, `resupply`, `aggr_consumed`, `aggr_on_hand`, `publish`, `cdrr_id`, `drug_id`,`unique_id`) VALUES (NULL, '{$beginning_balance}', '{$quantity_received_in_period}', '{$quantity_dispensed_in_period}', NULL, NULL, '{$adjustments_to_other_facilities}', '{$end_of_month_physical_count}', '{$quantity_required_for_supply}', NULL, NULL, '0', '{$facility_id}', '{$drug_id}','{$last_id}');");
             }
         }
         //Drugs for IOs
         for ($i = 78; $i <= 99; $i++) {
             for ($j = 1; $j <= $highestColumm; $j++) {
             }
             $quantity_required_for_supply = $arr[$i]['L'];
             $drug_name = $arr[$i]['A'];
             if ($quantity_required_for_supply != 0) {
                 $drug_id = $drug_name;
                 $basic_unit = $arr[$i]['B'];
                 $beginning_balance = $arr[$i]['C'];
                 $quantity_received_in_period = $arr[$i]['D'];
                 $quantity_dispensed_in_period = $arr[$i]['E'];
                 $adjustments_to_other_facilities = $arr[$i]['G'];
                 $end_of_month_physical_count = $arr[$i]['H'];
                 $quantity_required_for_supply = $arr[$i]['L'];
                 $query = $this->db->query("SELECT MAX(id) AS id FROM cdrr_item");
                 $results = $query->result_array();
                 $last_id = $results[0]['id'];
                 $last_id++;
                 $last_id = md5($last_id . $facility_code);
                 $cdrr_query = $this->db->query("INSERT INTO cdrr_item (`id`, `balance`, `received`, `dispensed_units`, `dispensed_packs`, `losses`, `adjustments`, `count`, `resupply`, `aggr_consumed`, `aggr_on_hand`, `publish`, `cdrr_id`, `drug_id`,`unique_id`) VALUES (NULL, '{$beginning_balance}', '{$quantity_received_in_period}', '{$quantity_dispensed_in_period}', NULL, NULL, '{$adjustments_to_other_facilities}', '{$end_of_month_physical_count}', '{$quantity_required_for_supply}', NULL, NULL, '0', '{$facility_id}', '{$drug_id}','{$last_id}');");
             }
         }
         //PMTCT Regimen 1.Pregnant Women
         for ($i = 19; $i <= 21; $i++) {
             for ($j = 19; $j <= $highestColumm; $j++) {
             }
             $regimen_code = $arr[$i]['S'];
             $regimen_desc = $arr[$i]['T'];
             $no_of_clients_dispensed_in_period = $arr[$i]['V'] . $arr[$i]['W'];
             if ($no_of_clients_dispensed_in_period) {
                 $regimen_id = $regimen_code . " | " . $regimen_desc;
                 $query = $this->db->query("SELECT MAX(id) AS id FROM maps_item");
                 $results = $query->result_array();
                 $last_id = $results[0]['id'];
                 $last_id++;
                 $last_id = md5($last_id . $facility_code);
                 $next_query = $this->db->query("INSERT INTO maps_item (`id`, `total`, `regimen_id`, `maps_id`,`unique_id`) VALUES (NULL, '{$no_of_clients_dispensed_in_period}', '{$regimen_id}', '{$facility_id}','{$last_id}');");
             }
         }
         //PMTCT Regimen 2.Infants
         for ($i = 23; $i <= 27; $i++) {
             for ($j = 19; $j <= $highestColumm; $j++) {
             }
             $regimen_code = $arr[$i]['S'];
             $regimen_desc = $arr[$i]['T'];
             $no_of_clients_dispensed_in_period = $arr[$i]['V'] . $arr[$i]['W'];
             if ($no_of_clients_dispensed_in_period) {
                 $this->load->database();
                 $regimen_id = $regimen_code . " | " . $regimen_desc;
                 $query = $this->db->query("SELECT MAX(id) AS id FROM maps_item");
                 $results = $query->result_array();
                 $last_id = $results[0]['id'];
                 $last_id++;
                 $last_id = md5($last_id . $facility_code);
                 $next_query = $this->db->query("INSERT INTO maps_item (`id`, `total`, `regimen_id`, `maps_id`,`unique_id`) VALUES (NULL, '{$no_of_clients_dispensed_in_period}', '{$regimen_id}', '{$facility_id}','{$last_id}');");
             }
         }
         //Adult ART First Line Regimens
         for ($i = 33; $i <= 43; $i++) {
             for ($j = 19; $j <= $highestColumm; $j++) {
             }
             $regimen_code = $arr[$i]['S'];
             $regimen_desc = $arr[$i]['T'];
             $no_of_clients_dispensed_in_period = $arr[$i]['V'] . $arr[$i]['W'];
             if ($no_of_clients_dispensed_in_period) {
                 $regimen_id = $regimen_code . " | " . $regimen_desc;
                 $query = $this->db->query("SELECT MAX(id) AS id FROM maps_item");
                 $results = $query->result_array();
                 $last_id = $results[0]['id'];
                 $last_id++;
                 $last_id = md5($last_id . $facility_code);
                 $next_query = $this->db->query("INSERT INTO maps_item (`id`, `total`, `regimen_id`, `maps_id`,`unique_id`) VALUES (NULL, '{$no_of_clients_dispensed_in_period}', '{$regimen_id}', '{$facility_id}','{$last_id}');");
             }
         }
         //Adult ART Second Line Regimens
         for ($i = 45; $i <= 58; $i++) {
             for ($j = 19; $j <= $highestColumm; $j++) {
             }
             $regimen_code = $arr[$i]['S'];
             $regimen_desc = $arr[$i]['T'];
             $no_of_clients_dispensed_in_period = $arr[$i]['V'] . $arr[$i]['W'];
             if ($no_of_clients_dispensed_in_period) {
                 $regimen_id = $regimen_code . " | " . $regimen_desc;
                 $query = $this->db->query("SELECT MAX(id) AS id FROM maps_item");
                 $results = $query->result_array();
                 $last_id = $results[0]['id'];
                 $last_id++;
                 $last_id = md5($last_id . $facility_code);
                 $next_query = $this->db->query("INSERT INTO maps_item (`id`, `total`, `regimen_id`, `maps_id`,`unique_id`) VALUES (NULL, '{$no_of_clients_dispensed_in_period}', '{$regimen_id}', '{$facility_id}','{$last_id}');");
             }
         }
         //Other Adult ART regimens
         for ($i = 60; $i <= 62; $i++) {
             for ($j = 19; $j <= $highestColumm; $j++) {
             }
             $regimen_code = $arr[$i]['S'];
             $regimen_desc = $arr[$i]['T'];
             $no_of_clients_dispensed_in_period = $arr[$i]['V'] . $arr[$i]['W'];
             if ($no_of_clients_dispensed_in_period) {
                 $regimen_id = $regimen_code . " | " . $regimen_desc;
                 $query = $this->db->query("SELECT MAX(id) AS id FROM maps_item");
                 $results = $query->result_array();
                 $last_id = $results[0]['id'];
                 $last_id++;
                 $last_id = md5($last_id . $facility_code);
                 $next_query = $this->db->query("INSERT INTO maps_item (`id`, `total`, `regimen_id`, `maps_id`,`unique_id`) VALUES (NULL, '{$no_of_clients_dispensed_in_period}', '{$regimen_id}', '{$facility_id}','{$last_id}');");
             }
         }
         //Paediatric ART First Line Regimens
         for ($i = 64; $i <= 74; $i++) {
             for ($j = 19; $j <= $highestColumm; $j++) {
             }
             $regimen_code = $arr[$i]['S'];
             $regimen_desc = $arr[$i]['T'];
             $no_of_clients_dispensed_in_period = $arr[$i]['V'] . $arr[$i]['W'];
             if ($no_of_clients_dispensed_in_period) {
                 $regimen_id = $regimen_code . " | " . $regimen_desc;
                 $query = $this->db->query("SELECT MAX(id) AS id FROM maps_item");
                 $results = $query->result_array();
                 $last_id = $results[0]['id'];
                 $last_id++;
                 $last_id = md5($last_id . $facility_code);
                 $next_query = $this->db->query("INSERT INTO maps_item (`id`, `total`, `regimen_id`, `maps_id`,`unique_id`) VALUES (NULL, '{$no_of_clients_dispensed_in_period}', '{$regimen_id}', '{$facility_id}','{$last_id}');");
             }
         }
         //Paediatric ART Second Line Regimens
         for ($i = 76; $i <= 84; $i++) {
             for ($j = 19; $j <= $highestColumm; $j++) {
             }
             $regimen_code = $arr[$i]['S'];
             $regimen_desc = $arr[$i]['T'];
             $no_of_clients_dispensed_in_period = $arr[$i]['V'] . $arr[$i]['W'];
             if ($no_of_clients_dispensed_in_period) {
                 $regimen_id = $regimen_code . " | " . $regimen_desc;
                 $query = $this->db->query("SELECT MAX(id) AS id FROM maps_item");
                 $results = $query->result_array();
                 $last_id = $results[0]['id'];
                 $last_id++;
                 $last_id = md5($last_id . $facility_code);
                 $next_query = $this->db->query("INSERT INTO maps_item (`id`, `total`, `regimen_id`, `maps_id`,`unique_id`) VALUES (NULL, '{$no_of_clients_dispensed_in_period}', '{$regimen_id}', '{$facility_id}','{$last_id}');");
             }
         }
         //Other Paediatric ART regimens
         for ($i = 86; $i <= 87; $i++) {
             for ($j = 19; $j <= $highestColumm; $j++) {
             }
             $regimen_code = $arr[$i]['S'];
             $regimen_desc = $arr[$i]['T'];
             $no_of_clients_dispensed_in_period = $arr[$i]['V'] . $arr[$i]['W'];
             if ($no_of_clients_dispensed_in_period) {
                 $regimen_id = $regimen_code . " | " . $regimen_desc;
                 $query = $this->db->query("SELECT MAX(id) AS id FROM maps_item");
                 $results = $query->result_array();
                 $last_id = $results[0]['id'];
                 $last_id++;
                 $last_id = md5($last_id . $facility_code);
                 $next_query = $this->db->query("INSERT INTO maps_item (`id`, `total`, `regimen_id`, `maps_id`,`unique_id`) VALUES (NULL, '{$no_of_clients_dispensed_in_period}', '{$regimen_id}', '{$facility_id}','{$last_id}');");
             }
         }
         //POST Exposure Prophylaxis(PEP)
         for ($i = 91; $i <= 99; $i++) {
             for ($j = 19; $j <= $highestColumm; $j++) {
             }
             $regimen_code = $arr[$i]['S'];
             $regimen_desc = $arr[$i]['T'];
             $no_of_clients_dispensed_in_period = $arr[$i]['V'] . $arr[$i]['W'];
             if ($no_of_clients_dispensed_in_period) {
                 $regimen_id = $regimen_code . " | " . $regimen_desc;
                 $query = $this->db->query("SELECT MAX(id) AS id FROM maps_item");
                 $results = $query->result_array();
                 $last_id = $results[0]['id'];
                 $last_id++;
                 $last_id = md5($last_id . $facility_code);
                 $next_query = $this->db->query("INSERT INTO maps_item (`id`, `total`, `regimen_id`, `maps_id`,`unique_id`) VALUES (NULL, '{$no_of_clients_dispensed_in_period}', '{$regimen_id}', '{$facility_id}','{$last_id}');");
             }
         }
         //ARV Data collection and Reporting Tools
         //1.Name of Data-DAR
         //a.ARVS Collection Tool
         $fifty_arv_page_requested = $arr[116]['D'];
         $three_hundred_arv_page_requested = $arr[116]['E'];
         if ($fifty_arv_page_requested) {
             $dar_arv_quantity_requested = $fifty_arv_page_requested;
         }
         if ($three_hundred_arv_page_requested) {
             $dar_arv_quantity_requested = $three_hundred_arv_page_requested;
         }
         //a.OIs Collection Tool
         $fifty_oi_page_requested = $arr[116]['G'];
         $three_hundred_oi_page_requested = $arr[116]['H'];
         if ($fifty_oi_page_requested) {
             $dar_oi_quantity_requested = $fifty_oi_page_requested;
         }
         if ($three_hundred_oi_page_requested) {
             $dar_oi_quantity_requested = $three_hundred_oi_page_requested;
         }
         //2.Name of Data-FCDRR
         $fcdrr_quantity_requested = $arr[116]['L'];
         //Prepared By details
         $report_prepared_by = $arr[119]['B'] . $arr[119]['C'] . $arr[119]['D'];
         $prepared_by_contact_telephone = $arr[121]['B'] . $arr[121]['C'] . $arr[121]['D'];
         $signature_prepared_by = $arr[119]['G'] . $arr[119]['H'] . $arr[119]['L'];
         $date_prepared_by_signature = $arr[121]['G'] . $arr[121]['H'];
         //Approved By details
         $report_approved_by = $arr[123]['B'] . $arr[123]['C'] . $arr[123]['D'];
         $approved_by_contact_telephone = $arr[126]['B'] . $arr[126]['C'] . $arr[126]['D'];
         $signature_approved_by = $arr[123]['G'] . $arr[123]['H'] . $arr[123]['L'];
         $date_approved_by_signature = $arr[126]['G'] . $arr[126]['H'];
         //$this -> session -> set_userdata('upload_counter','2');
         redirect("order_management/edit_order/{$order_number}");
     }
 }
 public function get_facility_stats($facility_code)
 {
     $facility_data = Facilities::get_facilities_users_data($facility_code);
     foreach ($facility_data as $key => $value) {
         $user_id = $value['id'];
         $name = $value['fname'] . ' ' . $value['lname'];
         $created_at = $value['created_at'];
         $email = $value['email'];
         $created = date('d F Y', strtotime($created_at));
         $output[] = array($user_id, $name, $email, $created);
     }
     $final_output = array('number' => count($facility_data), 'list' => $output);
     echo json_encode($final_output);
 }
Пример #25
0
 public function save_order()
 {
     $facilities_array = $_POST['facilities_id'];
     $order_array = $_POST['order'];
     $facilities = new Facilities();
     foreach ($facilities_array as $key => $value) {
         $facilities_id = $value;
         $facilities_order = $order_array[$key];
         $facilities->update('Facilities', array('sequence' => $facilities_order), 'id=' . $facilities_id);
     }
     Flash::set('success', __('This facilities sequence has been saved.'));
     redirect(get_url('facilities'));
 }
Пример #26
0
    $ACL = new ACL();
    $perms = array();
    /*
     * Look for user permissions and pass it to a PHP variable.
     * This variable will be used in JavaScript code
     * look at it as a PHP to JavaScript variable conversion.
     */
    foreach ($ACL->getAllUserPermsAccess() as $perm) {
        $perms[$perm['perm']] = $perm['value'];
    }
    unset($ACL);
    $User = new User();
    $userData = $User->getCurrentUserBasicData();
    $userData['token'] = $_SESSION['user']['token'];
    $userData['facility'] = $_SESSION['user']['facility'];
    $userData['localization'] = $_SESSION['user']['localization'];
    unset($User);
    $Facilities = new Facilities();
    $structure = $Facilities->geFacilitiesStructure();
    unset($Facilities);
    /*
     * Pass all the PHP to JavaScript
     */
    print 'window.acl = ' . json_encode($perms) . ';';
    print 'window.user = '******';';
    print 'window.structure = ' . json_encode($structure) . ';';
    print 'window.settings.site_url = "' . $global['url'] . '";';
    if (isset($_SESSION['styles'])) {
        print 'window.styles = ' . json_encode($_SESSION['styles']) . ';';
    }
}
Пример #27
0
 public function getItems()
 {
     //Default row values
     $row = array('beginning_balance' => 0, 'received_from' => 0, 'dispensed_to_patients' => 0, 'losses' => 0, 'adjustments' => 0, 'adjustments_neg' => 0, 'physical_stock' => 0, 'expiry_qty' => 0, 'expiry_month' => "--", 'stock_out' => 0, 'resupply' => 0);
     //Set parameters
     $param = array("drug_id" => $this->input->post("drug_id"), "period_begin" => $this->input->post("period_begin"), "facility_id" => $this->input->post("facility_id"), "code" => $this->input->post("code"), "stores" => $this->input->post("stores"));
     $code = $param['code'];
     $facility_id = $param['facility_id'];
     $period_begin = date('Y-m-01', strtotime($param['period_begin']));
     $period_end = date('Y-m-t', strtotime($param['period_begin']));
     $stores = $param['stores'];
     $stores = implode(",", $stores);
     $stores = str_replace("multiselect-all,", "", $stores);
     $drug_id = $param['drug_id'];
     //get packsize
     $drug = Sync_Drug::getPackSize($drug_id);
     $pack_size = $drug['packsize'];
     //check whether a satellite,standalone or central site
     $facility_code = $this->session->userdata("facility");
     $facility_type = Facilities::getType($facility_code);
     $row['beginning_balance'] = $this->getBeginningBalance($param);
     $row['pack_size'] = $pack_size;
     $row = $this->getOtherTransactions($param, $row);
     if ($row['stock_out'] == null) {
         $row['stock_out'] = 0;
     }
     if ($facility_type > 1) {
         //central site
         if ($code == "D-CDRR") {
             //reported_consumed & reported_stock_on_hand
             $reported_consumed = 0;
             $reported_count = 0;
             $satellites = Sync_Facility::getSatellites($facility_id);
             foreach ($satellites as $satellite) {
                 $satellite_site = $satellite['id'];
                 $sql = "SELECT ci.drug_id,SUM(ci.dispensed_units) as consumed,SUM(ci.count) as phy_count\n\t\t\t\t\t\t    FROM cdrr c\n\t\t\t\t\t\t    LEFT JOIN cdrr_item ci ON ci.cdrr_id=c.id\n\t\t\t\t\t\t    WHERE c.period_begin='{$period_begin}' \n\t\t\t\t\t\t    AND c.period_end='{$period_end}'\n\t\t\t\t\t\t    AND ci.drug_id='{$drug_id}'\n\t\t\t\t\t\t    AND c.status LIKE '%approved%'\n\t\t\t\t\t\t    AND c.facility_id='{$satellite_site}'\n\t\t\t\t\t\t    GROUP BY ci.drug_id";
                 $query = $this->db->query($sql);
                 $results = $query->result_array();
                 if (!$results) {
                     //if satellite did not report use previous period
                     $start_date = date('Y-m-01', strtotime($period_begin . "-1 month"));
                     $end_date = date('Y-m-t', strtotime($period_end . "-1 month"));
                     $sql = "SELECT ci.drug_id,SUM(ci.dispensed_units) as consumed,SUM(ci.count) as phy_count\n\t\t\t\t\t            FROM cdrr c\n\t\t\t\t\t            LEFT JOIN cdrr_item ci ON ci.cdrr_id=c.id\n\t\t\t\t\t            WHERE c.period_begin='{$start_date}' \n\t\t\t\t\t\t\t    AND c.period_end='{$end_date}'\n\t\t\t\t\t\t\t    AND ci.drug_id='{$drug_id}'\n\t\t\t\t\t\t\t    AND c.facility_id='{$satellite_site}'\n\t\t\t\t\t\t\t    GROUP BY ci.drug_id";
                     $query = $this->db->query($sql);
                     $results = $query->result_array();
                 }
                 if ($results) {
                     $reported_consumed += @$results[0]['consumed'];
                     $reported_count += @$results[0]['phy_count'];
                 }
             }
             //append to json array
             $row['reported_consumed'] = $reported_consumed;
             $row['reported_physical_stock'] = $reported_count;
             //get issued to satellites as dispensed_to patients
             $sql = "SELECT SUM(dsm.quantity_out) AS total \n\t\t\t          FROM drug_stock_movement dsm\n\t\t\t          LEFT JOIN drugcode d ON d.id=dsm.drug\n\t\t\t          LEFT JOIN sync_drug sd ON d.map=sd.id\n\t\t\t          LEFT JOIN transaction_type t ON t.id=dsm.transaction_type\n\t\t\t          WHERE dsm.transaction_date \n\t\t\t          BETWEEN  '{$period_begin}' \n\t\t\t          AND  '{$period_end}' \n\t\t\t          AND sd.id =  '{$drug_id}'\n\t\t\t          AND t.name LIKE '%issue%'\n\t\t\t          AND dsm.ccc_store_sp IN({$stores})";
             $query = $this->db->query($sql);
             $results = $query->result_array();
             $row['dispensed_to_patients'] = 0;
             if ($results) {
                 if ($results[0]['total'] != null) {
                     $row['dispensed_to_patients'] = $results[0]['total'];
                 }
             }
         }
     }
     // Changes made on DCDRR
     if ($code == "D-CDRR") {
         foreach ($row as $i => $v) {
             $exempted_columns = array('expiry_month', 'beginning_balance', 'reported_consumed', 'reported_physical_stock');
             if (!in_array($i, $exempted_columns)) {
                 $row[$i] = round(@$v / @$pack_size);
             }
         }
         //Get Physical Count
         $row['physical_stock'] = $row['beginning_balance'] + $row['received_from'] - $row['dispensed_to_patients'] - $row['losses'] + $row['adjustments'];
         //Get Resupply
         $row['resupply'] = $row['reported_consumed'] * 3 - $row['physical_stock'];
     } else {
         $row['physical_stock'] = $row['beginning_balance'] + $row['received_from'] - $row['dispensed_to_patients'] - $row['losses'] + $row['adjustments'];
         $row['resupply'] = $row['dispensed_to_patients'] * 3 - $row['physical_stock'];
     }
     if ($code == "F-CDRR_packs") {
         foreach ($row as $i => $v) {
             if ($i != "expiry_month" && $i != "dispensed_to_patients" && $i != "beginning_balance") {
                 $row[$i] = round(@$v / @$pack_size);
             }
         }
         $row['dispensed_packs'] = 0;
         if ($row['dispensed_to_patients'] > 0) {
             $row['dispensed_packs'] = round(@$row['dispensed_to_patients'] / @$pack_size);
         }
     }
     echo json_encode($row);
 }
Пример #28
0
 public function filter_monitoring($district_id = null)
 {
     //pick values form the session
     $facility_code = !$this->session->userdata('facility_id') ? null : $this->session->userdata('facility_id');
     $district_id = isset($district_id) && $district_id > 0 ? $district_id : $this->session->userdata('district_id');
     $county_id = !$this->session->userdata('county_id') ? null : $this->session->userdata('county_id');
     $category_data = $series_data = $graph_data = $series_data_ = array();
     //the old query that causes too many locks on the mysql tables
     //$facility_data=Facilities::get_facilities_monitoring_data( $facility_code,$district_id,$county_id,$identifier);
     //get the monitoring data from the log tables
     $facility_data = Facilities::facility_monitoring($county_id, $district_id, $facility_code);
     //echo "<pre>";print_r($facility_data);exit;
     foreach ($facility_data as $facility) {
         $date = strtotime($facility['last_seen']) ? date('j M, Y', strtotime($facility['last_seen'])) : "N/A";
         array_push($series_data, array($facility['fname'], $facility['lname'], $date, $facility['days_last_seen'], date('j M, Y', strtotime($facility['last_issued'])), $facility['days_last_issued'], $facility['district'], $facility['facility_name'], $facility['facility_code']));
     }
     $category_data = array(array("First Name", "Last Name", "date last seen", "# of days", "date last issued", "# of days", "Sub County", "facility name", "mfl"));
     $graph_data = array_merge($graph_data, array("table_id" => 'dem_graph_'));
     $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_";
     return $this->load->view("shared_files/report_templates/data_table_template_v", $data);
 }
Пример #29
0
 public function tester()
 {
     $id = $this->session->userdata('county_id');
     $sth = Facilities::model_tester();
     echo "<pre>";
     print_r($sth);
     echo "</pre>";
     exit;
 }
Пример #30
0
 public function edit($record_no)
 {
     $sql = "SELECT p.*,\n\t\t               rst.Name as service_name,\n\t\t               dp.child,\n\t\t               s.secondary_spouse \n\t\t               FROM patient p \n\t\t               LEFT JOIN regimen_service_type rst ON rst.id=p.service \n\t\t               LEFT JOIN dependants dp ON p.patient_number_ccc=dp.parent  \n\t\t        \t   LEFT JOIN spouses s ON p.patient_number_ccc=s.primary_spouse\n\t\t               WHERE p.id='{$record_no}'\n\t\t               GROUP BY p.id";
     $query = $this->db->query($sql);
     $results = $query->result_array();
     if ($results) {
         $results[0]['other_illnesses'] = $this->extract_illness($results[0]['other_illnesses']);
         $data['results'] = $results;
     }
     $data['record_no'] = $record_no;
     $data['districts'] = District::getPOB();
     $data['genders'] = Gender::getAll();
     $data['statuses'] = Patient_Status::getStatus();
     $data['sources'] = Patient_Source::getSources();
     $data['drug_prophylaxis'] = Drug_Prophylaxis::getAll();
     $data['service_types'] = Regimen_Service_Type::getHydratedAll();
     $data['facilities'] = Facilities::getAll();
     $data['family_planning'] = Family_Planning::getAll();
     $data['other_illnesses'] = Other_Illnesses::getAll();
     $data['pep_reasons'] = Pep_Reason::getActive();
     $data['regimens'] = Regimen::getRegimens();
     $data['drugs'] = Drugcode::getAllEnabled();
     $data['who_stages'] = Who_Stage::getAllHydrated();
     $data['content_view'] = 'edit_patients_v';
     //Hide side menus
     $data['hide_side_menu'] = '1';
     $this->base_params($data);
 }