コード例 #1
0
 public function getList($params)
 {
     $search = isset($params['search']) ? $params['search'] : null;
     $params['dateFrom'] = str_replace('T00:00:00', '', $params['dateFrom']);
     $params['dateTo'] = str_replace('T00:00:00', '', $params['dateTo']);
     $result = Translation::getAll('en', $params['start'], $params['limit'], $search, $params['dateFrom'], $params['dateTo']);
     //$result = Translation::getAll('en', $params['start'], $params['limit'], $search);
     /* foreach($result->data as $i=>$row){
        $result->data[$i]['TRN_VALUE'] = substr($row['TRN_VALUE'], 0, 15) . '...';
        } */
     echo G::json_encode($result);
 }
コード例 #2
0
 public function reportHeaders($fieldname = false, $rowRay = false)
 {
     require_once 'models/table/Translation.php';
     $translation = Translation::getAll();
     $headers = array('id' => 'ID', 'cnt' => t('Count'), 'active' => @$translation['Is Active'], 'first_name' => @$translation['First Name'], 'middle_name' => @$translation['Middle Name'], 'last_name' => @$translation['Last Name'], 'training_title' => @$translation['Training Name'], 'province_name' => @$translation['Region A (Province)'], 'district_name' => @$translation['Region B (Health District)'], 'pepfar_category_phrase' => @$translation['PEPFAR Category'], 'training_organizer_phrase' => @$translation['Training Organizer'], 'training_level_phrase' => @$translation['Training Level'], 'trainer_language_phrase' => t('Language'), 'training_location_name' => t('Location'), 'training_start_date' => t('Date'), 'training_topic_phrase' => t('Training Topic'), 'funding_phrase' => t('Funding'), 'is_tot' => t('TOT'), 'facility_name' => t('Facility Name'), 'facility_type_phrase' => t('Facility Type'), 'facility_sponsor_phrase' => t('Facility Sponsor'), 'course_recommended' => t('Recommended classes'), 'recommended' => t('Recommended'), 'qualification_phrase' => t('Qualification') . ' ' . t('(primary)'), 'qualification_secondary_phrase' => t('Qualification') . ' ' . t('(secondary)'), 'gender' => t('Gender'), 'name' => t('Name'), 'email' => t('Email'), 'phone' => t('Phone'), 'cat' => t('Category'), 'language_phrase' => t('Language'), 'trainer_type_phrase' => t('Type'), 'trainer_skill_phrase' => t('Skill'), 'trainer_language_phrase' => t('Language'), 'trainer_topic_phrase' => t('Topics Taught'), 'phone_work' => t('Work Phone'), 'phone_home' => t('Home Phone'), 'phone_mobile' => t('Mobile Phone'), 'type_option_id' => 'Type');
     // action => array(field => label)
     $headersSpecific = array('peopleByFacility' => array('qualification_phrase' => t('Qualification')), 'participantsByCategory' => array('cnt' => t('Participants'), 'person_cnt' => t('Unique Participants')));
     if ($rowRay) {
         $keys = array_keys(reset($rowRay));
         foreach ($keys as $k) {
             $csvheaders[] = $this->reportHeaders($k);
         }
         return array_merge(array('csvheaders' => $csvheaders), $rowRay);
     } elseif ($fieldname) {
         // check report specific headers first
         $action = $this->getRequest()->getActionName();
         if (isset($headersSpecific[$action]) && isset($headersSpecific[$action][$fieldname])) {
             return $headersSpecific[$action][$fieldname];
         }
         return isset($headers[$fieldname]) ? $headers[$fieldname] : $fieldname;
     } else {
         return $headers;
     }
 }
