/**
  * Test the getListForView function
  */
 public function testGetListForView()
 {
     // Get all
     $list = JobSpec::getListForView();
     $this->assertTrue(is_array($list));
     $this->assertEquals(4, count($list));
     $this->_compareSpecsWithOrder($this->jobSpecs, $list);
     // Get all in reverse order by name
     $list = JobSpec::getListForView(0, '', -1, 1, 'DESC');
     $this->assertTrue(is_array($list));
     $this->assertEquals(4, count($list));
     $expected = array($this->jobSpecs[4], $this->jobSpecs[3], $this->jobSpecs[2], $this->jobSpecs[1]);
     $this->_compareSpecsWithOrder($expected, $list);
     // Search by name with exact match
     $list = JobSpec::getListForView(0, 'Job Spec 3', 1, 1, 'DESC');
     $this->assertTrue(is_array($list));
     $this->assertEquals(1, count($list));
     $expected = array($this->jobSpecs[3]);
     $this->_compareSpecsWithOrder($expected, $list);
     // Search by name with multiple matches
     $list = JobSpec::getListForView(0, 'Job Spec', 1, 1, 'DESC');
     $this->assertTrue(is_array($list));
     $this->assertEquals(4, count($list));
     $expected = array($this->jobSpecs[4], $this->jobSpecs[3], $this->jobSpecs[2], $this->jobSpecs[1]);
     $this->_compareSpecsWithOrder($expected, $list);
     // Search by description with one match
     $list = JobSpec::getListForView(0, 'qb for job', 2, 1, 'ASC');
     $this->assertTrue(is_array($list));
     $this->assertEquals(1, count($list));
     $expected = array($this->jobSpecs[3]);
     $this->_compareSpecsWithOrder($expected, $list);
     // Search by id with one match
     $list = JobSpec::getListForView(0, '3', 0, 0, 'ASC');
     $this->assertTrue(is_array($list));
     $this->assertEquals(1, count($list));
     $expected = array($this->jobSpecs[3]);
     $this->_compareSpecsWithOrder($expected, $list);
     // when no job specs available
     $this->assertTrue(mysql_query('DELETE from hs_hr_job_spec'), mysql_error());
     $list = JobSpec::getAll();
     $this->assertTrue(is_array($list));
     $this->assertEquals(0, count($list));
     // Insert data for tests
     for ($i = 1; $i < 251; $i++) {
         $inc = 100 + $i;
         if ($i % 2 == 0) {
             $desc = "Even ";
             $even = true;
         } else {
             $desc = "Odd ";
             $even = false;
         }
         $spec = $this->_getJobSpec($i, "Spec-{$inc}", "{$desc}-{$inc}", "Duties");
         $specs[] = $spec;
         if ($even) {
             $evenSpecs[] = $spec;
         } else {
             $oddSpecs[] = $spec;
         }
     }
     $this->_createJobSpecs($specs);
     $sysConf = new sysConf();
     $pageSize = $sysConf->itemsPerPage;
     // check paging - without search
     // page 1
     $list = JobSpec::getListForView(1, '', -1, 1, 'ASC');
     $this->assertTrue(is_array($list));
     $this->assertEquals($pageSize, count($list));
     $pages = array_chunk($specs, $pageSize);
     $this->_compareSpecsWithOrder($pages[0], $list);
     // page 3
     $list = JobSpec::getListForView(3, '', -1, 1, 'ASC');
     $this->assertTrue(is_array($list));
     $this->assertEquals($pageSize, count($list));
     $this->_compareSpecsWithOrder($pages[2], $list);
     // paging with search
     // Separate even rows to pages
     $pages = array_chunk($evenSpecs, $pageSize);
     // Search only for even rows and check page 1
     $list = JobSpec::getListForView(1, 'Even', 2, 1, 'ASC');
     $this->assertTrue(is_array($list));
     $this->assertEquals(count($pages[0]), count($list));
     $this->_compareSpecsWithOrder($pages[0], $list);
     $list = JobSpec::getListForView(3, 'Even', 2, 1, 'ASC');
     $this->assertTrue(is_array($list));
     $this->assertEquals(count($pages[2]), count($list));
     $this->_compareSpecsWithOrder($pages[2], $list);
 }
 function selectIndexId($pageNO, $schStr, $mode, $sortField = 0, $sortOrder = 'ASC', $esp = false)
 {
     switch ($this->indexCode) {
         case 'EST':
             $this->empstat = new EmploymentStatus();
             $message = $this->empstat->getListofEmpStat($pageNO, $schStr, $mode, $sortField, $sortOrder);
             return $message;
         case 'JOB':
             $this->jobtit = new JobTitle();
             $message = $this->jobtit->getListofJobTitles($pageNO, $schStr, $mode, $sortField, $sortOrder);
             return $message;
         case 'SPC':
             return JobSpec::getListForView($pageNO, $schStr, $mode, $sortField, $sortOrder);
         case 'LOC':
             $this->location = new models_eimadmin_Location();
             $message = $this->location->getListofLocations($pageNO, $schStr, $mode, $sortField, $sortOrder);
             return $message;
         case 'SKI':
             $this->skills = new Skills();
             $message = $this->skills->getListofSkills($pageNO, $schStr, $mode, $sortField, $sortOrder);
             return $message;
         case 'ETH':
             $this->ethnicrace = new EthnicRace();
             $message = $this->ethnicrace->getListofEthnicRace($pageNO, $schStr, $mode, $sortField, $sortOrder);
             return $message;
         case 'MEM':
             $this->membershiptype = new MembershipType();
             $message = $this->membershiptype->getListofMembershipType($pageNO, $schStr, $mode, $sortField, $sortOrder);
             return $message;
         case 'NAT':
             $this->nationalityinfo = new NationalityInfo();
             $message = $this->nationalityinfo->getListofNationalityInfo($pageNO, $schStr, $mode, $sortField, $sortOrder);
             return $message;
         case 'LAN':
             $this->languageinfo = new LanguageInfo();
             $message = $this->languageinfo->getListofLanguageInfo($pageNO, $schStr, $mode, $sortField, $sortOrder);
             return $message;
         case 'MME':
             $this->membershipinformation = new MembershipInfo();
             $message = $this->membershipinformation->getListofMembershipInfo($pageNO, $schStr, $mode, $sortField, $sortOrder);
             return $message;
         case 'SGR':
             $this->salarygrade = new SalaryGrades();
             $message = $this->salarygrade->getListofSalaryGrades($pageNO, $schStr, $mode, $sortField, $sortOrder);
             return $message;
         case 'EDU':
             $this->qual = new Education();
             $message = $this->qual->getListofEducation($pageNO, $schStr, $mode, $sortField, $sortOrder);
             return $message;
         case 'BBS':
             $this->salgrd = new SalaryGrades();
             $message = $this->salgrd->getListofCashBenefits($pageNO, $schStr, $mode);
             return $message;
         case 'NBS':
             $this->salgrd = new SalaryGrades();
             $message = $this->salgrd->getListofNonCashBenefits($pageNO, $schStr, $mode);
             return $message;
         case 'EEC':
             $this->eeojobcat = new EEOJobCat();
             $message = $this->eeojobcat->getListofEEOJobCat($pageNO, $schStr, $mode, $sortField, $sortOrder);
             return $message;
         case 'LIC':
             $this->licenses = new Licenses();
             $message = $this->licenses->getListofLicenses($pageNO, $schStr, $mode, $sortField, $sortOrder);
             return $message;
         case 'USG':
             $this->userGroups = new UserGroups();
             $message = $this->userGroups->getListOfUserGroups($pageNO, $schStr, $mode, $sortField, $sortOrder);
             return $message;
         case 'CUS':
             $this->customer = new Customer();
             $message = $this->customer->getListofCustomers($pageNO, $schStr, $mode, $sortField, $sortOrder);
             return $message;
         case 'CTM':
             $this->customFields = new CustomFields();
             $message = $this->customFields->getCustomerFieldListForView($pageNO, $schStr, $mode, $sortField, $sortOrder);
             return $message;
         case 'CEX':
             return CustomExport::getCustomExportListForView($pageNO, $schStr, $mode, $sortField, $sortOrder);
         case 'CIM':
             return CustomImport::getCustomImportListForView($pageNO, $schStr, $mode, $sortField, $sortOrder);
         case 'PRJ':
             $this->projects = new Projects();
             $message = $this->projects->getListOfProjectsStr($pageNO, $schStr, $mode, $sortField, $sortOrder);
             return $message;
         case 'USR':
             $this->user = new Users();
             $message = $this->user->getListOfUsers($pageNO, $schStr, $mode, $sortField, $sortOrder, $esp);
             return $message;
     }
 }