PageRenderTime 42ms CodeModel.GetById 10ms 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

Large files files are truncated, but you can click here to view the full file

  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.advertis…

Large files files are truncated, but you can click here to view the full file