コード例 #3
0
 public function preDispatch()
 {
     require_once 'models/table/User.php';
     //add identity to view variables
     $auth = Zend_Auth::getInstance();
     $identity = null;
     if ($auth->hasIdentity()) {
         //get ACLs and add to identity
         $acls = User::getACLs($auth->getIdentity()->id);
         $identity = $auth->getIdentity();
         $identity->acls = $acls;
         $auth->getStorage()->write($identity);
         $this->view->assign('identity', $identity);
     }
     //set up localization
     //get country default locale, then check user settings
     if (isset($_COOKIE['locale']) and array_key_exists($_COOKIE['locale'], ITechTranslate::getLanguages())) {
         $locale = $_COOKIE['locale'];
     } else {
         $locale = $this->_countrySettings['locale'];
     }
     if (!$locale) {
         $locale = 'en_EN.UTF-8';
     }
     if ($auth->hasIdentity() and $auth->getIdentity()->locale) {
         $locale = $auth->getIdentity()->locale;
     }
     //set up localization
     ITechTranslate::init($locale);
     // get Country-specific phrases for fields
     self::$_translations = Translation::getAll();
     $this->view->assign('translation', self::translations());
     //look for any status messages in the session and put the validation container in the view scope
     $statusObj = ValidationContainer::instance();
     if (isset($_SESSION['status'])) {
         $statusObj->setStatusMessage($_SESSION['status']);
         unset($_SESSION['status']);
     }
     $this->view->assign('status', $statusObj);
 }
コード例 #4
0
 public function employeeSettingsAction()
 {
     require_once 'models/table/System.php';
     $sysTable = new System();
     // For "Labels"
     // same logic as other Settings pages - except the employee_header setting below
     require_once 'models/table/Translation.php';
     $labelNames = array('label_partner' => 'Partner', 'label_sub_partner' => 'Sub Partner', 'label_type' => 'Type of Partner', 'label_funder' => 'Funder', 'label_full_time' => 'Full Time', 'label_base' => 'Employee Based at', 'label_funded_hours_per_week' => 'Funded hours per week', 'label_cadre' => 'Staff Cadre', 'label_staff_category' => 'Staff Category', 'label_annual_cost' => 'Annual Cost', 'label_primary_role' => 'Primary Role', 'label_importance' => 'Importance', 'label_intended_transition' => 'Intended Transition', 'label_incoming_partner' => 'Incoming partner', 'label_relationship' => 'Relationship', 'label_referral_mechanism' => 'Referral Mechanism', 'label_chw_supervisor' => 'CHW Supervisor', 'label_trainings_provided' => 'Trainings provided', 'label_courses_completed' => 'Courses Completed', 'label_other_id' => 'Other ID', 'label_disability' => 'Disability', 'label_disability_comments' => 'Disability Comments', 'label_nationality' => 'Employee Nationality', 'label_race' => 'Race', 'label_registration_number' => 'Registration Number', 'label_salary' => 'Salary', 'label_benefits' => 'Benefits', 'label_additional_expenses' => 'Additional Expenses', 'label_stipend' => 'Stipend');
     $checkboxFields = array('check_partner' => 'display_employee_partner', 'check_sub_partner' => 'display_employee_sub_partner', 'check_type' => 'display_partner_type', 'check_funder' => 'display_employee_funder', 'check_full_time' => 'display_employee_full_time', 'check_base' => 'display_employee_base', 'check_site_type' => 'display_employee_site_type', 'check_funded_hours_per_week' => 'display_employee_funded_hours_per_week', 'check_staff_category' => 'display_employee_staff_category', 'check_annual_cost' => 'display_employee_annual_cost', 'check_primary_role' => 'display_employee_primary_role', 'check_importance' => 'display_employee_importance', 'check_contract_end_date' => 'display_employee_contract_end_date', 'check_agreement_end_date' => 'display_employee_agreement_end_date', 'check_intended_transition' => 'display_employee_intended_transition', 'check_transition_confirmed' => 'display_employee_transition_confirmed', 'check_transition_complete' => 'display_employee_complete_transition', 'check_transition_complete_date' => 'display_employee_actual_transition_date', 'check_incoming_partner' => 'display_employee_incoming_partner', 'check_relationship' => 'display_employee_relationship', 'check_referral_mechanism' => 'display_employee_referral_mechanism', 'check_chw_supervisor' => 'display_employee_chw_supervisor', 'check_trainings_provided' => 'display_employee_trainings_provided', 'check_courses_completed' => 'display_employee_courses_completed', 'check_site_name' => 'display_employee_site_name', 'check_employee_header' => 'display_employee_employee_header', 'check_other_id' => 'display_employee_other_id', 'check_disability' => 'display_employee_disability', 'check_nationality' => 'display_employee_nationality', 'check_race' => 'display_employee_race', 'check_registration_number' => 'display_employee_registration_number', 'check_salary' => 'display_employee_salary', 'check_benefits' => 'display_employee_benefits', 'check_additional_expenses' => 'display_employee_additional_expenses', 'check_stipend' => 'display_employee_stipend');
     if ($this->getRequest()->isPost()) {
         // Update db
         $updateData = array();
         // update translation labels
         $tranTable = new Translation();
         foreach ($labelNames as $input_key => $db_key) {
             if ($this->_getParam($input_key)) {
                 try {
                     $tranTable->update(array('phrase' => $this->_getParam($input_key)), "key_phrase = '{$db_key}'");
                     $this->viewAssignEscaped($input_key, $this->_getParam($input_key));
                 } catch (Zend_Exception $e) {
                     error_log($e);
                 }
             }
         }
         // update _system (checkboxes)
         foreach ($checkboxFields as $input_key => $db_field) {
             $value = $this->_getParam($input_key) == NULL ? 0 : 1;
             $updateData[$db_field] = $value;
             $this->view->assign($input_key, $value);
         }
         $updateData['employee_header'] = $this->_getParam('employee_header');
         $this->view->assign('employee_header', $this->_getParam('employee_header') ? $this->_getParam('employee_header') : '');
         $sysTable->update($updateData, '');
     } else {
         // view
         // checkboxes
         $sysRows = $sysTable->fetchRow($sysTable->select()->limit(1));
         $this->view->assign('employee_header', isset($sysRows->employee_header) ? $sysRows->employee_header : '');
         foreach ($checkboxFields as $input_key => $field_key) {
             if (isset($sysRows->{$field_key})) {
                 $this->view->assign($input_key, $sysRows->{$field_key});
             }
         }
         // labels
         $t = Translation::getAll();
         foreach ($labelNames as $input_key => $db_key) {
             $this->viewAssignEscaped($input_key, $t[$db_key]);
         }
     }
     // redirect to next page
     if ($this->_getParam('redirect')) {
         header("Location: " . $this->_getParam('redirect'));
         exit;
     } else {
         if ($this->_getParam('saveonly')) {
             $status = ValidationContainer::instance();
             $status->setStatusMessage(t('Your settings have been updated.'));
         }
     }
 }
