PageRenderTime 67ms CodeModel.GetById 22ms RepoModel.GetById 0ms app.codeStats 1ms

/recruitment/helper_functions.php

https://bitbucket.org/lecturer34/hrmis
PHP | 2471 lines | 1897 code | 483 blank | 91 comment | 300 complexity | 2076517d8bbf362131b0b8741effd67a MD5 | raw file
Possible License(s): LGPL-2.1
  1. <?php
  2. require_once(realpath(dirname(__FILE__) . "/../lib/globals.php"));
  3. function clean($str) {
  4. $str = @trim($str);
  5. if(get_magic_quotes_gpc()) {
  6. $str = stripslashes($str);
  7. }
  8. return mysql_real_escape_string(strip_tags($str,'<br><br /><p></p>'));
  9. }
  10. function get_my_date_format($mySQLDate, $MediumLong){
  11. //$mySQLDate comes in as '2012-01-06' for Jan 6, 2012 or '2012-01-21' for Jan 21, 2012
  12. $returnVal = get_month_name(substr($mySQLDate,5,2),$MediumLong) . substr($mySQLDate,8,2) . ", " . substr($mySQLDate,0,4);
  13. return $returnVal;
  14. }
  15. function get_month_name($monthNumber,$MediumLong) {
  16. $mthName = "???";
  17. switch ($monthNumber) {
  18. case '01':
  19. $mthName = 'January';
  20. break;
  21. case '02':
  22. $mthName = 'February';
  23. break;
  24. case '03':
  25. $mthName = 'March';
  26. break;
  27. case '04':
  28. $mthName= 'April';
  29. break;
  30. case '05':
  31. $mthName = 'May';
  32. break;
  33. case '06':
  34. $mthName = 'June';
  35. break;
  36. case '07':
  37. $mthName = 'July';
  38. break;
  39. case '08':
  40. $mthName = 'August';
  41. break;
  42. case '09':
  43. $mthName = 'September';
  44. break;
  45. case '10':
  46. $mthName = 'October';
  47. break;
  48. case '11':
  49. $mthName = 'November';
  50. break;
  51. case '12':
  52. $mthName = 'December';
  53. break;
  54. default:
  55. $mthName = 'January';
  56. break;
  57. }//end switch
  58. if(strtolower($MediumLong) == "m"){
  59. $mthName = substr($mthName,0,3);
  60. }
  61. return $mthName . ' ';
  62. }
  63. function get_next_3days($date_reserved){
  64. //used in pay_advice.php to get the 3-day deadline
  65. //for applicants to pay and complete their forms
  66. $q = "SELECT DATE_ADD('$date_reserved', INTERVAL 3 DAY) AS expiry_three_days";
  67. $query = mysql_query($q);
  68. $row = mysql_fetch_assoc($query);
  69. return get_my_date_format($row['expiry_three_days'],'L');
  70. }
  71. function get_age_from_date($date_value, $return_format){
  72. // $q = "SELECT DATEDIFF(NOW(),'" . $date_value . "') AS age_days";
  73. $q = "SELECT DATEDIFF('" . $date_value . "', NOW()) AS age_days";
  74. $query = mysql_query($q);
  75. $row = mysql_fetch_assoc($query);
  76. $age_in_days = $row['age_days'];
  77. $returnVal = '&nbsp;&nbsp;&nbsp;(' . $age_in_days . ' days to go).';
  78. return $returnVal;
  79. }
  80. function get_days_to_go ($date_value){
  81. $q = "SELECT DATEDIFF('" . $date_value . "', NOW()) AS age_days";
  82. $query = mysql_query($q);
  83. $row = mysql_fetch_assoc($query);
  84. $age_in_days = $row['age_days'];
  85. $returnVal = '&nbsp;&nbsp;&nbsp;(';
  86. switch($age_in_days){
  87. case 0:
  88. $returnVal .= 'expires today at 12:00 midnight!)';
  89. break;
  90. case 1:
  91. $returnVal .= 'expires tomorrow at 12:00 midnight!)';
  92. break;
  93. default:
  94. $returnVal .= $age_in_days . ' days to go).';
  95. break;
  96. }
  97. return $returnVal;
  98. }
  99. function is_future_date($date_value){
  100. $q = "SELECT DATEDIFF('" . $date_value . "', NOW()) AS date_difference";
  101. $query = mysql_query($q);
  102. $row = mysql_fetch_assoc($query);
  103. $date_diff = $row['date_difference'];
  104. return ($date_diff > 0);
  105. }
  106. function is_date_past($date_value){
  107. $date_value = get_mysql_date($date_value);
  108. $q = "SELECT DATEDIFF('" . $date_value . "', NOW()) AS date_difference";
  109. $query = mysql_query($q);
  110. if(mysql_num_rows($query) > 0){
  111. $row = mysql_fetch_assoc($query);
  112. $date_diff = $row['date_difference'];
  113. }else{
  114. $date_diff = -1;
  115. }
  116. return ($date_diff < 0);
  117. }
  118. function is_dateformat_ddmmyyyy($dateStr){
  119. //we want to date that $dateStr came in the format 'DD/MM/YYYY'
  120. if(strlen($dateStr) != 10){
  121. return false;
  122. }
  123. $dd = substr($dateStr,0,2);
  124. $mm = substr($dateStr,3,2);
  125. $yy = substr($dateStr,6,4);
  126. return (checkdate($mm,$dd,$yy));
  127. }
  128. function get_mysql_date($dateparameter){
  129. //$dateparameter = 'DD/MM/YYYY'
  130. //we want to return 'YYYY-MM-DD'
  131. $returnDate = "'". substr($dateparameter,6,4) . "-" . substr($dateparameter,3,2) ."-" . substr($dateparameter,0,2) . "'";
  132. return $returnDate ;
  133. }
  134. function get_date_ddmmyyyy($dateparameter){
  135. //$dateparameter = mySQL date 'YYYY-MM-DD'
  136. //we want to return 'DD/MM/YYYY'
  137. $returnDate = substr($dateparameter,8,2) . "/" . substr($dateparameter,5,2) . "/" . substr($dateparameter,0,4);
  138. return $returnDate ;
  139. }
  140. function is_dateformat_mmmddyyyy($dateStr){
  141. /*
  142. $dt=$_POST['dt'];
  143. //$dt="02/28/2007";
  144. $arr=split("/",$dt); // splitting the array
  145. $mm=$arr[0]; // first element of the array is month
  146. $dd=$arr[1]; // second element is date
  147. $yy=$arr[2]; // third element is year
  148. If(!checkdate($mm,$dd,$yy)){
  149. echo "invalid date";
  150. }else {
  151. echo "Entry date is correct";
  152. } */
  153. $rT = 0;
  154. $dateStr = trim($dateStr);
  155. if (!isset($dateStr) || strlen($dateStr) != 10){
  156. //1980-01-01
  157. $rT = 0;
  158. }else{
  159. $arr = split("-",$dateStr); // splitting the array
  160. $yy = $arr[0];
  161. $mm = $arr[1];
  162. $dd = $arr[2];
  163. if (strlen($yy) == 4 && strlen($mm) == 2 && strlen($dd) == 2){
  164. if (is_numeric($yy) && is_numeric($mm) && is_numeric($dd)){
  165. if(checkdate($mm,$dd,$yy)){
  166. $rT = 1;
  167. }
  168. }
  169. }
  170. }//end if (!isset($dateStr) || strlen($dateStr)==0)
  171. return $rT;
  172. }
  173. function get_full_age_from_date($date_value, $return_format){
  174. if(!isset($date_value) || strlen($date_value) < 10){
  175. return 'Unknown Age';
  176. }
  177. $q = "SELECT DATEDIFF(NOW(),'" . $date_value . "') AS age_days";
  178. $query = mysql_query($q);
  179. $row = mysql_fetch_assoc($query);
  180. $age_in_days = $row['age_days'];
  181. $q = "SELECT FROM_DAYS($age_in_days) AS age_full";
  182. $query = mysql_query($q);
  183. $row = mysql_fetch_assoc($query);
  184. $age_in_full = $row['age_full'];
  185. $age_array = explode("-", $age_in_full);
  186. $age_years = (int)$age_array[0];
  187. $returnVal = $age_years;
  188. if($return_format == 'Full Details'){
  189. $age_months = (int)$age_array[1];
  190. $age_days = (int)$age_array[2];
  191. $y = ' year';
  192. $m = ' month';
  193. $d = ' day';
  194. if($age_years > 1){
  195. $y .= 's';
  196. }
  197. if($age_months > 1){
  198. $m .= 's';
  199. }
  200. if($age_days > 1){
  201. $d .= 's';
  202. }
  203. $y .= ', ';
  204. $m .= ' and ';
  205. $d .= ' old today';
  206. $returnVal = $age_years . $y . $age_months . $m . $age_days . $d;
  207. }
  208. return $returnVal;
  209. }
  210. function is_biodata_complete($applicantid){
  211. $returnVal = false;
  212. $q = "SELECT rowid, surname, firstname, othernames, gender, maritalstatus, physicalchallenge, birthdate, birthplace, hometown, lga, nationality ";
  213. $q .= "FROM tblapplicantsdetails WHERE appaccountrowid = $applicantid";
  214. $query = mysql_query($q);
  215. $foundRecord = mysql_num_rows($query);
  216. if ($foundRecord == 1) {
  217. $row = mysql_fetch_assoc($query);
  218. $returnVal = ( isset($row['gender']) && (strlen($row['gender']) == 1) && isset($row['birthdate']) && isset($row['hometown']) && isset($row['nationality']) && $row['nationality'] > 0);
  219. }
  220. return $returnVal;
  221. }
  222. function is_academic_qualification_complete($applicantid){
  223. $returnVal = false;
  224. $q = "SELECT rowid FROM tblapplicantshighestqual WHERE appaccountrowid = $applicantid";
  225. $query = mysql_query($q);
  226. $foundRecord = mysql_num_rows($query);
  227. return ($foundRecord == 1);
  228. }
  229. function is_primary_contact_complete($applicantid){
  230. $returnVal = false;
  231. $q = "SELECT currentaddress, permanenthomeaddress ";
  232. $q .= "FROM tblapplicantscontacts WHERE appaccountrowid = $applicantid";
  233. $query = mysql_query($q);
  234. $foundRecord = mysql_num_rows($query);
  235. if ($foundRecord == 1) {
  236. $row = mysql_fetch_assoc($query);
  237. $returnVal = ( isset($row['currentaddress']) && (strlen($row['currentaddress']) > 0) && isset($row['permanenthomeaddress']) && (strlen($row['permanenthomeaddress']) > 0) );
  238. }
  239. return $returnVal;
  240. }
  241. function count_applicant_professional_quals($applicantid){
  242. $returnVal = 0;
  243. $q = "SELECT COUNT(rowid) AS tot FROM tblapplicantsprofqualifications WHERE appaccountrowid = $applicantid";
  244. $query = mysql_query($q);
  245. $foundRecord = mysql_num_rows($query);
  246. if($foundRecord > 0){
  247. $row = mysql_fetch_assoc($query);
  248. $returnVal = $row['tot'];
  249. }
  250. return $returnVal;
  251. }
  252. function count_applicant_work_experience($applicantid){
  253. $returnVal = 0;
  254. $q = "SELECT COUNT(workingexpid) AS tot FROM tblapplicantsworkexperience WHERE appaccountrowid = $applicantid";
  255. $query = mysql_query($q);
  256. $foundRecord = mysql_num_rows($query);
  257. if($foundRecord > 0){
  258. $row = mysql_fetch_assoc($query);
  259. $returnVal = $row['tot'];
  260. }
  261. return $returnVal;
  262. }
  263. function get_job_title_from_advert_id($ad_id){
  264. $returnVal = '';
  265. if(!isset($ad_id) || !is_numeric($ad_id) || ((int)$ad_id < 0) ){
  266. $ad_id = 0;
  267. }
  268. $q = "SELECT tbladvertisements.vacancyid, tblvacancies.rankid, tblrank.name as position_name, tbldepartment.name as department_name ";
  269. $q .= "FROM tbladvertisements LEFT JOIN tblvacancies ON tbladvertisements.vacancyid = tblvacancies.vacancyid LEFT JOIN tblrank ON ";
  270. $q .= "tblvacancies.rankid = tblrank.rankid LEFT JOIN tbldepartment ON tblvacancies.departmentid = tbldepartment.departmentid WHERE advertisementid = $ad_id";
  271. $query = mysql_query($q);
  272. $foundRecord = mysql_num_rows($query);
  273. if ($foundRecord == 1) {
  274. $row = mysql_fetch_assoc($query);
  275. $returnVal = '<strong>'. $row['position_name'] . ' (' . $row['department_name'].')</strong>';
  276. }else {
  277. $returnVal = 'Job Position Undefined';
  278. }//end if ($foundRecord == 1)
  279. return $returnVal;
  280. }
  281. function is_exist_item($item_value, $item_value_is_num, $column_name, $table_name){
  282. //for this function to work, the target table must have a column called "row_id"
  283. $param_item_value = clean($item_value);
  284. $param_column_name = clean($column_name);
  285. $param_table_name = clean($table_name);
  286. $q = "SELECT row_id FROM $param_table_name WHERE $param_column_name = ";
  287. if($item_value_is_num == 1){
  288. $q .= "$param_item_value";
  289. }else{
  290. $q .= "'$param_item_value'";
  291. }
  292. $query = mysql_query($q);
  293. $foundRecord = mysql_num_rows($query);
  294. return $foundRecord > 0;
  295. }
  296. function is_exist_nok($ad_response_id){
  297. $ad_response_id = clean($ad_response_id);
  298. $q = "SELECT rowid FROM tblapplicantsnok WHERE advertresponseid = $ad_response_id";
  299. $query = mysql_query($q);
  300. $foundRecord = mysql_num_rows($query);
  301. return ($foundRecord > 0);
  302. }
  303. function is_exist_score_item($item){
  304. $item = clean($item);
  305. $q = "SELECT scoreitemid FROM tblinterviewscoreitems WHERE scoreitemdescription = '$item'";
  306. $query = mysql_query($q);
  307. $foundRecord = mysql_num_rows($query);
  308. return ($foundRecord > 0);
  309. }
  310. function is_exist_position($pos_id){
  311. $pos_id = clean($pos_id);
  312. if(! is_numeric($pos_id)){
  313. $pos_id = 0;
  314. }
  315. $q = "SELECT name FROM tblrank WHERE rankid = $pos_id";
  316. $query = mysql_query($q);
  317. $foundRecord = mysql_num_rows($query);
  318. return ($foundRecord > 0);
  319. }
  320. function is_exist_job_application_id($job_app_id){
  321. $job_app_id = clean($job_app_id);
  322. if(! is_numeric($job_app_id)){
  323. $job_app_id = 0;
  324. }
  325. $q = "SELECT advertid FROM tbladvertresponses WHERE responseid = $job_app_id";
  326. $query = mysql_query($q);
  327. $foundRecord = mysql_num_rows($query);
  328. return ($foundRecord > 0);
  329. }
  330. function is_exist_vacancy_id($vacancy_id){
  331. $vacancy_id = clean($vacancy_id);
  332. if(! is_numeric($vacancy_id)){
  333. $vacancy_id = 0;
  334. }
  335. $_SESSION['vac_PositionID'] = 0;
  336. $_SESSION['vac_DepartmentID'] = 0;
  337. $_SESSION['vac_WorkSchedule'] = '';
  338. $_SESSION['vac_WorkShifts'] = '';
  339. $_SESSION['vac_WorkHours'] = '';
  340. $_SESSION['vac_Slots'] = '';
  341. $_SESSION['vac_PosSummary'] = '';
  342. $_SESSION['vac_ExperienceRequirements'] = '';
  343. $_SESSION['vac_EducationRequirements'] = '';
  344. $_SESSION['vac_Advantage'] = '';
  345. $_SESSION['vac_Reason'] = 0;
  346. $_SESSION['vac_Status'] = '';
  347. $_SESSION['vac_VacantDate'] = '';
  348. $q = "SELECT rankid, departmentid, vacantslots, jobschedule, jobshifts, jobhours, positionsummary, educationrequirements, experiencerequirements, ";
  349. $q .= "additional_requirements, status, vacancyreasonid, effectivedate FROM tblvacancies WHERE vacancyid = $vacancy_id";
  350. $query = mysql_query($q);
  351. $foundRecord = mysql_num_rows($query);
  352. if($foundRecord == 1){
  353. $row = mysql_fetch_assoc($query);
  354. $_SESSION['vac_PositionID'] = $row['rankid'];
  355. $_SESSION['vac_DepartmentID'] = $row['departmentid'];
  356. $_SESSION['vac_WorkSchedule'] = $row['jobschedule'];
  357. $_SESSION['vac_WorkShifts'] = $row['jobshifts'];
  358. $_SESSION['vac_WorkHours'] = $row['jobhours'];
  359. $_SESSION['vac_Slots'] = $row['vacantslots'];
  360. $_SESSION['vac_PosSummary'] = $row['positionsummary'];
  361. $_SESSION['vac_ExperienceRequirements'] = $row['experiencerequirements'];
  362. $_SESSION['vac_EducationRequirements'] = $row['educationrequirements'];
  363. $_SESSION['vac_Advantage'] = $row['additional_requirements'];
  364. $_SESSION['vac_Reason'] = $row['vacancyreasonid'];
  365. $_SESSION['vac_Status'] = $row['status'];
  366. $_SESSION['vac_VacantDate'] = $row['effectivedate'];
  367. }
  368. return ($foundRecord > 0);
  369. }
  370. function is_exist_advert_id($advert_id){
  371. $advert_id = clean($advert_id);
  372. if(! is_numeric($advert_id)){
  373. $advert_id = 0;
  374. }
  375. $q = "SELECT adverttype FROM tbladvertisements WHERE advertisementid = $advert_id";
  376. $query = mysql_query($q);
  377. $foundRecord = mysql_num_rows($query);
  378. return ($foundRecord > 0);
  379. }
  380. function load_schedule_session_vars($schedule_id){
  381. $_SESSION['biz_MaxThreshold'] = 0;
  382. $_SESSION['biz_MaxPixChange'] = 0;
  383. $_SESSION['biz_MaxBiodataEdit'] = 0;
  384. $_SESSION['biz_MaxJobApps'] = 0;
  385. $_SESSION['biz_Referees'] = 0;
  386. $q = "SELECT threshold, maxpicturechange, maxbiodataedit, maxjobapplications, requiredreferees FROM tblrecruitmentsettings WHERE rowid = 1";
  387. $query = mysql_query($q);
  388. $foundRecord = mysql_num_rows($query);
  389. if($foundRecord == 1){
  390. $row = mysql_fetch_assoc($query);
  391. $_SESSION['biz_MaxThreshold'] = $row['threshold'];
  392. $_SESSION['biz_MaxPixChange'] = $row['maxpicturechange'];
  393. $_SESSION['biz_MaxBiodataEdit'] = $row['maxbiodataedit'];
  394. $_SESSION['biz_MaxJobApps'] = $row['maxjobapplications'];
  395. $_SESSION['biz_Referees'] = $row['requiredreferees'];
  396. }
  397. }
  398. function load_settings_into_session_vars(){
  399. $_SESSION['biz_MaxThreshold'] = 0;
  400. $_SESSION['biz_MaxPixChange'] = 0;
  401. $_SESSION['biz_MaxBiodataEdit'] = 0;
  402. $_SESSION['biz_MaxJobApps'] = 0;
  403. $_SESSION['biz_Referees'] = 0;
  404. $q = "SELECT threshold, maxpicturechange, maxbiodataedit, maxjobapplications, requiredreferees FROM tblrecruitmentsettings WHERE rowid = 1";
  405. $query = mysql_query($q);
  406. $foundRecord = mysql_num_rows($query);
  407. if($foundRecord == 1){
  408. $row = mysql_fetch_assoc($query);
  409. $_SESSION['biz_MaxThreshold'] = $row['threshold'];
  410. $_SESSION['biz_MaxPixChange'] = $row['maxpicturechange'];
  411. $_SESSION['biz_MaxBiodataEdit'] = $row['maxbiodataedit'];
  412. $_SESSION['biz_MaxJobApps'] = $row['maxjobapplications'];
  413. $_SESSION['biz_Referees'] = $row['requiredreferees'];
  414. }
  415. }
  416. function load_workschedules_into_combo($sess_schedule){
  417. $returnVal = "<option value = '-1'>-- Please Select --</option>";
  418. switch ($sess_schedule){
  419. case 'Full-Time';
  420. $returnVal .= "<option value = 'Full-Time' selected='selected'>Full Time</option>";
  421. $returnVal .= "<option value = 'Part-Time'>Part Time</option>";
  422. $returnVal .= "<option value = 'Full and Part Time'>Full and Part Time</option>";
  423. break;
  424. case 'Part-Time';
  425. $returnVal .= "<option value = 'Full-Time'>Full Time</option>";
  426. $returnVal .= "<option value = 'Part-Time' selected='selected'>Part Time</option>";
  427. $returnVal .= "<option value = 'Full and Part Time'>Full and Part Time</option>";
  428. break;
  429. case 'Full and Part Time';
  430. $returnVal .= "<option value = 'Full-Time'>Full Time</option>";
  431. $returnVal .= "<option value = 'Part-Time'>Part Time</option>";
  432. $returnVal .= "<option value = 'Full and Part Time' selected='selected'>Full and Part Time</option>";
  433. break;
  434. default:
  435. $returnVal .= "<option value = 'Full-Time'>Full Time</option>";
  436. $returnVal .= "<option value = 'Part-Time'>Part Time</option>";
  437. $returnVal .= "<option value = 'Full and Part Time'>Full and Part Time</option>";
  438. break;
  439. }
  440. return $returnVal;
  441. }
  442. function load_workshifts_into_combo($sess_shift){
  443. $returnVal = "<option value = '-1'>-- Please Select --</option>";
  444. switch ($sess_shift){
  445. case 'Days';
  446. $returnVal .= "<option value = 'Days' selected='selected'>Days</option>";
  447. $returnVal .= "<option value = 'Nights'>Nights</option>";
  448. $returnVal .= "<option value = 'Days and Nights'>Days and Nights</option>";
  449. break;
  450. case 'Nights';
  451. $returnVal .= "<option value = 'Days'>Days</option>";
  452. $returnVal .= "<option value = 'Nights' selected='selected'>Nights</option>";
  453. $returnVal .= "<option value = 'Days and Nights'>Days and Nights</option>";
  454. break;
  455. case 'Days and Nights';
  456. $returnVal .= "<option value = 'Days'>Days</option>";
  457. $returnVal .= "<option value = 'Nights'>Nights</option>";
  458. $returnVal .= "<option value = 'Days and Nights' selected='selected'>Days and Nights</option>";
  459. break;
  460. default:
  461. $returnVal .= "<option value = 'Days'>Days</option>";
  462. $returnVal .= "<option value = 'Nights'>Nights</option>";
  463. $returnVal .= "<option value = 'Days and Nights'>Days and Nights</option>";
  464. break;
  465. }
  466. return $returnVal;
  467. }
  468. function load_vacancyreasons_into_combo($sess_reason){
  469. $returnVal = '';
  470. $q = "SELECT rowid, vacancyreason FROM tblvacancyreasons ORDER BY vacancyreason";
  471. $query = mysql_query($q);
  472. $foundRecord = mysql_num_rows($query);
  473. if ($foundRecord > 0) {
  474. $returnVal .= "<option value = '-1'>-- Please Select --</option>";
  475. while ($row = mysql_fetch_assoc($query)){
  476. if($row['rowid'] == $sess_reason){
  477. $returnVal .= "<option value='" . $row['rowid'] . "' selected='selected'>" . $row['vacancyreason'] . "</option>";
  478. }else{
  479. $returnVal .= "<option value='" . $row['rowid'] . "'>" . $row['vacancyreason'] . "</option>";
  480. }
  481. }
  482. }else{
  483. $returnVal = "<option value = '-1'>No Data in Vacancy Reasons Table</option>";
  484. }//end if ($foundRecord == 1)
  485. return $returnVal;
  486. }
  487. function load_positionstatus_into_combo($sess_status){
  488. $returnVal = "<option value = '-1'>-- Please Select --</option>";
  489. switch ($sess_status){
  490. case 'Occupied';
  491. $returnVal .= "<option value = 'Occupied' selected='selected'>Occupied</option>";
  492. $returnVal .= "<option value = 'Not Occupied'>Not Occupied</option>";
  493. break;
  494. case 'Not Occupied';
  495. $returnVal .= "<option value = 'Occupied'>Occupied</option>";
  496. $returnVal .= "<option value = 'Not Occupied' selected='selected'>Not Occupied</option>";
  497. break;
  498. default:
  499. $returnVal .= "<option value = 'Occupied'>Occupied</option>";
  500. $returnVal .= "<option value = 'Not Occupied'>Not Occupied</option>";
  501. break;
  502. }
  503. return $returnVal;
  504. }
  505. function load_interview_panels_into_combo($sess_panel_id){
  506. $returnVal = '';
  507. $q = "SELECT rowid, panelname FROM tblinterviewpanels ORDER BY panelname";
  508. $query = mysql_query($q);
  509. $foundRecord = mysql_num_rows($query);
  510. if ($foundRecord > 0) {
  511. $returnVal .= "<option value = '-1'>-- Please Select --</option>";
  512. while ($row = mysql_fetch_assoc($query)){
  513. if($row['rowid'] == $sess_panel_id){
  514. $returnVal .= "<option value='" . $row['rowid'] . "' selected='selected'>" . $row['panelname'] . "</option>";
  515. }else{
  516. $returnVal .= "<option value='" . $row['rowid'] . "'>" . $row['panelname'] . "</option>";
  517. }
  518. }
  519. }else{
  520. $returnVal = "<option value = '-1'>No Data in Panels Table</option>";
  521. }//end if ($foundRecord == 1)
  522. return $returnVal;
  523. }
  524. function is_exist_interview_panel_id($panel_ID){
  525. $_SESSION['pnl_PanelName'] = '';
  526. $_SESSION['pnl_DateConstituted'] = '';
  527. $_SESSION['pnl_ConstitutedBy'] = '';
  528. $panel_ID = clean($panel_ID);
  529. if(! is_numeric($panel_ID)){
  530. $panel_ID = 0;
  531. }
  532. $q = "SELECT panelname, dateconstituted, constitutedby FROM tblinterviewpanels WHERE rowid = $panel_ID";
  533. $query = mysql_query($q);
  534. $foundRecord = mysql_num_rows($query);
  535. if($foundRecord == 1){
  536. $row = mysql_fetch_assoc($query);
  537. $_SESSION['pnl_PanelName'] = $row['panelname'];
  538. $_SESSION['pnl_DateConstituted'] = $row['dateconstituted'];
  539. $_SESSION['pnl_ConstitutedBy'] = $row['constitutedby'];
  540. }
  541. return ($foundRecord == 1);
  542. }
  543. function panel_is_used_in_records($panel_id){
  544. $returnVal = true; //assume is used
  545. //tblinterviewresults
  546. $q = "SELECT schedulerowid FROM tblinterviewschedules WHERE panelrowid = $panel_id";
  547. $query = mysql_query($q);
  548. $returnVal = (mysql_num_rows($query) > 0);
  549. return $returnVal;
  550. }
  551. function is_exist_interview_panel_member_id($member_ID){
  552. $_SESSION['mem_PanelID'] = 0;
  553. $_SESSION['mem_FullNames'] = '';
  554. $_SESSION['mem_PNumber'] = '';
  555. $_SESSION['mem_Department'] = 0;
  556. $_SESSION['mem_Role'] = '';
  557. $member_ID = clean($member_ID);
  558. if(! is_numeric($member_ID)){
  559. $member_ID = 0;
  560. }
  561. $q = "SELECT panelrowid, memberfullname, personnelnumber, memberdepartmentid, memberrole, tbldepartment.name as department FROM tblinterviewpanelmembers ";
  562. $q .= "LEFT JOIN tbldepartment ON tblinterviewpanelmembers.memberdepartmentid = tbldepartment.departmentid WHERE tblinterviewpanelmembers.rowid = $member_ID";
  563. $query = mysql_query($q);
  564. $foundRecord = mysql_num_rows($query);
  565. if($foundRecord == 1){
  566. $row = mysql_fetch_assoc($query);
  567. $_SESSION['mem_PanelID'] = $row['panelrowid'];
  568. $_SESSION['mem_FullNames'] = $row['memberfullname'];
  569. $_SESSION['mem_PNumber'] = $row['personnelnumber'];
  570. $_SESSION['mem_Department'] = $row['memberdepartmentid'];
  571. $_SESSION['mem_Role'] = $row['memberrole'];
  572. }
  573. return ($foundRecord == 1);
  574. }
  575. function is_exist_interview_schedule_id($schedule_id){
  576. $schedule_id = clean($schedule_id);
  577. if(! is_numeric($schedule_id)){
  578. $schedule_id = 0;
  579. }
  580. $_SESSION['schedule_AdvertID'] = 0;
  581. $_SESSION['schedule_StartDate'] = '';
  582. $_SESSION['schedule_EndDate'] = '';
  583. $_SESSION['schedule_Venue'] = '';
  584. $_SESSION['schedule_Times'] = '';
  585. $_SESSION['schedule_Parentpanel'] = 'Unknown Panel';
  586. $q = "SELECT panelrowid, advertid, startdate, enddate, sittingvenue, sittingtimes, panelname ";
  587. $q .= "FROM tblinterviewschedules INNER JOIN tblinterviewpanels ON tblinterviewschedules.panelrowid = tblinterviewpanels.rowid ";
  588. $q .= "WHERE schedulerowid = $schedule_id";
  589. $query = mysql_query($q);
  590. $foundRecord = mysql_num_rows($query);
  591. if($foundRecord == 1){
  592. $row = mysql_fetch_assoc($query);
  593. $_SESSION['schedule_AdvertID'] = $row['advertid'];
  594. $_SESSION['schedule_StartDate'] = $row['startdate'];
  595. $_SESSION['schedule_EndDate'] = $row['enddate'];
  596. $_SESSION['schedule_Venue'] = $row['sittingvenue'];
  597. $_SESSION['schedule_Times'] = $row['sittingtimes'];
  598. $_SESSION['schedule_Parentpanel'] = $row['panelname'];
  599. }
  600. return ($foundRecord > 0);
  601. }
  602. function is_exist_department($dept_id){
  603. $dept_id = clean($dept_id);
  604. if(! is_numeric($dept_id)){
  605. $dept_id = 0;
  606. }
  607. $q = "SELECT name FROM tbldepartment WHERE departmentid = $dept_id";
  608. $query = mysql_query($q);
  609. $foundRecord = mysql_num_rows($query);
  610. return ($foundRecord > 0);
  611. }
  612. function is_exist_unit($unit_id){
  613. $unit_id = clean($unit_id);
  614. if(! is_numeric($unit_id)){
  615. $unit_id = 0;
  616. }
  617. $q = "SELECT unitname FROM tblunits WHERE unitid = $unit_id";
  618. $query = mysql_query($q);
  619. $foundRecord = mysql_num_rows($query);
  620. return ($foundRecord > 0);
  621. }
  622. function is_exist_vacancyreason($vac_reason_id){
  623. $vac_reason_id = clean($vac_reason_id);
  624. if(! is_numeric($vac_reason_id)){
  625. $vac_reason_id = 0;
  626. }
  627. $q = "SELECT vacancyreason FROM tblvacancyreasons WHERE rowid = $vac_reason_id";
  628. $query = mysql_query($q);
  629. $foundRecord = mysql_num_rows($query);
  630. return ($foundRecord > 0);
  631. }
  632. function is_exist_user_account_id($user_id){
  633. $user_id = clean($user_id);
  634. if(! is_numeric($user_id)){
  635. $user_id = 0;
  636. }
  637. $q = "SELECT datecreated FROM tblapplicantsaccount WHERE account_rowid = $user_id";
  638. $query = mysql_query($q);
  639. $foundRecord = mysql_num_rows($query);
  640. return ($foundRecord > 0);
  641. }
  642. function is_exist_user_alternate_phone($user_id){
  643. $user_id = clean($user_id);
  644. if(! is_numeric($user_id)){
  645. $user_id = 0;
  646. }
  647. $q = "SELECT rowid FROM tblapplicantsotherphones WHERE appaccountrowid = $user_id";
  648. $query = mysql_query($q);
  649. $foundRecord = mysql_num_rows($query);
  650. return ($foundRecord > 0);
  651. }
  652. function is_exist_user_highest_qualification($user_id){
  653. $user_id = clean($user_id);
  654. if(! is_numeric($user_id)){
  655. $user_id = 0;
  656. }
  657. $q = "SELECT rowid FROM tblapplicantshighestqual WHERE appaccountrowid = $user_id";
  658. $query = mysql_query($q);
  659. $foundRecord = mysql_num_rows($query);
  660. return ($foundRecord > 0);
  661. }
  662. function is_exist_user_prof_qualification($user_id, $qual_id){
  663. $user_id = clean($user_id);
  664. $qual_id = clean($qual_id);
  665. if(!is_numeric($user_id) || !is_numeric($qual_id)){
  666. return true;
  667. }
  668. $q = "SELECT rowid FROM tblapplicantsprofqualifications WHERE appaccountrowid = $user_id AND qualificationid = $qual_id";
  669. $query = mysql_query($q);
  670. $foundRecord = mysql_num_rows($query);
  671. return ($foundRecord > 0);
  672. }
  673. function is_exist_prof_qualification($qual_ID){
  674. $_SESSION['prof_Qualification'] = 0;
  675. $_SESSION['prof_AwardBody'] = '';
  676. $_SESSION['prof_AwardYear'] = '';
  677. $qual_row_id = (int)$qual_ID;
  678. if(!is_numeric($qual_row_id)){
  679. return false;
  680. }
  681. $q = "SELECT qualificationid, yearobtained, awardingbody FROM tblapplicantsprofqualifications WHERE rowid = $qual_row_id";
  682. $query = mysql_query($q);
  683. $foundRecord = mysql_num_rows($query);
  684. if($foundRecord == 1){
  685. $row = mysql_fetch_assoc($query);
  686. $_SESSION['prof_Qualification'] = $row['qualificationid'];
  687. $_SESSION['prof_AwardBody'] = $row['awardingbody'];
  688. $_SESSION['prof_AwardYear'] = $row['yearobtained'];
  689. }
  690. return ($foundRecord == 1);
  691. }
  692. function is_exist_work_experience($exp_ID){
  693. $_SESSION['exp_Employer'] = '';
  694. $_SESSION['exp_Position'] = '';
  695. $_SESSION['exp_StartDate'] = '';
  696. $_SESSION['exp_EndDate'] = '';
  697. $_SESSION['exp_Duties'] = '';
  698. $exp_row_id = (int)$exp_ID;
  699. if(!is_numeric($exp_row_id)){
  700. return false;
  701. }
  702. $q = "SELECT employer, positionheld, responsibilities, datefrom, dateto FROM tblapplicantsworkexperience WHERE workingexpid = $exp_ID";
  703. $query = mysql_query($q);
  704. $foundRecord = mysql_num_rows($query);
  705. if($foundRecord == 1){
  706. $row = mysql_fetch_assoc($query);
  707. $_SESSION['exp_Employer'] = $row['employer'];
  708. $_SESSION['exp_Position'] = $row['positionheld'];
  709. $_SESSION['exp_StartDate'] = $row['datefrom'];
  710. $_SESSION['exp_EndDate'] = $row['dateto'];
  711. $_SESSION['exp_Duties'] = $row['responsibilities'];
  712. }
  713. return ($foundRecord == 1);
  714. }
  715. function get_ranks($sess_rank){
  716. $returnVal = '';
  717. $q = "SELECT rankid, name FROM tblrank ORDER BY name";
  718. $query = mysql_query($q);
  719. $foundRecord = mysql_num_rows($query);
  720. if ($foundRecord >= 1) {
  721. $returnVal .= "<option value = '-1'>-- Please Select --</option>";
  722. while ($row = mysql_fetch_assoc($query)){
  723. if($row['rankid'] == $sess_rank){
  724. $returnVal .= "<option value='" . $row['rankid'] . "' selected='selected'>" . $row['name'] . "</option>";
  725. }else{
  726. $returnVal .= "<option value='" . $row['rankid'] . "'>" . $row['name'] . "</option>";
  727. }
  728. }
  729. }else{
  730. $returnVal = "<option value = '-1'>No Data in Ranks Table</option>";
  731. }//end if ($foundRecord == 1)
  732. return $returnVal;
  733. }
  734. function get_departments($sess_dept){
  735. $returnVal = '';
  736. $q = "SELECT departmentid, name FROM tbldepartment ORDER BY name";
  737. $query = mysql_query($q);
  738. $foundRecord = mysql_num_rows($query);
  739. if ($foundRecord >= 1) {
  740. $returnVal .= "<option value = '-1'>-- Please Select --</option>";
  741. while ($row = mysql_fetch_assoc($query)){
  742. if($row['departmentid'] == $sess_dept){
  743. $returnVal .= "<option value='" . $row['departmentid'] . "' selected='selected'>" . $row['name'] . "</option>";
  744. }else{
  745. $returnVal .= "<option value='" . $row['departmentid'] . "'>" . $row['name'] . "</option>";
  746. }
  747. }
  748. }else{
  749. $returnVal = "<option value = '-1'>No Data in Departments Table</option>";
  750. }//end if ($foundRecord == 1)
  751. return $returnVal;
  752. }
  753. function get_units($sess_unit){
  754. $returnVal = '';
  755. $q = "SELECT unitid, unitname FROM tblunits ORDER BY unitname";
  756. $query = mysql_query($q);
  757. $foundRecord = mysql_num_rows($query);
  758. if ($foundRecord >= 1) {
  759. $returnVal .= "<option value = '-1'>-- Please Select --</option>";
  760. while ($row = mysql_fetch_assoc($query)){
  761. if($row['unitid'] == $sess_unit){
  762. $returnVal .= "<option value='" . $row['unitid'] . "' selected='selected'>" . $row['unitname'] . "</option>";
  763. }else{
  764. $returnVal .= "<option value='" . $row['unitid'] . "'>" . $row['unitname'] . "</option>";
  765. }
  766. }
  767. }else{
  768. $returnVal = "<option value = '-1'>No Data in Units Table</option>";
  769. }//end if ($foundRecord == 1)
  770. return $returnVal;
  771. }
  772. function get_titles_into_combo($sess_title){
  773. $returnVal = '';
  774. $q = "SELECT salutationid, salutation FROM tblsalutationslookup ORDER BY salutation";
  775. $query = mysql_query($q);
  776. $foundRecord = mysql_num_rows($query);
  777. if ($foundRecord >= 1) {
  778. $returnVal .= "<option value = '-1'>-- Please Select --</option>";
  779. while ($row = mysql_fetch_assoc($query)){
  780. if($row['salutationid'] == $sess_title){
  781. $returnVal .= "<option value='" . $row['salutationid'] . "' selected='selected'>" . $row['salutation'] . "</option>";
  782. }else{
  783. $returnVal .= "<option value='" . $row['salutationid'] . "'>" . $row['salutation'] . "</option>";
  784. }
  785. }
  786. $returnVal .= "<option value = '0'>-- Others --</option>";
  787. }else{
  788. $returnVal = "<option value = '-1'>No Data in Salutations Table</option>";
  789. }//end if ($foundRecord == 1)
  790. return $returnVal;
  791. }
  792. function get_countries_into_combo($sess_country){
  793. $returnVal = '';
  794. $q = "SELECT countryid, countryname FROM tblcountries ORDER BY countryname";
  795. $query = mysql_query($q);
  796. $foundRecord = mysql_num_rows($query);
  797. if ($foundRecord >= 1) {
  798. $returnVal .= "<option value = '-1'>-- Please Select --</option>";
  799. while ($row = mysql_fetch_assoc($query)){
  800. if($row['countryid'] == $sess_country){
  801. $returnVal .= "<option value='" . $row['countryid'] . "' selected='selected'>" . $row['countryname'] . "</option>";
  802. }else if (strtoupper($row['countryname']) == 'NIGERIA'){
  803. $returnVal .= "<option value='" . $row['countryid'] . "' selected='selected'>" . $row['countryname'] . "</option>";
  804. }else{
  805. $returnVal .= "<option value='" . $row['countryid'] . "'>" . $row['countryname'] . "</option>";
  806. }
  807. }
  808. // $returnVal .= "<option value = '0'>-- Others --</option>";
  809. }else{
  810. $returnVal = "<option value = '-1'>No Data in Countries Table</option>";
  811. }//end if ($foundRecord == 1)
  812. return $returnVal;
  813. }
  814. function get_states_into_combo($sess_state){
  815. $returnVal = '';
  816. $q = "SELECT stateid, statename FROM tblstate ORDER BY statename";
  817. $query = mysql_query($q);
  818. $foundRecord = mysql_num_rows($query);
  819. if ($foundRecord >= 1) {
  820. $returnVal .= "<option value = '-1'>-- Please Select --</option>";
  821. while ($row = mysql_fetch_assoc($query)){
  822. if($row['stateid'] == $sess_state){
  823. $returnVal .= "<option value='" . $row['stateid'] . "' selected='selected'>" . $row['statename'] . "</option>";
  824. }else{
  825. $returnVal .= "<option value='" . $row['stateid'] . "'>" . $row['statename'] . "</option>";
  826. }
  827. }
  828. $returnVal .= "<option value = '0'>Others [Non-Nigerian]</option>";
  829. }else{
  830. $returnVal = "<option value = '-1'>No Data in States Table</option>";
  831. }//end if ($foundRecord == 1)
  832. return $returnVal;
  833. }
  834. function get_lgas_into_combo($sess_lga, $state_id){
  835. $returnVal = '';
  836. $q = "SELECT lgaid, stateid, lganame FROM tbllga ";
  837. if(isset($state_id) && $state_id > 0){
  838. $q .= " WHERE stateid = $state_id ";
  839. }
  840. $q .= "ORDER BY lganame";
  841. $query = mysql_query($q);
  842. $foundRecord = mysql_num_rows($query);
  843. if ($foundRecord >= 1) {
  844. $returnVal .= "<option value = '-1'>-- Please Select --</option>";
  845. while ($row = mysql_fetch_assoc($query)){
  846. if($row['lgaid'] == $sess_lga){
  847. $returnVal .= "<option value='" . $row['lgaid'] . "' selected='selected'>" . $row['lganame'] . "</option>";
  848. }else{
  849. $returnVal .= "<option value='" . $row['lgaid'] . "'>" . $row['lganame'] . "</option>";
  850. }
  851. }
  852. $returnVal .= "<option value = '0'>Others [Non-Nigerian]</option>";
  853. }else{
  854. $returnVal = "<option value = '-1'>No Data in LGAs Table</option>";
  855. }//end if ($foundRecord == 1)
  856. return $returnVal;
  857. }
  858. function get_title_from_id($title_id){
  859. $returnVal = '';
  860. $q = "SELECT salutation FROM tblsalutationslookup WHERE salutationid = $title_id";
  861. $query = mysql_query($q);
  862. $foundRecord = mysql_num_rows($query);
  863. if ($foundRecord >= 1) {
  864. $row = mysql_fetch_assoc($query);
  865. $returnVal = $row['salutation'];
  866. }
  867. return $returnVal;
  868. }
  869. function get_unit_name_from_id($unit_id){
  870. $returnVal = '';
  871. $q = "SELECT unitname FROM tblunits WHERE unitid = $unit_id";
  872. $query = mysql_query($q);
  873. $foundRecord = mysql_num_rows($query);
  874. if ($foundRecord >= 1) {
  875. $row = mysql_fetch_assoc($query);
  876. $returnVal = $row['unitname'];
  877. }
  878. return $returnVal;
  879. }
  880. function get_department_name_from_id($dept_id){
  881. $returnVal = '';
  882. $q = "SELECT name FROM tbldepartment WHERE departmentid = $dept_id";
  883. $query = mysql_query($q);
  884. $foundRecord = mysql_num_rows($query);
  885. if ($foundRecord >= 1) {
  886. $row = mysql_fetch_assoc($query);
  887. $returnVal = $row['name'];
  888. }
  889. return $returnVal;
  890. }
  891. function get_position_name_from_id($pos_id){
  892. $returnVal = '';
  893. $q = "SELECT name FROM tblrank WHERE rankid = $pos_id";
  894. $query = mysql_query($q);
  895. $foundRecord = mysql_num_rows($query);
  896. if ($foundRecord >= 1) {
  897. $row = mysql_fetch_assoc($query);
  898. $returnVal = $row['name'];
  899. }
  900. return $returnVal;
  901. }
  902. function get_vacancyreason_from_id($reason_id){
  903. $returnVal = '';
  904. $q = "SELECT vacancyreason FROM tblvacancyreasons WHERE rowid = $reason_id";
  905. $query = mysql_query($q);
  906. $foundRecord = mysql_num_rows($query);
  907. if ($foundRecord > 0) {
  908. $row = mysql_fetch_assoc($query);
  909. $returnVal = $row['vacancyreason'];
  910. }
  911. return $returnVal;
  912. }
  913. function get_schedule_parent_id($schedule_id){
  914. $returnVal = '';
  915. $q = "SELECT panelrowid FROM tblinterviewschedules WHERE schedulerowid = $schedule_id";
  916. $query = mysql_query($q);
  917. $foundRecord = mysql_num_rows($query);
  918. if ($foundRecord > 0) {
  919. $row = mysql_fetch_assoc($query);
  920. $returnVal = $row['panelrowid'];
  921. }
  922. return $returnVal;
  923. }
  924. function load_unadvertised_jobs_into_combo($sess_vacancyid){
  925. $returnVal = '';
  926. $q = "SELECT tblvacancies.vacancyid, vacantslots, effectivedate, tblrank.name as position_name, tbldepartment.name as department_name FROM tblvacancies LEFT JOIN tblrank ON tblvacancies.rankid = tblrank.rankid LEFT JOIN tbldepartment ON tblvacancies.departmentid = tbldepartment.departmentid WHERE isadvertised = 'no' ORDER BY tblrank.name DESC";
  927. $query = mysql_query($q);
  928. $foundRecord = mysql_num_rows($query);
  929. if ($foundRecord > 0) {
  930. $returnVal .= "<option value = '-1'>-- Please Select --</option>";
  931. while ($row = mysql_fetch_assoc($query)){
  932. if($row['vacancyid'] == $sess_vacancyid){
  933. $returnVal .= "<option value='" . $row['vacancyid'] . "' selected='selected'>" . $row['position_name'] . "&nbsp;&nbsp;&nbsp;(" . $row['department_name']. ")</option>";
  934. }else{
  935. $returnVal .= "<option value='" . $row['vacancyid'] . "'>" . $row['position_name'] . "&nbsp;&nbsp;&nbsp;(" . $row['department_name']. ")</option>";
  936. }
  937. }
  938. }else{
  939. $returnVal = "<option value = '-1'>No Registered Job Posting Found</option>";
  940. }//end if ($foundRecord == 1)
  941. return $returnVal;
  942. }
  943. function commit_advert_response($advert_ID, $applicant_ID){
  944. $dt = date('Y-m-d');
  945. // $transcode = gettranscode('JB'); //from fee manager functions
  946. $q = "INSERT INTO tbladvertresponses (advertid, applicantid, responsedate, responsetime) ";
  947. $q .= "VALUES ($advert_ID, $applicant_ID, '$dt', curtime())";
  948. $query = mysql_query($q);
  949. return mysql_insert_id();
  950. /*
  951. $session = substr($dt,0,4);
  952. $amount = 2000.00;//should get this from a table: tblfeeitems or tblformfees?
  953. $q = "INSERT INTO tbl_feemngr_transaction(`transcode`, `studreg`,`code`,`transamount`,`session`, `paymentstatus`,`dategen`) ";
  954. $q .= "VALUES('$transcode','$applicant_ID','JOB',$amount,'$session','Not Paid', now())";
  955. $query = mysql_query($q);
  956. */
  957. }
  958. function count_adverts_responded_to($applicant_id){
  959. $q = "SELECT COUNT(responseid) AS tot_responses FROM tbladvertresponses WHERE applicantid = $applicant_id";
  960. $query = mysql_query($q);
  961. $foundRecord = mysql_num_rows($query);
  962. $c = 0;
  963. if($foundRecord == 1){
  964. $row = mysql_fetch_assoc($query);
  965. $c = $row['tot_responses'];
  966. }
  967. return $c;
  968. }
  969. function applicant_responded_to_this_advert($advert_id, $applicant_id){
  970. $q = "SELECT responseid FROM tbladvertresponses WHERE advertid = $advert_id AND applicantid = $applicant_id";
  971. $query = mysql_query($q);
  972. $foundRecord = mysql_num_rows($query);
  973. if($foundRecord == 1){
  974. $row = mysql_fetch_assoc($query);
  975. $_SESSION['advt_response_id'] = $row['responseid'];
  976. }
  977. return ($foundRecord > 0);
  978. }
  979. function get_advert_response_id_from_advert_id($advert_id, $applicant_id){
  980. $q = "SELECT responseid FROM tbladvertresponses WHERE advertid = $advert_id AND applicantid = $applicant_id";
  981. $query = mysql_query($q);
  982. $foundRecord = mysql_num_rows($query);
  983. $r = 0;
  984. if($foundRecord == 1){
  985. $row = mysql_fetch_assoc($query);
  986. $r = $row['responseid'];
  987. }
  988. return $r;
  989. }
  990. function applicant_submitted_this_application($advert_id, $applicant_id){
  991. $response_id = get_advert_response_id_from_advert_id($advert_id, $applicant_id);
  992. $q = "SELECT rowid FROM tblapplicantscvs WHERE advertresponseid = $response_id";
  993. $query = mysql_query($q);
  994. $foundRecord = mysql_num_rows($query);
  995. $returnVal = 0;
  996. if($foundRecord == 1){
  997. $row = mysql_fetch_assoc($query);
  998. $returnVal = $row['rowid'];
  999. }
  1000. return $returnVal;
  1001. }
  1002. function get_applicant_row_id_from_cv_id($app_cv_id){
  1003. $q = "SELECT cv.advertresponseid, resp.applicantid FROM tblapplicantscvs AS cv INNER JOIN tbladvertresponses AS resp ";
  1004. $q .= "ON cv.advertresponseid = resp.responseid WHERE cv.rowid = $app_cv_id";
  1005. $query = mysql_query($q);
  1006. $foundRecord = mysql_num_rows($query);
  1007. $r = 0;
  1008. if($foundRecord == 1){
  1009. $row = mysql_fetch_assoc($query);
  1010. $r = $row['applicantid'];
  1011. }
  1012. return $r;
  1013. }
  1014. function get_applicant_fullnames($applicant_row_id){
  1015. $q = "SELECT d.titleid, d.surname, d.firstname, d.othernames, t.salutation ";
  1016. $q .= "FROM tblapplicantsdetails AS d LEFT JOIN tblsalutationslookup AS t ";
  1017. $q .= "ON d.titleid = t.salutationid WHERE d.appaccountrowid = $applicant_row_id";
  1018. $query = mysql_query($q);
  1019. $foundRecord = mysql_num_rows($query);
  1020. $r = '';
  1021. if($foundRecord == 1){
  1022. $row = mysql_fetch_assoc($query);
  1023. $r = trim($row['salutation'] . ' ' . strtoupper($row['surname']) . ', ' . $row['firstname'] . ' ' . $row['othernames']);
  1024. }
  1025. return $r;
  1026. }
  1027. function get_advert_id_from_cv_id($app_cv_id){
  1028. $q = "SELECT cv.advertresponseid, resp.advertid FROM tblapplicantscvs AS cv INNER JOIN tbladvertresponses AS resp ";
  1029. $q .= "ON cv.advertresponseid = resp.responseid WHERE cv.rowid = $app_cv_id";
  1030. $query = mysql_query($q);
  1031. $foundRecord = mysql_num_rows($query);
  1032. $r = 0;
  1033. if($foundRecord == 1){
  1034. $row = mysql_fetch_assoc($query);
  1035. $r = $row['advertid'];
  1036. }
  1037. return $r;
  1038. }
  1039. function get_job_reference_number($advert_ID){
  1040. $appyear = substr(date('Y-d-m'),0,4);
  1041. return ('PJA-ABU' . substr($appyear,2,2) . '-' . str_pad($advert_ID, 3, "0", STR_PAD_LEFT)); //eg: ABU/PJA12/005
  1042. // PJA12#ABU#005
  1043. }
  1044. function embed_user_profile_pic($userRowID, $path_shift){
  1045. /* **************************************************************
  1046. ** Function to try retrieve the URL of user's profile picture **
  1047. ** Returns the URL pre-embedded in the <img > tag: **
  1048. ** **************************************************************/
  1049. $finalURL = get_current_photo($userRowID, $path_shift);
  1050. if (user_photo_not_uploaded($userRowID)){
  1051. $finalURL .= '<div style="float:center; text-align:center; width:100px; margin: 5px; margin-left:-3px; background-color:#eeeeee; border: 1px solid #339933"><a href="photo_upload.php" title="click to upload your photo">upload photo</a></div>';
  1052. }
  1053. echo $finalURL;
  1054. }//end function getUserProfilePicURL()
  1055. function getPicNA($gender){
  1056. if($gender == 'F'){
  1057. $p = 'naF';
  1058. }else{
  1059. $p = 'naM';
  1060. }
  1061. return $p;
  1062. }
  1063. function user_photo_not_uploaded($userRowID){
  1064. $returnVal = true;
  1065. if ($userRowID > 0){
  1066. $q = "SELECT profile_pic FROM tblapplicantsdetails WHERE appaccountrowid = " . $userRowID;
  1067. $query = mysql_query($q);
  1068. $foundRecord = mysql_num_rows($query);
  1069. if ($foundRecord == 1) {
  1070. $row = mysql_fetch_assoc($query);
  1071. if (isset($row['profile_pic']) && strlen($row['profile_pic']) == 16) {
  1072. $returnVal = false;
  1073. }
  1074. }
  1075. }
  1076. return $returnVal;
  1077. }
  1078. function get_current_photo($userRowID, $path_shift){
  1079. $finalURL = "";
  1080. $returnVal = "";
  1081. $altTitle = "Image Not Available";
  1082. $naFile = 'naM';
  1083. if ($userRowID > 0){
  1084. $q = "SELECT surname, firstname, othernames, profile_pic, gender FROM tblapplicantsdetails WHERE appaccountrowid = " . $userRowID;
  1085. $query = mysql_query($q);
  1086. $foundRecord = mysql_num_rows($query);
  1087. if ($foundRecord == 1) {
  1088. $row = mysql_fetch_assoc($query);
  1089. if (isset($row['profile_pic']) && strlen($row['profile_pic']) == 16) {
  1090. $returnVal = $row['profile_pic'];
  1091. $altTitle = $row['surname'] . ' ' . $row['firstname'] . ' ' . $row['othernames'];
  1092. }else{
  1093. $naFile = getPicNA($row['gender']);
  1094. }//end if (isset($row['m_profile_pic']) && $row['m_profile_pic'] != "")
  1095. }else {
  1096. $returnVal = $naFile;
  1097. }
  1098. $returnVal = $path_shift . "profilepics/" . $returnVal . ".jpg";
  1099. }else{
  1100. $r = 'recruitment/profile/profilepics/naM.jpg';
  1101. $returnVal = $path_shift . "profilepics/" . $returnVal . ".jpg";
  1102. }
  1103. // Whatever is to be returned, check that the image exists and is a file:
  1104. if (file_exists ($returnVal) && (is_file($returnVal))) {
  1105. $finalURL= "<img src='" . $returnVal . "' alt='" . $altTitle . "' title='" . $altTitle . "' width='95px' height='110px' style='border:solid 1px #000000'>";
  1106. }else{
  1107. $finalURL= "<img src='" . $path_shift . "profilepics/" . getPicNA($row['gender']) . ".jpg' alt='" . $altTitle . "' title='" . $altTitle . "' width='95px' height='110px' style='border:solid 1px #000000'>";
  1108. }//end if (file_exists ($returnVal) && (is_file($returnVal)))
  1109. return $finalURL;
  1110. }
  1111. function generate_random_chars($num_chars) {
  1112. $returnVal = '';
  1113. if ((is_numeric($num_chars)) && ($num_chars > 0) && (! is_null($num_chars))) {
  1114. $accepted_chars = 'abcdefghijklmnpqrstuvwxyz1234567890ABCDEFGHIJKLMNPQRSTUVWXYZ{_}(-)~^$';
  1115. // Seed the generator if necessary.
  1116. srand(((int)((double)microtime()*1000003)) );
  1117. for ($i = 0; $i < $num_chars; $i++) {
  1118. $random_number = rand(0, (strlen($accepted_chars) -1));
  1119. $returnVal .= $accepted_chars[$random_number];
  1120. }
  1121. }
  1122. return $returnVal;
  1123. }
  1124. function get_qualification_types_into_combo($sess_qualID){
  1125. $returnVal = '';
  1126. $q = "SELECT id, certificate FROM tblqualificationslookup ORDER BY certificate";
  1127. $query = mysql_query($q);
  1128. $foundRecord = mysql_num_rows($query);
  1129. if ($foundRecord >= 1) {
  1130. $returnVal .= "<option value = '-1'>-- Please Select --</option>";
  1131. while ($row = mysql_fetch_assoc($query)){
  1132. if($row['id'] == $sess_qualID){
  1133. $returnVal .= "<option value='" . $row['id'] . "' selected='selected'>" . $row['certificate'] . "</option>";
  1134. }else{
  1135. $returnVal .= "<option value='" . $row['id'] . "'>" . $row['certificate'] . "</option>";
  1136. }
  1137. }
  1138. $returnVal .= "<option value = '0'>-- NONE --</option>";
  1139. }else{
  1140. $returnVal = "<option value = '-1'>No Data in Qualifications Table</option>";
  1141. }//end if ($foundRecord == 1)
  1142. return $returnVal;
  1143. }
  1144. function get_qualification_classes_into_combo($sess_qualclassID){
  1145. $returnVal = '';
  1146. $q = "SELECT qualificationclassid, qualification FROM tblqualificationclass ORDER BY qualification";
  1147. $query = mysql_query($q);
  1148. $foundRecord = mysql_num_rows($query);
  1149. if ($foundRecord >= 1) {
  1150. $returnVal .= "<option value = '-1'>-- Please Select --</option>";
  1151. while ($row = mysql_fetch_assoc($query)){
  1152. if($row['qualificationclassid'] == $sess_qualclassID){
  1153. $returnVal .= "<option value='" . $row['qualificationclassid'] . "' selected='selected'>" . $row['qualification'] . "</option>";
  1154. }else{
  1155. $returnVal .= "<option value='" . $row['qualificationclassid'] . "'>" . $row['qualification'] . "</option>";
  1156. }
  1157. }
  1158. $returnVal .= "<option value = '0'>-- Not Applicable --</option>";
  1159. }else{
  1160. $returnVal = "<option value = '-1'>No Data in Qualifications Table</option>";
  1161. }//end if ($foundRecord == 1)
  1162. return $returnVal;
  1163. }
  1164. function get_professional_qualifications_into_combo($sess_qualID){
  1165. $returnVal = '';
  1166. $q = "SELECT id, name FROM tblprofessionalqualslookup ORDER BY name";
  1167. $query = mysql_query($q);
  1168. $foundRecord = mysql_num_rows($query);
  1169. if ($foundRecord >= 1) {
  1170. $returnVal .= "<option value = '-1'>-- Please Select --</option>";
  1171. while ($row = mysql_fetch_assoc($query)){
  1172. if($row['id'] == $sess_qualID){
  1173. $returnVal .= "<option value='" . $row['id'] . "' selected='selected'>" . $row['name'] . "</option>";
  1174. }else{
  1175. $returnVal .= "<option value='" . $row['id'] . "'>" . $row['name'] . "</option>";
  1176. }
  1177. }
  1178. $returnVal .= "<option value = '0'>-- NONE --</option>";
  1179. }else{
  1180. $returnVal = "<option value = '-1'>No Data in Qualifications Table</option>";
  1181. }//end if ($foundRecord == 1)
  1182. return $returnVal;
  1183. }
  1184. function get_programmes_of_study_into_combo($sess_studyID){
  1185. $returnVal = '';
  1186. $q = "SELECT id, studyfield FROM tblstudyfieldlookup ORDER BY studyfield";
  1187. $query = mysql_query($q);
  1188. $foundRecord = mysql_num_rows($query);
  1189. if ($foundRecord >= 1) {
  1190. $returnVal .= "<option value = '-1'>-- Please Select --</option>";
  1191. while ($row = mysql_fetch_assoc($query)){
  1192. if($row['id'] == $sess_studyID){
  1193. $returnVal .= "<option value='" . $row['id'] . "' selected='selected'>" . $row['studyfield'] . "</option>";
  1194. }else{
  1195. $returnVal .= "<option value='" . $row['id'] . "'>" . $row['studyfield'] . "</option>";
  1196. }
  1197. }
  1198. $returnVal .= "<option value = '0'>-- Others --</option>";
  1199. }else{
  1200. $returnVal = "<option value = '-1'>No Data in Fields of Study Table</option>";
  1201. }//end if ($foundRecord == 1)
  1202. return $returnVal;
  1203. }
  1204. function get_applicant_advert_to_track($advert_ID, $applicant_id){
  1205. $returnVal = '<table border="1px" style="border-collapse: collapse; width:100%; margin-top:10px" cellpadding="5px" cellspacing="10px">';
  1206. if(!is_numeric($advert_ID) || ((int)$advert_ID < 1) || !is_numeric($applicant_id) || ((int)$applicant_id < 1)){
  1207. $returnVal .= '<tr style="border: solid 1px;"><td colspan="2">Error while retrieving the requested information: <strong>"Invalid Advert ID"</strong></td></tr>';
  1208. }else{
  1209. $q = "SELECT tbladvertresponses.responseid, tbladvertresponses.advertid, applicantid, responsedate, ";
  1210. $q .= "datecompleted, applicantcomments, tbladvertisements.advertisementid, adverttype, tbladvertisements.vacancyid, ";
  1211. $q .= "tblvacancies.vacancyid, tblvacancies.rankid, tblvacancies.departmentid, tblrank.name as position_name, tbldepartment.name as department_name ";
  1212. $q .= "FROM tbladvertresponses LEFT JOIN tbladvertisements ON tbladvertresponses.advertid = tbladvertisements.advertisementid ";
  1213. $q .= "LEFT JOIN tblvacancies ON tbladvertisements.vacancyid = tblvacancies.vacancyid ";
  1214. $q .= "LEFT JOIN tblrank ON tblvacancies.rankid = tblrank.rankid ";
  1215. $q .= "LEFT JOIN tbldepartment ON tblvacancies.departmentid = tbldepartment.departmentid ";
  1216. $q .= "WHERE tbladvertresponses.advertid = $advert_ID AND tbladvertresponses.applicantid = $applicant_id";
  1217. $query = mysql_query($q);
  1218. $foundRecord = mysql_num_rows($query);
  1219. if ($foundRecord > 0) {
  1220. $row = mysql_fetch_assoc($query);
  1221. $returnVal .= '<tr style="border: solid 1px;text-align:center"><td colspan="2"><strong>' . $row['position_name'] . '</strong></td></tr>';
  1222. $returnVal .= '<tr style="border: solid 1px;"><td>Department</td><td>' . $row['department_name'] . ' </td></tr>';
  1223. $returnVal .= '<tr style="border: solid 1px;"><td>Response Date</td><td>' . get_my_date_format($row['responsedate'], 'L') . ' </td></tr>';
  1224. $returnVal .= '<tr style="border: solid 1px;"><td>Your Comments</td><td>' . $row['applicantcomments'] . '</td></tr>';
  1225. $returnVal .= '<tr style="border: solid 1px;"><td>Application Status</td><td>' . $row['datecompleted'] . ' </td></tr>';
  1226. $returnVal .= '<tr style="border: solid 1px;"><td>ABU&rsquo;s Action</td><td>Pending / Acknowledged / Shortlisted for Interview</td></tr>';
  1227. $returnVal .= '<tr style="border: solid 1px; text-align:right"><td colspan="2"><a href="#" title="click to complete your application for this job">[complete application]</a>&nbsp;&nbsp;&nbsp;<a href="#" title="click to cancel your application for this job">[cancel application]</a>&nbsp;&nbsp;&nbsp;<a href="../adverts/running_adverts.php" title="click to go back to adverts page">[back to adverts]</a></td></tr>';
  1228. }else {
  1229. $returnVal .= '<tr style="border: solid 1px;"><td colspan="2">Error while retrieving the requested information: <strong>"Invalid User ID"</strong></td></tr>';
  1230. }//end if ($foundRecord == 1)
  1231. }//end if(!is_numeric($user_row_id) || ((int)$user_row_id < 1)
  1232. $returnVal .= '</table></br>';
  1233. echo $returnVal;
  1234. }
  1235. function get_applicant_other_job_apps($applicant_id){
  1236. $returnVal = '<table border="1px" style="border-collapse: collapse; width:100%; margin-top:10px" cellpadding="5px" cellspacing="10px">';
  1237. if(!is_numeric($applicant_id) || ((int)$applicant_id < 1)){
  1238. $returnVal .= '<tr style="border: solid 1px;"><td colspan="2">Error while retrieving the requested information: <strong>"Invalid Advert ID"</strong></td></tr>';
  1239. }else{
  1240. $q = "SELECT tbladvertresponses.responseid, tbladvertresponses.advertid, applicantid, responsedate, ";
  1241. $q .= "datecompleted, applicantcomments, tbladvertisements.advertisementid, adverttype, tbladvertisements.vacancyid, ";
  1242. $q .= "tblvacancies.vacancyid, tblvacancies.rankid, tblvacancies.departmentid, tblrank.name as position_name, tbldepartment.name as department_name ";
  1243. $q .= "FROM tbladvertresponses LEFT JOIN tbladvertisements ON tbladvertresponses.advertid = tbladvertisements.advertisementid ";
  1244. $q .= "LEFT JOIN tblvacancies ON tbladvertisements.vacancyid = tblvacancies.vacancyid ";
  1245. $q .= "LEFT JOIN tblrank ON tblvacancies.rankid = tblrank.rankid ";
  1246. $q .= "LEFT JOIN tbldepartment ON tblvacancies.departmentid = tbldepartment.departmentid ";
  1247. $q .= "WHERE tbladvertresponses.applicantid = $applicant_id";
  1248. $query = mysql_query($q);
  1249. $foundRecord = mysql_num_rows($query);
  1250. if ($foundRecord > 0) {
  1251. $row = mysql_fetch_assoc($query);
  1252. $returnVal .= '<tr style="border: solid 1px;text-align:center"><td colspan="2"><strong>' . $row['position_name'] . '</strong></td></tr>';
  1253. $returnVal .= '<tr style="border: solid 1px;"><td>Department</td><td>' . $row['department_name'] . ' </td></tr>';
  1254. $returnVal .= '<tr style="border: solid 1px;"><td>Response Date</td><td>' . get_my_date_format($row['responsedate'], 'L') . ' </td></tr>';
  1255. $returnVal .= '<tr style="border: solid 1px;"><td>Your Comments</td><td>' . $row['applicantcomments'] . '</td></tr>';
  1256. $returnVal .= '<tr style="border: solid 1px;"><td>Application Status</td><td>' . $row['datecompleted'] . ' </td></tr>';
  1257. $returnVal .= '<tr style="border: solid 1px;"><td>ABU&rsquo;s Action</td><td>Pending / Acknowledged / Shortlisted for Interview</td></tr>';
  1258. $returnVal .= '<tr style="border: solid 1px; text-align:right"><td colspan="2"><a href="#" title="click to complete your application for this job">[complete application]</a>&nbsp;&nbsp;&nbsp;<a href="#" title="click to cancel your application for this job">[cancel application]</a>&nbsp;&nbsp;&nbsp;<a href="../adverts/running_adverts.php" title="click to go back to adverts page">[back to adverts]</a></td></tr>';
  1259. }else {
  1260. $returnVal .= '<tr style="border: solid 1px;"><td colspan="2">Error while retrieving the requested information: <strong>"Invalid User ID"</strong></td></tr>';
  1261. }//end if ($foundRecord == 1)
  1262. }//end if(!is_numeric($user_row_id) || ((int)$user_row_id < 1)
  1263. $returnVal .= '</table></br>';
  1264. echo $returnVal;
  1265. }
  1266. function send_email($recepient_email, $msg_title, $msg_body, $msg_sender){
  1267. /*
  1268. $subject = "2011/2012 Ahmadu Bello University Zaria Postgraduate Application";
  1269. // Build the message
  1270. $message = "Dear $surname,\n\n";
  1271. $message .="Thank you very much for indicating interest in our post graduate programs. Please take note of your login paramerets: \n\n";
  1272. $message .= "Username: $email\n\n";
  1273. $message .= "Password: $pwd \n\n";
  1274. $message .= "Please use these to login at any time. \n\n However, for you to continue your application, you must go to any designated bank and pay the prescribed fees for the form. \n\n";
  1275. $message .= "Thank you. \n\n";
  1276. */
  1277. $msg_body .= $msg_body ."\n\n" . $msg_sender;
  1278. $msg_body = wordwrap($msg_body, 70); // limit line length to 70 characters
  1279. //mail(to,subject,message,headers,parameters)
  1280. $msg_sender = "From: " . $msg_sender;
  1281. return mail($recepient_email, $msg_title, $msg_body, $msg_sender);
  1282. }
  1283. function get_applicant_prof_qual($applicantid){
  1284. $prof_qualification="";
  1285. $query=mysql_query("SELECT tblprofessionalqualslookup.name AS profqual,tblapplicantsprofqualifications.yearobtained
  1286. FROM tblapplicantsprofqualifications
  1287. INNER JOIN tblprofessionalqualslookup ON tblapplicantsprofqualifications.qualificationid = tblprofessionalqualslookup.id
  1288. WHERE tblapplicantsprofqualifications.appaccountrowid=$applicantid")
  1289. or die("query cannot be executed: ".mysql_error());
  1290. if(mysql_num_rows($query)>0){
  1291. while($row=mysql_fetch_assoc($query)){
  1292. $profqualification=$row['profqual'];
  1293. $yearobtained=$row['yearobtained'];
  1294. $prof_qualification.=$profqualification." (".$yearobtained.")"."<br/>";
  1295. }
  1296. }
  1297. return $prof_qualification;
  1298. }
  1299. function is_applicant_shortlisted($applicantid){
  1300. $query=mysql_query("SELECT * FROM tbladvertresponses WHERE applicantid=$applicantid AND applicationstatus='shortlisted'")
  1301. or die("Query cannot be executed! ".mysql_error());
  1302. if(mysql_num_rows($query)>0){
  1303. return 1;
  1304. }else{
  1305. return 0;
  1306. }
  1307. }
  1308. function get_max_score_obtainable($scoreitemid,$scheduleid){
  1309. $scorequery=mysql_query("SELECT tblinterviewpanelscoresettings.scoreobtainable FROM tblinterviewpanelscoresettings WHERE tblinterviewpanelscoresettings.scoreitemid=$scoreitemid AND scheduleid = $scheduleid") or die("Query cannot be executed: " . mysql_error());
  1310. if(mysql_num_rows($scorequery) > 0){
  1311. $row=mysql_fetch_assoc($scorequery);
  1312. return $row['scoreobtainable'];
  1313. }else{
  1314. return 0;
  1315. }
  1316. }
  1317. function interview_score_exists($applicant_id,$schedule_id,$scoreitem_id,$member_id){
  1318. $q = "SELECT rowid FROM tblinterviewresults WHERE appaccountrowid = $applicant_id AND scheduleid = $schedule_id ";
  1319. $q .= "AND scoreitemid = $scoreitem_id AND scorerid = $member_id";
  1320. $query = mysql_query($q);
  1321. $foundRecord = mysql_num_rows($query);
  1322. return ($foundRecord > 0);
  1323. }
  1324. // Validation of the form of Appointment
  1325. function validate_appointment_form($appointment_type,$contract_effective_date,$contract_end_date,$temporary_part_time_session,$grade_level,$step,$salary_category,$staff_category){
  1326. $errormsg='';
  1327. //,$contract_effective_date,$contract_end_date,
  1328. if(!isset($appointment_type) || $appointment_type==0){
  1329. $errormsg.="<li>Please specify the type of appointment</li>";
  1330. }
  1331. if(isset($appointment_type) && $appointment_type!=0){
  1332. if(get_appointment_type_from_id($appointment_type)=="Contract"){
  1333. if(!isset($contract_effective_date) || $contract_effective_date==""){
  1334. $errormsg.="<li>Please, specify the effective date of contract!</li>";
  1335. }
  1336. if(!isset($contract_end_date) || $contract_end_date==""){
  1337. $errormsg.="<li>Please, specify the end date of contract!</li>";
  1338. }
  1339. }
  1340. if(get_appointment_type_from_id($appointment_type)=="Temporary Part-Time"){
  1341. if(!isset($temporary_part_time_session) || $temporary_part_time_session==""){
  1342. $errormsg.="<li>Please, specify the session for temporary part-time appointment!</li>";
  1343. }
  1344. }
  1345. if(get_appointment_type_from_id($appointment_type)=="Tenure" || get_appointment_type_from_id($appointment_type)=="Visiting" ||
  1346. get_appointment_type_from_id($appointment_type)=="Sabbatical" || get_appointment_type_from_id($appointment_type)=="Junior Staff" ||
  1347. get_appointment_type_from_id($appointment_type)=="Temporary Month-to-Month"){
  1348. if(!isset($salary_category) || $salary_category==0){
  1349. $errormsg.="<li>Please, specify the salary scale!</li>";
  1350. }
  1351. if((get_salary_category_from_id($salary_category)=="CONTISS" && $staff_category=="Academic")){
  1352. $errormsg.="<li>This salary scale (CONTISS) is applicable to only Non-Academic staff!</li>";
  1353. }
  1354. if((get_salary_category_from_id($salary_category)=="CONUASS" && $staff_category=="Non-Academic")){
  1355. $errormsg.="<li>This salary scale (CONUASS) is applicable to only Academic staff!</li>";
  1356. }
  1357. if(!isset($grade_level) || $grade_level=="0"){
  1358. $errormsg.="<li>Please, specify the grade level!</li>";
  1359. }
  1360. if(!isset($step) || $step=="0"){
  1361. $errormsg.="<li>Please, specify the step!</li>";
  1362. }
  1363. }
  1364. }
  1365. return $errormsg;
  1366. }
  1367. // function to determine whether the appointment is for Academic or Non-Academic
  1368. function is_staff_academic($applicantid,$advertid){
  1369. $advertresponseid=get_advertresponse_id($applicantid,$advertid);
  1370. $query=mysql_query("select staffcategory from tblapplicantsappointments where advertresponseid=$advertresponseid");
  1371. if(mysql_num_rows($query)==1){
  1372. while($row=mysql_fetch_assoc($query)){
  1373. $staffcategory=$row['staffcategory'];
  1374. $status=($staffcategory=="Academic")?true:false;
  1375. }
  1376. }
  1377. return $status;
  1378. }
  1379. //function to determine whether the staff's cadre is Graduate Assistance to show the changes in appoinment letter
  1380. function is_staff_graduate_assitance($applicantid,$advertid){
  1381. $advertresponseid=get_advertresponse_id($applicantid,$advertid);
  1382. $status=false;
  1383. $query=mysql_query("select designation from tblapplicantsappointments where advertresponseid=$advertresponseid");
  1384. if(mysql_num_rows($query)==1){
  1385. $designationid=mysql_result($query,0,'designation');
  1386. $rankquery=mysql_query("select name from tblrank where rankid=$designationid");
  1387. if(mysql_num_rows($rankquery)){
  1388. $designation=mysql_result($rankquery,0,'name');
  1389. if($designation=="Graduate Assistant"){
  1390. $status=true;
  1391. }
  1392. }
  1393. }
  1394. return $status;
  1395. }
  1396. //this is a function determine whether a rank is academic or non-academic
  1397. function is_rank_academic($advertid){
  1398. $status=false;
  1399. $staff_category='';
  1400. $query=mysql_query("SELECT tblstaffcategory.name AS category FROM tblstaffcategory
  1401. INNER JOIN tblcadre on tblstaffcategory.categoryid=tblcadre.categoryid
  1402. INNER JOIN tblrank on tblrank.cadreid=tblcadre.cadreid where tblrank.rankid=
  1403. (SELECT tblrank.rankid FROM tbladvertisements
  1404. INNER JOIN tblvacancies ON tblvacancies.vacancyid = tbladvertisements.vacancyid
  1405. INNER JOIN tblrank ON tblrank.rankid = tblvacancies.rankid
  1406. INNER JOIN tbladvertresponses ON tbladvertresponses.advertid=tbladvertisements.advertisementid
  1407. WHERE tbladvertisements.advertisementid=$advertid LIMIT 1)")
  1408. or die("Query cannot be executed: ".mysql_error());
  1409. if(mysql_num_rows($query)==1){
  1410. $staff_category=mysql_result($query,0,'category');
  1411. }
  1412. switch($staff_category){
  1413. case "academic" : case "research":
  1414. $status=true;
  1415. break;
  1416. case "non academic":
  1417. $status=false;
  1418. break;
  1419. default :
  1420. $status=false;
  1421. break;
  1422. }
  1423. return $status;
  1424. }
  1425. // function return the initial grade level for a particular rank
  1426. function initial_gradelevel($advertid){
  1427. $initial_grade=0;
  1428. $query=mysql_query("SELECT tblrank.grade FROM tbladvertisements
  1429. INNER JOIN tblvacancies ON tblvacancies.vacancyid = tbladvertisements.vacancyid
  1430. INNER JOIN tblrank ON tblrank.rankid = tblvacancies.rankid
  1431. INNER JOIN tbladvertresponses ON tbladvertresponses.advertid=tbladvertisements.advertisementid
  1432. WHERE tbladvertisements.advertisementid=$advertid LIMIT 1");
  1433. if(mysql_num_rows($query)==1){
  1434. $initial_grade=mysql_result($query,0,'grade');
  1435. }
  1436. return $initial_grade;
  1437. }
  1438. // get maximum step( for salary) based on the rank and grade
  1439. function get_maximum_step($advertid){
  1440. $maxstep=0;
  1441. $gradelevel=initial_gradelevel($advertid);
  1442. $query=mysql_query("select maxstep from tblsalary where gradelevel=$gradelevel") or die("Query cannot be executed: ".mysql_error());
  1443. if(mysql_num_rows($query)==1){
  1444. $maxstep=mysql_result($query,0,'maxstep');
  1445. }
  1446. return $maxstep;
  1447. }
  1448. // To show in the Appointment letter as an applicant's address
  1449. function get_applicant_contactaddress($applicantid) {
  1450. $returnVal ="";
  1451. $address='';
  1452. $query= mysql_query("SELECT currentaddress, permanenthomeaddress FROM tblapplicantscontacts WHERE appaccountrowid = $applicantid")or die("query cannot be execued: ".mysql_error());
  1453. $foundRecord = mysql_num_rows($query);
  1454. if ($foundRecord == 1) {
  1455. $row = mysql_fetch_assoc($query);
  1456. $address = explode(',',$row["currentaddress"]);
  1457. }
  1458. foreach($address as $splite_address){
  1459. $returnVal.="<span>".$splite_address."</span>"."<br/>";
  1460. }
  1461. return $returnVal;
  1462. }
  1463. /*this is a function that returns the difference between two date in months
  1464. and use it to determine when salary increment will be due
  1465. */
  1466. function monthsBetween($startDate, $endDate) {
  1467. $retval = "";
  1468. // Assume YYYY-mm-dd - as is common MYSQL format
  1469. $splitStart = explode('-', $startDate);
  1470. $splitEnd = explode('-', $endDate);
  1471. if (is_array($splitStart) && is_array($splitEnd)) {
  1472. $difYears = $splitEnd[0] - $splitStart[0];
  1473. $difMonths = $splitEnd[1] - $splitStart[1];
  1474. $difDays = $splitEnd[2] - $splitStart[2];
  1475. $retval = ($difDays > 0) ? $difMonths : $difMonths - 1;
  1476. $retval += $difYears * 12;
  1477. }
  1478. return $retval;
  1479. }
  1480. // determine date of next salary increment after an appointment
  1481. function get_next_salary_increment_date(){
  1482. $strdate=date("Y")."-".date("m")."-".date("d");
  1483. $enddate=date("Y")."-10-01";
  1484. if(monthsBetween($strdate,$enddate)>=6){ // you must work for atleast 6 months before October
  1485. echo date("Y");
  1486. }else{
  1487. echo date("Y")+1;
  1488. }
  1489. }
  1490. function get_appointment_type_from_id($appointment_typeid){
  1491. $appointment_type='';
  1492. $query=mysql_query("select appointmenttype from tblapplicantappointmenttype where appointmenttypeid=$appointment_typeid")
  1493. or die("Query cannot be executed: ".mysql_error());
  1494. if(mysql_num_rows($query)>0){
  1495. $row=mysql_fetch_assoc($query);
  1496. $appointment_type=trim($row['appointmenttype']);
  1497. }else{
  1498. echo "<font>No such type of appointment exist!</font>";
  1499. }
  1500. return $appointment_type;
  1501. }
  1502. // To determine which template to show when Appointing applicant(Tenure, Temporary, Visiting, etc)
  1503. function get_appointment_template($appointment_typeid){
  1504. $Url_redirect="";
  1505. $appointment_type=get_appointment_type_from_id($appointment_typeid);
  1506. switch($appointment_type){
  1507. case "Tenure":
  1508. $Url_redirect="tenure_appointment_letter.php";
  1509. break;
  1510. case "Temporary Part-Time":
  1511. $Url_redirect="temporary_part-time_appoint_letter.php";
  1512. break;
  1513. case "Temporary Month-to-Month":
  1514. $Url_redirect="month-month_appoint_letter.php";
  1515. break;
  1516. case "Visiting":
  1517. $Url_redirect="visiting_appointment_letter.php";
  1518. break;
  1519. case "Contract":
  1520. $Url_redirect="contract_appointment_letter.php";
  1521. break;
  1522. case "Sabbatical":
  1523. $Url_redirect="sabbatical_appoint_letter.php";
  1524. break;
  1525. case "Junior Staff":
  1526. $Url_redirect="junior_staff_appointment_letter.php";
  1527. break;
  1528. }
  1529. return $Url_redirect;
  1530. }
  1531. //function to determines you as either Sir or Madam to be used in the appointment letter
  1532. function get_salutation($applicant_id){
  1533. $salution='';
  1534. $gender='';
  1535. $query=mysql_query("select gender from tblapplicantscvs inner join tbladvertresponses on
  1536. tbladvertresponses.responseid=tblapplicantscvs.advertresponseid where tbladvertresponses.applicantid=$applicant_id");
  1537. if(mysql_num_rows($query)==1){
  1538. $row=mysql_fetch_assoc($query);
  1539. $gender=$row['gender'];
  1540. }
  1541. switch($gender){
  1542. case 'M':
  1543. $salution='Sir';
  1544. break;
  1545. case 'F':
  1546. $salution='Madam';
  1547. break;
  1548. }
  1549. return $salution;
  1550. }
  1551. //function to format the date from the date(example 1st July, 2012) from the format dd/mm/yyyy
  1552. function format_day_from_date($date){
  1553. $splitedate=explode('/',$date);
  1554. $day=$splitedate[0];
  1555. $month=$splitedate[1];
  1556. $year=$splitedate[2];
  1557. $format='';
  1558. switch($day){
  1559. case 1: case 21: case 31:
  1560. $format='<sup>st</sup>';
  1561. break;
  1562. case 2: case 22:
  1563. $format='<sup>nd</sup>';
  1564. break;
  1565. case 3: case 23:
  1566. $format='<sup>rd</sup>';
  1567. break;
  1568. default:
  1569. $format='<sup>th</sup>';
  1570. }
  1571. return ($day.$format.' '.trim(get_month_name($month,'???')).','.' '.$year);
  1572. }
  1573. // function to get salary amount for any Grade Level, Step, and Salary Category;
  1574. function get_salary($grade_level,$step,$salaryid){
  1575. $amount=0.0;
  1576. $query=mysql_query("SELECT amount from tblsalaryplacement WHERE (grade=$grade_level AND step=$step AND salaryid=$salaryid)")or
  1577. die("Query cannot be executed: ".mysql_error());
  1578. if(mysql_num_rows($query)>0){
  1579. $amount=mysql_result($query,0,'amount');
  1580. }
  1581. return $amount;
  1582. }
  1583. // function to show salary amount fro a specific applicant
  1584. function get_applicant_salary($applicantid, $advertid){
  1585. $advertresponseid=get_advertresponse_id($applicantid,$advertid);
  1586. $gradelevel='';
  1587. $salaryid=0;
  1588. $amount=0.0;
  1589. $query=mysql_query("select gradelevel, salaryid from tblapplicantsappointments where advertresponseid=$advertresponseid");
  1590. if(mysql_num_rows($query)>0){
  1591. while($row=mysql_fetch_assoc($query)){
  1592. $gradelevel=$row['gradelevel'];
  1593. $salaryid=$row['salaryid'];
  1594. }
  1595. $splited_grade_step=explode('/',$gradelevel);
  1596. $grade=$splited_grade_step[0];
  1597. $step=$splited_grade_step[1];
  1598. }
  1599. $amount=get_salary($grade,$step,$salaryid);
  1600. return number_format($amount,2,":",",");
  1601. }
  1602. //function to get the maximum step for a particular salary category and grade
  1603. function get_max_step($grade,$salaryid){
  1604. $maxstep=0;
  1605. $query=mysql_query("select max(step) as maxstep from tblsalaryplacement where grade=$grade and salaryid=$salaryid");
  1606. if(mysql_num_rows($query)==1){
  1607. $maxstep=mysql_result($query,0,'maxstep');
  1608. }
  1609. return $maxstep;
  1610. }
  1611. // function get range of salary to be displayed in appointment letter
  1612. function get_range_of_salary($applicantid, $advertid){
  1613. $advertresponseid=get_advertresponse_id($applicantid,$advertid);
  1614. $maxstep=0;
  1615. $query=mysql_query("select gradelevel,salaryid from tblapplicantsappointments where advertresponseid=$advertresponseid");
  1616. if(mysql_num_rows($query)>0){
  1617. $row=mysql_fetch_assoc($query);
  1618. $grade_step=$row['gradelevel'];
  1619. $salaryid=$row['salaryid'];
  1620. $splited_grade_step=explode('/',$grade_step);
  1621. $grade=$splited_grade_step[0];
  1622. $maxstep=get_max_step($grade,$salaryid);
  1623. }
  1624. $amount="N".number_format(get_salary($grade,1,$salaryid),2,":",",")." - "."N".number_format(get_salary($grade,$maxstep,$salaryid),2,":",",");
  1625. return $amount;
  1626. }
  1627. // function to get Salary Category CONTISS CONNUAS
  1628. function get_salary_category_from_id($salary_categoryid){
  1629. $salary_category="";
  1630. if($salary_categoryid>1 || $salary_categoryid !=""){
  1631. $query=mysql_query("select category from tblsalarytable where salaryid=$salary_categoryid");
  1632. if(mysql_num_rows($query)==1){
  1633. $salary_category=mysql_result($query,0,'category');
  1634. }
  1635. }
  1636. return $salary_category;
  1637. }
  1638. // function to get applicant Salary Category weather CONTISS CONNUAS
  1639. function get_applicant_salary_category($applicantid, $advertid){
  1640. $advertreponseid=get_advertresponse_id($applicantid,$advertid);
  1641. $salaryid=0;
  1642. $query=mysql_query("select salaryid from tblapplicantsappointments where advertresponseid=$advertreponseid");
  1643. if(mysql_num_rows($query)>0){
  1644. while($row=mysql_fetch_assoc($query)){
  1645. $salaryid=$row['salaryid'];
  1646. }
  1647. }
  1648. return get_salary_category_from_id($salaryid);
  1649. }
  1650. // grade like 07/02, 08/03 etc
  1651. function get_applicant_grade_level($applicantid, $advertid){
  1652. $advertreponseid=get_advertresponse_id($applicantid,$advertid);
  1653. $gradelevel='';
  1654. $query=mysql_query("select gradelevel from tblapplicantsappointments where advertresponseid=$advertreponseid");
  1655. if(mysql_num_rows($query)>0){
  1656. while($row=mysql_fetch_assoc($query)){
  1657. $gradelevel=$row['gradelevel'];
  1658. }
  1659. }
  1660. return $gradelevel;
  1661. }
  1662. // function to return the effective and end date of contract appointment
  1663. function get_contract_date($applicantid, $advertid){
  1664. $advertreponseid=get_advertresponse_id($applicantid,$advertid);
  1665. $gradelevel='';
  1666. $query=mysql_query("select contracteffectivedate,contractenddate from tblapplicantsappointments where advertresponseid=$advertreponseid");
  1667. if(mysql_num_rows($query)>0){
  1668. while($row=mysql_fetch_assoc($query)){
  1669. $contracteffectivedate=get_date_ddmmyyyy($row['contracteffectivedate']);
  1670. $contractenddate=get_date_ddmmyyyy($row['contractenddate']);
  1671. }
  1672. }
  1673. return format_day_from_date($contracteffectivedate)." to ".format_day_from_date($contractenddate);
  1674. }
  1675. //function to return session for Temporary Part-Time Appointement
  1676. function get_temporary_part_time_session($applicantid, $advertid){
  1677. $advertreponseid=get_advertresponse_id($applicantid,$advertid);
  1678. $temporarysession='';
  1679. $query=mysql_query("select temporarysession from tblapplicantsappointments where advertresponseid=$advertreponseid");
  1680. if(mysql_num_rows($query)>0){
  1681. while($row=mysql_fetch_assoc($query)){
  1682. $temporarysession=$row['temporarysession'];
  1683. }
  1684. }
  1685. return $temporarysession;
  1686. }
  1687. //function to return hourly rate for temporary part-time appointment
  1688. function get_hourly_rate($applicantid,$advertid){
  1689. $amount=0;
  1690. $advertreponseid=get_advertresponse_id($applicantid,$advertid);
  1691. $query=mysql_query("select hourlyrate from tblapplicanthourlyrate where rankid=(select designation from tblapplicantsappointments where advertresponseid=$advertreponseid)")or
  1692. die("Query cannot be executed: ".mysql_error());
  1693. if(mysql_num_rows($query)<1){
  1694. $amount=number_format(0,2,'.',',');
  1695. }else{
  1696. $amount=number_format(mysql_result($query,0,'hourlyrate'),2,'.',',');
  1697. }
  1698. return $amount;
  1699. }
  1700. // function that will retrieve the posted applicant's records from tblapplicantappointments to be edited
  1701. function get_applicant_appointment_settings($applicantid, $advertid){
  1702. $advertreponseid=get_advertresponse_id($applicantid,$advertid);
  1703. $query=mysql_query("select appointmenttype,contracteffectivedate,contractenddate,temporarysession,departmentid,
  1704. gradelevel,salaryid from tblapplicantsappointments where advertresponseid=$advertreponseid");
  1705. if(mysql_num_rows($query)>0){
  1706. while($row=mysql_fetch_assoc($query)){
  1707. $appointmenttype=$row['appointmenttype'];
  1708. $contracteffectivedate=$row['contracteffectivedate'];
  1709. $contractenddate=$row['contractenddate'];
  1710. $gradelevel=$row['gradelevel'];
  1711. $salaryid=$row['salaryid'];
  1712. $temporarysession=$row['temporarysession'];
  1713. }
  1714. }
  1715. if($appointmenttype!=0){
  1716. $sql=mysql_query("SELECT * FROM tblapplicantappointmenttype") or die("Query cannot be executed! ".mysql_error());
  1717. echo "<div>";
  1718. echo "<div>Appintment Type:</div>";
  1719. echo "<div><select name='appointtype'>";
  1720. echo "<option value='0'>--Please select--</option>";
  1721. while($row=mysql_fetch_assoc($sql)){
  1722. $appint_type=$row['appointmenttype'];
  1723. $appointmenttype_id=$row['appointmenttypeid'];
  1724. if($appointmenttype==$appointmenttype_id){
  1725. echo "<option value='$appointmenttype_id' selected>$appint_type</option>";
  1726. }else{
  1727. echo "<option value='$appointmenttype_id'>$appint_type</option>";
  1728. }
  1729. }
  1730. echo "</select></div>";
  1731. echo "</div>";
  1732. }
  1733. if(get_appointment_type_from_id($appointmenttype)=="Contract"){
  1734. $contract_from=get_date_ddmmyyyy($contracteffectivedate);
  1735. $contract_to=get_date_ddmmyyyy($contractenddate);
  1736. echo "<div class='span2'>";
  1737. echo "<div>Effective Date:</div>";
  1738. echo "<div><input type='text' name='contract_from' value='$contract_from'/></div>";
  1739. echo "</div>";
  1740. echo "<div class='span2'>";
  1741. echo "<div>End Date:</div>";
  1742. echo "<div><input type='text' name='contract_to' value='$contract_to'/></div>";
  1743. echo "</div>";
  1744. }
  1745. if(get_appointment_type_from_id($appointmenttype)=="Tenure" || get_appointment_type_from_id($appointmenttype)=="Junior Staff" || get_appointment_type_from_id($appointmenttype)=="Temporary Month-to-Month"
  1746. || get_appointment_type_from_id($appointmenttype)=="Sabbatical" || get_appointment_type_from_id($appointmenttype)=="Visiting"){
  1747. if(get_appointment_type_from_id($appointmenttype)=="Tenure"){
  1748. if(is_rank_academic($advertid)==true){
  1749. $checktrue="checked";
  1750. }else{
  1751. $checkfalse="checked";
  1752. }
  1753. echo "<div class='span3 control-group'>";
  1754. echo "<div><input type='radio' name='staff_category' value='Academic' $checktrue />Academic Staff &nbsp;&nbsp; <input type='radio' name='staff_category' value='Non-Academic' $checkfalse />Non Academic Staff</div>";
  1755. echo "</div>";
  1756. }
  1757. echo "<div class='span2'>";
  1758. echo "<div>Salary Scale:</div>";
  1759. echo "<div><select name='salary_category' id='salary_category'>";
  1760. echo "<option value='0'>--Please select--</option>";
  1761. $query=mysql_query("select salaryid,category from tblsalarytable");
  1762. if (mysql_num_rows($query)>0){
  1763. for($i=0;$i<mysql_num_rows($query);$i++){
  1764. $salary_id=mysql_result($query,$i,'salaryid');
  1765. $category=mysql_result($query,$i,'category');
  1766. if($salaryid==$salary_id){
  1767. echo "<option value='$salary_id' selected>$category</option>";
  1768. }else{
  1769. echo "<option value='$salary_id'>$category</option>";
  1770. }
  1771. }
  1772. }
  1773. echo "</select></div>";
  1774. echo "</div>";
  1775. $gradelevel_step=explode('/',$gradelevel);
  1776. $gradelevel=$gradelevel_step[0];
  1777. $step=$gradelevel_step[1];
  1778. echo "<div class='span2'>";
  1779. echo "<div>Grade Level:</div>";
  1780. echo "<div><select name='gradelevel' id='gradelevel'>";
  1781. echo "<option value='0'>--Please Select--</option>";
  1782. for($i=1;$i<=15;$i++){
  1783. if($i<10)
  1784. $i='0'.$i;
  1785. if($gradelevel==$i){
  1786. echo "<option value='$i' selected>$i</option>";
  1787. }else{
  1788. echo "<option value='$i'>$i</option>";
  1789. }
  1790. }
  1791. echo "</select></div>";
  1792. echo "</div>";
  1793. echo "<div>Step:</div>";
  1794. echo "<div><select name='step' id='step'>";
  1795. echo "<option value='0'>--Please Select--</option>";
  1796. for($i=1;$i<=15;$i++){
  1797. if($i<10)
  1798. $i='0'.$i;
  1799. if($step==$i){
  1800. echo "<option value='$i' selected>$i</option>";
  1801. }else{
  1802. echo "<option value='$i'>$i</option>";
  1803. }
  1804. }
  1805. echo "</select></div>";
  1806. echo "</div>";
  1807. }//end if Tunure
  1808. if(get_appointment_type_from_id($appointmenttype)=="Temporary Part-Time"){
  1809. echo "<div class='span2'>";
  1810. echo "<div>Session:<div>";
  1811. echo "<div><input type='text' name='temporary_parttime_session' value='$temporarysession'/></div>";
  1812. echo "</div>";
  1813. }//end if temporary part time
  1814. }// end function get_applicant_appointment_settings
  1815. // function to determine where to send a copy of appointment letter
  1816. function send_copy_of_appointment_to($departmentid){
  1817. $result="";
  1818. $query=mysql_query("select tblunitheads.unitheaddescription from tblunitheads
  1819. inner join tbldepartment on tbldepartment.unitheadid=tblunitheads.unitheadid where tbldepartment.departmentid=$departmentid")
  1820. or die("Query cannot be executed: ".mysql_error());
  1821. if(mysql_num_rows($query)==1)
  1822. $result=mysql_result($query,0,'unitheaddescription');
  1823. else
  1824. $result="The unit is not defined to recieved a copy";
  1825. return $result;
  1826. }
  1827. // function to display either as in the department of or in the Iya Abubakar Computer Centre etc.
  1828. function show_department($departmentid){
  1829. $append="";
  1830. $result=send_copy_of_appointment_to($departmentid);
  1831. switch($result){
  1832. case "Head of Department" :
  1833. $append="Department of";
  1834. break;
  1835. default:
  1836. $append="";
  1837. break;
  1838. }
  1839. return $append;
  1840. }
  1841. // function to determine whether is VC's Office or Office of the Bursar
  1842. function is_vc_office_or_bursar($departmentid){
  1843. $status=false;
  1844. $result=send_copy_of_appointment_to($departmentid);
  1845. switch($result){
  1846. case "Vice-Chancellor" : case "Bursar" :
  1847. $status=true;
  1848. break;
  1849. default:
  1850. $status=false;
  1851. break;
  1852. }
  1853. return $status;
  1854. }
  1855. function get_advertresponse_id($applicantid, $advert_id){
  1856. $advertresponseid=0;
  1857. $query=mysql_query("select tbladvertresponses.responseid from tbladvertresponses where
  1858. tbladvertresponses.applicantid=$applicantid AND tbladvertresponses.advertid=$advert_id");
  1859. if(mysql_num_rows($query)>0){
  1860. $advertresponseid=mysql_result($query,0,'responseid');
  1861. }
  1862. return $advertresponseid;
  1863. }
  1864. function is_applicant_appointment_ready($applicantid,$advert_id){
  1865. $status=false;
  1866. $advertresponseid=get_advertresponse_id($applicantid, $advert_id);
  1867. $query=mysql_query("select notified from tblapplicantsappointments where advertresponseid=$advertresponseid ")
  1868. or die("Query cannot be executed: ".mysql_error());
  1869. if(mysql_num_rows($query)>0){
  1870. $notified=mysql_result($query,0,'notified');
  1871. if($notified=="yes"){
  1872. $status=true;
  1873. }
  1874. }
  1875. return $status;
  1876. }
  1877. function show_Applicant_appointment($applicantid,$advert_id){
  1878. $advertresponseid=get_advertresponse_id($applicantid, $advert_id);
  1879. $pnumber='';
  1880. $salaryscale='';
  1881. $appointmenttypeid=0;
  1882. $query=mysql_query("select appointmenttype, gradelevel from tblapplicantsappointments where advertresponseid=$advertresponseid");
  1883. if(mysql_num_rows($query)>0){
  1884. $row=mysql_fetch_assoc($query);
  1885. $appointmenttypeid=$row['appointmenttype'];
  1886. //$appointmenttype=get_appointment_type_from_id($row['appointmenttype']);
  1887. }
  1888. return get_appointment_template($appointmenttypeid);;
  1889. }
  1890. function load_relationships(){
  1891. $cmb = '<option value = "-1" selected="selected">-- Please Select --</option>';
  1892. $cmb .= '<option value = "Spouse">Spouse</option>';
  1893. $cmb .= '<option value = "Biological Child">Biological Child</option>';
  1894. $cmb .= '<option value = "Legal Ward">Legal Ward</option>';
  1895. return $cmb;
  1896. }
  1897. function load_state(){
  1898. $cmb = '';
  1899. $q = "SELECT stateid, statename FROM tblstate ORDER BY statename";
  1900. $query = mysql_query($q);
  1901. $foundRecord = mysql_num_rows($query);
  1902. if ($foundRecord >= 1) {
  1903. $cmb = '<option value = "-1">-- Please Select --</option>';
  1904. while($row = mysql_fetch_assoc($query)){
  1905. //$i++;
  1906. if($row['stateid'] == $stateID){
  1907. $cmb .= "<option value='" . $row['stateid'] . "' selected='selected'>" . $row['statename'] . "</option>";
  1908. }else{
  1909. $cmb .= "<option value='" . $row['stateid'] . "'>" . $row['statename'] . "</option>";
  1910. }
  1911. }//end while
  1912. $cmb .= "<option value = '0'>-- Others --</option>";
  1913. }else{
  1914. $cmb = "<option value = '-1'>No Data in State Table</option>";
  1915. }//end if ($foundRecord == 1)
  1916. echo $cmb;
  1917. }
  1918. function load_senatorialdistrict($stateID, $session_senatorialDistrict){
  1919. $cmb = '';
  1920. $q = "SELECT senatorial_id, senatorialdistrictname FROM tbldistrict WHERE stateid = $stateID";
  1921. $query = mysql_query($q);
  1922. $foundRecord = mysql_num_rows($query);
  1923. if ($foundRecord >= 1) {
  1924. $cmb .= "<option value = '-1'>-- Please Select --</option>";
  1925. while($row = mysql_fetch_assoc($query)){
  1926. if($session_senatorialDistrict == $row['senatorialdistrictname']){
  1927. $cmb .= "<option value='" . $row['senatorial_id'] . "' selected='selected'>" . $row['senatorialdistrictname'] . "</option>";
  1928. }else{
  1929. $cmb .= "<option value='" . $row['senatorial_id'] . "'>" . $row['senatorialdistrictname'] . "</option>";
  1930. }
  1931. }//end while
  1932. }else{
  1933. $cmb = "<option value = '-1'>No Data in Senatorial District Table</option>";
  1934. }//end if ($foundRecord == 1)
  1935. //$stateID = $row['senatorial_id'];
  1936. return $cmb;
  1937. }
  1938. function load_senatorialID($state_id){
  1939. $cmb = '';
  1940. $q = "SELECT senatorial_id, senatorialdistrictname FROM tbldistrict WHERE stateid = $state_id";
  1941. /*if(isset($state_id) && $state_id > 0){
  1942. $q .= "WHERE stateid = $state_id";
  1943. }*/
  1944. //$q .= "ORDER BY senatorialdistrictname";
  1945. $query = mysql_query($q) or die("Query cannoe be executed: ".mysql_error());
  1946. $foundRecord = mysql_num_rows($query);
  1947. if ($foundRecord >= 1) {
  1948. $cmb .= "<option value = '-1'>-- Please Select --</option>";
  1949. while($row = mysql_fetch_assoc($query)){
  1950. $cmb .= "<option value='" . $row['senatorial_id'] . "'>" . $row['senatorialdistrictname'] . "</option>";
  1951. }//end while
  1952. }else{
  1953. $cmb = "<option value = '-1'>No Data in Senatorial District Table</option>";
  1954. }//end if ($foundRecord == 1)
  1955. //$stateID = $row['senatorial_id'];
  1956. return $cmb;
  1957. }
  1958. function load_gender(){
  1959. $cmb = '<option value = "-1">-- Please Select --</option>';
  1960. if(isset($_SESSION['bio_Gender']) && $_SESSION['bio_Gender'] == 'M'){
  1961. $cmb .= '<option value = "M" selected="selected">Male</option>';
  1962. }else{
  1963. $cmb .= '<option value = "M">Male</option>';
  1964. }
  1965. if(isset($_SESSION['bio_Gender']) && $_SESSION['bio_Gender'] == 'F'){
  1966. $cmb .= '<option value = "F" selected="selected">Female</option>';
  1967. }else{
  1968. $cmb .= '<option value = "F">Female</option>';
  1969. }
  1970. echo $cmb;
  1971. }
  1972. function loadGender($session_Gender){
  1973. $cmb = '<option value = "-1">-- Please Select --</option>';
  1974. if(isset($session_Gender) && $session_Gender == 'Male'){
  1975. $cmb .= '<option value = "M" selected="selected">Male</option>';
  1976. }else{
  1977. $cmb .= '<option value = "Male">Male</option>';
  1978. }
  1979. if(isset($session_Gender) && $session_Gender == 'Female'){
  1980. $cmb .= '<option value = "Female" selected="selected">Female</option>';
  1981. }else{
  1982. $cmb .= '<option value = "Female">Female</option>';
  1983. }
  1984. return $cmb;
  1985. }
  1986. ?>