コード例 #5
0
 public function psFacilityReportAction()
 {
     $db = Zend_Db_Table_Abstract::getDefaultAdapter();
     //locations
     $this->viewAssignEscaped('locations', Location::getAll());
     $helper = new Helper();
     $this->view->assign('mode', 'id');
     $this->view->assign('institutions', $helper->getInstitutions());
     $this->view->assign('cadres', $helper->getCadres());
     $this->view->assign('institutiontypes', $helper->AdminInstitutionTypes());
     $this->view->assign('cohorts', $helper->getCohorts());
     $this->view->assign('nationalities', $helper->getNationalities());
     $this->view->assign('funding', $helper->getFunding());
     $this->view->assign('tutors', $helper->getTutors());
     $this->view->assign('facilities', $helper->getFacilities());
     $this->view->assign('facilitytypes', $helper->getFacilityTypes());
     $this->view->assign('sponsors', $helper->getOldSponsors());
     $this->view->assign('coursetypes', $helper->AdminCourseTypes());
     $this->view->assign('degrees', $helper->getDegrees());
     $this->view->assign('tutortypes', $helper->AdminTutortypes());
     if ($this->getSanParam('process')) {
         // INITIALIZING ARRAYS
         $headers = array();
         $select = array();
         $from = array();
         $join = array();
         //
         //	$join[] = array(
         // 		"type"   => "inner",
         //		"table"  => "tablename t",
         //		"field1" => "t.field1",
         //		"field2" => "t2.field2",
         //	);
         //
         $where = array();
         $sort = array();
         $locations = Location::getAll();
         $translation = Translation::getAll();
         $showfacility = isset($_GET['showfacility']);
         $showProvince = isset($_GET['showProvince']);
         $showDistrict = isset($_GET['showDistrict']);
         $showRegionC = isset($_GET['showRegionC']);
         $showfacilitytype = isset($_GET['showfacilitytype']);
         $showinstitutionsponsors = isset($_GET['showinstitutionsponsors']);
         $showcadre = isset($_GET['showcadre']);
         $showgraduates = isset($_GET['showgraduates']);
         $showgraduatesyear = isset($_GET['showgraduatesyear']);
         $showpatients = isset($_GET['showpatients']);
         $startday = isset($_GET['startday']);
         $facility = $this->getSanParam('facility');
         $province_id = $this->getSanParam('province_id');
         $district_id = $this->getSanParam('district_id');
         $region_c_id = $this->getSanParam('region_c_id');
         $facilitytype = $this->getSanParam('facilitytype');
         $institutionsponsors = $this->getSanParam('institutionsponsors');
         $cadre = $this->getSanParam('cadre');
         $from[] = "facility f";
         //if ($showfacility){
         $headers[] = "Facility";
         $select[] = "f.facility_name";
         $sort[] = "f.facility_name";
         //}
         if ($facility != "") {
             $where[] = "f.id = " . $facility;
         }
         if ($showfacilitytype || $facilitytype) {
             // Need join on facility type to show OR filter
             if ($showfacilitytype) {
                 // Only add header and select if showing field
                 $headers[] = "Facility type";
                 $select[] = "fto.facility_type_phrase";
             }
             $join[] = array("type" => "inner", "table" => "facility_type_option fto", "field1" => "fto.id", "field2" => "f.type_option_id");
             if ($facilitytype) {
                 $where[] = "fto.id = " . $facilitytype;
             }
             $sort[] = "fto.facility_type_phrase";
         }
         if ($showinstitutionsponsors || $institutionsponsors) {
             // Need join on facility type to show OR filter
             if ($showinstitutionsponsors) {
                 // Only add header and select if showing field
                 $headers[] = "Sponsor";
                 $select[] = "fso.facility_sponsor_phrase";
             }
             // OPTIONAL LINK - LEFT JOINING
             $join[] = array("type" => "left", "table" => "facility_sponsor_option fso", "field1" => "fso.id", "field2" => "f.sponsor_option_id");
             if ($institutionsponsors) {
                 $where[] = "fso.id = " . $institutionsponsors;
             }
             $sort[] = "fso.facility_sponsor_phrase";
         }
         // INCLUDING LOCATION IDENTIFYER, IF NECESSARY
         if ($region_c_id != "" || $district_id != "" || $province_id != "" || $showProvince != "" || $showDistrict != "" || $showRegionC != "") {
             $select[] = "f.location_id";
         }
         if ($showcadre || $cadre) {
             $join[] = array("type" => "left", "table" => "person_qualification_option pqo", "field1" => "pqo.id", "field2" => "f.sponsor_option_id");
         }
         $query = "SELECT ";
         $query .= implode(", ", $select);
         $query .= " FROM ";
         $query .= implode(", ", $from) . " ";
         if (count($join) > 0) {
             foreach ($join as $j) {
                 $query .= strtoupper($j['type']) . " JOIN " . $j['table'] . " ON " . $j['field1'] . " = " . $j['field2'] . " ";
             }
         }
         if (count($where) > 0) {
             $query .= " WHERE " . implode(" AND ", $where);
         }
         if (count($sort) > 0) {
             $query .= " ORDER BY " . implode(", ", $sort);
         }
         //echo $query . "<br>";
         $rows = $db->fetchAll($query);
         $regions = array();
         #			var_dump ($rows);
         // Filtering by locations
         if ($region_c_id != "" || $district_id != "" || $province_id != "") {
             $__rows = array();
             if ($region_c_id != "") {
                 // 3 levels selected. Going with this one first
                 $regions = explode("_", $region_c_id[0]);
             } elseif ($district_id != "") {
                 // 2 levels selected
                 $regions = explode("_", $district_id[0]);
             } elseif ($province_id != "") {
                 // 1 level selected
                 $regions = explode("_", $province_id[0]);
             }
             // Include headers once
             if ($showProvince) {
                 $headers[] = @$translation['Region A (Province)'];
             }
             if ($showDistrict) {
                 $headers[] = @$translation['Region B (Health District)'];
             }
             if ($showRegionC) {
                 $headers[] = @$translation['Region C (Local Region)'];
             }
             foreach ($rows as $row) {
                 list($cname, $prov, $dist, $regc) = Location::getCityInfo($row['location_id'], $this->setting('num_location_tiers'));
                 if ($showProvince) {
                     $loc = $locations[$prov];
                     $row[@$translation['Region A (Province)']] = $loc['name'];
                 }
                 if ($showDistrict) {
                     $loc = $locations[$dist];
                     $row[@$translation['Region B (Health District)']] = $loc['name'];
                 }
                 if ($showRegionC) {
                     $loc = $locations[$regc];
                     $row[@$translation['Region C (Local Region)']] = $loc['name'];
                 }
                 unset($row['location_id']);
                 $userow = true;
                 if (count($regions) > 0) {
                     switch (count($regions)) {
                         case 1:
                             // Selected province
                             if ($prov != $regions[0]) {
                                 $userow = false;
                             }
                             break;
                         case 2:
                             // Selected province, district
                             if ($prov != $regions[0] || $dist != $regions[1]) {
                                 $userow = false;
                             }
                             break;
                         case 3:
                             // Selected province, district, regionc
                             if ($prov != $regions[0] || $dist != $regions[1] || $regc != $regions[2]) {
                                 $userow = false;
                             }
                             break;
                     }
                 }
                 if ($userow) {
                     $__rows[] = $row;
                 }
             }
             $rows = $__rows;
         } elseif ($showProvince != "" || $showDistrict != "" || $showRegionC != "") {
             // NOT FILTERING, BUT STILL INCLUDING LOCATION COLUMNS
             // Include headers once
             if ($showProvince) {
                 $headers[] = @$translation['Region A (Province)'];
             }
             if ($showDistrict) {
                 $headers[] = @$translation['Region B (Health District)'];
             }
             if ($showRegionC) {
                 $headers[] = @$translation['Region C (Local Region)'];
             }
             $__rows = array();
             foreach ($rows as $row) {
                 list($cname, $prov, $dist, $regc) = Location::getCityInfo($row['location_id'], $this->setting('num_location_tiers'));
                 if ($showProvince) {
                     $loc = $locations[$prov];
                     $row[@$translation['Region A (Province)']] = $loc['name'];
                 }
                 if ($showDistrict) {
                     $loc = $locations[$dist];
                     $row[@$translation['Region B (Health District)']] = $loc['name'];
                 }
                 if ($showRegionC) {
                     $loc = $locations[$regc];
                     $row[@$translation['Region C (Local Region)']] = $loc['name'];
                 }
                 unset($row['location_id']);
                 $__rows[] = $row;
             }
             $rows = $__rows;
         }
         #			var_dump ($head);
         #			var_dump ($rows);
         /*
         		//locations
         		$this->viewAssignEscaped ( 'locations', $locations );
         		list ( $cname, $prov, $dist, $regc ) = Location::getCityInfo ( $facilityRow->location_id, $this->setting ( 'num_location_tiers' ) );
         		$facilityArray ['facility_city'] = $cname;
         		$facilityArray ['region_c_id'] = $regc;
         		$facilityArray ['district_id'] = $dist;
         		$facilityArray ['province_id'] = $prov;
         */
         $this->viewAssignEscaped("headers", $headers);
         $this->viewAssignEscaped("output", $rows);
     }
 }