Guest User

Untitled

a guest
Jul 8th, 2017
294
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 303.19 KB | None | 0 0
  1. <?php
  2.  
  3. error_reporting(E_ALL ^ E_NOTICE);
  4. sfLoader::loadHelpers(array('Tag', 'Url'));
  5. include(sfConfig::get('sf_app_template_dir') . '/DBFragment.php');
  6.  
  7. /**
  8. * main actions.
  9. *
  10. * @package myproject
  11. * @subpackage main
  12. * @author bob
  13. * @version SVN: $Id: actions.class.php 9301 2008-05-27 01:08:46Z dwhittle $
  14. */
  15. class mainActions extends sfActions {
  16.  
  17. public function executeNoScript() {
  18. $module = 'main';
  19. $action = 'index';
  20. $link = link_to('Try again', $module . '/' . $action);
  21. $html = '<font face=arial>JavaScript must be enabled in order for you to use <i> Performance Evaluation System</i>. It seems JavaScript is either disabled or not supported by your browser.' . $link . '
  22. </font>';
  23. $html = '<br><br><br><br><br>
  24. <table border="0" style="border:1px solid #455F76;"><TR><TD style="color:#619B09; font-size:13px;">' . $html . '</TD></TR></table>';
  25. echo $html;
  26. die;
  27. }
  28.  
  29. public function executeAjaxPager() {
  30. $this->pager = $this->getPager();
  31. }
  32.  
  33. public function executeIndex(sfWebRequest $request) {
  34. if (isset($_SESSION['empId'])) {
  35. $role = $_SESSION['empRole'];
  36. if ($role == "admin") {
  37. $empId = $this->getUser()->getAttribute('empId');
  38. $team_members = GroupwareEmployeesPeer::getAllSubordinatesId($empId);
  39. $nc = new Criteria();
  40. $nc->add(PeDatesPeer::NAME, 'Dashboard');
  41. $resultset = PeDatesPeer::doSelect($nc);
  42. if ($resultset) {
  43. $dashboardDate = $resultset[0]->getYear();
  44. $DateArray = explode('-', $dashboardDate);
  45. $this->year = $DateArray[0];
  46. $this->startdate = $dashboardDate;
  47. }
  48. else {
  49. $this->year = Date("Y");
  50. $this->startdate = Date("Y-m-d");
  51. }
  52. $this->search_pattern = "%" . $this->year . "%";
  53.  
  54. $criteria = new Criteria();
  55. $criteria->add(PeEmployeesPeer::EMPID, $team_members, CRITERIA::IN);
  56. $criteria->add(PeEmployeesPeer::STATUSID, 2);
  57. // $criteria->add(PeEmployeesPeer::ISSUEDATE, $this->search_pattern, CRITERIA::LIKE);
  58. $criteria->add(PeEmployeesPeer::ISSUEDATE, $this->startdate, Criteria::GREATER_EQUAL);
  59. $this->kids_count = PeEmployeesPeer::doCount($criteria);
  60.  
  61. $c = new Criteria();
  62. $direct_teammembers = GroupwareEmployeesPeer::getSubordinatesId($empId);
  63. $c->add(PeEmployeesPeer::EMPID, $direct_teammembers, CRITERIA::IN);
  64. $c->add(PeEmployeesPeer::STATUSID, 4);
  65. // $c->add(PeEmployeesPeer::ISSUEDATE, $this->search_pattern, CRITERIA::LIKE);
  66. $c->add(PeEmployeesPeer::ISSUEDATE, $this->startdate, Criteria::GREATER_EQUAL);
  67. $this->kids_origin_count = PeEmployeesPeer::doCount($c);
  68.  
  69. $PeAssignedadminPeer = new PeAssignedadminPeer;
  70. $c1 = new Criteria();
  71. $assigned_teammembers = PeAssignedadminPeer::getAssignedEmployeesId($empId);
  72. $c1->add(PeEmployeesPeer::EMPID, $assigned_teammembers, CRITERIA::IN);
  73. $c1->add(PeEmployeesPeer::STATUSID, 4);
  74. // $c1->add(PeEmployeesPeer::ISSUEDATE, $this->search_pattern, CRITERIA::LIKE);
  75. $c1->add(PeEmployeesPeer::ISSUEDATE, $this->startdate, Criteria::GREATER_EQUAL);
  76. $this->assignkids_count = PeEmployeesPeer::doCount($c1);
  77.  
  78. $PeEmployeesPeer = new PeEmployeesPeer();
  79. $this->reevaluate = $PeEmployeesPeer->getReevaluatePE($team_members, $this->startdate);
  80. $this->acceptemployee = $PeEmployeesPeer->getAcceptanceEmp($team_members, $this->startdate);
  81. $this->accepetedbyemp = $PeEmployeesPeer->getAccepetedByEmp($team_members, $this->startdate);
  82. $this->accepetedbyadmin = $PeEmployeesPeer->getAccepetedByAdmin($team_members, $this->startdate);
  83. $this->escalatedtocore = $PeEmployeesPeer->getEscalatedToCore($team_members, $this->startdate);
  84. $this->approved = $PeEmployeesPeer->getCoreApprovedPE($team_members, $this->startdate);
  85. $this->monthlyPE = $PeEmployeesPeer->getMonthlyPE($team_members, $this->startdate);
  86.  
  87. // To list monthly PE employee comments added count in dashboard refs #100211
  88. $this->monthlyPeAccepetedByEmp = $PeEmployeesPeer->getmonthlyPeAccepetedByEmp($team_members, $this->startdate);
  89. $this->getPeAdminNotification();
  90. }elseif (($role == "core") || ($role == "hr")) {
  91. $nc = new Criteria();
  92. $nc->add(PeDatesPeer::NAME, 'Dashboard');
  93. $resultset = PeDatesPeer::doSelect($nc);
  94. if ($resultset) {
  95. $dashboardDate = $resultset[0]->getYear();
  96. $DateArray = explode('-', $dashboardDate);
  97. $this->year = $DateArray[0];
  98. $this->startdate = $dashboardDate;
  99. }
  100. else {
  101. $this->year = Date("Y-m-d");
  102. }
  103. $PeEmployeesPeer = new PeEmployeesPeer();
  104. $this->staff_count = $PeEmployeesPeer->getStaffPE($this->startdate);
  105. $this->admin_staff_count = $PeEmployeesPeer->getStaffOriginalPE($this->startdate);
  106. $this->reevaluate = $PeEmployeesPeer->getReevaluatePE('', $this->startdate);
  107. $this->acceptemployee = $PeEmployeesPeer->getAcceptanceEmp('', $this->startdate);
  108. $this->accepetedbyemp = $PeEmployeesPeer->getAccepetedByEmp('', $this->startdate);
  109. $this->accepetedbyadmin = $PeEmployeesPeer->getAccepetedByAdmin('', $this->startdate);
  110. $this->escalatedtocore = $PeEmployeesPeer->getEscalatedToCore('', $this->startdate);
  111. $this->approved = $PeEmployeesPeer->getCoreApprovedPE('', $this->startdate);
  112. $this->monthlyPE = $PeEmployeesPeer->getMonthlyPE('', $this->startdate);
  113.  
  114. // To list monthly PE employee comments added count in dashboard refs #100211
  115. $this->monthlyPeAccepetedByEmp = $PeEmployeesPeer->getmonthlyPeAccepetedByEmp('', $this->startdate);
  116.  
  117. $this->getPeCoreNotification();
  118. }
  119. elseif (($role == 'staff') || ($role == 'qm')) {
  120. $this->getPeNotification();
  121. }
  122. }else
  123. $this->redirect('login/index');
  124. }
  125.  
  126. /**
  127. * Executes View action
  128. *
  129. * @param sfRequest $request A request object
  130. */
  131. public function executeView(sfWebRequest $request) {
  132. $empId = $request->getParameter('Self') ? $request->getParameter('Self') : $request->getParameter('Original');
  133. if ($empId) {
  134. $date = $request->getParameter('date');
  135. $tmpDate = explode('-', $date);
  136. $issueYear = '%' . $tmpDate[0] . '%';
  137. // To check whether an original PE of status >=6 exist for this employee
  138. $newCriteria = new Criteria();
  139. $newCriteria->add(PeEmployeesPeer::EMPID, $empId);
  140. $newCriteria->add(PeEmployeesPeer::TYPE, ORIGINALCODE);
  141. $newCriteria->add(PeEmployeesPeer::ISSUEDATE, $issueYear, Criteria::LIKE);
  142. $resultSet = PeEmployeesPeer::doSelect($newCriteria);
  143. if (!empty($resultSet)) {
  144. $peIdStatus = $resultSet[0]->getStatusId();
  145. } else {
  146. // No original PE form exist for this year
  147. $peIdStatus = 1; // Default status
  148. }
  149. $criteria = new Criteria();
  150. $criteria->add(PeEmployeesPeer::EMPID, $empId);
  151. $criteria->add(PeEmployeesPeer::ISSUEDATE, $issueYear, Criteria::LIKE);
  152. if ($request->getParameter('Self')) {
  153. $criteria->add(PeEmployeesPeer::TYPE, SELFCODE);
  154. } else {
  155. $criteria->add(PeEmployeesPeer::TYPE, ORIGINALCODE);
  156. }
  157. $criteria->addSelectColumn(PeEmployeesPeer::PEID);
  158. $result = PeEmployeesPeer::doSelect($criteria);
  159. if (!empty($result) && (($this->isCore() || $this->isHr()) || $peIdStatus >= 6 )) {
  160. $this->redirect('main/PeForm?view=' . $result[0]->getPeId());
  161. } else {
  162. $_SESSION['error_msg'] = 'Sorry, No PE form found!!!';
  163. $this->redirect('main/index');
  164. }
  165. }
  166. }
  167.  
  168. //added by renjo to redirect to staff or admin form when MyPeform is clicked
  169. public function executeMyPeForm(sfWebRequest $request) {
  170. $empId = $_SESSION['empId'];
  171. $criteria = new Criteria();
  172. $criteria->add(PeChangeformPeer::EMPID, $empId);
  173. $results = PeChangeformPeer::doSelect($criteria);
  174. if ($results) {
  175. $formType = $results[0]->getFormType();
  176. if ($formType == STAFF)
  177. $this->redirect('main/StaffPEForm');
  178. else if ($formType == ADMIN)
  179. $this->redirect('main/AdminPEForm');
  180. }else if ($this->isAdmin()) {
  181. $this->redirect('main/AdminPEForm');
  182. } else if ($this->isStaff()) {
  183. $this->redirect('main/StaffPEForm');
  184. }
  185. }
  186.  
  187. public function executePeForm(sfWebRequest $request) {
  188. $peEmployeesInstance = new PeEmployeesPeer();
  189. if ($this->getRequestParameter('edit')) {
  190. $peId = $this->getRequestParameter('edit');
  191. // ************************REDIRECTION TO NEW PE FORM********************
  192.  
  193. if ($peId > MAX_OLD_2009) {
  194. $this->redirect('index/pe?edit=' . $peId);
  195. }
  196.  
  197. // ***********************************************************************
  198.  
  199. if ($this->isEditable($peId)) {
  200. $peOwner = $peEmployeesInstance->whosePEForm($peId);
  201. switch ($peOwner) {
  202. case '0':if ($this->getRequestParameter('status') == "monthlysave") {
  203. $_SESSION['status'] = "monthlysave";
  204. $this->redirect('main/AdminPEForm?edit=' . $peId . '&type=monthly');
  205. } else if ($this->getRequestParameter('status') == "adminsave") {
  206. $_SESSION['status'] = "adminsave";
  207. $this->redirect('main/AdminPEForm?edit=' . $peId . '&type=original');
  208. } else if ($this->getRequestParameter('value') == "staffSaved") {
  209. $this->redirect('main/AdminPEForm?edit=' . $peId);
  210. } elseif ($this->getRequestParameter('type') == "original") {
  211. $this->redirect('main/AdminPEForm?edit=' . $peId . '&type=original');
  212. } else {
  213. $this->redirect('main/AdminPEForm?edit=' . $peId);
  214. }
  215. break;
  216. case '1':
  217. if ($this->getRequestParameter('status') == "adminsave") {
  218. $_SESSION['status'] = "adminsave";
  219. $this->redirect('main/QMPEForm?edit=' . $peId . '&type=original');
  220. } elseif ($this->getRequestParameter('type') == "original") {
  221. $this->redirect('main/QMPEForm?edit=' . $peId . '&type=original');
  222. } else {
  223. $this->redirect('main/QMPEForm?edit=' . $peId);
  224. }
  225. break;
  226. case '2':if ($this->getRequestParameter('status') == "monthlysave") {
  227. $_SESSION['status'] = "monthlysave";
  228. $this->redirect('main/StaffPEForm?edit=' . $peId . '&type=monthly');
  229. } else if ($this->getRequestParameter('status') == "adminsave") {//echo "in staff";die;
  230. $_SESSION['status'] = "adminsave";
  231. $this->redirect('main/StaffPEForm?edit=' . $peId . '&type=original');
  232. } else if ($this->getRequestParameter('value') == "staffSaved") {
  233. $this->redirect('main/StaffPEForm?edit=' . $peId);
  234. } elseif ($this->getRequestParameter('type') == "original") {
  235. $this->redirect('main/StaffPEForm?edit=' . $peId . '&type=original');
  236. } else {
  237. $this->redirect('main/StaffPEForm?edit=' . $peId);
  238. }
  239. break;
  240. default:
  241. $_SESSION['error_msg'] = 'No Such PE form Exists';
  242. $this->redirect('main/ListPEForm');
  243. break;
  244. }
  245. } else {
  246. $_SESSION['error_msg'] = 'Not authorized to edit the Pe form';
  247. $this->redirect('main/index');
  248. }
  249. } elseif ($this->getRequestParameter('view')) {
  250. $peId = $this->getRequestParameter('view');
  251. // **************************REDIRECTION TO NEW PE FORM***************
  252.  
  253. if ($peId > MAX_OLD_2009) {
  254. $this->redirect('index/pe?view=' . $peId);
  255. }
  256.  
  257. // ********************************************************************
  258. $peOwner = $peEmployeesInstance->whosePEForm($peId);
  259. if ($this->isViewable($peId)) {
  260. switch ($peOwner) {
  261. case '0':
  262. $this->redirect('main/AdminPEForm?view=' . $peId);
  263. break;
  264. case '1':
  265. $this->redirect('main/QMPEForm?view=' . $peId);
  266. break;
  267. case '2':
  268. $this->redirect('main/StaffPEForm?view=' . $peId);
  269. break;
  270. default:
  271. $_SESSION['error_msg'] = 'No Such PE form Exists';
  272. $this->redirect('main/ListPEForm');
  273. break;
  274. }
  275. } else {
  276. $_SESSION['error_msg'] = 'Not authorized to view the Pe form';
  277. $this->redirect('main/index');
  278. }
  279. } elseif ($this->getRequestParameter('delete')) {
  280. $peId = $this->getRequestParameter('delete');
  281. $criteria = new Criteria();
  282. $criteria->add(PeEmployeesPeer::PEID, $peId);
  283. $result = PeEmployeesPeer::doSelect($criteria);
  284. if ($result) {
  285. $takenById = $result[0]->getTakenBy();
  286. if ($takenById != $this->getUser()->getAttribute('empId') && !$this->coreCheck($takenById)) {
  287. $_SESSION['error_msg'] = 'Not authorized to delete the Pe form';
  288. $this->redirect('main/index');
  289. }
  290. }
  291. $this->redirect('main/deletePEForm?delete=' . $peId);
  292. } else {
  293. $_SESSION['error_msg'] = 'Unable to proccess your request';
  294. }
  295. }
  296.  
  297. /**
  298. * Executes admin Form display action
  299. *
  300. * @param sfRequest $request A request object
  301. */
  302. public function executeAdminPEForm(sfWebRequest $request) {
  303. if (isset($_SESSION['empId'])) {
  304. if ($request->isMethod('post')) {
  305. $this->getPostedValues();
  306. }
  307. if ($this->getRequestParameter('edit') && (($this->getRequestParameter('type') == "original") || ($this->getRequestParameter('type') == "monthly"))) {
  308. $peId = $this->getRequestParameter('edit');
  309. if ($this->isEditable($peId)) {
  310. if ($this->isAdmin() || $this->isCore()) {
  311. if ($this->isAdmin()) {
  312. $currentAdmin = false;
  313. $hasAdminThisPeriod = false;
  314. $criteria = new Criteria();
  315. $criteria->add(PeEmployeesPeer::PEID, $peId);
  316. $users = PeEmployeesPeer::doSelect($criteria);
  317. $empid = $users[0]->getEmpid();
  318. $takenBy = $users[0]->getTakenBy();
  319. $admin_id = $this->getUser()->getAttribute('empId');
  320. if ($takenBy != $admin_id) {
  321. $_SESSION['error_msg'] = 'Not authorized to edit the Pe form as this PE form is not prepared by you';
  322. if (isset($_SESSION['msg'])) {
  323. unset($_SESSION['msg']);
  324. }
  325. $this->redirect('main/index');
  326. }
  327. $employeeInstance = new GroupwareEmployeesPeer();
  328. $searckkid_admin = $employeeInstance->getEmployeeAdminId($empid);
  329. if ($admin_id == $searckkid_admin) {
  330. $directadmin = true;
  331. } else if ($admin_id == $pestatus_evaluator) {
  332. $directadmin = true;
  333. } else {
  334. $directadmin = false;
  335. }
  336.  
  337. $criteriaAssign = new Criteria();
  338. $criteriaAssign->add(PeAssignedAdminPeer::EMPLOYEE, $empid);
  339. $resultSet = PeAssignedAdminPeer::doSelect($criteriaAssign);
  340. if ($resultSet) {
  341. foreach ($resultSet as $results) {
  342. $oldstartdate = $results->getStartDate();
  343. $oldenddate = $results->getEndDate();
  344. $newAdmin = $results->getNewAdmin();
  345. $compare = $this->betweenRangeCriteriaAssign($oldstartdate, $oldenddate);
  346. if ($compare == true) {
  347. $hasAdminThisPeriod = true;
  348. if ($admin_id == $newAdmin) {
  349. $currentAdmin = true;
  350. $hasAdminThisPeriod = false;
  351.  
  352. break;
  353. }
  354. }
  355. }
  356. if (($currentAdmin == false && $directadmin == false) || $hasAdminThisPeriod == true) {
  357.  
  358. $_SESSION['error_msg'] = 'You are not authorized to do this operation as you are not the current evaluator of the specified kid';
  359. if (isset($_SESSION['msg'])) {
  360. unset($_SESSION['msg']);
  361. }
  362. $this->redirect('main/index');
  363. }
  364. }
  365. } elseif ($this->isCore()) {
  366. $criteria = new Criteria();
  367. $criteria->add(PeEmployeesPeer::PEID, $peId);
  368. $result = PeEmployeesPeer::doSelect($criteria);
  369. if ($result) {
  370. $takenById = $result[0]->getTakenBy();
  371. /* if($takenById != $this->getUser()->getAttribute('empId')){
  372. $_SESSION['error_msg'] = 'Not authorized to edit the Pe form';
  373. $this->redirect('main/index');
  374. //} */
  375. }
  376. }
  377. //added by renjo for Monthly PE
  378. if ($this->getRequestParameter('type') == "monthly")
  379. $this->peform = "monthly";
  380. else
  381. $this->peform = "original";
  382. $this->editPEForm($peId);
  383. }
  384. else {
  385. $_SESSION['error_msg'] = 'Not authorized to edit the Pe form';
  386. $this->redirect('main/index');
  387. }
  388. } else {
  389. $_SESSION['error_msg'] = 'Not authorized to edit the Pe form';
  390. $this->redirect('main/index');
  391. }
  392. } elseif ($this->getRequestParameter('edit')) {
  393. $peId = $this->getRequestParameter('edit');
  394. if ($this->isEditable($peId)) {
  395. $criteria = new Criteria();
  396. $criteria->add(PeEmployeesPeer::PEID, $peId);
  397. $users = PeEmployeesPeer::doSelect($criteria);
  398. $empId = $users[0]->getEmpid();
  399. $this->peform = "self";
  400. $this->editPEForm($peId, $empId);
  401. } else {
  402. $_SESSION['error_msg'] = 'Not authorized to edit the Pe form';
  403. $this->redirect('main/index');
  404. }
  405. } elseif ($this->getRequestParameter('view')) {
  406. $peId = $this->getRequestParameter('view');
  407. if ($this->isViewable($peId)) {
  408. $PeEmployeesPeer = new PeEmployeesPeer;
  409. $empId = $PeEmployeesPeer->getEmpId($peId);
  410. if ($this->isAdmin() && $empId != $this->getUser()->getAttribute('empId')) {
  411.  
  412. $currentAdmin = false;
  413. $admin_id = $this->getUser()->getAttribute('empId');
  414. $employeeInstance = new GroupwareEmployeesPeer();
  415. $searckkid_admin = $employeeInstance->getEmployeeAdminId($empId);
  416. if ($admin_id == $searckkid_admin) {
  417. $directadmin = true;
  418. } else if ($admin_id == $pestatus_evaluator) {
  419. $directadmin = true;
  420. } else {
  421. $directadmin = false;
  422. }
  423. $criteriaAssign = new Criteria();
  424. $criteriaAssign->add(PeAssignedAdminPeer::EMPLOYEE, $empId);
  425. $resultSet = PeAssignedAdminPeer::doSelect($criteriaAssign);
  426. if ($resultSet) {
  427.  
  428. foreach ($resultSet as $results) {
  429. $oldstartdate = $results->getStartDate();
  430. $oldenddate = $results->getEndDate();
  431. $newAdmin = $results->getNewAdmin();
  432. $compare = $this->betweenRangeCriteriaAssign($oldstartdate, $oldenddate);
  433. if ($compare == true) {
  434. if ($admin_id == $newAdmin) {
  435. $currentAdmin = true;
  436. break;
  437. }
  438. }
  439. }
  440. if ($currentAdmin == false && $directadmin = false) {
  441.  
  442. $_SESSION['error_msg'] = 'You are not authorized to do this operation as you are not the current evaluator of the specified kid';
  443. $_SESSION['msg'] = '';
  444. $this->redirect('main/index');
  445. }
  446. }
  447. }
  448. $this->viewPEForm($peId);
  449. $PeEmployeesPeer = new PeEmployeesPeer;
  450. $empId = $PeEmployeesPeer->getEmpId($peId);
  451. $this->emp_count = $this->isStaffAndAdminSaved($empId);
  452. // To check whether the emloyee's direct admin is core or not
  453. $pestatus = $PeEmployeesPeer->getPestatusvalue($peId);
  454. $pestatus_id = $pestatus[0]->getStatusId();
  455. $pestatus_evaluator = $pestatus[0]->getTakenby();
  456. if ($pestatus_id == 6 && $empId == $this->getUser()->getAttribute('empId')) {
  457. $this->self = true;
  458. }
  459. if ($pestatus_id == 7 || $pestatus_id == 11) {
  460. $admin_id = $this->getUser()->getAttribute('empId');
  461. $employeeInstance = new GroupwareEmployeesPeer();
  462. $searckkid_admin = $employeeInstance->getEmployeeAdminId($empId);
  463. if ($admin_id == $searckkid_admin) {
  464. $this->directadmin = true;
  465. } else if ($admin_id == $pestatus_evaluator) {
  466. $this->directadmin = true;
  467. } else {
  468. $this->directadmin = false;
  469. }
  470. }
  471. } else {
  472. $_SESSION['error_msg'] = 'Not authorized to view the Pe form';
  473. $this->redirect('main/index');
  474. }
  475. } else if ($this->getRequestParameter('peForm')) {
  476. $empId = $this->getRequestParameter('peForm');
  477. if ($_SESSION['empRole'] == 'core') {
  478. $year = "%" . date("Y") . "%";
  479. $criteria = new Criteria();
  480. $criteria->add(PeEmployeesPeer::EMPID, $empId);
  481. $criteria->add(PeEmployeesPeer::ISSUEDATE, $year, Criteria::LIKE);
  482. $criteria->add(PeEmployeesPeer::STATUSID, 2, Criteria::GREATER_THAN);
  483. $criteria->add(PeEmployeesPeer::TYPE, 2, Criteria::NOT_EQUAL);
  484. $result = PeEmployeesPeer::doSelect($criteria);
  485. if ($result && $result[0]->getTakenBy() != $this->getUser()->getAttribute('empId')) {
  486. $_SESSION['error_msg'] = 'You are not authorized to do this operation as the admin is preparing a PE form of the specified kid';
  487. if (isset($_SESSION['msg'])) {
  488. unset($_SESSION['msg']);
  489. }
  490. $this->redirect('main/index');
  491. }
  492. } elseif ($_SESSION['empRole'] == 'admin') {
  493. $admin_id = $this->getUser()->getAttribute('empId');
  494. $employeeInstance = new GroupwareEmployeesPeer();
  495. $searckkid_admin = $employeeInstance->getEmployeeAdminId($empId);
  496. if ($admin_id == $searckkid_admin) {
  497. $directadmin = true;
  498. } else if ($admin_id == $pestatus_evaluator) {
  499. $directadmin = true;
  500. } else {
  501. $directadmin = false;
  502. }
  503. $hasAdminThisPeriod = false;
  504. $currentAdmin = false;
  505. $criteriaAssign = new Criteria();
  506. $criteriaAssign->add(PeAssignedAdminPeer::EMPLOYEE, $empId);
  507. $resultSet = PeAssignedAdminPeer::doSelect($criteriaAssign);
  508. if ($resultSet) {
  509. foreach ($resultSet as $results) {
  510. $oldstartdate = $results->getStartDate();
  511. $oldenddate = $results->getEndDate();
  512. $newAdmin = $results->getNewAdmin();
  513. $compare = $this->betweenRangeCriteriaAssign($oldstartdate, $oldenddate);
  514. if ($compare == true) {
  515. $hasAdminThisPeriod = true;
  516. if ($admin_id == $newAdmin) {
  517. $currentAdmin = true;
  518. $hasAdminThisPeriod = false;
  519. break;
  520. }
  521. }
  522. }
  523. if (($currentAdmin == false && $directadmin == false) || $hasAdminThisPeriod == true) {
  524.  
  525. $_SESSION['error_msg'] = 'You are not authorized to do this operation as you are not the current evaluator of the specified kid';
  526. if (isset($_SESSION['msg'])) {
  527. unset($_SESSION['msg']);
  528. }
  529.  
  530. $this->redirect('main/index');
  531. }
  532. }
  533. }
  534. $this->getPreForm($empId, null, 'original');
  535. $peDetails[3] = $peDetails[4] = date('Y-m-d');
  536. $peDetails[5] = date("Y-m-d", strtotime("+1 years"));
  537. $this->getEmpSupervisor($empId);
  538. $this->peform = "original";
  539. $this->peDetails = $peDetails;
  540. $this->readonly = false;
  541. sfView::SUCCESS;
  542. } else {
  543. $empId = $this->getUser()->getAttribute('empId');
  544. $this->checkExpToSubmitPE($empId); /* checking wether the employee has sufficient experience to submit the PE */
  545. $empId = $this->getUser()->getAttribute('empId');
  546. $this->formType = "self";
  547. $this->getPreForm($empId, null, null);
  548. $this->getEmpSupervisor($empId);
  549. $this->emp = $this->getUser();
  550. $this->readonly = false;
  551. $peDetails[3] = $peDetails[4] = date('Y-m-d');
  552. $peDetails[5] = date("Y-m-d", strtotime("+1 years"));
  553. $this->peDetails = $peDetails;
  554. sfView::SUCCESS;
  555. }
  556. $c = new Criteria();
  557. $this->result_val = PeHelpAdminPeer::doSelect($c);
  558. $this->result_valSample = PeSampleAdminPeer::doSelect($c);
  559. $this->role = $this->getUser()->getAttribute('empRole');
  560. } else {
  561. $this->redirect('login/index');
  562. }
  563. }
  564.  
  565. /**
  566. * Executes Staff Form display action
  567. *
  568. * @param sfRequest $request A request object
  569. */
  570. public function executeStaffPEForm(sfWebRequest $request) {
  571.  
  572.  
  573. if (isset($_SESSION['empId'])) {
  574. if ($request->isMethod('post')) {
  575. $this->getPostedValues();
  576. }
  577. if ($this->getRequestParameter('edit')) {
  578. $peId = $this->getRequestParameter('edit');
  579. if ($this->isEditable($peId)) {
  580. if ($this->getRequestParameter('edit') && ( ($this->getRequestParameter('type') == "original") || ($this->getRequestParameter('type') == "monthly"))) {
  581. if ($this->isAdmin() || $this->isCore()) {
  582. if ($this->isAdmin()) {
  583. $currentAdmin = false;
  584. $hasAdminThisPeriod = false;
  585. $criteria = new Criteria();
  586. $criteria->add(PeEmployeesPeer::PEID, $peId);
  587. $users = PeEmployeesPeer::doSelect($criteria);
  588. $empid = $users[0]->getEmpid();
  589. $takenBy = $users[0]->getTakenBy();
  590. $admin_id = $this->getUser()->getAttribute('empId');
  591. if ($takenBy != $admin_id) {
  592. $_SESSION['error_msg'] = 'Not authorized to edit the Pe form as this PE form is not prepared by you';
  593. if (isset($_SESSION['msg'])) {
  594. unset($_SESSION['msg']);
  595. }
  596. $this->redirect('main/index');
  597. }
  598. $employeeInstance = new GroupwareEmployeesPeer();
  599. $searckkid_admin = $employeeInstance->getEmployeeAdminId($empid);
  600. if ($admin_id == $searckkid_admin) {
  601. $directadmin = true;
  602. } else if ($admin_id == $pestatus_evaluator) {
  603. $directadmin = true;
  604. } else {
  605. $directadmin = false;
  606. }
  607. $criteriaAssign = new Criteria();
  608. $criteriaAssign->add(PeAssignedAdminPeer::EMPLOYEE, $empid);
  609. $resultSet = PeAssignedAdminPeer::doSelect($criteriaAssign);
  610. if ($resultSet) {
  611. foreach ($resultSet as $results) {
  612. $oldstartdate = $results->getStartDate();
  613. $oldenddate = $results->getEndDate();
  614. $newAdmin = $results->getNewAdmin();
  615. $compare = $this->betweenRangeCriteriaAssign($oldstartdate, $oldenddate);
  616. if ($compare == true) {
  617. $hasAdminThisPeriod = true;
  618. if ($admin_id == $newAdmin) {
  619. $currentAdmin = true;
  620. $hasAdminThisPeriod = false;
  621. break;
  622. }
  623. }
  624. }
  625. if (($currentAdmin == false && $directadmin == false) || $hasAdminThisPeriod == true) {
  626.  
  627. $_SESSION['error_msg'] = 'You are not authorized to do this operation as you are not the current evaluator of the specified kid';
  628. if (isset($_SESSION['msg'])) {
  629. unset($_SESSION['msg']);
  630. }
  631. $this->redirect('main/index');
  632. }
  633. }
  634. } elseif ($this->isCore()) {
  635. $criteria = new Criteria();
  636. $criteria->add(PeEmployeesPeer::PEID, $peId);
  637. $result = PeEmployeesPeer::doSelect($criteria);
  638. if ($result) {
  639. $takenById = $result[0]->getTakenBy();
  640. // if($takenById != $this->getUser()->getAttribute('empId')){
  641. // $_SESSION['error_msg'] = 'Not authorized to edit the Pe form';
  642. // $this->redirect('main/index');
  643. // }
  644. }
  645. }
  646. //added by renjo for monthly PE
  647. if ($this->getRequestParameter('type') == "monthly")
  648. $this->peform = "monthly";
  649. else
  650. $this->peform = "original";
  651. $this->editPEForm($peId, $empid);
  652. }
  653. else {
  654. $_SESSION['error_msg'] = 'Not authorized to edit the Pe form';
  655. $this->redirect('main/index');
  656. }
  657. } else if ($this->getRequestParameter('edit')) {
  658. $criteria = new Criteria();
  659. $criteria->add(PeEmployeesPeer::PEID, $peId);
  660. $users = PeEmployeesPeer::doSelect($criteria);
  661. $empId = $users[0]->getEmpid();
  662. $this->peform = "self";
  663. $this->editPEForm($peId, $empId);
  664. }
  665. } else {
  666. $_SESSION['error_msg'] = 'Not authorized to edit the Pe form';
  667. $this->redirect('main/index');
  668. }
  669. } elseif ($this->getRequestParameter('view')) {
  670. $peId = $this->getRequestParameter('view');
  671. if ($this->isViewable($peId)) {
  672. if ($this->isAdmin() && !$this->isSelf($peId, $this->getUser()->getAttribute('empId'))) {
  673.  
  674. $currentAdmin = false;
  675. $PeEmployeesPeer = new PeEmployeesPeer;
  676. $empId = $PeEmployeesPeer->getEmpId($peId);
  677. $admin_id = $this->getUser()->getAttribute('empId');
  678. $employeeInstance = new GroupwareEmployeesPeer();
  679. $searckkid_admin = $employeeInstance->getEmployeeAdminId($empId);
  680. if ($admin_id == $searckkid_admin) {
  681. $directadmin = true;
  682. } else if ($admin_id == $pestatus_evaluator) {
  683. $directadmin = true;
  684. } else {
  685. $directadmin = false;
  686. }
  687. $criteriaAssign = new Criteria();
  688. $criteriaAssign->add(PeAssignedAdminPeer::EMPLOYEE, $empId);
  689. $resultSet = PeAssignedAdminPeer::doSelect($criteriaAssign);
  690. if ($resultSet) {
  691.  
  692. foreach ($resultSet as $results) {
  693. $oldstartdate = $results->getStartDate();
  694. $oldenddate = $results->getEndDate();
  695. $newAdmin = $results->getNewAdmin();
  696. $compare = $this->betweenRangeCriteriaAssign($oldstartdate, $oldenddate);
  697. if ($compare == true) {
  698. if ($admin_id == $newAdmin) {
  699. $currentAdmin = true;
  700. break;
  701. }
  702. }
  703. }
  704. if ($currentAdmin == false && $directadmin == false) {
  705.  
  706. $_SESSION['error_msg'] = 'You are not authorized to do this operation as you are not the current evaluator of the specified kid';
  707. if (isset($_SESSION['msg'])) {
  708. unset($_SESSION['msg']);
  709. }
  710. $this->redirect('main/index');
  711. }
  712. }
  713. }
  714.  
  715. $this->viewPEForm($peId);
  716. $PeEmployeesPeer = new PeEmployeesPeer;
  717. $empId = $PeEmployeesPeer->getEmpId($peId);
  718. $this->emp_count = $this->isStaffAndAdminSaved($empId);
  719. // To check whether the emloyee's direct admin is core or not
  720. $pestatus = $PeEmployeesPeer->getPestatusvalue($peId);
  721. $pestatus_id = $pestatus[0]->getStatusId();
  722. $pestatus_evaluator = $pestatus[0]->getTakenby();
  723. if ($pestatus_id == 6 && $empId == $this->getUser()->getAttribute('empId')) {
  724. $this->self = true;
  725. }
  726. if ($pestatus_id == 7 || $pestatus_id == 11) {
  727. $admin_id = $this->getUser()->getAttribute('empId');
  728. $employeeInstance = new GroupwareEmployeesPeer();
  729. $searckkid_admin = $employeeInstance->getEmployeeAdminId($empId);
  730.  
  731. if ($admin_id == $searckkid_admin) {
  732. $this->directadmin = true;
  733. } else if ($admin_id == $pestatus_evaluator) {
  734. $this->directadmin = true;
  735. } else {
  736. $this->directadmin = false;
  737. }
  738. }
  739. } else {
  740. $_SESSION['error_msg'] = 'Not authorized to view the Pe form';
  741. $this->redirect('main/index');
  742. }
  743. } elseif ($this->getRequestParameter('peForm')) {
  744. $empId = $this->getRequestParameter('peForm');
  745. if ($_SESSION['empRole'] == 'core') {
  746. $year = "%" . date("Y") . "%";
  747. $criteria = new Criteria();
  748. $criteria->add(PeEmployeesPeer::EMPID, $empId);
  749. $criteria->add(PeEmployeesPeer::ISSUEDATE, $year, Criteria::LIKE);
  750. $criteria->add(PeEmployeesPeer::STATUSID, 2, Criteria::GREATER_THAN);
  751. $criteria->add(PeEmployeesPeer::TYPE, 2, Criteria::NOT_EQUAL);
  752. $result = PeEmployeesPeer::doSelect($criteria);
  753. if ($result && $result[0]->getTakenBy() != $this->getUser()->getAttribute('empId')) {
  754. $_SESSION['error_msg'] = 'You are not authorized to do this operation as the admin is preparing a PE form of the specified kid';
  755. if (isset($_SESSION['msg'])) {
  756. unset($_SESSION['msg']);
  757. }
  758. $this->redirect('main/index');
  759. }
  760. } elseif ($_SESSION['empRole'] == 'admin') {
  761. $currentAdmin = false;
  762. $hasAdminThisPeriod = false;
  763. $admin_id = $this->getUser()->getAttribute('empId');
  764. $employeeInstance = new GroupwareEmployeesPeer();
  765. $searckkid_admin = $employeeInstance->getEmployeeAdminId($empId);
  766. if ($admin_id == $searckkid_admin) {
  767. $directadmin = true;
  768. } else if ($admin_id == $pestatus_evaluator) {
  769. $directadmin = true;
  770. } else {
  771. $directadmin = false;
  772. }
  773. $criteriaAssign = new Criteria();
  774. $criteriaAssign->add(PeAssignedAdminPeer::EMPLOYEE, $empId);
  775. $resultSet = PeAssignedAdminPeer::doSelect($criteriaAssign);
  776. if ($resultSet) {
  777. foreach ($resultSet as $results) {
  778. $oldstartdate = $results->getStartDate();
  779. $oldenddate = $results->getEndDate();
  780. $newAdmin = $results->getNewAdmin();
  781. $compare = $this->betweenRangeCriteriaAssign($oldstartdate, $oldenddate);
  782. if ($compare == true) {
  783. $hasAdminThisPeriod = true;
  784. if ($admin_id == $newAdmin) {
  785. $currentAdmin = true;
  786. $hasAdminThisPeriod = false;
  787. break;
  788. }
  789. }
  790. }
  791. if (($currentAdmin == false && $directadmin == false) || $hasAdminThisPeriod == true) {
  792.  
  793. $_SESSION['error_msg'] = 'You are not authorized to do this operation as you are not the current evaluator of the specified kid';
  794. if (isset($_SESSION['msg'])) {
  795. unset($_SESSION['msg']);
  796. }
  797. $this->redirect('main/index');
  798. }
  799. }
  800. }
  801. if ($this->staffCheck($empId)) {
  802. $this->getPreForm($empId, null, 'original');
  803. $this->getEmpSupervisor($empId);
  804. $this->peform = "original";
  805. $peDetails[3] = $peDetails[4] = date('Y-m-d');
  806. $peDetails[5] = date("Y-m-d", strtotime("+1 years"));
  807. $this->peDetails = $peDetails;
  808. $this->readonly = false;
  809. sfView::SUCCESS;
  810. } else {
  811. $_SESSION['warning_msg'] = 'The selected person is not a Staff';
  812. $this->redirect('login/index');
  813. }
  814. } else {
  815.  
  816. $empId = $this->getUser()->getAttribute('empId');
  817. $this->checkExpToSubmitPE($empId); /* checking wether the employee has sufficient experience to submit the PE */
  818. $empId = $this->getUser()->getAttribute('empId');
  819. $this->formType = "self";
  820. $this->getPreForm($empId, null, null);
  821. $this->getEmpSupervisor($empId);
  822. $this->emp = $this->getUser();
  823. $peDetails[3] = $peDetails[4] = date('Y-m-d');
  824. $peDetails[5] = date("Y-m-d", strtotime("+1 years"));
  825. $this->peDetails = $peDetails;
  826. $this->readonly = false;
  827. sfView::SUCCESS;
  828. }
  829. $c = new Criteria();
  830. $this->result_val = PeHelpStaffPeer::doSelect($c);
  831. $this->result_valSample = PeSampleStaffPeer::doSelect($c);
  832. $this->peid = $this->getRequestParameter('view');
  833. $this->role = $this->getUser()->getAttribute('empRole');
  834. } else {
  835. $this->redirect('login/index');
  836. }
  837. }
  838.  
  839. //added by renjo to list all Monthly PE forms
  840. function executeMonthlyPE(sfWebRequest $request) {
  841. if (isset($_SESSION['empId'])) {
  842. $this->managementSkill = "false"; //To check whether management skill should be displayed or not in view form
  843. $empId = $this->getRequestParameter('view');
  844. $issueDate = $this->getRequestParameter('date');
  845. $tmpDate = explode('-', $issueDate);
  846. $this->issueYear = $tmpDate[0];
  847. $criteria = new Criteria();
  848. $criteria->add(PeEmployeesPeer::EMPID, $empId);
  849. $criteria->add(PeEmployeesPeer::ISSUEDATE, $this->issueYear . "%", Criteria::LIKE);
  850. $criteria->add(PeEmployeesPeer::TYPE, MONTHLYCODE);
  851. $criteria->addAscendingOrderByColumn(PeEmployeesPeer::ISSUEDATE);
  852. $users = PeEmployeesPeer::doSelect($criteria);
  853. foreach ($users as $results) {
  854. $peId = $results->getPeId();
  855. $roleType = $results->getRoletype();
  856. $date = $results->getIssueDate();
  857. $tmpDate = explode('-', $date);
  858. $issueMonth = $tmpDate[1];
  859.  
  860. $monthlyDetails[$issueMonth]['mark'] = $this->getPeDetails($peId, 1);
  861. $this->getPreForm(null, $peId, null);
  862.  
  863. $monthlyDetails[$issueMonth]['accomp'] = $this->getAccomplishments($peId, 1);
  864.  
  865.  
  866.  
  867. $monthlyDetails[$issueMonth]['respons'] = $this->getResponsibility($peId, 1);
  868. $monthlyDetails[$issueMonth]['qualqty'] = $this->getQualityQuantity($peId, 1);
  869. $monthlyDetails[$issueMonth]['commun'] = $this->getCommunication($peId, 1);
  870. $monthlyDetails[$issueMonth]['jobknge'] = $this->getJobKnowledge($peId, 1);
  871. //$this -> getQualityQuantity($peId);
  872. //$this -> getCommunication($peId);
  873. //$this -> getJobKnowledge($peId);
  874. if ($roleType != STAFF) {
  875. //echo $roleType."Management skill".$this->managementSkill;exit;
  876. $this->managementSkill = "true";
  877. $monthlyDetails[$issueMonth]['manageskill'] = $this->getManagementSkills($peId, 1);
  878. //$this -> getManagementSkills($peId);
  879. }
  880.  
  881. $monthlyDetails[$issueMonth]['social'] = $this->getSocialEffectiveness($peId, 1);
  882. $monthlyDetails[$issueMonth]['satisf'] = $this->getSatisfaction($peId, 1);
  883. $monthlyDetails[$issueMonth]['leave'] = $this->getLeaveAttendance($peId, 1);
  884. $monthlyDetails[$issueMonth]['qms'] = $this->getQms($peId, 1);
  885. $monthlyDetails[$issueMonth]['otheract'] = $this->getOtherActivity($peId, 1);
  886. $monthlyDetails[$issueMonth]['empcomm'] = $this->getEmpComments($peId, 1);
  887. $monthlyDetails[$issueMonth]['devplan'] = $this->getDevelopmentPlan($peId, 1);
  888. $this->monthlyDetails = $monthlyDetails;
  889. }
  890. } else {
  891. $this->redirect('login/index');
  892. }
  893. }
  894.  
  895. public function executeQMPEForm(sfWebRequest $request) {
  896. if (isset($_SESSION['empId'])) {
  897. if ($request->isMethod('post')) {
  898. $this->getPostedValues();
  899. }
  900. if ($this->getRequestParameter('edit') && $this->getRequestParameter('type') == "original") {
  901. $peId = $this->getRequestParameter('edit');
  902. if ($this->isEditable($peId)) {
  903. if ($this->isCore()) {
  904. $this->peform = "original";
  905. $this->editPEForm($peId);
  906. } else {
  907. $_SESSION['error_msg'] = 'Not authorized to edit the Pe form';
  908. $this->redirect('main/index');
  909. }
  910. } else {
  911. $_SESSION['error_msg'] = 'Not authorized to edit the Pe form';
  912. $this->redirect('main/index');
  913. }
  914. } else if ($this->getRequestParameter('edit')) {
  915. $peId = $this->getRequestParameter('edit');
  916. if ($this->isEditable($peId)) {
  917. $criteria = new Criteria();
  918. $criteria->add(PeEmployeesPeer::PEID, $peId);
  919. $users = PeEmployeesPeer::doSelect($criteria);
  920. $empId = $users[0]->getEmpid();
  921. $this->peform = "self";
  922. $this->editPEForm($peId, $empId);
  923. } else {
  924. $_SESSION['error_msg'] = 'Not authorized to edit the Pe form';
  925. $this->redirect('main/index');
  926. }
  927. } elseif ($this->getRequestParameter('view')) {
  928. $peId = $this->getRequestParameter('view');
  929. if ($this->isViewable($peId)) {
  930. $this->viewPEForm($peId);
  931. $PeEmployeesPeer = new PeEmployeesPeer;
  932. $empId = $PeEmployeesPeer->getEmpId($peId);
  933. $this->emp_count = $this->isStaffAndAdminSaved($empId);
  934. // To check whether the emloyee's direct admin is core or not
  935. $pestatus = $PeEmployeesPeer->getPestatusvalue($peId);
  936. $pestatus_id = $pestatus[0]->getStatusId();
  937. $pestatus_evaluator = $pestatus[0]->getTakenby();
  938. $this->evaluator = $empId;
  939. if ($pestatus_id == 7) {
  940. $admin_id = $this->getUser()->getAttribute('empId');
  941. $employeeInstance = new GroupwareEmployeesPeer();
  942. $searckkid_admin = $employeeInstance->getEmployeeAdminId($empId);
  943. if ($admin_id == $searckkid_admin) {
  944. $this->directadmin = true;
  945. } else if ($admin_id == $pestatus_evaluator) {
  946. $this->directadmin = true;
  947. } else {
  948. $this->directadmin = false;
  949. }
  950. }
  951. } else {
  952. $_SESSION['error_msg'] = 'Not authorized to view the Pe form';
  953. $this->redirect('main/index');
  954. }
  955. } elseif ($this->getRequestParameter('peForm')) {
  956. $empId = $this->getRequestParameter('peForm');
  957. if ($this->qmCheck($empId)) {
  958. $this->getPreForm($empId, null, 'original');
  959. $peDetails[3] = $peDetails[4] = date('Y-m-d');
  960. $peDetails[5] = date("Y-m-d", strtotime("+1 years"));
  961. $this->getEmpSupervisor($empId);
  962. $this->peform = "original";
  963. $this->peDetails = $peDetails;
  964. $this->readonly = false;
  965. sfView::SUCCESS;
  966. } else {
  967. $_SESSION['warning_msg'] = 'The selected person is not a QM';
  968. $this->redirect('login/index');
  969. }
  970. } else {
  971. $empId = $this->getUser()->getAttribute('empId');
  972. $this->checkExpToSubmitPE($empId); /* checking wether the employee has sufficient experience to submit the PE */
  973. $empId = $this->getUser()->getAttribute('empId');
  974. $this->getPreForm($empId, null, null);
  975. $this->getEmpSupervisor($empId);
  976. $this->emp = $this->getUser();
  977. $this->readonly = false;
  978. $peDetails[3] = $peDetails[4] = date('Y-m-d');
  979. $peDetails[5] = date("Y-m-d", strtotime("+1 years"));
  980. $this->peDetails = $peDetails;
  981. sfView::SUCCESS;
  982. }
  983. $c = new Criteria();
  984. $this->result_val = PeHelpQmPeer::doSelect($c);
  985. $this->result_valSample = PeSampleQmPeer::doSelect($c);
  986. $this->role = $this->getUser()->getAttribute('empRole');
  987. } else {
  988. $this->redirect('login/index');
  989. }
  990. }
  991.  
  992. public function executeAssignAdmin(sfWebRequest $request) {
  993. if (isset($_SESSION['empId'])) {
  994. $this->getUser()->setAttribute('editAssignAdmin', '');
  995. if ($request->isMethod('post')) {
  996. if ($this->getRequestParameter('Cancel')) {
  997. $this->redirect('main/ViewAdmin');
  998. }
  999.  
  1000. $startdate = $this->getRequestParameter('startdate');
  1001. if (!$startdate) {
  1002. $startdate = $this->getRequestParameter('oldstartdate');
  1003. }
  1004. $endadate = $this->getRequestParameter('enddate');
  1005.  
  1006. $nameOfAdmin = $this->getRequestParameter('admin');
  1007. if (!is_numeric($nameOfAdmin)) {
  1008. $groupwareEmployee = new GroupwareEmployeesPeer();
  1009. $tempNameOfAdmin = $groupwareEmployee->getEmployeeId($this->getRequestParameter('admin'));
  1010. $nameOfAdmin = $tempNameOfAdmin[0];
  1011. }
  1012. if ($nameOfAdmin == '0') {
  1013. $_SESSION['error_msg'] = 'The name of the admin is not entered';
  1014. }
  1015.  
  1016. $nameOfKid = $this->getRequestParameter('kids');
  1017. if (!is_numeric($nameOfKid)) {
  1018. $groupwareEmployee = new GroupwareEmployeesPeer();
  1019. $tempNameOfKid = $groupwareEmployee->getEmployeeId($this->getRequestParameter('kids'));
  1020. $nameOfKid = $tempNameOfKid[0];
  1021. }
  1022. $groupwareEmployee = new GroupwareEmployeesPeer();
  1023. if ($groupwareEmployee->getEmployeeAdminId($nameOfKid) == $nameOfAdmin) {
  1024. $_SESSION['error_msg'] = GroupwareEmployeesPeer::getEmployeeName($nameOfKid) . ' is currently under direct supervision of ' . GroupwareEmployeesPeer::getEmployeeName($nameOfAdmin);
  1025. }
  1026.  
  1027. if ($nameOfKid == '0') {
  1028. $_SESSION['error_msg'] = 'The name of the kid is not entered';
  1029. }
  1030.  
  1031. if ($startdate > $endadate) {
  1032. $_SESSION['error_msg'] = 'End Date can never be before Start Date';
  1033. }
  1034. if ($_SESSION['error_msg'] != '') {
  1035. $this->redirect('main/AssignAdmin');
  1036. } else {
  1037.  
  1038. $criteriaAssign = new Criteria();
  1039. $criteriaAssign->add(PeAssignedAdminPeer::PETYPE, $this->getRequestParameter('peType'));
  1040.  
  1041. if ($this->getRequestParameter('Update')) {
  1042. $assignID = $this->getRequestParameter('editId');
  1043. $criteriaAssign->add(PeAssignedAdminPeer::ASSIGNADMINID, $assignID, Criteria::NOT_EQUAL);
  1044. $criteriaAssign->add(PeAssignedAdminPeer::EMPLOYEE, $nameOfKid);
  1045. // $resultSet = PeAssignedAdminPeer::doSelect($criteriaAssign);
  1046. }
  1047. else
  1048. $criteriaAssign->add(PeAssignedAdminPeer::EMPLOYEE, $nameOfKid);
  1049. $resultSet = PeAssignedAdminPeer::doSelect($criteriaAssign);
  1050. if ($resultSet) {
  1051. foreach ($resultSet as $results) {
  1052. $oldstartdate = $results->getStartDate();
  1053. $oldenddate = $results->getEndDate();
  1054. $peType = $results->getPetype();
  1055.  
  1056. $compare = $this->betweenRangeCriteria($oldstartdate, $oldenddate, $startdate, $endadate);
  1057. if (!$compare) {
  1058. $groupwareEmployee = new GroupwareEmployeesPeer();
  1059. $kidName = $groupwareEmployee->getEmployeeName($nameOfKid);
  1060.  
  1061. $_SESSION['error_msg'] = $kidName . ' has been assigned to another admin.Please delete the entry before assigning new admin';
  1062. $this->redirect('main/ViewAdmin');
  1063. }
  1064. }
  1065. }
  1066. if ($this->getRequestParameter('Update')) {
  1067. $assignID = $this->getRequestParameter('editId');
  1068. $criteria = new Criteria();
  1069. $criteria->add(PeAssignedAdminPeer::ASSIGNADMINID, $assignID);
  1070. $criteria->add(PeAssignedAdminPeer::NEWADMIN, $nameOfAdmin);
  1071. $criteria->add(PeAssignedAdminPeer::ENDDATE, $this->getRequestParameter('enddate'));
  1072. $criteria->add(PeAssignedAdminPeer::ASSIGNEDBY, $this->getUser()->getAttribute('empId'));
  1073. $criteria->add(PeAssignedAdminPeer::PETYPE, $this->getRequestParameter('peType'));
  1074. PeAssignedAdminPeer::doUpdate($criteria);
  1075. $groupwareEmployee = new GroupwareEmployeesPeer();
  1076. $adminName = $groupwareEmployee->getEmployeeName($nameOfAdmin);
  1077. $kidName = $groupwareEmployee->getEmployeeName($nameOfKid);
  1078. $assignedBy = $groupwareEmployee->getEmployeeName($this->getUser()->getAttribute('empId'));
  1079. $logs = new PelogsPeer();
  1080. $assignedlog = $logs->getAssignedAdminLog($adminName, $kidName, $startdate, $endadate, $assignedBy);
  1081. $_SESSION['msg'] = ' Entry updated successfully';
  1082. $this->redirect('main/ViewAdmin');
  1083. }
  1084.  
  1085. /*
  1086. * Bug: #9799
  1087. * Summary: Unable to do admin assignments for monthly PE forms if there is anyPE form (yearly or monthly) added in the given month
  1088. * Edited by: Miriam
  1089. * Date: Nov 10, 2011
  1090. * Modifications:-
  1091. * added the following line:
  1092. $currentPeId = 0;
  1093. */
  1094. $currentPeId = 0;
  1095. if ($request->getPostParameter('peType') == MONTHLYCODE) {
  1096. /* to check whether employeees Monthly PE form is already filled */
  1097. $criteria = new Criteria();
  1098. $criteria->add(PeEmployeesPeer::EMPID, $this->getRequestParameter('kids'));
  1099. /*
  1100. * Bug: #9799
  1101. * Summary: Unable to do admin assignments for monthly PE forms if there isany PE form (yearly or monthly) added in the given month
  1102. * Edited by: Miriam
  1103. * Date: Nov 10, 2011
  1104. * Modifications:-
  1105. * removed the following line:
  1106. $criteria->add(PeEmployeesPeer::STATUSID, 2, Criteria::GREATER_THAN);
  1107. * added the following line:
  1108. $criteria->add(PeEmployeesPeer::TYPE, 2, Criteria::EQUAL);
  1109. */
  1110. $criteria->add(PeEmployeesPeer::TYPE, 2, Criteria::EQUAL);
  1111. $criteria->addDescendingOrderByColumn(PeEmployeesPeer::ISSUEDATE);
  1112. $resultObject = PeEmployeesPeer::doSelect($criteria);
  1113.  
  1114. if ($resultObject) {
  1115. $issueDate = $resultObject[0]->getIssueDate();
  1116. $tmpDate = explode('-', $issueDate);
  1117. $issueMonth = $tmpDate[1];
  1118. $assignDate = explode('-', $startdate);
  1119. $assignMonth = $assignDate[1];
  1120. /* Edited by Nevil on 2009-01-24. Added extra condition to check the count of array */
  1121. if ($issueMonth == $assignMonth) {
  1122. /*
  1123. * Bug: #9799
  1124. * Edited by: Miriam
  1125. * Date: Nov 10, 2011
  1126. * Modifications:-
  1127. * removed the following lines:
  1128. $peId = $resultObject[0]->getPeId();
  1129. $_SESSION['warning_msg'] = 'This employee\'s Monthly PE form already saved or submitted.<br>Please delete it before asssigning a new Admin to the employee.';
  1130. $this->redirect('main/deletePEForm?peId=' . $peId);
  1131. * added the following line:
  1132. $currentPeId = $resultObject[0]->getPeId();
  1133. */
  1134. $currentPeId = $resultObject[0]->getPeId();
  1135. }
  1136. }
  1137. } else {
  1138.  
  1139. /* to check whether employeees Original PE form is already filled */
  1140. $criteria = new Criteria();
  1141. $criteria->add(PeEmployeesPeer::EMPID, $this->getRequestParameter('kids'));
  1142. $criteria->add(PeEmployeesPeer::STATUSID, 2, Criteria::GREATER_THAN);
  1143. /**
  1144. * @author Nazz
  1145. * @BugId 9744
  1146. */
  1147. $criteria->add(PeEmployeesPeer::STATUSID, array(12,13), Criteria::NOT_IN);
  1148. //Nazz End
  1149.  
  1150. $criteria->addDescendingOrderByColumn(PeEmployeesPeer::ISSUEDATE);
  1151. $resultObject = PeEmployeesPeer::doSelect($criteria);
  1152. /* Edited BY Jayaraj */
  1153. if ($resultObject) {
  1154. //echo "<pre>";print_r($resultObject);die;
  1155. $issueDate = $resultObject[0]->getIssueDate();
  1156. $tmpDate = explode('-', $issueDate);
  1157. $issueYear = $tmpDate[0];
  1158. $assignDate = explode('-', $startdate);
  1159. $assignYear = $assignDate[0];
  1160. /* Edited by Nevil on 2009-01-24. Added extra condition to check the count of array */
  1161. //echo $issueYear."asd".$assignYear;
  1162. if ($issueYear == $assignYear) {
  1163. /*
  1164. * Bug: #9792, #9780, #9758
  1165. * Summary: Unable to do admin assignments for yearly PE forms if there is any PE form added for the given year
  1166. * Edited by: Miriam
  1167. * Date: Nov 10, 2011
  1168. * Modifications:-
  1169. * removed the following lines:
  1170. $peId = $resultObject[0]->getPeId();
  1171. $_SESSION['warning_msg'] = 'This employee\'s original PE form already saved or submitted.<br>Please delete it before asssigning a new Admin to the employee.';
  1172. $this->redirect('main/deletePEForm?peId=' . $peId);
  1173. * added the following line:
  1174. $currentPeId = $resultObject[0]->getPeId();
  1175. */
  1176. $currentPeId = $resultObject[0]->getPeId();
  1177. }
  1178. }
  1179. }
  1180.  
  1181. $criteria = new Criteria();
  1182. $criteria->add(GroupwareEmployeesPeer::ID, $this->getRequestParameter('kids'));
  1183. $resultObject = GroupwareEmployeesPeer::doSelect($criteria);
  1184. foreach ($resultObject as $result)
  1185. $oldadminId = $result->getSupervisor();
  1186. $groupwareEmployee = new GroupwareEmployeesPeer();
  1187. $adminName = $groupwareEmployee->getEmployeeName($this->getRequestParameter('admin'));
  1188. $kidName = $groupwareEmployee->getEmployeeName($this->getRequestParameter('kids'));
  1189. $assignedBy = $groupwareEmployee->getEmployeeName($this->getUser()->getAttribute('empId'));
  1190.  
  1191.  
  1192.  
  1193. $peadmin = new PEAssignedAdmin();
  1194. $peadmin->setEmployee($this->getRequestParameter('kids'));
  1195. $peadmin->setNewAdmin($this->getRequestParameter('admin'));
  1196. $peadmin->setStartDate($this->getRequestParameter('startdate'));
  1197. $peadmin->setEndDate($this->getRequestParameter('enddate'));
  1198. $peadmin->setAssignedBy($this->getUser()->getAttribute('empId'));
  1199. $peadmin->setOldAdmin($oldadminId);
  1200. $peadmin->setPetype($this->getRequestParameter('peType')); // monthly or yearly
  1201.  
  1202. $peadmin->save();
  1203. $logs = new PelogsPeer();
  1204. $assignedlog = $logs->getAssignedAdminLog($adminName, $kidName, $startdate, $endadate, $assignedBy);
  1205.  
  1206.  
  1207. //to change the evaluator in the pe form
  1208. $criteria = new Criteria();
  1209. $criteria->add(PeEmployeesPeer::EMPID, $this->getRequestParameter('kids'));
  1210. $criteria->add(PeEmployeesPeer::STATUSID, 3, Criteria::LESS_THAN);
  1211. $resultObject = PeEmployeesPeer::doSelect($criteria);
  1212. if (is_array($resultObject) && (count($resultObject) > 0)) {
  1213. $PeId = $resultObject[0]->getPeId();
  1214. $groupwareEmployee = new GroupwareEmployeesPeer();
  1215. $adminName = $groupwareEmployee->getEmployeeName($this->getRequestParameter('admin'));
  1216. $criteria = new Criteria();
  1217. $criteria->add(PeEmployeesPeer::PEID, $PeId);
  1218. $criteria->add(PeEmployeesPeer::TAKENBY, $adminName);
  1219. PeEmployeesPeer::doUpdate($criteria);
  1220. }
  1221. /*
  1222. * Bug: #9792, #9780, #9799, #9758
  1223. * Edited by: Miriam
  1224. * Date: Nov 10, 2011
  1225. * Modifications:-
  1226. * added the following lines:
  1227. if($currentPeId) {
  1228. $criteria = new Criteria();
  1229. $criteria->add(PeEmployeesPeer::PEID, $currentPeId);
  1230. $criteria->add(PeEmployeesPeer::TAKENBY, $this->getRequestParameter('admin'));
  1231. PeEmployeesPeer::doUpdate($criteria);
  1232. }
  1233. */
  1234. if($currentPeId) {
  1235. $criteria = new Criteria();
  1236. $criteria->add(PeEmployeesPeer::PEID, $currentPeId);
  1237. $criteria->add(PeEmployeesPeer::TAKENBY, $this->getRequestParameter('admin'));
  1238. PeEmployeesPeer::doUpdate($criteria);
  1239. }
  1240. $this->redirect('main/ViewAdmin');
  1241. }
  1242. } else if ($this->getRequestParameter('edit')) {
  1243. $this->role = $this->getUser()->getAttribute('empRole');
  1244. $this->getUser()->setAttribute('editAssignAdmin', 'true');
  1245. $assignAdminId = $this->getRequestParameter('edit');
  1246. $this->assignedID = $assignAdminId;
  1247. if ($this->role == 'core' || $this->role == 'hr') {
  1248. $criteria = new Criteria();
  1249. $criteria->add(PeAssignedadminPeer::ASSIGNADMINID, $assignAdminId);
  1250. $resultSet = PeAssignedadminPeer::doSelect($criteria);
  1251. $employee = $resultSet[0]->getEmployee();
  1252. $newAdmin = $resultSet[0]->getNewAdmin();
  1253. $this->peType = $resultSet[0]->getPeType();
  1254.  
  1255. $this->startDate = $resultSet[0]->getStartDate();
  1256. $this->endDate = $resultSet[0]->getEndDate();
  1257. $groupwareEmployees = new GroupwareEmployeesPeer();
  1258. $this->noncore_user = $groupwareEmployees->getEmployeeName($employee);
  1259. $this->newAdmin = $groupwareEmployees->getEmployeeName($newAdmin);
  1260. $tmpDate = explode('-', $this->startDate);
  1261. $issueYear = $tmpDate[0];
  1262. $currentYear = '%' . date('Y') . '%';
  1263. $nc = new Criteria();
  1264. $nc->add(PeEmployeesPeer::EMPID, $employee);
  1265. $nc->add(PeEmployeesPeer::TAKENBY, $newAdmin);
  1266. $nc->add(PeEmployeesPeer::TYPE, 1);
  1267. $nc->add(PeEmployeesPeer::ISSUEDATE, $currentYear, Criteria::LIKE);
  1268. $results = PeEmployeesPeer::doSelect($nc);
  1269. if ($results) {
  1270. $this->adminlist = $groupwareEmployees->getEmployeeName($newAdmin);
  1271. } else {
  1272. $groupwareEmployees = new GroupwareEmployeesPeer();
  1273. $this->noncore_users = $groupwareEmployees->getEmployeeAccounts();
  1274. $this->adminlist = $groupwareEmployees->getAllAdmins();
  1275. $this->corelist = $groupwareEmployees->getCoreMembers();
  1276. }
  1277. }
  1278. } else {
  1279. $this->role = $this->getUser()->getAttribute('empRole');
  1280. if ($this->role == 'core' || $this->role == 'hr') {
  1281. $groupwareEmployees = new GroupwareEmployeesPeer();
  1282. $this->noncore_users = $groupwareEmployees->getEmployeeAccounts();
  1283. $this->adminlist = $groupwareEmployees->getAllAdmins();
  1284. $this->corelist = $groupwareEmployees->getCoreMembers();
  1285. } else {
  1286. $_SESSION['error_msg'] = 'You do not have privilege to assign admin';
  1287. $this->redirect('main/index');
  1288. }
  1289. }
  1290. }
  1291. else
  1292. $this->redirect('login/index');
  1293. }
  1294.  
  1295. public function executeViewAdmin(sfWebRequest $request) {
  1296. if ($this->getRequestParameter('year'))
  1297. $this->year = $this->getRequestParameter('year');
  1298. else
  1299. $this->year = date('Y');
  1300. $GroupwareEmployeesPeer = new GroupwareEmployeesPeer;
  1301. $this->current_empid = $this->getUser()->getAttribute('empId');
  1302. $this->admin_name = $GroupwareEmployeesPeer->getEmployeeName($this->current_empid);
  1303. $this->role = $this->getUser()->getAttribute('empRole');
  1304.  
  1305. /* @bug : To give QM the permission to add PE form for employee
  1306. * as per the request from HR
  1307. * @author : John Varghese
  1308. * @modified : Oct 4 2011
  1309. * @work_done : removed the line $this->role != 'qm' from the code
  1310. */
  1311. //if (isset($_SESSION['empId']) && ($this->role != 'staff') && ($this->role != 'qm')) {
  1312.  
  1313. if (isset($_SESSION['empId']) && ($this->role != 'staff')){
  1314. if ($request->isMethod('post')) {
  1315. $deleteid = $this->getRequestParameter('delete');
  1316. $criteria = new Criteria();
  1317. if ($deleteid) {
  1318. foreach ($deleteid as $deletid) {
  1319.  
  1320. /* @bug : To give QM the permission to add PE form for employee
  1321. * as per the request from HR
  1322. * @author : John Varghese
  1323. * @modified : Oct 4 2011
  1324. * @work_done : added aditional check for qm, this->role=="qm"
  1325. */
  1326. //if ($this->role == "admin")
  1327.  
  1328. if ($this->role == "admin" || $this->role == "qm")
  1329. $criteria->add(PeAssignedadminPeer::ASSIGNEDBY, $this->current_empid);
  1330. $criteria->add(PeAssignedadminPeer::ASSIGNADMINID, $deletid);
  1331. $resultObject = PeAssignedadminPeer::doSelect($criteria);
  1332. if (is_array($resultObject) && (count($resultObject) > 0)) {
  1333. $oldAdmin = $resultObject[0]->getOldAdmin();
  1334. $empId = $resultObject[0]->getEmployee();
  1335. $groupwareEmployees = new GroupwareEmployeesPeer();
  1336. $oldAdminName = $groupwareEmployees->getEmployeeName($oldAdmin);
  1337. $newAdmin = $resultObject[0]->getNewAdmin();
  1338. $newAdminName = $groupwareEmployees->getEmployeeName($newAdmin);
  1339. }
  1340. $result = PeAssignedadminPeer::doDelete($criteria);
  1341. $groupwareEmployee = new GroupwareEmployeesPeer();
  1342. $kidName = $groupwareEmployee->getEmployeeName($empId);
  1343. $empName = $groupwareEmployee->getEmployeeName($this->current_empid);
  1344. $logs = new PelogsPeer();
  1345. $assignedlog = $logs->getDeletedAdminLog($newAdminName, $kidName, $empName);
  1346. // to change the evaluator field as old admin
  1347. $peEmployee = new PeEmployeesPeer();
  1348. $peId = $peEmployee->getPeId($empId);
  1349. $criteria = new Criteria();
  1350. $criteria->add(PeEmployeesPeer::PEID, $peId);
  1351. $criteria->add(PeEmployeesPeer::TAKENBY, $oldAdminName);
  1352. PeEmployeesPeer::doUpdate($criteria);
  1353. if ($result == "1") {
  1354. $_SESSION['msg'] = 'Successfully deleted the entry !!';
  1355. } else {
  1356. $_SESSION['error_msg'] = 'You dont have permission to delete this entry';
  1357. }
  1358. }
  1359. }
  1360. }
  1361.  
  1362. $criteria = new Criteria();
  1363. $year = "%" . $this->year . "%";
  1364. $selectedYear = $this->year;
  1365. $assignAdminArray = $this->checkRangeCriteria($selectedYear);
  1366.  
  1367. $cton1 = $criteria->getNewCriterion(PeAssignedadminPeer::ASSIGNADMINID, $assignAdminArray, Criteria::IN);
  1368.  
  1369. $cton2 = $criteria->getNewCriterion(PeAssignedadminPeer::STARTDATE, $year, CRITERIA::LIKE);
  1370. $cton1->addOr($cton2);
  1371.  
  1372. /* @bug : To give QM the permission to add PE form for employee
  1373. * as per the request from HR
  1374. * @author : John Varghese
  1375. * @modified : Oct 4 2011
  1376. * @work_done : added aditional check for qm role, this->role == "qm"
  1377. */
  1378. //if ($this->role == "admin") {
  1379. if ($this->role == "admin" || $this->role == "qm") {
  1380. $cton3 = $criteria->getNewCriterion(PeAssignedadminPeer::ASSIGNEDBY, $this->current_empid);
  1381.  
  1382. $cton4 = $criteria->getNewCriterion(PeAssignedadminPeer::NEWADMIN, $this->current_empid);
  1383. $cton3->addOr($cton4);
  1384. $cton1->addAnd($cton3);
  1385. }
  1386. $criteria->add($cton1);
  1387. if ($this->getRequestParameter('sort')) {
  1388. if ($this->getRequestParameter('order') == 'desc') {
  1389. $criteria->addDescendingOrderByColumn(PeAssignedadminPeer::translateFieldName($this->getRequestParameter('sort'), BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_COLNAME));
  1390. } else {
  1391. $criteria->addAscendingOrderByColumn(PeAssignedadminPeer::translateFieldName($this->getRequestParameter('sort'), BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_COLNAME));
  1392. }
  1393. } else {
  1394. // sorted by date by default
  1395. $criteria->addDescendingOrderByColumn(PeAssignedadminPeer::ASSIGNADMINID);
  1396. }
  1397.  
  1398. if($this->getRequestParameter('search_employee')) {
  1399. $this->search_employee = $this->getRequestParameter('search_employee');
  1400. $groupwareEmployeesPeer = new GroupwareEmployeesPeer();
  1401. $employeeIds = $groupwareEmployeesPeer->getEmployeeId('%'.$this->search_employee.'%');
  1402. $criteria->add(PeAssignedadminPeer::EMPLOYEE, $employeeIds, Criteria::IN);
  1403. }
  1404.  
  1405.  
  1406. $pager = new sfPropelPager('PEAssignedAdmin', PAGE);
  1407. $pager->setCriteria($criteria);
  1408. $pager->setPage($this->getRequestParameter('page', 1));
  1409. $pager->init();
  1410. $this->pager = $pager;
  1411.  
  1412. foreach ($pager->getResults() as $page) {
  1413. $empid = $page->getEmployee();
  1414. $name[$empid] = $GroupwareEmployeesPeer->getEmployeeName($empid);
  1415. $assignedadminid = $page->getNewAdmin();
  1416. $adminname[$assignedadminid] = $GroupwareEmployeesPeer->getEmployeeName($assignedadminid);
  1417. $assignedbyid = $page->getAssignedBy();
  1418. $assignedbyname[$assignedbyid] = $GroupwareEmployeesPeer->getEmployeeName($assignedbyid);
  1419. }
  1420. $this->employename = $name;
  1421. $this->newadminname = $adminname;
  1422. $this->assignedbyname = $assignedbyname;
  1423. $this->role = $this->getUser()->getAttribute('empRole');
  1424. }
  1425. else
  1426. $this->redirect('login/index');
  1427. }
  1428.  
  1429. public function executePeNotifications(sfWebRequest $request) {
  1430. $number = $request->getParameter('page');
  1431. if ($_SESSION['empRole'] == 'hr' || $_SESSION['empRole'] == 'core')
  1432. $this->getPeCoreNotification($number);
  1433. else if ($_SESSION['empRole'] == 'admin')
  1434. $this->getPeAdminNotification($number);
  1435. else if ($_SESSION['empRole'] == 'staff' || $_SESSION['empRole'] == 'qm')
  1436. $this->getPeNotification($number);
  1437. }
  1438.  
  1439. public function executeCheckQc(sfWebRequest $request) {
  1440. $type = $request->getParameter('type');
  1441. $this->type = $type;
  1442. }
  1443.  
  1444. /**
  1445. * Function (executeAddPEForm) for admin to fill staff PE Forms
  1446. * author:sony
  1447. */
  1448. public function executeAddPEForm(sfWebRequest $request) {
  1449. if (isset($_SESSION['empId'])) {
  1450. if ($request->isMethod('post')) {
  1451.  
  1452. $empId = $request->getParameter('employee_id');
  1453. if ($empId == 0) {
  1454. $_SESSION['msg'] = 'Please select an employee';
  1455. $this->redirect('main/addPEForm');
  1456. }
  1457. // to check whether employee filled Self pe form.
  1458. $criteria = new Criteria();
  1459. $criteria->add(PeEmployeesPeer::EMPID, $empId);
  1460. $resultObject = PeEmployeesPeer::doCount($criteria);
  1461. if ($resultObject == 0)
  1462. $_SESSION['msg'] = 'The employee hasn\'t submitted the self PE Form yet !!';
  1463.  
  1464. if ($request->getParameter('peform_type') == 'admin') {
  1465. $_SESSION['peFormType'] = 'admin';
  1466. $this->redirect('main/AdminPEForm?peForm=' . $empId);
  1467. } elseif ($request->getParameter('peform_type') == 'staff') {
  1468.  
  1469. $_SESSION['peFormType'] = 'staff';
  1470. $this->redirect('main/StaffPEForm?peForm=' . $empId);
  1471. } elseif ($request->getParameter('peform_type') == 'admin_monthly') {
  1472. $_SESSION['msg'] = null;
  1473. $year = $this->getRequestParameter("date[year]");
  1474. $month = $this->getRequestParameter("date[month]");
  1475. $day = $this->getRequestParameter("date[day]");
  1476. if ($month < 10)
  1477. $month = "0" . $month;
  1478. if ($day < 10)
  1479. $day = "0" . $day;
  1480. $issuedate = $year . "-" . $month . "-" . $day;
  1481. $this->isSubmittedThisMonth($empId, $issuedate);
  1482. $peId = $this->setMonthlyPEform($empId, $issuedate, ADMIN);
  1483. $_SESSION['peFormType'] = 'admin_monthly';
  1484. $this->redirect('main/AdminPEForm?edit=' . $peId . '&type=monthly');
  1485. }
  1486.  
  1487. elseif ($request->getParameter('peform_type') == 'staff_monthly') {
  1488. $_SESSION['msg'] = null;
  1489. $year = $this->getRequestParameter("date[year]");
  1490. $month = $this->getRequestParameter("date[month]");
  1491. $day = $this->getRequestParameter("date[day]");
  1492. if ($month < 10)
  1493. $month = "0" . $month;
  1494. if ($day < 10)
  1495. $day = "0" . $day;
  1496. $issuedate = $year . "-" . $month . "-" . $day;
  1497. $this->isSubmittedThisMonth($empId, $issuedate);
  1498. $_SESSION['peFormType'] = 'staff_monthly';
  1499. $peId = $this->setMonthlyPEform($empId, $issuedate, STAFF);
  1500. $this->redirect('main/StaffPEForm?edit=' . $peId . '&type=monthly');
  1501. }
  1502.  
  1503. elseif ($request->getParameter('peform_type') == 'qm') {
  1504. $_SESSION['peFormType'] = 'qm';
  1505. $this->redirect('main/QMPEForm?peForm=' . $empId);
  1506. }
  1507. } else {
  1508.  
  1509. /* @bug : To give QM the permission to add PE form for employee
  1510. * as per the request from HR
  1511. * @author : John Varghese
  1512. * @modified : Oct 4 2011
  1513. * @work_done : added the condition to check for qm, this->isQm()
  1514. */
  1515. //if ($this->isCore()) {
  1516.  
  1517. if ($this->isCore() || $this->isQm() || $this->isHr()){
  1518.  
  1519. $employeeInstance = new GroupwareEmployeesPeer();
  1520. $peFormTypes = array('2' => ' Admin PE Form ', '3' => ' Staff PE Form ', '4' => ' Admin Monthly PE Form ', '5' => ' Staff Monthly PE Form ');
  1521. $staff = $employeeInstance->getEmployeeAccounts();
  1522. foreach ($staff as $results) {
  1523. $staffName[$results->getId()] = $results->getName();
  1524. }
  1525. $adminlist = $employeeInstance->getAllAdmins();
  1526. foreach ($adminlist as $admin) {
  1527. $adminName[$admin->getId()] = $admin->getName();
  1528. }
  1529. $optgroup_array = array('-- Select a Staff --', 'Staff' => $staffName, 'Admin' => $adminName);
  1530. $this->optgroup_array = $optgroup_array;
  1531. $this->peFormTypes = $peFormTypes;
  1532. } elseif ($this->isAdmin()) {
  1533.  
  1534. $adminId = $this->getUser()->getAttribute('empId');
  1535. $peFormTypes = array('3' => ' Staff PE Form ', '2' => ' Admin PE Form ', '4' => ' Admin Monthly PE Form ', '5' => ' Staff Monthly PE Form ');
  1536. $optgroup_array = array(); // Array to store staff list
  1537.  
  1538. $teamMembersName = GroupwareEmployeesPeer::getSubordinates($adminId); //To get Subordinates
  1539. $assignedMembersName = PeAssignedadminPeer::getAssignedEmployeesName($adminId); //To get Assigned Employees
  1540.  
  1541. count($assignedMembersName);
  1542.  
  1543. if (is_array($assignedMembersName))
  1544. $optgroup_array = array('-- Select a Staff --', 'Staff' => $teamMembersName, 'Assigned Staff' => $assignedMembersName);
  1545. else
  1546. $optgroup_array = array('-- Select a Staff --', 'Staff' => $teamMembersName);
  1547.  
  1548. $this->peFormTypes = $peFormTypes;
  1549. $this->optgroup_array = $optgroup_array;
  1550. }
  1551. else {
  1552. $_SESSION['error_msg'] = 'You Don\'t have access for this operation';
  1553. $this->redirect('main\index');
  1554. }
  1555. }
  1556. }
  1557. else
  1558. $this->redirect('login/index');
  1559. }
  1560.  
  1561. public function executeSuggestion(sfWebRequest $request) {
  1562. if (isset($_SESSION['empId'])) {
  1563. if ($request->isMethod('post')) {
  1564. $this->getPostedValues();
  1565. }
  1566. } else {
  1567. $this->redirect('login/index');
  1568. }
  1569. }
  1570.  
  1571. function updatePEForm($peStatus) {
  1572. $this->updateEmployee($this->getRequestParameter('update'), $peStatus);
  1573. $this->updateAccomplishments($this->getRequestParameter('accomId'));
  1574. $this->updateResponsibilities($this->getRequestParameter('respId'));
  1575. $this->updateCommunication($this->getRequestParameter('commId'));
  1576. $this->updateQualityQuantity($this->getRequestParameter('qqId'));
  1577. $this->updateJobKnowledge($this->getRequestParameter('jobId'));
  1578. $this->updateManagementSkills($this->getRequestParameter('skillId'));
  1579. $this->updateSocialEffectiveness($this->getRequestParameter('socialId'));
  1580. $this->updateSatisfaction($this->getRequestParameter('satisfactionId'));
  1581. $this->updateLeaveAttendance($this->getRequestParameter('laId'));
  1582. $this->updateQms($this->getRequestParameter('qmsId'));
  1583. $this->updateOtherActivity($this->getRequestParameter('otherId'));
  1584. $this->updateEmpComments($this->getRequestParameter('empCommId'));
  1585. $this->updateDevelopmentPlan($this->getRequestParameter('devId'));
  1586. return true;
  1587. }
  1588.  
  1589. function setPEForm($peStatus, $peform=null, $empid=null) {
  1590. $role = $this->getUser()->getAttribute('empRole');
  1591. // To check whether Employee already Submitted PE Form in the year.
  1592. $peId = $this->isSubmittedThisYear($peform, $empid);
  1593. if ($peId) {
  1594. if ($this->isAdminSaved($peId) || $this->isStaffSaved($peId)) {
  1595. $this->redirect('main/PeForm?edit=' . $peId . '');
  1596. } else {
  1597. $_SESSION['error_msg'] = 'You have already filled a PE Form this year';
  1598. $this->redirect('main/ListPEForm');
  1599. }
  1600. } else {
  1601. $peId = $this->setEmployee($peStatus, $peform, $empid);
  1602. $this->setAccomplishments($peId);
  1603. $this->setResponsibilities($peId);
  1604. $this->setCommunication($peId);
  1605. $this->setQualityQuantity($peId);
  1606. $this->setJobKnowledge($peId);
  1607. $formType = PeChangeformPeer::getFormType($this->getUser()->getAttribute('empId'));
  1608. if ($role != "staff" || $formType == 'admin') {
  1609. $this->setManagementSkills($peId);
  1610. }
  1611. $this->setManagementSkills($peId);
  1612. $this->setSocialEffectiveness($peId);
  1613. $this->setSatisfaction($peId);
  1614. $this->setLeaveAttendance($peId);
  1615. $this->setQms($peId);
  1616. $this->setOtherActivity($peId);
  1617. $this->setEmpComments($peId);
  1618. $this->setDevelopmentPlan($peId);
  1619. return true;
  1620. }
  1621. }
  1622.  
  1623. function editPEForm($peId, $empid=null) {
  1624. $role = $this->getUser()->getAttribute('empRole');
  1625. $this->getPreForm(null, $peId, null);
  1626. $this->emp = $this->getUser();
  1627. $this->getPeDetails($peId);
  1628. $this->getAccomplishments($peId);
  1629. $this->getResponsibility($peId);
  1630. $this->getQualityQuantity($peId);
  1631. $this->getCommunication($peId);
  1632. $this->getJobKnowledge($peId);
  1633. $formType = PeChangeformPeer::getFormType($this->getUser()->getAttribute('empId'));
  1634. if ($role != "staff" || $formType == 'admin') {
  1635. $this->setManagementSkills($peId);
  1636. }
  1637. $this->getManagementSkills($peId);
  1638. $this->getSocialEffectiveness($peId);
  1639. $this->getSocialEffectiveness($peId);
  1640. $this->getSatisfaction($peId);
  1641. $this->getLeaveAttendance($peId);
  1642. $this->getQms($peId);
  1643. $this->getOtherActivity($peId);
  1644. $this->getEmpComments($peId);
  1645. $this->getDevelopmentPlan($peId);
  1646. $this->getSuggestions($peId);
  1647. $this->empid = $empid;
  1648. $this->readonly = false;
  1649. if ($this->getRequestParameter('type') == "original") {
  1650. if ($_SESSION['status'] == "adminsave") {
  1651. $this->editStatus = true;
  1652. } else {
  1653. $this->editStatus = false;
  1654. }
  1655. $_SESSION['status'] = null;
  1656. } else {
  1657. $this->editStatus = true;
  1658. }
  1659. return true;
  1660. }
  1661.  
  1662. function viewPEForm($peId) {
  1663. $role = $this->getUser()->getAttribute('empRole');
  1664. $this->getPreForm(null, $peId, null);
  1665. $this->emp = $this->getUser();
  1666. $this->getPeDetails($peId);
  1667. $this->getAccomplishments($peId);
  1668. $this->getResponsibility($peId);
  1669. $this->getQualityQuantity($peId);
  1670. $this->getCommunication($peId);
  1671. $this->getJobKnowledge($peId);
  1672. // if($role!="staff")
  1673. $this->getManagementSkills($peId);
  1674. $this->getSocialEffectiveness($peId);
  1675. $this->getSocialEffectiveness($peId);
  1676. $this->getSatisfaction($peId);
  1677. $this->getLeaveAttendance($peId);
  1678. $this->getQms($peId);
  1679. $this->getOtherActivity($peId);
  1680. $this->getEmpComments($peId);
  1681. $this->getDevelopmentPlan($peId);
  1682. $this->getSuggestions($peId);
  1683. $this->readonly = true;
  1684. $this->editStatus = false;
  1685. return true;
  1686. }
  1687.  
  1688. // ********** Function TO LIST PEForms *********************
  1689.  
  1690. public function executeListPEForm() {
  1691. if (isset($_SESSION['empId'])) {
  1692. $current_empid = $this->getUser()->getAttribute('empId');
  1693. $newcriteria = new Criteria();
  1694. $newcriteria->add(GroupwareEmployeesPeer::ID, $current_empid);
  1695. $this->user_det = GroupwareEmployeesPeer::doSelect($newcriteria);
  1696. $criteria = new Criteria();
  1697.  
  1698. //************ code down TO SORT in order *****************************
  1699.  
  1700. if ($this->getRequestParameter('sort')) {
  1701. if ($this->getRequestParameter('order') == 'desc') {
  1702. $criteria->addDescendingOrderByColumn(PeEmployeesPeer::translateFieldName($this->getRequestParameter('sort'), BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_COLNAME));
  1703. } else {
  1704. $criteria->addAscendingOrderByColumn(PeEmployeesPeer::translateFieldName($this->getRequestParameter('sort'), BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_COLNAME));
  1705. }
  1706. } else {
  1707. // sorted by PeId by default
  1708. $criteria->addDescendingOrderByColumn(PeEmployeesPeer::PEID);
  1709. }
  1710.  
  1711. //************ code up TO SORT in order *****************************
  1712. $criteria->add(PeEmployeesPeer::EMPID, $current_empid);
  1713. $criteria->setDistinct(true);
  1714. $pager = new sfPropelPager('PeEmployees', PAGE);
  1715. $pager->setCriteria($criteria);
  1716. $pager->setPage($this->getRequestParameter('page', 1));
  1717. $pager->init();
  1718. $this->pager = $pager;
  1719. /**
  1720. * Modified by Eby Paul on 30-11-2013
  1721. * To correct the pagination issues #47208
  1722. * When clicking the next page of the pagination it was showing all the PE forms of all employees
  1723. */
  1724. /****************Eby Paul Starts**********************/
  1725. $pager->getNbResults();
  1726. $pager->getFirstIndice();
  1727. $pager->getLastIndice();
  1728. /*****************Eby Paul Ends**********************/
  1729.  
  1730. $this->role = $this->getUser()->getAttribute('empRole');
  1731. // ******* TO GET THE DETAILS OF THE STATUS TABLE ***************//
  1732. $criteria = new Criteria();
  1733. $resultObject = PeStatusPeer::doSelect($criteria);
  1734. foreach ($resultObject as $result) {
  1735. $statusArray[$result->getstatusId()] = $result->getStatus();
  1736. }
  1737. $this->statusInfo = $statusArray;
  1738. }
  1739. else
  1740. $this->redirect('login/index');
  1741. }
  1742.  
  1743. /* * ***************Function to save an employees PE from ************************** */
  1744.  
  1745. function setEmployee($peStatus, $perform=null, $empid=null) {
  1746. $role = $this->getUser()->getAttribute('empRole');
  1747. if ($_SESSION['peFormType']) {
  1748. $type = ORIGINALCODE;
  1749. if ($_SESSION['peFormType'] == 'admin')
  1750. $emproletype = ADMIN;
  1751. elseif ($_SESSION['peFormType'] == 'staff')
  1752. $emproletype = STAFF;
  1753. elseif ($_SESSION['peFormType'] == 'qm')
  1754. $emproletype = QM;
  1755. $emp_id = $empid;
  1756. $_SESSION['peFormType'] = null;
  1757. }
  1758. elseif ($perform == "original") {
  1759. $emp_id = $this->getRequestParameter('empId');
  1760. $GroupwareTeamsPeer = new GroupwareTeamsPeer();
  1761. $teamAdmins = $GroupwareTeamsPeer->getTeamAdmins();
  1762. $GroupwareEmployeesPeer = new GroupwareEmployeesPeer();
  1763. $empName = $GroupwareEmployeesPeer->getEmployeeUserName($emp_id);
  1764. $nc = new Criteria();
  1765. $nc->add(GroupwareAccountsPeer::ACCOUNT_LID, $empName);
  1766. $nc->addJoin(GroupwareAccountsPeer::ACCOUNT_ID, GroupwareAclPeer::ACL_ACCOUNT);
  1767. $results = GroupwareAclPeer ::doSelect($nc);
  1768. foreach ($results as $user) {
  1769. $roleId = $user->getAclLocation();
  1770. }
  1771. if (in_array($emp_id, $teamAdmins)) {
  1772. $emproletype = ADMIN;
  1773. } elseif (qmRoleId == $roleId) {
  1774. $emproletype = QM;
  1775. } else {
  1776. $emproletype = STAFF;
  1777. }
  1778. $type = ORIGINALCODE;
  1779. $peStatuscode = $peStatus;
  1780. } else {
  1781. $type = SELFCODE;
  1782. $peStatuscode = $peStatus;
  1783. $emproletype = $this->getEmployeeRoleType();
  1784. $emp_id = $this->getRequestParameter('empId');
  1785. }
  1786.  
  1787. $criteria = new Criteria();
  1788. $criteria->add(GroupwareTeamMembersPeer::EMPID, $emp_id);
  1789. $team = GroupwareTeamMembersPeer::doSelect($criteria);
  1790. $employee = new PeEmployees();
  1791. $employee->setEmpId($emp_id);
  1792. if ($team) {
  1793. if ($role != 'qm' && $emproletype != QM)
  1794. $employee->setTeamid($team[0]->getTeamId());
  1795. }
  1796. $employee->setIssueDate($this->getRequestParameter('issue_date'));
  1797. $employee->setReviewDate($this->getRequestParameter('review_date'));
  1798. $employee->setNextReviewDate($this->getRequestParameter('next_date'));
  1799. $employee->setStatusId($peStatus);
  1800. $employee->setTotalMark($this->getRequestParameter('grant_total'));
  1801. $employee->setType($type);
  1802. $employee->setRoletype($emproletype);
  1803. $total = $this->getRequestParameter('grant_total');
  1804. // to calculate Employee Percentage
  1805. if ($emproletype == 0)
  1806. $percentage = ($total / ADMIN_TOTAL) * 100;
  1807. elseif ($emproletype == 1)
  1808. $percentage = ($total / QM_TOTAL) * 100;
  1809. elseif ($emproletype == 2)
  1810. $percentage = ($total / STAFF_TOTAL) * 100;
  1811. $employee->setPercentage($percentage);
  1812. $employee->setImmediateSupervisor($this->getRequestParameter('immediateSupervisor'));
  1813. $employee->setNextSupervisor($this->getRequestParameter('nextSupervisor'));
  1814. $employee->setTakenBy($this->getRequestParameter('takenBy'));
  1815. $employee->save();
  1816. $peId = $employee->getPeId();
  1817. return $peId;
  1818. }
  1819.  
  1820. /* * ***************Function to save an employees Monthly PE form ************************** */
  1821.  
  1822. public function setMonthlyPEform($emp_id=null, $issuedate=null, $emproletype=null) {
  1823. $criteria = new Criteria();
  1824. $criteria->add(GroupwareTeamMembersPeer::EMPID, $emp_id);
  1825. $team = GroupwareTeamMembersPeer::doSelect($criteria);
  1826. $employee = new PeEmployees();
  1827. $employee->setEmpId($emp_id);
  1828. if ($team) {
  1829. if ($role != 'qm' && $emproletype != QM)
  1830. $employee->setTeamid($team[0]->getTeamId());
  1831. }
  1832. $employee->setIssueDate($issuedate);
  1833. $employee->setReviewDate($issuedate);
  1834. $employee->setNextReviewDate($issuedate);
  1835. $employee->setStatusId(12);
  1836. $employee->setType(2);
  1837. $GroupwareTeamsPeer = new GroupwareTeamsPeer();
  1838. $teamAdmins = $GroupwareTeamsPeer->getTeamAdmins();
  1839.  
  1840. $employee->setRoletype($emproletype);
  1841. $employeeDetails = $this->getEmpSupervisorforMonthly($emp_id);
  1842. $employee->setImmediateSupervisor($employeeDetails["supervisor"]);
  1843. $employee->setNextSupervisor($employeeDetails["nextsupervisor"]);
  1844. $employee->setTakenBy($employeeDetails["takenby"]);
  1845. $employee->save();
  1846. $peId = $employee->getPeId();
  1847. $this->setAccomplishments($peId);
  1848. $this->setResponsibilities($peId);
  1849. $this->setCommunication($peId);
  1850. $this->setQualityQuantity($peId);
  1851. $this->setJobKnowledge($peId);
  1852. $this->setManagementSkills($peId);
  1853. $this->setSocialEffectiveness($peId);
  1854. $this->setSatisfaction($peId);
  1855. $this->setLeaveAttendance($peId);
  1856. $this->setQms($peId);
  1857. $this->setOtherActivity($peId);
  1858. $this->setEmpComments($peId);
  1859. $this->setDevelopmentPlan($peId);
  1860. return $peId;
  1861. }
  1862.  
  1863. //added by renjo for executing leave bug report function
  1864. public function executeBugReport(sfWebRequest $request) {
  1865. if (isset($_SESSION['empId'])) {
  1866. $this->role = $this->getUser()->getAttribute('empRole');
  1867. if ($this->role == 'hr' && !$this->getRequestParameter('commit')) {
  1868. $_SESSION['msg'] = 'Please select the staff to add leave bug report';
  1869. }
  1870. if ($this->role == 'core') {
  1871. $_SESSION['msg'] = 'Please select an employee to view leave bug report';
  1872. }
  1873. if ($this->role == 'admin') {
  1874. $_SESSION['msg'] = 'Please select an employee to view leave bug report';
  1875. }
  1876. if (isset($_SESSION['pageempId']) && !$this->getRequestParameter('page') && !$this->getRequestParameter('Cancel')) {
  1877. if ($this->getUser()->getAttribute('CancelStatus') != 'true') {
  1878. $_SESSION['temppageempId'] = '';
  1879. $_SESSION['temppageemprole'] = '';
  1880. $this->getUser()->getAttributeHolder()->remove('selectAllEmployee');
  1881. }
  1882. }
  1883. $this->getUser()->getAttributeHolder()->remove('CancelStatus');
  1884. $this->role = $this->getUser()->getAttribute('empRole');
  1885. if ($this->role == 'staff' || $this->role == 'qm') {
  1886. $this->empId = $this->getUser()->getAttribute('empId');
  1887. $this->getUser()->setAttribute('bugrole2', 'employee');
  1888.  
  1889. $c = new Criteria();
  1890. $c->add(PeBugEmployeePeer::EMPID, $this->empId);
  1891.  
  1892. $pager = new sfPropelPager('PeBugEmployee', PAGE);
  1893. $pager->setCriteria($c);
  1894. $pager->setPage($this->getRequestParameter('page', 1));
  1895. $pager->init();
  1896. $this->pager = $pager;
  1897. }
  1898. if ($this->role == 'admin') {
  1899.  
  1900. $this->getUser()->getAttributeHolder()->remove('bugrole1');
  1901. $this->getUser()->getAttributeHolder()->remove('bugrole2');
  1902. $empId = $this->getUser()->getAttribute('empId');
  1903. //$teamMembersId=$this->getUser()->getAttribute('teamMembers');
  1904. $this->adminId = $empId;
  1905. $groupwareEmployee = new GroupwareEmployeesPeer();
  1906. $this->adminName = $groupwareEmployee->getEmployeeName($empId);
  1907. // to get employee name from employee IDs
  1908. $this->teamMembersName = GroupwareEmployeesPeer::getSubordinates($empId);
  1909. //$this->teamMembersName = $employeeInstance -> getEmployeeNameValue($teamMembersId);
  1910. if ($request->isMethod('post') || $this->getRequestParameter('page')) {
  1911.  
  1912.  
  1913. if ($this->getRequestParameter('page')) {
  1914.  
  1915. }
  1916. $nameOfEmployee = $this->getRequestParameter('employee_id');
  1917. $roleOfEmployee = $this->getRequestParameter('role');
  1918. if ($nameOfEmployee == 0 && ($roleOfEmployee == 'Employee')) {
  1919. $this->getUser()->setAttribute('selectAllEmployee', 'employee');
  1920. $this->redirect('main/ListBugReports?year=' . Date("Y"));
  1921. }
  1922.  
  1923. if ($nameOfEmployee == 0 && $roleOfEmployee == 'Supervisor') {
  1924. $this->getUser()->setAttribute('selectAllEmployee', 'supervisor');
  1925. $this->redirect('main/ListBugReports?year=' . Date("Y"));
  1926. }
  1927. if (!$nameOfEmployee && isset($_SESSION['pageempId'])) {
  1928. $nameOfEmployee = $_SESSION['pageempId'];
  1929. }
  1930.  
  1931. $criteria = new Criteria();
  1932. $criteria->add(GroupwareTeamsPeer::ADMIN_ID, $nameOfEmployee);
  1933. $result = GroupwareTeamsPeer::doSelect($criteria);
  1934. $roleOfEmployee = $this->getRequestParameter('role');
  1935.  
  1936.  
  1937. if (!$roleOfEmployee && isset($_SESSION['pageemprole'])) {
  1938. $roleOfEmployee = $_SESSION['pageemprole'];
  1939. }
  1940.  
  1941.  
  1942.  
  1943. if ($_SESSION['error_msg'] != '') {
  1944.  
  1945. } else {
  1946. if ($result && $roleOfEmployee == 'Supervisor') {
  1947. $this->supervisorId = $this->getRequestParameter('employee_id');
  1948. if (!$this->supervisorId) {
  1949. $this->supervisorId = $_SESSION['pageempId'];
  1950. } else {
  1951. $_SESSION['pageempId'] = $this->supervisorId;
  1952. $_SESSION['temppageempId'] = $this->supervisorId;
  1953. }
  1954.  
  1955. $_SESSION['pageemprole'] = 'Supervisor';
  1956. $_SESSION['temppageemprole'] = 'Supervisor';
  1957. $this->getUser()->setAttribute('bugrole1', 'supervisor');
  1958. $this->getUser()->setAttribute('bugempId', $this->supervisorId);
  1959. $nc = new Criteria();
  1960. $nc->add(PeBugSupervisorPeer::SUPERVISORID, $this->supervisorId);
  1961. $pager = new sfPropelPager('PeBugSupervisor', PAGE);
  1962. $pager->setCriteria($nc);
  1963. $pager->setPage($this->getRequestParameter('page', 1));
  1964.  
  1965. $pager->setParameter('pageempId', $this->supervisorId);
  1966. $pager->setParameter('pageemprole', 'Supervisor');
  1967.  
  1968. $pager->init();
  1969. $this->pager = $pager;
  1970. } else if (!$result && $roleOfEmployee == 'Supervisor') {
  1971. $_SESSION['error_msg'] = 'The selected person is not a supervisor';
  1972. } else {
  1973. $this->empId = $this->getRequestParameter('employee_id');
  1974. $this->getUser()->setAttribute('bugempId', $this->empId);
  1975. $this->getUser()->setAttribute('bugrole2', 'employee');
  1976. if (!$this->empId) {
  1977. $this->empId = $_SESSION['pageempId'];
  1978. } else {
  1979. $_SESSION['pageempId'] = $this->empId;
  1980. $_SESSION['temppageempId'] = $this->empId;
  1981. }
  1982. $_SESSION['pageemprole'] = 'Employee';
  1983. $_SESSION['temppageemprole'] = 'Employee';
  1984. $nc = new Criteria();
  1985. $nc->add(PeBugEmployeePeer::EMPID, $this->empId);
  1986. $pager = new sfPropelPager('PeBugEmployee', PAGE);
  1987. $pager->setCriteria($nc);
  1988. $pager->setPage($this->getRequestParameter('page', 1));
  1989.  
  1990. $pager->setParameter('pageempId', $this->empId);
  1991. $pager->setParameter('pageemprole', 'Employee');
  1992.  
  1993. $pager->init();
  1994. $this->pager = $pager;
  1995. }
  1996. }
  1997. }
  1998. }
  1999. if ($this->role == 'core' || $this->role == 'hr') {
  2000. if ($this->getRequestParameter('Cancel')) {
  2001. $this->getUser()->setAttribute('CancelStatus', 'true');
  2002. $this->redirect('main/BugReport');
  2003. }
  2004. $groupwareEmployees = new GroupwareEmployeesPeer();
  2005. $this->noncore_users = $groupwareEmployees->getEmployeeAccounts();
  2006. $this->adminlist = $groupwareEmployees->getAllAdmins();
  2007. $this->corelist = $groupwareEmployees->getCoreMembers();
  2008. $this->getUser()->getAttributeHolder()->remove('bugrole1');
  2009. $this->getUser()->getAttributeHolder()->remove('bugrole2');
  2010. //
  2011. if ($request->isMethod('post') || $this->getRequestParameter('page')) {
  2012.  
  2013. if ($this->getRequestParameter('page')) {
  2014.  
  2015. }
  2016.  
  2017. $nameOfEmployee = $this->getRequestParameter('employee');
  2018. $roleOfEmployee = $this->getRequestParameter('role');
  2019. if ($nameOfEmployee == 0 && ($roleOfEmployee == 'Employee')) {
  2020. $this->getUser()->setAttribute('selectAllEmployee', 'employee');
  2021. $this->redirect('main/ListBugReports?year=' . Date("Y"));
  2022. }
  2023.  
  2024. if ($nameOfEmployee == 0 && $roleOfEmployee == 'Supervisor') {
  2025. $this->getUser()->setAttribute('selectAllEmployee', 'supervisor');
  2026. $this->redirect('main/ListBugReports?year=' . Date("Y"));
  2027. }
  2028. if (!$nameOfEmployee && isset($_SESSION['pageempId'])) {
  2029. $nameOfEmployee = $_SESSION['pageempId'];
  2030. }
  2031.  
  2032. $criteria = new Criteria();
  2033. $criteria->add(GroupwareTeamsPeer::ADMIN_ID, $nameOfEmployee);
  2034. $result = GroupwareTeamsPeer::doSelect($criteria);
  2035. $roleOfEmployee = $this->getRequestParameter('role');
  2036.  
  2037. if (!$roleOfEmployee && isset($_SESSION['pageemprole'])) {
  2038. $roleOfEmployee = $_SESSION['pageemprole'];
  2039. }
  2040.  
  2041.  
  2042.  
  2043. if ($_SESSION['error_msg'] != '') {
  2044.  
  2045. } else {
  2046. if ($result && $roleOfEmployee == 'Supervisor') {
  2047. $this->supervisorId = $this->getRequestParameter('employee');
  2048. if (!$this->supervisorId) {
  2049. $this->supervisorId = $_SESSION['pageempId'];
  2050. } else {
  2051. $_SESSION['pageempId'] = $this->supervisorId;
  2052. $_SESSION['temppageempId'] = $this->supervisorId;
  2053. }
  2054.  
  2055. $_SESSION['pageemprole'] = 'Supervisor';
  2056. $_SESSION['temppageemprole'] = 'Supervisor';
  2057. $this->getUser()->setAttribute('bugrole1', 'supervisor');
  2058. $this->getUser()->setAttribute('bugempId', $this->supervisorId);
  2059. $nc = new Criteria();
  2060. $nc->add(PeBugSupervisorPeer::SUPERVISORID, $this->supervisorId);
  2061. $pager = new sfPropelPager('PeBugSupervisor', PAGE);
  2062. $pager->setCriteria($nc);
  2063. $pager->setPage($this->getRequestParameter('page', 1));
  2064.  
  2065. $pager->setParameter('pageempId', $this->supervisorId);
  2066. $pager->setParameter('pageemprole', 'Supervisor');
  2067.  
  2068. $pager->init();
  2069. $this->pager = $pager;
  2070. } else if (!$result && $roleOfEmployee == 'Supervisor') {
  2071. $_SESSION['error_msg'] = 'The selected person is not a supervisor';
  2072. } else {
  2073. $this->empId = $this->getRequestParameter('employee');
  2074. $this->getUser()->setAttribute('bugempId', $this->empId);
  2075. $this->getUser()->setAttribute('bugrole2', 'employee');
  2076. if (!$this->empId) {
  2077. $this->empId = $_SESSION['pageempId'];
  2078. } else {
  2079. $_SESSION['pageempId'] = $this->empId;
  2080. $_SESSION['temppageempId'] = $this->empId;
  2081. }
  2082. $_SESSION['pageemprole'] = 'Employee';
  2083. $_SESSION['temppageemprole'] = 'Employee';
  2084. $nc = new Criteria();
  2085. $nc->add(PeBugEmployeePeer::EMPID, $this->empId);
  2086. $pager = new sfPropelPager('PeBugEmployee', PAGE);
  2087. $pager->setCriteria($nc);
  2088. $pager->setPage($this->getRequestParameter('page', 1));
  2089.  
  2090. $pager->setParameter('pageempId', $this->empId);
  2091. $pager->setParameter('pageemprole', 'Employee');
  2092.  
  2093. $pager->init();
  2094. $this->pager = $pager;
  2095. }
  2096. }
  2097. }
  2098. }
  2099. }
  2100. else
  2101. $this->redirect('login/index');
  2102. }
  2103.  
  2104. //code for executing bug report form
  2105. public function executeBugReportForm(sfWebRequest $request) {
  2106. $this->role = $this->getUser()->getAttribute('empRole');
  2107. if (isset($_SESSION['empId']) && ($this->role == 'hr')) {
  2108. if ($request->isMethod('post')) {
  2109. $bugNo = $this->getRequestParameter('bugno');
  2110. if ($this->getUser()->getAttribute('bugrole1') == 'supervisor') {
  2111. //echo "hello";exit;
  2112. $c = new Criteria();
  2113. $c->add(PeBugSupervisorPeer::BUGNO, $bugNo);
  2114. $resultSet = PeBugSupervisorPeer::doSelect($c);
  2115. if ($resultSet) {
  2116. $_SESSION['error_msg'] = 'The entered Bug Number already exists.Please re-enter';
  2117. }
  2118. $teammemberId = $request->getParameter('employee_id');
  2119. if ($teammemberId == 0) {
  2120. $_SESSION['error_msg'] = 'Please select an employee';
  2121. }
  2122. } else if ($this->getUser()->getAttribute('bugrole2') == 'employee') {
  2123.  
  2124. $nc = new Criteria();
  2125. $nc->add(PeBugEmployeePeer::BUGNO, $bugNo);
  2126. $results = PeBugEmployeePeer::doSelect($nc);
  2127. if ($results) {
  2128. $_SESSION['error_msg'] = 'The entered Bug Number already exists.Please re-enter';
  2129. }
  2130. }
  2131. $emp_Id = $this->getUser()->getAttribute('bugempId');
  2132. $groupwareEmployee = new GroupwareEmployeesPeer();
  2133. $EmployeeName = $groupwareEmployee->getEmployeeName($emp_Id);
  2134.  
  2135. $teammemberName = $groupwareEmployee->getEmployeeName($teammemberId);
  2136. $emp_instance = new GroupwareEmployeesPeer();
  2137. $admin_Id = $emp_instance->getEmployeeAdminId($emp_Id);
  2138. $leaveType = $this->getRequestParameter('leavetype');
  2139. if ($leaveType == '0') {
  2140. $_SESSION['error_msg'] = 'Please select leave type';
  2141. }
  2142. $leaveDate = $this->getRequestParameter('leaveDate');
  2143. $appliedDate = $this->getRequestParameter('appliedDate');
  2144. $approvalDate = $this->getRequestParameter('approvalDate');
  2145. if ($bugNo == 0 || $leaveDate == 0 || $appliedDate == 0 || $approvalDate == 0) {
  2146. $_SESSION['error_msg'] = 'Please do not leave any field blank';
  2147. }
  2148.  
  2149. if ($this->getUser()->getAttribute('bugrole1') == 'supervisor') {
  2150. $reason = $this->getRequestParameter('reason');
  2151. if (!$reason) {
  2152. $_SESSION['error_msg'] = 'Please enter the reason';
  2153. }
  2154. }
  2155. if ($_SESSION['error_msg'] != '') {
  2156.  
  2157. } else {
  2158. if ($this->getUser()->getAttribute('bugrole1') == 'supervisor') {
  2159. $bug_sup = new PeBugSupervisor();
  2160. $bug_sup->setBugNo($bugNo);
  2161. $bug_sup->setSupervisorName($EmployeeName);
  2162. $bug_sup->setStaffName($teammemberName);
  2163. $bug_sup->setSupervisorId($emp_Id);
  2164. $bug_sup->setStaffId($teammemberId);
  2165. $bug_sup->setLeaveType($leaveType);
  2166. $bug_sup->setLeaveDate($leaveDate);
  2167. $bug_sup->setAppliedDate($appliedDate);
  2168. $bug_sup->setApprovalDate($approvalDate);
  2169. $bug_sup->setLeaveReason($reason);
  2170. $bug_sup->save();
  2171. $_SESSION['msg'] = 'Bug Report added successfully';
  2172. $groupwareEmployee = new GroupwareEmployeesPeer();
  2173. $kidName = $groupwareEmployee->getEmployeeName($emp_Id);
  2174. $empName = $groupwareEmployee->getEmployeeName($_SESSION['empId']);
  2175. $logs = new PelogsPeer();
  2176. $approveEmployeeLog = $logs->getBugSupervisorLog($kidName, $empName, $bugNo);
  2177. $this->redirect('main/ListBugReports?year=' . Date("Y"));
  2178. } else if ($this->getUser()->getAttribute('bugrole2') == 'employee') {
  2179. $emp_instance = new GroupwareEmployeesPeer();
  2180. $supervisor = $emp_instance->getEmployeeAdmin($emp_Id);
  2181. $bug_emp = new PeBugEmployee();
  2182. $bug_emp->setBugNo($bugNo);
  2183. $bug_emp->setEmpId($emp_Id);
  2184. $bug_emp->setTeamMember($EmployeeName);
  2185. $bug_emp->setSupervisor($supervisor);
  2186. $bug_emp->setLeaveType($leaveType);
  2187. $bug_emp->setLeaveDate($leaveDate);
  2188. $bug_emp->setAppliedDate($appliedDate);
  2189. $bug_emp->setApprovalDate($approvalDate);
  2190. $bug_emp->save();
  2191. $_SESSION['msg'] = 'Bug Report added successfully';
  2192. $groupwareEmployee = new GroupwareEmployeesPeer();
  2193. $kidName = $groupwareEmployee->getEmployeeName($emp_Id);
  2194. $empName = $groupwareEmployee->getEmployeeName($_SESSION['empId']);
  2195. $logs = new PelogsPeer();
  2196. $approveEmployeeLog = $logs->getBugEmployeeLog($kidName, $empName, $bugNo);
  2197. $this->redirect('main/ListBugReports?year=' . Date("Y"));
  2198. }
  2199. }
  2200. }
  2201. }else
  2202. $this->redirect('login/index');
  2203. }
  2204.  
  2205. public function executeViewBugReport(sfWebRequest $request) {
  2206. if (isset($_SESSION['empId'])) {
  2207. if ($this->getRequestParameter('view')) {
  2208. $bugId = $this->getRequestParameter('view');
  2209. if ($this->getUser()->getAttribute('bugrole1') == 'supervisor') {
  2210. $c = new Criteria();
  2211. $c->add(PeBugSupervisorPeer::BUGID, $bugId);
  2212. $this->bug_list = PeBugSupervisorPeer::doSelect($c);
  2213. } else if ($this->getUser()->getAttribute('bugrole2') == 'employee') {
  2214. $c = new Criteria();
  2215. $c->add(PeBugEmployeePeer::BUGID, $bugId);
  2216. $this->bug_list = PeBugEmployeePeer::doSelect($c);
  2217. }
  2218. }
  2219. if ($this->getRequestParameter('delete')) {
  2220. $delId = $this->getRequestParameter('delete');
  2221.  
  2222. if ($this->getUser()->getAttribute('bugrole1') == 'supervisor') {
  2223. $nc = new Criteria();
  2224. $nc->add(PeBugSupervisorPeer::BUGID, $delId);
  2225. $results = PeBugSupervisorPeer::doSelect($nc);
  2226. foreach ($results as $bugs) {
  2227. $emp_Id = $bugs->getSupervisorId();
  2228. $bugNo = $bugs->getBugNo();
  2229. }
  2230. $groupwareEmployee = new GroupwareEmployeesPeer();
  2231. $kidName = $groupwareEmployee->getEmployeeName($emp_Id);
  2232. $empName = $groupwareEmployee->getEmployeeName($_SESSION['empId']);
  2233. $logs = new PelogsPeer();
  2234. $logs->getDeleteBugSupervisorLog($kidName, $empName, $bugNo);
  2235.  
  2236. $c = new Criteria();
  2237. $c->add(PeBugSupervisorPeer::BUGID, $delId);
  2238. $this->bug_list = PeBugSupervisorPeer::doDelete($c);
  2239. $_SESSION['msg'] = 'Bug Report deleted successfully';
  2240. $this->redirect('main/ListBugReports?year=' . Date("Y"));
  2241. } else if ($this->getUser()->getAttribute('bugrole2') == 'employee') {
  2242. $nc = new Criteria();
  2243. $nc->add(PeBugEmployeePeer::BUGID, $delId);
  2244. $results = PeBugEmployeePeer::doSelect($nc);
  2245. foreach ($results as $bugs) {
  2246. $emp_Id = $bugs->getEmpId();
  2247. $bugNo = $bugs->getBugNo();
  2248. }
  2249. $groupwareEmployee = new GroupwareEmployeesPeer();
  2250. $kidName = $groupwareEmployee->getEmployeeName($emp_Id);
  2251. $empName = $groupwareEmployee->getEmployeeName($_SESSION['empId']);
  2252. $logs = new PelogsPeer();
  2253. $logs->getDeleteBugEmployeeLog($kidName, $empName, $bugNo);
  2254.  
  2255. $c = new Criteria();
  2256. $c->add(PeBugEmployeePeer::BUGID, $delId);
  2257. $this->bug_list = PeBugEmployeePeer::doDelete($c);
  2258. $_SESSION['msg'] = 'Bug Report deleted successfully';
  2259. $this->redirect('main/ListBugReports?year=' . Date("Y"));
  2260. }
  2261. }
  2262. }
  2263. }
  2264.  
  2265. public function executeEditBugReport(sfWebRequest $request) {
  2266. $this->role = $this->getUser()->getAttribute('empRole');
  2267. if (isset($_SESSION['empId']) && ($this->role == 'hr')) {
  2268. if ($this->getRequestParameter('edit')) {
  2269. $bugeditId = $this->getRequestParameter('edit');
  2270. if ($this->getUser()->getAttribute('bugrole1') == 'supervisor') {
  2271.  
  2272. $c = new Criteria();
  2273. $c->add(PeBugSupervisorPeer::BUGID, $bugeditId);
  2274. $this->bug_list = PeBugSupervisorPeer::doSelect($c);
  2275. foreach ($this->bug_list as $resultsupervisor) {
  2276. $emp_Id = $resultsupervisor->getSupervisorId();
  2277. }
  2278. } else if ($this->getUser()->getAttribute('bugrole2') == 'employee') {
  2279. $c = new Criteria();
  2280. $c->add(PeBugEmployeePeer::BUGID, $bugeditId);
  2281. $this->bug_list = PeBugEmployeePeer::doSelect($c);
  2282. foreach ($this->bug_list as $resultemployee) {
  2283. $emp_Id = $resultemployee->getEmpId();
  2284. }
  2285. }
  2286. }
  2287. if ($this->getRequestParameter('Cancel')) {
  2288. $this->redirect('main/BugReport');
  2289. }
  2290. if ($request->isMethod('post')) {
  2291. $bugNo = $this->getRequestParameter('bugno');
  2292. $bugId = $this->getRequestParameter('bugNumber');
  2293. if ($this->getUser()->getAttribute('bugrole1') == 'supervisor') {
  2294. $c = new Criteria();
  2295. $c->add(PeBugSupervisorPeer::BUGID, $bugId);
  2296. $this->bug_list = PeBugSupervisorPeer::doSelect($c);
  2297. foreach ($this->bug_list as $resultsupervisor) {
  2298. $emp_Id = $resultsupervisor->getSupervisorId();
  2299. $tempBugNo = $resultsupervisor->getBugNo();
  2300. }
  2301. if ($bugNo != $tempBugNo) {
  2302. $c = new Criteria();
  2303. $c->add(PeBugSupervisorPeer::BUGNO, $bugNo);
  2304. $resultSet = PeBugSupervisorPeer::doSelect($c);
  2305. if ($resultSet) {
  2306. $_SESSION['error_msg'] = 'The entered Bug Number already exists.Please re-enter';
  2307. }
  2308. }
  2309. } else if ($this->getUser()->getAttribute('bugrole2') == 'employee') {
  2310. $c = new Criteria();
  2311. $c->add(PeBugEmployeePeer::BUGID, $bugId);
  2312. $this->bug_list = PeBugEmployeePeer::doSelect($c);
  2313. foreach ($this->bug_list as $resultemployee) {
  2314. $emp_Id = $resultemployee->getEmpId();
  2315. $tempBugNo = $resultemployee->getBugNo();
  2316. }
  2317. if ($bugNo != $tempBugNo) {
  2318. $nc = new Criteria();
  2319. $nc->add(PeBugEmployeePeer::BUGNO, $bugNo);
  2320. $results = PeBugEmployeePeer::doSelect($nc);
  2321. if ($results) {
  2322. $_SESSION['error_msg'] = 'The entered Bug Number already exists.Please re-enter';
  2323. }
  2324. }
  2325. }
  2326. $groupwareEmployee = new GroupwareEmployeesPeer();
  2327. $EmployeeName = $groupwareEmployee->getEmployeeName($emp_Id);
  2328. $teammemberId = $request->getParameter('employee_id');
  2329. $teammemberName = $groupwareEmployee->getEmployeeName($teammemberId);
  2330. $emp_instance = new GroupwareEmployeesPeer();
  2331. $admin_Id = $emp_instance->getEmployeeAdminId($emp_Id);
  2332. $leaveType = $this->getRequestParameter('leavetype');
  2333. if ($leaveType == '0') {
  2334. $_SESSION['error_msg'] = 'Please select leave type';
  2335. }
  2336. $leaveDate = $this->getRequestParameter('leaveDate');
  2337. $appliedDate = $this->getRequestParameter('appliedDate');
  2338. $approvalDate = $this->getRequestParameter('approvalDate');
  2339. if ($bugNo == 0 || $leaveDate == 0 || $appliedDate == 0 || $approvalDate == 0) {
  2340. $_SESSION['error_msg'] = 'Please do not leave any field blank';
  2341. }
  2342.  
  2343. if ($this->getUser()->getAttribute('bugrole1') == 'supervisor') {
  2344. $reason = $this->getRequestParameter('reason');
  2345. if (!$reason) {
  2346. $_SESSION['error_msg'] = 'Please enter the reason';
  2347. }
  2348. }
  2349. if ($_SESSION['error_msg'] != '') {
  2350.  
  2351. } else {
  2352. if ($this->getUser()->getAttribute('bugrole1') == 'supervisor') {
  2353. $criteria = new Criteria();
  2354. $criteria->add(PeBugSupervisorPeer::BUGID, $bugId);
  2355. $criteria->add(PeBugSupervisorPeer::BUGNO, $bugNo);
  2356. $criteria->add(PeBugSupervisorPeer::SUPERVISORID, $emp_Id);
  2357. $criteria->add(PeBugSupervisorPeer::STAFFID, $teammemberId);
  2358. $criteria->add(PeBugSupervisorPeer::LEAVETYPE, $leaveType);
  2359. $criteria->add(PeBugSupervisorPeer::LEAVEDATE, $leaveDate);
  2360. $criteria->add(PeBugSupervisorPeer::APPLIEDDATE, $appliedDate);
  2361. $criteria->add(PeBugSupervisorPeer::APPROVALDATE, $approvalDate);
  2362. $criteria->add(PeBugSupervisorPeer::LEAVEREASON, $reason);
  2363. PeBugSupervisorPeer::doUpdate($criteria);
  2364.  
  2365. $_SESSION['msg'] = 'Bug Report updated successfully';
  2366. $groupwareEmployee = new GroupwareEmployeesPeer();
  2367. $kidName = $groupwareEmployee->getEmployeeName($emp_Id);
  2368. $empName = $groupwareEmployee->getEmployeeName($_SESSION['empId']);
  2369. $logs = new PelogsPeer();
  2370. $logs->getEditBugSupervisorLog($kidName, $empName, $bugNo);
  2371. $this->redirect('main/ListBugReports?year=' . Date("Y"));
  2372. } else if ($this->getUser()->getAttribute('bugrole2') == 'employee') {
  2373. $criteria = new Criteria();
  2374. $criteria->add(PeBugEmployeePeer::BUGID, $bugId);
  2375. $criteria->add(PeBugEmployeePeer::BUGNO, $bugNo);
  2376. $criteria->add(PeBugEmployeePeer::EMPID, $emp_Id);
  2377. $criteria->add(PeBugEmployeePeer::LEAVETYPE, $leaveType);
  2378. $criteria->add(PeBugEmployeePeer::LEAVEDATE, $leaveDate);
  2379. $criteria->add(PeBugEmployeePeer::APPLIEDDATE, $appliedDate);
  2380. $criteria->add(PeBugEmployeePeer::APPROVALDATE, $approvalDate);
  2381. PeBugEmployeePeer::doUpdate($criteria);
  2382. $_SESSION['msg'] = 'Bug Report updated successfully';
  2383. $groupwareEmployee = new GroupwareEmployeesPeer();
  2384. $kidName = $groupwareEmployee->getEmployeeName($emp_Id);
  2385. $empName = $groupwareEmployee->getEmployeeName($_SESSION['empId']);
  2386. $logs = new PelogsPeer();
  2387. $logs->getEditBugEmployeeLog($kidName, $empName, $bugNo);
  2388. $this->redirect('main/ListBugReports?year=' . Date("Y"));
  2389. }
  2390. }
  2391. }
  2392. }else
  2393. $this->redirect('login/index');
  2394. }
  2395.  
  2396. public function executeListBugReports(sfWebRequest $request) {
  2397. $this->role = $this->getUser()->getAttribute('empRole');
  2398. if (isset($_SESSION['empId']) && ($this->role == 'hr' || $this->role == 'core')) {
  2399.  
  2400. if ($this->role == 'core') {
  2401. $_SESSION['msg'] = 'Please select an employee to view leave bug report';
  2402. }
  2403. $groupwareAccounts = new GroupwareEmployeesPeer();
  2404. $this->noncore_users = $groupwareAccounts->getEmployeeAccounts(); //defined in/lib/model/GroupwareAccountsPeer.php
  2405.  
  2406. $this->adminlist = $groupwareAccounts->getAllAdmins();
  2407. $nc = new Criteria();
  2408. $nc->add(GroupwareEmployeesPeer::GRADE, array('MEG'), Criteria::IN);
  2409. $this->corelist = GroupwareEmployeesPeer::doSelect($nc);
  2410. if ($this->getUser()->getAttribute('selectAllEmployee') == 'employee') {
  2411. if ($this->getRequestParameter('year'))
  2412. $year = $this->getRequestParameter('year');
  2413. else
  2414. $year=Date("Y");
  2415. $this->year = $year;
  2416. $this->getUser()->setAttribute('bugrole2', 'employee');
  2417. $_SESSION['temppageemprole'] = 'Employee';
  2418. $pager = new sfPropelPager('PeBugEmployee', PAGE);
  2419. $nc1 = new Criteria();
  2420. $nc1->add(PeBugEmployeePeer::LEAVEDATE, $year . "%", Criteria::LIKE);
  2421. $pager->setCriteria($nc1);
  2422.  
  2423. $pager->setPage($this->getRequestParameter('page', 1));
  2424. $pager->init();
  2425. $this->pager = $pager;
  2426. }else if ($this->getUser()->getAttribute('selectAllEmployee') == 'supervisor') {
  2427. $this->getUser()->setAttribute('bugrole1', 'supervisor');
  2428. $_SESSION['temppageemprole'] = 'Supervisor';
  2429. $pager = new sfPropelPager('PeBugSupervisor', PAGE);
  2430. if ($this->getRequestParameter('year'))
  2431. $year = $this->getRequestParameter('year');
  2432. else
  2433. $year=Date("Y");
  2434. $this->year = $year;
  2435. $nc1 = new Criteria();
  2436. $nc1->add(PeBugSupervisorPeer::LEAVEDATE, $year . "%", Criteria::LIKE);
  2437. $pager->setCriteria($nc1);
  2438. $pager->setPage($this->getRequestParameter('page', 1));
  2439. $pager->init();
  2440. $this->pager = $pager;
  2441. }
  2442. }
  2443. if (isset($_SESSION['empId']) && ($this->role == 'admin')) {
  2444. if ($this->role == 'admin') {
  2445. $_SESSION['msg'] = 'Please select an employee to view leave bug report';
  2446. }
  2447. $empId = $this->getUser()->getAttribute('empId');
  2448. $this->adminId = $empId;
  2449. $groupwareEmployee = new GroupwareEmployeesPeer();
  2450. $this->adminName = $groupwareEmployee->getEmployeeName($empId);
  2451. // to get employee name from employee IDs
  2452. //$teamMembersId=$this->getUser()->getAttribute('teamMembers');
  2453. $this->teamMembersName = GroupwareEmployeesPeer::getSubordinates($empId);
  2454. //$employeeInstance = new GroupwareEmployeesPeer();
  2455. //$this->teamMembersName = $employeeInstance -> getEmployeeNameValue($teamMembersId);
  2456.  
  2457. if ($this->getUser()->getAttribute('selectAllEmployee') == 'employee') {
  2458. $this->getUser()->setAttribute('bugrole2', 'employee');
  2459. $_SESSION['temppageemprole'] = 'Employee';
  2460. $groupwareEmployee = new GroupwareEmployeesPeer();
  2461. $supervisorName = $groupwareEmployee->getEmployeeName($_SESSION['empId']);
  2462. if ($this->getRequestParameter('year'))
  2463. $year = $this->getRequestParameter('year');
  2464. else
  2465. $year=Date("Y");
  2466. $this->year = $year;
  2467. $nc = new Criteria();
  2468. $nc->add(PeBugEmployeePeer::SUPERVISOR, $supervisorName);
  2469. $nc->add(PeBugEmployeePeer::LEAVEDATE, $year . "%", Criteria::LIKE);
  2470. $pager = new sfPropelPager('PeBugEmployee', PAGE);
  2471. $pager->setCriteria($nc);
  2472. $pager->setPage($this->getRequestParameter('page', 1));
  2473. $pager->init();
  2474. $this->pager = $pager;
  2475. }else if ($this->getUser()->getAttribute('selectAllEmployee') == 'supervisor') {
  2476. if ($this->getRequestParameter('year'))
  2477. $year = $this->getRequestParameter('year');
  2478. else
  2479. $year=Date("Y");
  2480. $this->year = $year;
  2481. $this->getUser()->setAttribute('bugrole1', 'supervisor');
  2482. $_SESSION['temppageemprole'] = 'Supervisor';
  2483. $nc = new Criteria();
  2484. $nc->add(PeBugSupervisorPeer::LEAVEDATE, $year . "%", Criteria::LIKE);
  2485. $nc->add(PeBugSupervisorPeer::SUPERVISORID, $_SESSION['empId']);
  2486. $pager = new sfPropelPager('PeBugSupervisor', PAGE);
  2487. $pager->setCriteria($nc);
  2488. $pager->setPage($this->getRequestParameter('page', 1));
  2489. $pager->init();
  2490. $this->pager = $pager;
  2491. }
  2492. }
  2493. }
  2494.  
  2495. //end of leave bug report
  2496. /* * ************ Function to save employee accomplishments into PE_Accomplishments table ******************** */
  2497.  
  2498. public function executeAccessLogs(sfWebRequest $request) {
  2499. if ($_SESSION['empRole'] == 'hr' || $_SESSION['empRole'] == 'core') {
  2500. if ($this->getRequestParameter('delete')) {
  2501. $id = $this->getRequestParameter('delete');
  2502. $accounts = new PeAccessLogsPeer();
  2503. $accounts->unBlockIP($id);
  2504. $_SESSION['msg'] = 'The record has been deleted successfully.';
  2505. }
  2506. } else {
  2507. $this->redirect('login/index');
  2508. }
  2509. }
  2510.  
  2511. public function executeAutoSave(sfWebRequest $request) {
  2512. $success = $this->validateMark();
  2513. if ($success == false) {
  2514. $this->msg = "Unable to save the Form";
  2515. } else {
  2516. if ($this->getRequestParameter('perform') == "original") {
  2517. $peStatus = 3;
  2518. } else {
  2519. $peStatus = 1;
  2520. }
  2521. if ($this->getRequestParameter('update') || isset($_SESSION['autoSave'])) {
  2522. if ($this->getRequestParameter('update')) {
  2523. $peId = $this->getRequestParameter('update');
  2524. $accomId = $this->getRequestParameter('accomId');
  2525. $respId = $this->getRequestParameter('respId');
  2526. $qqId = $this->getRequestParameter('qqId');
  2527. $commId = $this->getRequestParameter('commId');
  2528. $jobId = $this->getRequestParameter('jobId');
  2529. $mngId = $this->getRequestParameter('skillId');
  2530. $socialId = $this->getRequestParameter('socialId');
  2531. $satId = $this->getRequestParameter('satisfactionId');
  2532. $lecId = $this->getRequestParameter('laId');
  2533. $qmsId = $this->getRequestParameter('qmsId');
  2534. $otherId = $this->getRequestParameter('otherId');
  2535. $empId = $this->getRequestParameter('empCommId');
  2536. $devId = $this->getRequestParameter('devId');
  2537. } else {
  2538. $peId = $_SESSION['autoSave'];
  2539. $Accomcriteria = new Criteria();
  2540. $Accomcriteria->add(AccomplishmentsPeer::PEID, $peId);
  2541. $Accomcriteria->addSelectColumn(AccomplishmentsPeer::ACCOMID);
  2542. $resultSet = AccomplishmentsPeer::doSelect($Accomcriteria);
  2543. $accomId = $resultSet[0]->getAccomId();
  2544.  
  2545. $Respcriteria = new Criteria();
  2546. $Respcriteria->add(ResponsibilitiesPeer::PEID, $peId);
  2547. $Respcriteria->addSelectColumn(ResponsibilitiesPeer::RESPID);
  2548. $resultSet = ResponsibilitiesPeer::doSelect($Respcriteria);
  2549. $respId = $resultSet[0]->getRespId();
  2550.  
  2551. $Qltycriteria = new Criteria();
  2552. $Qltycriteria->add(QualityQuantityPeer::PEID, $peId);
  2553. $Qltycriteria->addSelectColumn(QualityQuantityPeer::QQID);
  2554. $resultSet = QualityQuantityPeer::doSelect($Qltycriteria);
  2555. $qqId = $resultSet[0]->getQqId();
  2556.  
  2557. $Commcriteria = new Criteria();
  2558. $Commcriteria->add(CommunicationPeer::PEID, $peId);
  2559. $Commcriteria->addSelectColumn(CommunicationPeer::COMMID);
  2560. $resultSet = CommunicationPeer::doSelect($Commcriteria);
  2561. $commId = $resultSet[0]->getCommId();
  2562.  
  2563. $Jobcriteria = new Criteria();
  2564. $Jobcriteria->add(JobKnowledgePeer::PEID, $peId);
  2565. $Jobcriteria->addSelectColumn(JobKnowledgePeer::JOBID);
  2566. $resultSet = JobKnowledgePeer::doSelect($Jobcriteria);
  2567. $jobId = $resultSet[0]->getJobId();
  2568.  
  2569. $Mngcriteria = new Criteria();
  2570. $Mngcriteria->add(ManagementSkillsPeer::PEID, $peId);
  2571. $Mngcriteria->addSelectColumn(ManagementSkillsPeer::SKILLID);
  2572. $resultSet = ManagementSkillsPeer::doSelect($Mngcriteria);
  2573. $mngId = $resultSet[0]->getSkillId();
  2574.  
  2575. $Socialcriteria = new Criteria();
  2576. $Socialcriteria->add(SocialEffectivenessPeer::PEID, $peId);
  2577. $Socialcriteria->addSelectColumn(SocialEffectivenessPeer::SOCIALID);
  2578. $resultSet = SocialEffectivenessPeer::doSelect($Socialcriteria);
  2579. $socialId = $resultSet[0]->getSocialId();
  2580.  
  2581. $Satcriteria = new Criteria();
  2582. $Satcriteria->add(SatisfactionPeer::PEID, $peId);
  2583. $Satcriteria->addSelectColumn(SatisfactionPeer::ID);
  2584. $resultSet = SatisfactionPeer::doSelect($Satcriteria);
  2585. $satId = $resultSet[0]->getId();
  2586.  
  2587. $Levcriteria = new Criteria();
  2588. $Levcriteria->add(LeaveAttendancePeer::PEID, $peId);
  2589. $Levcriteria->addSelectColumn(LeaveAttendancePeer::LAID);
  2590. $resultSet = LeaveAttendancePeer::doSelect($Levcriteria);
  2591. $lecId = $resultSet[0]->getLaId();
  2592.  
  2593. $Qmscriteria = new Criteria();
  2594. $Qmscriteria->add(QmsPeer::PEID, $peId);
  2595. $Qmscriteria->addSelectColumn(QmsPeer::ID);
  2596. $resultSet = QmsPeer::doSelect($Qmscriteria);
  2597. $qmsId = $resultSet[0]->getId();
  2598.  
  2599. $Othercriteria = new Criteria();
  2600. $Othercriteria->add(OtherActivityPeer::PEID, $peId);
  2601. $Othercriteria->addSelectColumn(OtherActivityPeer::ACTIVITYID);
  2602. $resultSet = OtherActivityPeer::doSelect($Othercriteria);
  2603. $otherId = $resultSet[0]->getActivityId();
  2604.  
  2605. $Empcriteria = new Criteria();
  2606. $Empcriteria->add(EmpCommentsPeer::PEID, $peId);
  2607. $Empcriteria->addSelectColumn(EmpCommentsPeer::ID);
  2608. $resultSet = EmpCommentsPeer::doSelect($Empcriteria);
  2609. $empId = $resultSet[0]->getId();
  2610.  
  2611. $Devcriteria = new Criteria();
  2612. $Devcriteria->add(DevelopmentPlanPeer::PEID, $peId);
  2613. $Devcriteria->addSelectColumn(DevelopmentPlanPeer::DEVID);
  2614. $resultSet = DevelopmentPlanPeer::doSelect($Devcriteria);
  2615. $devId = $resultSet[0]->getDevId();
  2616. }
  2617. $this->updateEmployee($peId, $peStatus);
  2618. $this->updateAccomplishments($accomId);
  2619. $this->updateResponsibilities($respId);
  2620. $this->updateCommunication($commId);
  2621. $this->updateQualityQuantity($qqId);
  2622. $this->updateJobKnowledge($jobId);
  2623. $this->updateManagementSkills($mngId);
  2624. $this->updateSocialEffectiveness($socialId);
  2625. $this->updateSatisfaction($satId);
  2626. $this->updateLeaveAttendance($lecId);
  2627. $this->updateQms($qmsId);
  2628. $this->updateOtherActivity($otherId);
  2629. $this->updateEmpComments($empId);
  2630. $this->updateDevelopmentPlan($devId);
  2631. } else {
  2632. $peform = $this->getRequestParameter('perform');
  2633. $empid = $this->getRequestParameter('empId');
  2634. $peId = $this->setEmployee($peStatus, $peform, $empid);
  2635. $this->setAccomplishments($peId);
  2636. $this->setResponsibilities($peId);
  2637. $this->setCommunication($peId);
  2638. $this->setQualityQuantity($peId);
  2639. $this->setJobKnowledge($peId);
  2640. $this->setManagementSkills($peId);
  2641. $this->setManagementSkills($peId);
  2642. $this->setSocialEffectiveness($peId);
  2643. $this->setSatisfaction($peId);
  2644. $this->setLeaveAttendance($peId);
  2645. $this->setQms($peId);
  2646. $this->setOtherActivity($peId);
  2647. $this->setEmpComments($peId);
  2648. $this->setDevelopmentPlan($peId);
  2649. $_SESSION['autoSave'] = $peId;
  2650. }
  2651. $this->msg = 'Autosaving the PE form ';
  2652. }
  2653. }
  2654.  
  2655. public function executeAccessLogsResult(sfWebRequest $request) {
  2656. if ($_SESSION['empRole'] == 'hr' || $_SESSION['empRole'] == 'core') {
  2657. if ($this->getRequestParameter('page')) {
  2658. if (isset($_SESSION['accessLogUsername']))
  2659. $username = $_SESSION['accessLogUsername'];
  2660. if (isset($_SESSION['accessLogIp']))
  2661. $ip = $_SESSION['accessLogIp'];
  2662. }
  2663. else {
  2664. $_SESSION['accessLogUsername'] = '';
  2665. $_SESSION['accessLogIp'] = '';
  2666. }
  2667. $c = new Criteria();
  2668. $c->addAscendingOrderByColumn(PeAccessLogsPeer::USERNAME);
  2669. $peAccess = PeAccessLogsPeer::doSelect($c);
  2670. foreach ($peAccess as $results) {
  2671. $accessArray[] = $results->getUsername();
  2672. }
  2673. $accessArr = array_unique($accessArray);
  2674. $this->accessArr = $accessArr;
  2675. if ($this->getRequestParameter('username')) {
  2676. $usernameId = $this->getRequestParameter('username');
  2677. $username = $accessArr[$usernameId];
  2678. $_SESSION['accessLogUsername'] = $username;
  2679. }
  2680. if ($this->getRequestParameter('ip')) {
  2681. $ip = $this->getRequestParameter('ip');
  2682. $_SESSION['accessLogIp'] = $ip;
  2683. }
  2684. $this->getAccessLogs($ip, $username);
  2685. } else {
  2686. $this->redirect('login/index');
  2687. }
  2688. }
  2689.  
  2690. function getAccessLogs($ip=null, $username=null) {
  2691. $i = 0;
  2692. $c = new Criteria();
  2693. $c->addAscendingOrderByColumn(PeAccessLogsPeer::USERNAME);
  2694. $peAccess = PeAccessLogsPeer::doSelect($c);
  2695. foreach ($peAccess as $results) {
  2696. $accessArray[] = $results->getUsername();
  2697. }
  2698. $accessArr = array_unique($accessArray);
  2699. $this->accessArr = $accessArr;
  2700. $criteria = new Criteria();
  2701. $criteria->addDescendingOrderByColumn(PeAccessLogsPeer::LASTLOGIN);
  2702. if ($username != null && $ip != null) {
  2703. $criteria->add(PeAccessLogsPeer::IP, $ip);
  2704. $criteria->add(PeAccessLogsPeer::USERNAME, $username);
  2705. } else if ($username == null && $ip != null) {
  2706. $criteria->add(PeAccessLogsPeer::IP, $ip);
  2707. } else if ($ip == null && $username != null) {
  2708. $criteria->add(PeAccessLogsPeer::USERNAME, $username);
  2709. }
  2710. $pager = new sfPropelPager('PeAccessLogs', PAGE);
  2711. $pager->setCriteria($criteria);
  2712. $pager->setPage($this->getRequestParameter('page', 1));
  2713. $pager->init();
  2714. $this->pager = $pager;
  2715. }
  2716.  
  2717. function setAccomplishments($peId) {
  2718. $accomplishment = new Accomplishments();
  2719. $accomplishment->setPeId($peId);
  2720. $accomplishment->setAccomOne($this->getRequestParameter('accom1'));
  2721. $accomplishment->setAccomTwo($this->getRequestParameter('accom2'));
  2722. $accomplishment->setAccomThree($this->getRequestParameter('accom3'));
  2723. $accomplishment->setAccomOneMark($this->getRequestParameter('accom_mark1'));
  2724. $accomplishment->setAccomTwoMark($this->getRequestParameter('accom_mark2'));
  2725. $accomplishment->setAccomThreeMark($this->getRequestParameter('accom_mark3'));
  2726. $accomplishment->setAccomComments($this->getRequestParameter('accom_comment'));
  2727. $accomplishment->setAccomMark($this->getRequestParameter('accom_total'));
  2728. $accomplishment->save();
  2729. }
  2730.  
  2731. function setResponsibilities($peId) {
  2732. $responsibility = new Responsibilities();
  2733. $responsibility->setPeId($peId);
  2734. $responsibility->setRespOne($this->getRequestParameter('resp1'));
  2735. $responsibility->setRespTwo($this->getRequestParameter('resp2'));
  2736. $responsibility->setRespThree($this->getRequestParameter('resp3'));
  2737. $responsibility->setRespOneMark($this->getRequestParameter('resp_mark1'));
  2738. $responsibility->setRespTwoMark($this->getRequestParameter('resp_mark2'));
  2739. $responsibility->setRespThreeMark($this->getRequestParameter('resp_mark3'));
  2740. $responsibility->setRespComments($this->getRequestParameter('resp_comment'));
  2741. $responsibility->setRespMark($this->getRequestParameter('resp_total'));
  2742. $responsibility->save();
  2743. }
  2744.  
  2745. function setQualityQuantity($peId) {
  2746. $quality_quantity = new QualityQuantity();
  2747. $quality_quantity->setPeId($peId);
  2748. $quality_quantity->setIfQC($this->getRequestParameter('qc'));
  2749. $quality_quantity->setAvgQC($this->getRequestParameter('avg_qc'));
  2750. $quality_quantity->setAvgLastQC($this->getRequestParameter('avg_last_qc'));
  2751. $quality_quantity->setQualityMark($this->getRequestParameter('quality_mark'));
  2752. $quality_quantity->setQualityRating($this->getRequestParameter('quality_rating'));
  2753. $quality_quantity->setQualityGoals($this->getRequestParameter('quality_goal'));
  2754. $quality_quantity->setIfNC($this->getRequestParameter('if_nc'));
  2755. $quality_quantity->setNC($this->getRequestParameter('nc'));
  2756. $quality_quantity->setTicketPerShift($this->getRequestParameter('tkt_shift'));
  2757. $quality_quantity->setQuantityMark($this->getRequestParameter('quantity_mark'));
  2758. $quality_quantity->setQuantityRating($this->getRequestParameter('quantity_rating'));
  2759. $quality_quantity->setQuantityGoals($this->getRequestParameter('quantity_goal'));
  2760. $quality_quantity->setQqMark($this->getRequestParameter('quantity_mark') + $this->getRequestParameter('quality_mark'));
  2761. $quality_quantity->save();
  2762. }
  2763.  
  2764. function setCommunication($peId) {
  2765. $communication = new Communication();
  2766. $communication->setPeId($peId);
  2767. $communication->setWritten($this->getRequestParameter('written'));
  2768. $communication->setSpoken($this->getRequestParameter('spoken'));
  2769. $communication->setWithAdmin($this->getRequestParameter('with_admin'));
  2770. $communication->setWithClients($this->getRequestParameter('with_clients'));
  2771. $communication->setWrittenMark($this->getRequestParameter('comm_mark1'));
  2772. $communication->setSpokenMark($this->getRequestParameter('comm_mark2'));
  2773. $communication->setWithAdminMark($this->getRequestParameter('comm_mark3'));
  2774. $communication->setWithClientsMark($this->getRequestParameter('comm_mark4'));
  2775. $communication->setWrittenExpect($this->getRequestParameter('written_expect'));
  2776. $communication->setSpokenExpect($this->getRequestParameter('spoken_expect'));
  2777. $communication->setWithAdminExpect($this->getRequestParameter('with_admin_expect'));
  2778. $communication->setWithClientsExpect($this->getRequestParameter('with_clients_expect'));
  2779. $communication->setCommMark($this->getRequestParameter('comm_total'));
  2780. $communication->setCommGoals($this->getRequestParameter('comm_goal'));
  2781. $communication->save();
  2782. }
  2783.  
  2784. function setJobKnowledge($peId) {
  2785. $job = new JobKnowledge();
  2786. $job->setPeId($peId);
  2787. $job->setTechOne($this->getRequestParameter('tech1'));
  2788. $job->setTechTwo($this->getRequestParameter('tech2'));
  2789. $job->setTechThree($this->getRequestParameter('tech3'));
  2790. $job->setTechFour($this->getRequestParameter('tech4'));
  2791. $job->setTechFive($this->getRequestParameter('tech5'));
  2792. $job->setTechSix($this->getRequestParameter('tech6'));
  2793. $job->setTechSeven($this->getRequestParameter('tech7'));
  2794. $job->setTechEight($this->getRequestParameter('tech8'));
  2795. $job->setTechOneMark($this->getRequestParameter('tech_mark1'));
  2796. $job->setTechTwoMark($this->getRequestParameter('tech_mark2'));
  2797. $job->setTechThreeMark($this->getRequestParameter('tech_mark3'));
  2798. $job->setTechFourMark($this->getRequestParameter('tech_mark4'));
  2799. $job->setTechFiveMark($this->getRequestParameter('tech_mark5'));
  2800. $job->setTechSixMark($this->getRequestParameter('tech_mark6'));
  2801. $job->setTechSevenMark($this->getRequestParameter('tech_mark7'));
  2802. $job->setTechEightMark($this->getRequestParameter('tech_mark8'));
  2803. $job->setTechOneExpect($this->getRequestParameter('tech1_expect'));
  2804. $job->setTechTwoExpect($this->getRequestParameter('tech2_expect'));
  2805. $job->setTechThreeExpect($this->getRequestParameter('tech3_expect'));
  2806. $job->setTechFourExpect($this->getRequestParameter('tech4_expect'));
  2807. $job->setTechFiveExpect($this->getRequestParameter('tech5_expect'));
  2808. $job->setTechSixExpect($this->getRequestParameter('tech6_expect'));
  2809. $job->setTechSevenExpect($this->getRequestParameter('tech7_expect'));
  2810. $job->setTechEightExpect($this->getRequestParameter('tech8_expect'));
  2811. $job->setJobMark($this->getRequestParameter('tech_total'));
  2812. $job->setJobComments($this->getRequestParameter('tech_comment'));
  2813. $job->setJobGoals($this->getRequestParameter('tech_goal'));
  2814. $job->save();
  2815. }
  2816.  
  2817. function setManagementSkills($peId) {
  2818. $management = new ManagementSkills();
  2819. $management->setPeId($peId);
  2820. $management->setLeadership($this->getRequestParameter('leadership'));
  2821. $management->setDelegation($this->getRequestParameter('delegation'));
  2822. $management->setJudgement($this->getRequestParameter('decision'));
  2823.  
  2824. $management->setAdministration($this->getRequestParameter('administration'));
  2825. $management->setPerformance($this->getRequestParameter('performance'));
  2826. $management->setpersonal($this->getRequestParameter('personal'));
  2827. $management->setLeadershipMark($this->getRequestParameter('skill_mark1'));
  2828. $management->setDelegationMark($this->getRequestParameter('skill_mark2'));
  2829. $management->setJudgementMark($this->getRequestParameter('skill_mark3'));
  2830. $management->setAdministrationMark($this->getRequestParameter('skill_mark4'));
  2831. $management->setPerformanceMark($this->getRequestParameter('skill_mark6'));
  2832. $management->setpersonalMark($this->getRequestParameter('skill_mark5'));
  2833. $management->setLeadershipExpect($this->getRequestParameter('leadership_expect'));
  2834. $management->setDelegationExpect($this->getRequestParameter('delegation_expect'));
  2835. $management->setJudgementExpect($this->getRequestParameter('decision_expect'));
  2836. $management->setAdministrationExpect($this->getRequestParameter('administration_expect'));
  2837. $management->setPerformanceExpect($this->getRequestParameter('performance_expect'));
  2838. $management->setpersonalExpect($this->getRequestParameter('personal_expect'));
  2839. $management->setSkillMark($this->getRequestParameter('skill_total'));
  2840. $management->save();
  2841. }
  2842.  
  2843. function setSocialEffectiveness($peId) {
  2844. $social = new SocialEffectiveness();
  2845. $social->setPeId($peId);
  2846. $social->setDependable($this->getRequestParameter('dependability'));
  2847. $social->setCreative($this->getRequestParameter('creativity'));
  2848. $social->setOrganize($this->getRequestParameter('organize'));
  2849. $social->setWithOthers($this->getRequestParameter('with_others'));
  2850. $social->setAdaptable($this->getRequestParameter('adaptable'));
  2851. $social->setSkillImprove($this->getRequestParameter('improve'));
  2852. $social->setDependableMark($this->getRequestParameter('social_mark1'));
  2853. $social->setCreativeMark($this->getRequestParameter('social_mark2'));
  2854. $social->setOrganizeMark($this->getRequestParameter('social_mark3'));
  2855. $social->setWithOthersMark($this->getRequestParameter('social_mark4'));
  2856. $social->setAdaptableMark($this->getRequestParameter('social_mark5'));
  2857. $social->setSkillImproveMark($this->getRequestParameter('social_mark6'));
  2858. $social->setDependableExpect($this->getRequestParameter('dependability_expect'));
  2859. $social->setCreativeExpect($this->getRequestParameter('creativity_expect'));
  2860. $social->setOrganizeExpect($this->getRequestParameter('organize_expect'));
  2861. $social->setWithOthersExpect($this->getRequestParameter('with_others_expect'));
  2862. $social->setAdaptableExpect($this->getRequestParameter('adaptable_expect'));
  2863. $social->setSkillImproveExpect($this->getRequestParameter('improve_expect'));
  2864. $social->setSocialMark($this->getRequestParameter('social_total'));
  2865. $social->setTeamMeetingMark($this->getRequestParameter('social_mark7'));
  2866. $social->setTimelyCompletionMark($this->getRequestParameter('social_mark8'));
  2867. $social->setSocialComments($this->getRequestParameter('social_comments'));
  2868. $social->save();
  2869. }
  2870.  
  2871. function setSatisfaction($peId) {
  2872. $satisfaction = new Satisfaction();
  2873. $satisfaction->setPeId($peId);
  2874. $satisfaction->setComments($this->getRequestParameter('customer_comments'));
  2875. $satisfaction->setGoals($this->getRequestParameter('customer_goals'));
  2876. $satisfaction->setTotalMark($this->getRequestParameter('cus_total'));
  2877. $satisfaction->save();
  2878. }
  2879.  
  2880. function setLeaveAttendance($peId) {
  2881. $leave_attendance = new LeaveAttendance();
  2882. $leave_attendance->setPeId($peId);
  2883. $leave_attendance->setAttendanceMark($this->getRequestParameter('attendance_total'));
  2884. $leave_attendance->setLeaveSelfMark($this->getRequestParameter('leave_mark1'));
  2885. $leave_attendance->setLeaveTeamMark($this->getRequestParameter('leave_mark2'));
  2886. $leave_attendance->setLeaveMark($this->getRequestParameter('leave_total'));
  2887. $leave_attendance->setAttendanceComments($this->getRequestParameter('attendance_comment'));
  2888. $leave_attendance->setLeaveComments($this->getRequestParameter('leave_comment'));
  2889. $leave_attendance->save();
  2890. }
  2891.  
  2892. function setQms($peId) {
  2893. $qms = new Qms();
  2894. $qms->setPeId($peId);
  2895. $qms->setItfMember($this->getRequestParameter('itf'));
  2896. $qms->setIntenalAuditor($this->getRequestParameter('internal'));
  2897. $qms->setIsoAwareness($this->getRequestParameter('iso'));
  2898. $qms->setTotalMark($this->getRequestParameter('qms_total'));
  2899. $qms->setComments($this->getRequestParameter('qms_comment'));
  2900. $qms->setItfmark($this->getRequestParameter('qms_mark1'));
  2901. $qms->setInternalauditormark($this->getRequestParameter('qms_mark2'));
  2902. $qms->setIsoawarenessmark($this->getRequestParameter('qms_mark3'));
  2903. $qms->save();
  2904. }
  2905.  
  2906. function setOtherActivity($peId) {
  2907. $other = new OtherActivity();
  2908. $other->setPeId($peId);
  2909. $other->setGroupOne($this->getRequestParameter('group1'));
  2910. $other->setGroupTwo($this->getRequestParameter('group2'));
  2911. $other->setGroupThree($this->getRequestParameter('group3'));
  2912. $other->setGroupOneMark($this->getRequestParameter('group_mark1'));
  2913. $other->setGroupTwoMark($this->getRequestParameter('group_mark2'));
  2914. $other->setGroupThreeMark($this->getRequestParameter('group_mark3'));
  2915. $other->setGroupMark($this->getRequestParameter('group_total'));
  2916. $other->setSeminarMark($this->getRequestParameter('indvl_mark1'));
  2917. $other->setKbEntryMark($this->getRequestParameter('indvl_mark2'));
  2918. $other->setWorkshopMark($this->getRequestParameter('indvl_mark3'));
  2919. $other->setActivityComments($this->getRequestParameter('other_comment'));
  2920. $other->setIndvidualMark($this->getRequestParameter('indvl_total'));
  2921. $other->save();
  2922. }
  2923.  
  2924. function setEmpComments($peId) {
  2925. $negative = new EmpComments();
  2926. $negative->setPeId($peId);
  2927. $negative->setNegComments($this->getRequestParameter('negative_comment'));
  2928. $negative->setNegMark($this->getRequestParameter('negative_mark'));
  2929. $negative->setEmpComments($this->getRequestParameter('emp_comment'));
  2930. $negative->save();
  2931. }
  2932.  
  2933. function setDevelopmentPlan($peId) {
  2934.  
  2935. $development = new DevelopmentPlan();
  2936. $development->setPeId($peId);
  2937. $development->setBookOne($this->getRequestParameter('dev_book1'));
  2938. $development->setBookTwo($this->getRequestParameter('dev_book2'));
  2939. $development->setBookThree($this->getRequestParameter('dev_book3'));
  2940. $development->setBookFour($this->getRequestParameter('dev_book4'));
  2941. $development->setBookFive($this->getRequestParameter('dev_book5'));
  2942. $development->setSeminarOne($this->getRequestParameter('dev_seminar1'));
  2943. $development->setSeminarTwo($this->getRequestParameter('dev_seminar2'));
  2944. $development->setSeminarThree($this->getRequestParameter('dev_seminar3'));
  2945. $development->setSeminarFour($this->getRequestParameter('dev_seminar4'));
  2946. $development->setSeminarFive($this->getRequestParameter('dev_seminar5'));
  2947. $development->setArticleOne($this->getRequestParameter('dev_write1'));
  2948. $development->setArticleTwo($this->getRequestParameter('dev_write2'));
  2949. $development->setArticleThree($this->getRequestParameter('dev_write3'));
  2950. $development->setArticleFour($this->getRequestParameter('dev_write4'));
  2951. $development->setArticleFive($this->getRequestParameter('dev_write5'));
  2952. $development->setWorkshopOne($this->getRequestParameter('dev_workshop1'));
  2953. $development->setWorkshopTwo($this->getRequestParameter('dev_workshop2'));
  2954. $development->setWorkshopThree($this->getRequestParameter('dev_workshop3'));
  2955. $development->setWorkshopFour($this->getRequestParameter('dev_workshop4'));
  2956. $development->setWorkshopFive($this->getRequestParameter('dev_workshop5'));
  2957. $development->setDevelopComments($this->getRequestParameter('develop_comment'));
  2958. $development->save();
  2959. }
  2960.  
  2961. //Server-side Validation for All forms.......
  2962. function validation() {
  2963.  
  2964. $arguments = array('quality_rating',
  2965. 'quantity_rating',
  2966. 'quality_goal',
  2967. 'quantity_goal',
  2968. 'tech_comment',
  2969. 'tech_goal',
  2970. 'customer_comments',
  2971. 'customer_goals',
  2972. 'attendance_comment',
  2973. 'leave_comment',
  2974. 'qms_comment',
  2975. 'other_comment',
  2976. 'negative_comment',
  2977. 'comm_goal',
  2978. // 'emp_comment'
  2979. );
  2980. foreach ($arguments as $argument) {
  2981. if (trim($this->getRequestParameter($argument)) == '')
  2982. return false;
  2983. }
  2984. return true;
  2985. }
  2986.  
  2987. //Server-side Validation for mark field
  2988.  
  2989. function validateMark() {
  2990. $resp_total = 0;
  2991. $comm_total = 0;
  2992. $tech_total = 0;
  2993. $social_total = 0;
  2994. $qms_total = 0;
  2995. $group_total = 0;
  2996. $indvl_total = 0;
  2997. $skill_total = 0;
  2998. $leave_total = 0;
  2999. $accom_total = 0;
  3000. for ($i = 1; $i <= 3; $i++) {
  3001. if ($this->getRequestParameter('accom_mark' . $i) > ACCOM_MAX_MARK) {
  3002. $_SESSION['error_msg'] = 'Accomplishment mark is greater than the maximum mark';
  3003. return false;
  3004. }
  3005. $accom_mark[] = $this->getRequestParameter('accom_mark' . $i);
  3006. }
  3007.  
  3008. sort($accom_mark);
  3009. $accom_total = $accom_mark[2] + $accom_mark[3];
  3010. if ($this->getRequestParameter('accom_total') != $accom_total) {
  3011. $_SESSION['error_msg'] = 'Accomplishment total mark is incorrect';
  3012. return false;
  3013. }
  3014.  
  3015. for ($i = 1; $i <= 3; $i++) {
  3016. if ($this->getRequestParameter('resp_mark' . $i) > RESP_MAX_MARK) {
  3017. $_SESSION['error_msg'] = 'Responsibility mark is greater than the maximum mark';
  3018. return false;
  3019. }
  3020. $resp_total += $this->getRequestParameter('resp_mark' . $i);
  3021. }
  3022. if ($this->getRequestParameter('resp_total') != $resp_total) {
  3023. $_SESSION['error_msg'] = 'Responsibility total mark is incorrect';
  3024. return false;
  3025. }
  3026. if ($this->getRequestParameter('quality_mark') > QUALITY_QUANTITY_TOTAL || $this->getRequestParameter('quantity_mark') > QUALITY_QUANTITY_TOTAL) {
  3027. $_SESSION['error_msg'] = 'Quality/Quantity mark is incorrect';
  3028. return false;
  3029. }
  3030.  
  3031. for ($i = 1; $i <= 4; $i++) {
  3032. if ($this->getRequestParameter('comm_mark' . $i) > COMM_MAX_MARK) {
  3033. $_SESSION['error_msg'] = 'Communication mark is greater than the maximum mark';
  3034. return false;
  3035. }
  3036. $comm_total += $this->getRequestParameter('comm_mark' . $i);
  3037. }
  3038. if ($this->getRequestParameter('comm_total') != $comm_total) {
  3039. $_SESSION['error_msg'] = 'Communication total mark is incorrect';
  3040. return false;
  3041. }
  3042. //$ tech_marks = array('tech_mark1' ,
  3043. for ($i = 1; $i <= 8; $i++) {
  3044. if ($this->getRequestParameter('tech_mark' . $i) > JOB_MAX_MARK) {
  3045. $_SESSION['error_msg'] = 'Job knowledge mark is greater the the maximum mark';
  3046. return false;
  3047. }
  3048. $tech_total += $this->getRequestParameter('tech_mark' . $i);
  3049. }
  3050. if ($this->getRequestParameter('tech_total') != $tech_total) {
  3051. $_SESSION['error_msg'] = 'Job knowlwdge total mark is incorrect';
  3052. return false;
  3053. }
  3054. for ($i = 1; $i <= 8; $i++) {
  3055. if ($this->getRequestParameter('social_mark' . $i) > SOCIAL_MAX_MARK) {
  3056. $_SESSION['error_msg'] = 'Social effectiveness mark is greater than the maximum mark';
  3057. return false;
  3058. }
  3059. $social_total += $this->getRequestParameter('social_mark' . $i);
  3060. }
  3061. if ($this->getRequestParameter('social_total') != $social_total) {
  3062. $_SESSION['error_msg'] = 'Social effectiveness total mark is incorrect';
  3063. return false;
  3064. }
  3065. if ($this->getRequestParameter('cus_total') > CUS_TOTAL) {
  3066. $_SESSION['error_msg'] = 'Customer delight mark is incorrect';
  3067. return false;
  3068. }
  3069. if ($this->getRequestParameter('attendance_total') > ATTENDANCE_TOTAL) {
  3070. $_SESSION['error_msg'] = 'Attendance mark is incorrect';
  3071. return false;
  3072. }
  3073. for ($i = 1; $i <= 3; $i++) {
  3074. if ($this->getRequestParameter('qms_mark' . $i) > QMS_MAX_MARK) {
  3075. $_SESSION['error_msg'] = 'QMS mark is greater than the maximum mark';
  3076. return false;
  3077. }
  3078. $qms_total += $this->getRequestParameter('qms_mark' . $i);
  3079. }
  3080. if ($this->getRequestParameter('qms_total') != $qms_total) {
  3081. $_SESSION['error_msg'] = 'QMS total mark is incorrect';
  3082. return false;
  3083. }
  3084. for ($i = 1; $i <= 3; $i++) {
  3085. if ($this->getRequestParameter('group_mark' . $i) > GROUP_MAX_MARK) {
  3086. $_SESSION['error_msg'] = 'Other activities mark is incorrect';
  3087. return false;
  3088. }
  3089. $group_total += $this->getRequestParameter('group_mark' . $i);
  3090. }
  3091. if ($this->getRequestParameter('group_total') != $group_total) {
  3092. $_SESSION['error_msg'] = 'Other activities mark is incorrect';
  3093. return false;
  3094. }
  3095. for ($i = 2; $i <= 3; $i++) {
  3096. if ($this->getRequestParameter('indvl_mark' . $i) > IND_MAX_MARK) {
  3097. $_SESSION['error_msg'] = 'Other activities mark is incorrect';
  3098.  
  3099. return false;
  3100. }
  3101. $indvl_total += $this->getRequestParameter('indvl_mark' . $i);
  3102. }
  3103. if ($this->getRequestParameter('indvl_mark1') > IND_SEMINAR_MARK) {
  3104. $_SESSION['error_msg'] = 'Other activities mark is incorrect';
  3105. return false;
  3106. }
  3107. $indvl_total += $this->getRequestParameter('indvl_mark1');
  3108. if ($this->getRequestParameter('indvl_total') != $indvl_total) {
  3109. $_SESSION['error_msg'] = 'Other activities mark is incorrect';
  3110. return false;
  3111. }
  3112.  
  3113. if ($this->getRequestParameter('skill_total')) {
  3114. for ($i = 1; $i <= 6; $i++) {
  3115. if ($this->getRequestParameter('skill_mark' . $i) > SKILL_MAX_MARK) {
  3116. $_SESSION['error_msg'] = 'Management skill mark is incorrect';
  3117. return false;
  3118. }
  3119. $skill_total += $this->getRequestParameter('skill_mark' . $i);
  3120. }
  3121. if ($this->getRequestParameter('skill_total') != $skill_total) {
  3122. $_SESSION['error_msg'] = 'Management skill mark is incorrect';
  3123. return false;
  3124. }
  3125. }
  3126. if ($this->getRequestParameter('leave_mark1') || $this->getRequestParameter('leave_mark2')) {
  3127. if ($this->getRequestParameter('leave_mark1') > LEAVE_MAX_MARK || $this->getRequestParameter('leave_mark2') > LEAVE_MAX_MARK) {
  3128. $_SESSION['error_msg'] = 'Leave management mark is incorrect';
  3129. }
  3130. $leave_total = $this->getRequestParameter('leave_mark1') + $this->getRequestParameter('leave_mark2');
  3131. } else {
  3132. $leave_total = LEAVE_MAX_MARK;
  3133. }
  3134. if ($this->getRequestParameter('leave_total') > $leave_total) {
  3135. $_SESSION['error_msg'] = 'Leave management mark is incorrect';
  3136. return false;
  3137. }
  3138.  
  3139. $grant_total = $this->getRequestParameter('resp_total') + $this->getRequestParameter('quality_mark') + $this->getRequestParameter('quantity_mark') + $this->getRequestParameter('comm_total') +
  3140. $this->getRequestParameter('tech_total') + $this->getRequestParameter('social_total') +
  3141. $this->getRequestParameter('cus_total') + $this->getRequestParameter('attendance_total') + $this->getRequestParameter('qms_total') + $this->getRequestParameter('group_total') +
  3142. $this->getRequestParameter('indvl_total') + $this->getRequestParameter('skill_total') + $this->getRequestParameter('leave_total');
  3143.  
  3144. $negative_mark = $this->getRequestParameter('negative_mark');
  3145. if ($negative_mark < 0) {
  3146. $_SESSION['error_msg'] = 'Negative mark is incorrect';
  3147. }
  3148. $grant_total -= $negative_mark;
  3149. if ($this->getRequestParameter('grant_total') != $grant_total) {
  3150. return false;
  3151. }
  3152. return true;
  3153. }
  3154.  
  3155. //********* Function to GET the PREPEFORM FOR AN EMPLOYEE*****************//
  3156.  
  3157. function getPreForm($empId = null, $peId = null, $peform=null) {
  3158. if ($peId) {
  3159. $peEmployeeinstance = new PeEmployeesPeer();
  3160. $empId = $peEmployeeinstance->getEmpId($peId);
  3161. } else {
  3162. //Checking whether PE Form is already Submitted Thai Year..
  3163. $peId = $this->isSubmittedThisYear($peform, $empId);
  3164. if ($peId) {
  3165. $criteria = new Criteria();
  3166. $criteria->add(PeEmployeesPeer::PEID, $peId);
  3167. $result = PeEmployeesPeer::doSelect($criteria);
  3168. $peStatusId = $result[0]->getStatusId();
  3169. if ($peStatusId == 3)
  3170. $this->redirect('main/PeForm?edit=' . $peId . '&status=adminsave');
  3171. else
  3172. $this->redirect('main/PeForm?edit=' . $peId);
  3173. }
  3174. }
  3175.  
  3176. $employeeDetails['empId'] = $empId;
  3177. $groupwareEmployeeInstance = new GroupwareEmployeesPeer();
  3178. $employeeAccounts = $groupwareEmployeeInstance->getEmployeeAccounts($empId);
  3179. foreach ($employeeAccounts as $employee) {
  3180. $employeeDetails['empName'] = $employee->getName();
  3181. $employeeDetails['empJobTitle'] = $employee->getTitle();
  3182. }
  3183. $employeeDetails['empSupervisor'] = $groupwareEmployeeInstance->getEmployeeAdmin($empId);
  3184. $employeeDetails['empTeam'] = $groupwareEmployeeInstance->getEmployeeTeam($empId);
  3185. $employeeDetails['empExp'] = $groupwareEmployeeInstance->getEmployeeExperience($empId);
  3186. $this->employeeDetails = $employeeDetails;
  3187. }
  3188.  
  3189. //************* functions to GET PEFORM values of an EMPLOYEE**********************
  3190.  
  3191. function getPeDetails($peId, $key=null) {
  3192. $criteria = new Criteria();
  3193. $criteria->add(PeEmployeesPeer::PEID, $peId);
  3194. $resultSet = PeEmployeesPeer::doSelectStmt($criteria);
  3195.  
  3196.  
  3197.  
  3198. $peDetailsTemp = $resultSet->fetch(PDO::FETCH_NUM);
  3199. for ($i = 0; $i <= 17; $i++) {
  3200. $peDetails[$i + 1] = $peDetailsTemp[$i];
  3201. }
  3202. // $_SESSION['pestatusId'] = $peDetails[6]; // To use in executeView for More button View Self/original Pe from
  3203. /* TO get employee Supervisor value from */
  3204. $groupwareEmployee = new GroupwareEmployeesPeer();
  3205. $this->immediateSupervisorId = $peDetails[14];
  3206. $this->immediateSupervisor = $groupwareEmployee->getEmployeeName($peDetails[14]);
  3207. $this->nextSupervisorId = $peDetails[15];
  3208. $this->nextSupervisor = $groupwareEmployee->getEmployeeName($peDetails[15]);
  3209. $this->takenById = $peDetails[16];
  3210. $this->takenBy = $groupwareEmployee->getEmployeeName($peDetails[16]);
  3211. $this->peDetails = $peDetails;
  3212. if ($key != null)
  3213. return $peDetails[8];
  3214. }
  3215.  
  3216. function getAccomplishments($peId, $key=null) {
  3217. $criteria = new Criteria();
  3218. $criteria->add(AccomplishmentsPeer::PEID, $peId);
  3219. $resultSet = AccomplishmentsPeer::doSelectStmt($criteria);
  3220. $accomplishmentsTemp = $resultSet->fetch(PDO::FETCH_NUM);
  3221. for ($i = 0; $i <= 9; $i++) {
  3222.  
  3223. $accomplishments[$i + 1] = $accomplishmentsTemp[$i];
  3224. }
  3225. $this->accomplishment = $accomplishments;
  3226. //added by renjo to check if PE form is monthly
  3227. if ($key != null)
  3228. return $accomplishments;
  3229. }
  3230.  
  3231. function getResponsibility($peId, $key=null) {
  3232. $criteria = new Criteria();
  3233. $criteria->add(ResponsibilitiesPeer::PEID, $peId);
  3234. $resultSet = ResponsibilitiesPeer::doSelectStmt($criteria);
  3235. $responsibilitiesTemp = $resultSet->fetch(PDO::FETCH_NUM);
  3236.  
  3237. for ($i = 0; $i <= 9; $i++) {
  3238.  
  3239. $responsibilities[$i + 1] = $responsibilitiesTemp[$i];
  3240. }
  3241. $this->responsibilities = $responsibilities;
  3242. //added by renjo to check if PE form is monthly
  3243. if ($key != null)
  3244. return $responsibilities;
  3245. }
  3246.  
  3247. function getQualityQuantity($peId, $key=null) {
  3248. $criteria = new Criteria();
  3249. $criteria->add(QualityQuantityPeer::PEID, $peId);
  3250. $resultSet = QualityQuantityPeer::doSelectStmt($criteria);
  3251. $qualityQuantityTemp = $resultSet->fetch(PDO::FETCH_NUM);
  3252. for ($i = 0; $i <= 14; $i++) {
  3253.  
  3254. $qualityQuantity[$i + 1] = $qualityQuantityTemp[$i];
  3255. }
  3256. $this->qualityQuantity = $qualityQuantity;
  3257. //added by renjo to check if PE form is monthly
  3258. if ($key != null)
  3259. return $qualityQuantity;
  3260. }
  3261.  
  3262. function getCommunication($peId, $key=null) {
  3263. $criteria = new Criteria();
  3264. $criteria->add(CommunicationPeer::PEID, $peId);
  3265. $resultSet = CommunicationPeer::doSelectStmt($criteria);
  3266. $communicationTemp = $resultSet->fetch(PDO::FETCH_NUM);
  3267. for ($i = 0; $i <= 15; $i++) {
  3268.  
  3269. $communication[$i + 1] = $communicationTemp[$i];
  3270. }
  3271.  
  3272. $this->communication = $communication;
  3273. //added by renjo to check if PE form is monthly
  3274. if ($key != null)
  3275. return $communication;
  3276. }
  3277.  
  3278. function getJobKnowledge($peId, $key=null) {
  3279. $criteria = new Criteria();
  3280. $criteria->add(JobKnowledgePeer::PEID, $peId);
  3281. $resultSet = JobKnowledgePeer::doSelectStmt($criteria);
  3282. $jobsTemp = $resultSet->fetch(PDO::FETCH_NUM);
  3283. for ($i = 0; $i <= 30; $i++) {
  3284.  
  3285. $jobs[$i + 1] = $jobsTemp[$i];
  3286. }
  3287. $this->job = $jobs;
  3288. //added by renjo to check if PE form is monthly
  3289. if ($key != null)
  3290. return $jobs;
  3291. }
  3292.  
  3293. function getManagementSkills($peId, $key=null) {
  3294. $criteria = new Criteria();
  3295. $criteria->add(ManagementSkillsPeer::PEID, $peId);
  3296. $resultSet = ManagementSkillsPeer::doSelectStmt($criteria);
  3297. $managementTemp = $resultSet->fetch(PDO::FETCH_NUM);
  3298. for ($i = 0; $i <= 20; $i++) {
  3299.  
  3300. $management[$i + 1] = $managementTemp[$i];
  3301. }
  3302. $this->management = $management;
  3303. //added by renjo to check if PE form is monthly
  3304. if ($key != null)
  3305. return $management;
  3306. }
  3307.  
  3308. function getSocialEffectiveness($peId, $key=null) {
  3309. $criteria = new Criteria();
  3310. $criteria->add(SocialEffectivenessPeer::PEID, $peId);
  3311. $resultSet = SocialEffectivenessPeer::doSelectStmt($criteria);
  3312. $socialTemp = $resultSet->fetch(PDO::FETCH_NUM);
  3313. for ($i = 0; $i <= 23; $i++) {
  3314.  
  3315. $social[$i + 1] = $socialTemp[$i];
  3316. }
  3317. $this->social = $social;
  3318. //added by renjo to check if PE form is monthly
  3319. if ($key != null)
  3320. return $social;
  3321. }
  3322.  
  3323. function getSatisfaction($peId, $key=null) {
  3324. $criteria = new Criteria();
  3325. $criteria->add(SatisfactionPeer::PEID, $peId);
  3326. $resultSet = SatisfactionPeer::doSelectStmt($criteria);
  3327. $satisfactionTemp = $resultSet->fetch(PDO::FETCH_NUM);
  3328. for ($i = 0; $i <= 4; $i++) {
  3329.  
  3330. $satisfaction[$i + 1] = $satisfactionTemp[$i];
  3331. }
  3332. $this->satisfaction = $satisfaction;
  3333. //added by renjo to check if PE form is monthly
  3334. if ($key != null)
  3335. return $satisfaction;
  3336. }
  3337.  
  3338. function getLeaveAttendance($peId, $key=null) {
  3339. $criteria = new Criteria();
  3340. $criteria->add(LeaveAttendancePeer::PEID, $peId);
  3341. $resultSet = LeaveAttendancePeer::doSelectStmt($criteria);
  3342. $leaveAttendanceTemp = $resultSet->fetch(PDO::FETCH_NUM);
  3343. for ($i = 0; $i <= 8; $i++) {
  3344.  
  3345. $leaveAttendance[$i + 1] = $leaveAttendanceTemp[$i];
  3346. }
  3347. $this->leaveAttendance = $leaveAttendance;
  3348. //added by renjo to check if PE form is monthly
  3349. if ($key != null)
  3350. return $leaveAttendance;
  3351. }
  3352.  
  3353. function getQms($peId, $key=null) {
  3354. $criteria = new Criteria();
  3355. $criteria->add(QmsPeer::PEID, $peId);
  3356. $resultSet = QmsPeer::doSelectStmt($criteria);
  3357. $qmsTemp = $resultSet->fetch(PDO::FETCH_NUM);
  3358. for ($i = 0; $i <= 9; $i++) {
  3359.  
  3360. $qms[$i + 1] = $qmsTemp[$i];
  3361. }
  3362. $this->qms = $qms;
  3363. //added by renjo to check if PE form is monthly
  3364. if ($key != null)
  3365. return $qms;
  3366. }
  3367.  
  3368. function getOtherActivity($peId, $key=null) {
  3369. $criteria = new Criteria();
  3370. $criteria->add(OtherActivityPeer::PEID, $peId);
  3371. $resultSet = OtherActivityPeer::doSelectStmt($criteria);
  3372. $otherTemp = $resultSet->fetch(PDO::FETCH_NUM);
  3373. for ($i = 0; $i <= 13; $i++) {
  3374.  
  3375. $other[$i + 1] = $otherTemp[$i];
  3376. }
  3377. $this->others = $other;
  3378. //added by renjo to check if PE form is monthly
  3379. if ($key != null)
  3380. return $other;
  3381. }
  3382.  
  3383. function getEmpComments($peId, $key=null) {
  3384. $criteria = new Criteria();
  3385. $criteria->add(EmpCommentsPeer::PEID, $peId);
  3386. $resultSet = EmpCommentsPeer::doSelectStmt($criteria);
  3387. $empCommentsTemp = $resultSet->fetch(PDO::FETCH_NUM);
  3388. for ($i = 0; $i <= 4; $i++) {
  3389.  
  3390. $empComments[$i + 1] = $empCommentsTemp[$i];
  3391. }
  3392. $this->empComments = $empComments;
  3393. //added by renjo to check if PE form is monthly
  3394. if ($key != null)
  3395. return $empComments;
  3396. }
  3397.  
  3398. function getDevelopmentPlan($peId, $key=null) {
  3399. $criteria = new Criteria();
  3400. $criteria->add(DevelopmentPlanPeer::PEID, $peId);
  3401. $resultSet = DevelopmentPlanPeer::doSelectStmt($criteria);
  3402. $developmentTemp = $resultSet->fetch(PDO::FETCH_NUM);
  3403. for ($i = 0; $i <= 22; $i++) {
  3404.  
  3405. $development[$i + 1] = $developmentTemp[$i];
  3406. }
  3407. $this->development = $development;
  3408. //added by renjo to check if PE form is monthly
  3409. if ($key != null)
  3410. return $development;
  3411. }
  3412.  
  3413. // Update functions.............
  3414.  
  3415. function updateEmployee($peId, $peStatus) {
  3416. $criteria = new Criteria();
  3417. $criteria->add(PeEmployeesPeer::PEID, $peId);
  3418. $criteria->add(PeEmployeesPeer::ISSUEDATE, $this->getRequestParameter('issue_date'));
  3419. $criteria->add(PeEmployeesPeer::REVIEWDATE, $this->getRequestParameter('review_date'));
  3420. $criteria->add(PeEmployeesPeer::NEXTREVIEWDATE, $this->getRequestParameter('next_date'));
  3421. $criteria->add(PeEmployeesPeer::TOTALMARK, $this->getRequestParameter('grant_total'));
  3422. $criteria->add(PeEmployeesPeer::STATUSID, $peStatus);
  3423. $total = $this->getRequestParameter('grant_total');
  3424.  
  3425. // to calculate Employee Percentage
  3426. $emproletype = $this->getRequestParameter('roleType');
  3427.  
  3428. if ($emproletype == 0)
  3429. $percentage = ($total / ADMIN_TOTAL) * 100;
  3430. elseif ($emproletype == 1)
  3431. $percentage = ($total / QM_TOTAL) * 100;
  3432. elseif ($emproletype == 2)
  3433. $percentage = ($total / STAFF_TOTAL) * 100;
  3434. $percentage = round($percentage, 2);
  3435. $criteria->add(PeEmployeesPeer::PERCENTAGE, $percentage);
  3436.  
  3437. PeEmployeesPeer::doUpdate($criteria);
  3438. }
  3439.  
  3440. function updateAccomplishments($accomId) {
  3441. $criteria = new Criteria();
  3442. $criteria->add(AccomplishmentsPeer::ACCOMID, $accomId);
  3443. $criteria->add(AccomplishmentsPeer::ACCOMONE, $this->getRequestParameter('accom1'));
  3444. $criteria->add(AccomplishmentsPeer::ACCOMTWO, $this->getRequestParameter('accom2'));
  3445. $criteria->add(AccomplishmentsPeer::ACCOMTHREE, $this->getRequestParameter('accom3'));
  3446. $criteria->add(AccomplishmentsPeer::ACCOMONEMARK, $this->getRequestParameter('accom_mark1'));
  3447. $criteria->add(AccomplishmentsPeer::ACCOMTWOMARK, $this->getRequestParameter('accom_mark2'));
  3448. $criteria->add(AccomplishmentsPeer::ACCOMTHREEMARK, $this->getRequestParameter('accom_mark3'));
  3449. $criteria->add(AccomplishmentsPeer::ACCOMCOMMENTS, $this->getRequestParameter('accom_comment'));
  3450. $criteria->add(AccomplishmentsPeer::ACCOMMARK, $this->getRequestParameter('accom_total'));
  3451.  
  3452. AccomplishmentsPeer::DoUpdate($criteria);
  3453. }
  3454.  
  3455. function updateResponsibilities($respId) {
  3456. $criteria = new Criteria();
  3457. $criteria->add(ResponsibilitiesPeer::RESPID, $respId);
  3458. $criteria->add(ResponsibilitiesPeer::RESPONE, $this->getRequestParameter('resp1'));
  3459. $criteria->add(ResponsibilitiesPeer::RESPTWO, $this->getRequestParameter('resp2'));
  3460. $criteria->add(ResponsibilitiesPeer::RESPTHREE, $this->getRequestParameter('resp3'));
  3461. $criteria->add(ResponsibilitiesPeer::RESPONEMARK, $this->getRequestParameter('resp_mark1'));
  3462. $criteria->add(ResponsibilitiesPeer::RESPTWOMARK, $this->getRequestParameter('resp_mark2'));
  3463. $criteria->add(ResponsibilitiesPeer::RESPTHREEMARK, $this->getRequestParameter('resp_mark3'));
  3464. $criteria->add(ResponsibilitiesPeer::RESPCOMMENTS, $this->getRequestParameter('resp_comment'));
  3465. $criteria->add(ResponsibilitiesPeer::RESPMARK, $this->getRequestParameter('resp_total'));
  3466.  
  3467. ResponsibilitiesPeer::DoUpdate($criteria);
  3468. }
  3469.  
  3470. function updateQualityQuantity($qqId) {
  3471. $criteria = new Criteria();
  3472. $criteria->add(QualityQuantityPeer::QQID, $qqId);
  3473. $criteria->add(QualityQuantityPeer::IFQC, $this->getRequestParameter('qc'));
  3474. $criteria->add(QualityQuantityPeer::AVGQC, $this->getRequestParameter('avg_qc'));
  3475. $criteria->add(QualityQuantityPeer::AVGLASTQC, $this->getRequestParameter('avg_last_qc'));
  3476. $criteria->add(QualityQuantityPeer::QUALITYMARK, $this->getRequestParameter('quality_mark'));
  3477. $criteria->add(QualityQuantityPeer::QUALITYRATING, $this->getRequestParameter('quality_rating'));
  3478. $criteria->add(QualityQuantityPeer::QUALITYGOALS, $this->getRequestParameter('quality_goal'));
  3479. $criteria->add(QualityQuantityPeer::IFNC, $this->getRequestParameter('if_nc'));
  3480. $criteria->add(QualityQuantityPeer::NC, $this->getRequestParameter('nc'));
  3481. $criteria->add(QualityQuantityPeer::TICKETPERSHIFT, $this->getRequestParameter('tkt_shift'));
  3482. $criteria->add(QualityQuantityPeer::QUANTITYMARK, $this->getRequestParameter('quantity_mark'));
  3483. $criteria->add(QualityQuantityPeer::QUANTITYRATING, $this->getRequestParameter('quantity_rating'));
  3484. $criteria->add(QualityQuantityPeer::QUANTITYGOALS, $this->getRequestParameter('quantity_goal'));
  3485. $criteria->add(QualityQuantityPeer::QQMARK, $this->getRequestParameter('quantity_mark') + $this->getRequestParameter('quality_mark'));
  3486.  
  3487. QualityQuantityPeer::doUpdate($criteria);
  3488. }
  3489.  
  3490. function UpdateCommunication($commId) {
  3491. $criteria = new Criteria();
  3492. $criteria->add(CommunicationPeer::COMMID, $commId);
  3493. $criteria->add(CommunicationPeer::WRITTEN, $this->getRequestParameter('written'));
  3494. $criteria->add(CommunicationPeer::SPOKEN, $this->getRequestParameter('spoken'));
  3495. $criteria->add(CommunicationPeer::WITHADMIN, $this->getRequestParameter('with_admin'));
  3496. $criteria->add(CommunicationPeer::WITHCLIENTS, $this->getRequestParameter('with_clients'));
  3497. $criteria->add(CommunicationPeer::WRITTENMARK, $this->getRequestParameter('comm_mark1'));
  3498. $criteria->add(CommunicationPeer::SPOKENMARK, $this->getRequestParameter('comm_mark2'));
  3499. $criteria->add(CommunicationPeer::WITHADMINMARK, $this->getRequestParameter('comm_mark3'));
  3500. $criteria->add(CommunicationPeer::WITHCLIENTSMARK, $this->getRequestParameter('comm_mark4'));
  3501. $criteria->add(CommunicationPeer::WRITTENEXPECT, $this->getRequestParameter('written_expect'));
  3502. $criteria->add(CommunicationPeer::SPOKENEXPECT, $this->getRequestParameter('spoken_expect'));
  3503. $criteria->add(CommunicationPeer::WITHADMINEXPECT, $this->getRequestParameter('with_admin_expect'));
  3504. $criteria->add(CommunicationPeer::WITHCLIENTSEXPECT, $this->getRequestParameter('with_clients_expect'));
  3505. $criteria->add(CommunicationPeer::COMMMARK, $this->getRequestParameter('comm_total'));
  3506. $criteria->add(CommunicationPeer::COMMGOALS, $this->getRequestParameter('comm_goal'));
  3507.  
  3508. CommunicationPeer::doUpdate($criteria);
  3509. }
  3510.  
  3511. function updateJobKnowledge($jobId) {
  3512. $criteria = new Criteria();
  3513. $criteria->add(JobKnowledgePeer::JOBID, $jobId);
  3514. $criteria->add(JobKnowledgePeer::TECHONE, $this->getRequestParameter('tech1'));
  3515. $criteria->add(JobKnowledgePeer::TECHTWO, $this->getRequestParameter('tech2'));
  3516. $criteria->add(JobKnowledgePeer::TECHTHREE, $this->getRequestParameter('tech3'));
  3517. $criteria->add(JobKnowledgePeer::TECHFOUR, $this->getRequestParameter('tech4'));
  3518. $criteria->add(JobKnowledgePeer::TECHFIVE, $this->getRequestParameter('tech5'));
  3519. $criteria->add(JobKnowledgePeer::TECHSIX, $this->getRequestParameter('tech6'));
  3520. $criteria->add(JobKnowledgePeer::TECHSEVEN, $this->getRequestParameter('tech7'));
  3521. $criteria->add(JobKnowledgePeer::TECHEIGHT, $this->getRequestParameter('tech8'));
  3522. $criteria->add(JobKnowledgePeer::TECHONEMARK, $this->getRequestParameter('tech_mark1'));
  3523. $criteria->add(JobKnowledgePeer::TECHTWOMARK, $this->getRequestParameter('tech_mark2'));
  3524. $criteria->add(JobKnowledgePeer::TECHTHREEMARK, $this->getRequestParameter('tech_mark3'));
  3525. $criteria->add(JobKnowledgePeer::TECHFOURMARK, $this->getRequestParameter('tech_mark4'));
  3526. $criteria->add(JobKnowledgePeer::TECHFIVEMARK, $this->getRequestParameter('tech_mark5'));
  3527. $criteria->add(JobKnowledgePeer::TECHSIXMARK, $this->getRequestParameter('tech_mark6'));
  3528. $criteria->add(JobKnowledgePeer::TECHSEVENMARK, $this->getRequestParameter('tech_mark7'));
  3529. $criteria->add(JobKnowledgePeer::TECHEIGHTMARK, $this->getRequestParameter('tech_mark8'));
  3530. $criteria->add(JobKnowledgePeer::TECHONEEXPECT, $this->getRequestParameter('tech1_expect'));
  3531. $criteria->add(JobKnowledgePeer::TECHTWOEXPECT, $this->getRequestParameter('tech2_expect'));
  3532. $criteria->add(JobKnowledgePeer::TECHTHREEEXPECT, $this->getRequestParameter('tech3_expect'));
  3533. $criteria->add(JobKnowledgePeer::TECHFOUREXPECT, $this->getRequestParameter('tech4_expect'));
  3534. $criteria->add(JobKnowledgePeer::TECHFIVEEXPECT, $this->getRequestParameter('tech5_expect'));
  3535. $criteria->add(JobKnowledgePeer::TECHSIXEXPECT, $this->getRequestParameter('tech6_expect'));
  3536. $criteria->add(JobKnowledgePeer::TECHSEVENEXPECT, $this->getRequestParameter('tech7_expect'));
  3537. $criteria->add(JobKnowledgePeer::TECHEIGHTEXPECT, $this->getRequestParameter('tech8_expect'));
  3538. $criteria->add(JobKnowledgePeer::JOBMARK, $this->getRequestParameter('tech_total'));
  3539. $criteria->add(JobKnowledgePeer::JOBCOMMENTS, $this->getRequestParameter('tech_comment'));
  3540. $criteria->add(JobKnowledgePeer::JOBGOALS, $this->getRequestParameter('tech_goal'));
  3541.  
  3542. JobKnowledgePeer::doUpdate($criteria);
  3543. }
  3544.  
  3545. function updateManagementSkills($skillId) {
  3546. $criteria = new Criteria();
  3547. $criteria->add(ManagementSkillsPeer::SKILLID, $skillId);
  3548. $criteria->add(ManagementSkillsPeer::LEADERSHIP, $this->getRequestParameter('leadership'));
  3549. $criteria->add(ManagementSkillsPeer::DELEGATION, $this->getRequestParameter('delegation'));
  3550. $criteria->add(ManagementSkillsPeer::JUDGEMENT, $this->getRequestParameter('decision'));
  3551. $criteria->add(ManagementSkillsPeer::ADMINISTRATION, $this->getRequestParameter('administration'));
  3552. $criteria->add(ManagementSkillsPeer::PERSONAL, $this->getRequestParameter('personal'));
  3553. $criteria->add(ManagementSkillsPeer::PERFORMANCE, $this->getRequestParameter('performance'));
  3554. $criteria->add(ManagementSkillsPeer::LEADERSHIPMARK, $this->getRequestParameter('skill_mark1'));
  3555. $criteria->add(ManagementSkillsPeer::DELEGATIONMARK, $this->getRequestParameter('skill_mark2'));
  3556. $criteria->add(ManagementSkillsPeer::JUDGEMENTMARK, $this->getRequestParameter('skill_mark3'));
  3557. $criteria->add(ManagementSkillsPeer::ADMINISTRATIONMARK, $this->getRequestParameter('skill_mark4'));
  3558. $criteria->add(ManagementSkillsPeer::PERSONALMARK, $this->getRequestParameter('skill_mark5'));
  3559. $criteria->add(ManagementSkillsPeer::PERFORMANCEMARK, $this->getRequestParameter('skill_mark6'));
  3560. $criteria->add(ManagementSkillsPeer::LEADERSHIPEXPECT, $this->getRequestParameter('leadership_expect'));
  3561. $criteria->add(ManagementSkillsPeer::DELEGATIONEXPECT, $this->getRequestParameter('delegation_expect'));
  3562. $criteria->add(ManagementSkillsPeer::JUDGEMENTEXPECT, $this->getRequestParameter('decision_expect'));
  3563. $criteria->add(ManagementSkillsPeer::ADMINISTRATIONEXPECT, $this->getRequestParameter('administration_expect'));
  3564. $criteria->add(ManagementSkillsPeer::PERSONALEXPECT, $this->getRequestParameter(''));
  3565. $criteria->add(ManagementSkillsPeer::PERFORMANCEEXPECT, $this->getRequestParameter('performance_expect'));
  3566. $criteria->add(ManagementSkillsPeer::PERSONALEXPECT, $this->getRequestParameter('personal_expect'));
  3567. $criteria->add(ManagementSkillsPeer::SKILLMARK, $this->getRequestParameter('skill_total'));
  3568.  
  3569. ManagementSkillsPeer::doUpdate($criteria);
  3570. }
  3571.  
  3572. function updateSocialEffectiveness($socialId) {
  3573. $criteria = new Criteria();
  3574. $criteria->add(SocialEffectivenessPeer::SOCIALID, $socialId);
  3575. $criteria->add(SocialEffectivenessPeer::DEPENDABLE, $this->getRequestParameter('dependability'));
  3576. $criteria->add(SocialEffectivenessPeer::CREATIVE, $this->getRequestParameter('creativity'));
  3577. $criteria->add(SocialEffectivenessPeer::ORGANIZE, $this->getRequestParameter('organize'));
  3578. $criteria->add(SocialEffectivenessPeer::WITHOTHERS, $this->getRequestParameter('with_others'));
  3579. $criteria->add(SocialEffectivenessPeer::ADAPTABLE, $this->getRequestParameter('adaptable'));
  3580. $criteria->add(SocialEffectivenessPeer::SKILLIMPROVE, $this->getRequestParameter('improve'));
  3581. $criteria->add(SocialEffectivenessPeer::DEPENDABLEMARK, $this->getRequestParameter('social_mark1'));
  3582. $criteria->add(SocialEffectivenessPeer::CREATIVEMARK, $this->getRequestParameter('social_mark2'));
  3583. $criteria->add(SocialEffectivenessPeer::ORGANIZEMARK, $this->getRequestParameter('social_mark3'));
  3584. $criteria->add(SocialEffectivenessPeer::WITHOTHERSMARK, $this->getRequestParameter('social_mark4'));
  3585. $criteria->add(SocialEffectivenessPeer::ADAPTABLEMARK, $this->getRequestParameter('social_mark5'));
  3586. $criteria->add(SocialEffectivenessPeer::SKILLIMPROVEMARK, $this->getRequestParameter('social_mark6'));
  3587. $criteria->add(SocialEffectivenessPeer::DEPENDABLEEXPECT, $this->getRequestParameter('dependability_expect'));
  3588. $criteria->add(SocialEffectivenessPeer::CREATIVEEXPECT, $this->getRequestParameter('creativity_expect'));
  3589. $criteria->add(SocialEffectivenessPeer::ORGANIZEEXPECT, $this->getRequestParameter('organize_expect'));
  3590. $criteria->add(SocialEffectivenessPeer::WITHOTHERSEXPECT, $this->getRequestParameter('with_others_expect'));
  3591. $criteria->add(SocialEffectivenessPeer::ADAPTABLEEXPECT, $this->getRequestParameter('adaptable_expect'));
  3592. $criteria->add(SocialEffectivenessPeer::SKILLIMPROVEEXPECT, $this->getRequestParameter('adaptable_expect'));
  3593. $criteria->add(SocialEffectivenessPeer::SKILLIMPROVEEXPECT, $this->getRequestParameter('improve_expect'));
  3594. $criteria->add(SocialEffectivenessPeer::TEAMMEETINGMARK, $this->getRequestParameter('social_mark7'));
  3595. $criteria->add(SocialEffectivenessPeer::TIMELYCOMPLETIONMARK, $this->getRequestParameter('social_mark8'));
  3596. $criteria->add(SocialEffectivenessPeer::SOCIALCOMMENTS, $this->getRequestParameter('social_comments'));
  3597. $criteria->add(SocialEffectivenessPeer::SOCIALMARK, $this->getRequestParameter('social_total'));
  3598.  
  3599. SocialEffectivenessPeer::doUpdate($criteria);
  3600. }
  3601.  
  3602. function updateSatisfaction($satisfactionId) {
  3603. $criteria = new Criteria();
  3604. $criteria->add(SatisfactionPeer::ID, $satisfactionId);
  3605. $criteria->add(SatisfactionPeer::COMMENTS, $this->getRequestParameter('customer_comments'));
  3606. $criteria->add(SatisfactionPeer::GOALS, $this->getRequestParameter('customer_goals'));
  3607. $criteria->add(SatisfactionPeer::TOTALMARK, $this->getRequestParameter('cus_total'));
  3608.  
  3609. SatisfactionPeer::doUpdate($criteria);
  3610. }
  3611.  
  3612. function updateLeaveAttendance($laId) {
  3613. $criteria = new Criteria();
  3614. $criteria->add(LeaveAttendancePeer::LAID, $laId);
  3615. $criteria->add(LeaveAttendancePeer::ATTENDANCEMARK, $this->getRequestParameter('attendance_total'));
  3616. $criteria->add(LeaveAttendancePeer::LEAVESELFMARK, $this->getRequestParameter('leave_mark1'));
  3617. $criteria->add(LeaveAttendancePeer::LEAVETEAMMARK, $this->getRequestParameter('leave_mark2'));
  3618. $criteria->add(LeaveAttendancePeer::LEAVEMARK, $this->getRequestParameter('leave_total'));
  3619. $criteria->add(LeaveAttendancePeer::ATTENDANCECOMMENTS, $this->getRequestParameter('attendance_comment'));
  3620. $criteria->add(LeaveAttendancePeer::LEAVECOMMENTS, $this->getRequestParameter('leave_comment'));
  3621.  
  3622. LeaveAttendancePeer::doUpdate($criteria);
  3623. }
  3624.  
  3625. function UpdateQms($qmsId) {
  3626. $criteria = new Criteria();
  3627. $criteria->add(QMSPeer::ID, $qmsId);
  3628. $criteria->add(QMSPeer::ITFMEMBER, $this->getRequestParameter('itf'));
  3629. $criteria->add(QMSPeer::INTENALAUDITOR, $this->getRequestParameter('internal'));
  3630. $criteria->add(QMSPeer::ISOAWARENESS, $this->getRequestParameter('iso'));
  3631. $criteria->add(QMSPeer::TOTALMARK, $this->getRequestParameter('qms_total'));
  3632. $criteria->add(QMSPeer::COMMENTS, $this->getRequestParameter('qms_comment'));
  3633. $criteria->add(QMSPeer::ITFMARK, $this->getRequestParameter('qms_mark1'));
  3634. $criteria->add(QMSPeer::INTERNALAUDITORMARK, $this->getRequestParameter('qms_mark2'));
  3635. $criteria->add(QMSPeer::ISOAWARENESSMARK, $this->getRequestParameter('qms_mark3'));
  3636.  
  3637. QMSPeer::doUpdate($criteria);
  3638. }
  3639.  
  3640. function updateOtherActivity($activityId) {
  3641. $criteria = new Criteria();
  3642. $criteria->add(OtherActivityPeer::ACTIVITYID, $activityId);
  3643. $criteria->add(OtherActivityPeer::GROUPONE, $this->getRequestParameter('group1'));
  3644. $criteria->add(OtherActivityPeer::GROUPTWO, $this->getRequestParameter('group2'));
  3645. $criteria->add(OtherActivityPeer::GROUPTHREE, $this->getRequestParameter('group3'));
  3646. $criteria->add(OtherActivityPeer::GROUPONEMARK, $this->getRequestParameter('group_mark1'));
  3647. $criteria->add(OtherActivityPeer::GROUPTWOMARK, $this->getRequestParameter('group_mark2'));
  3648. $criteria->add(OtherActivityPeer::GROUPTHREEMARK, $this->getRequestParameter('group_mark3'));
  3649. $criteria->add(OtherActivityPeer::GROUPMARK, $this->getRequestParameter('group_total'));
  3650. $criteria->add(OtherActivityPeer::SEMINARMARK, $this->getRequestParameter('indvl_mark1'));
  3651. $criteria->add(OtherActivityPeer::KBENTRYMARK, $this->getRequestParameter('indvl_mark2'));
  3652. $criteria->add(OtherActivityPeer::WORKSHOPMARK, $this->getRequestParameter('indvl_mark3'));
  3653. $criteria->add(OtherActivityPeer::ACTIVITYCOMMENTS, $this->getRequestParameter('other_comment'));
  3654. $criteria->add(OtherActivityPeer::INDVIDUALMARK, $this->getRequestParameter('indvl_total'));
  3655.  
  3656. OtherActivityPeer::doUpdate($criteria);
  3657. }
  3658.  
  3659. function updateEmpComments($empCommId) {
  3660. $criteria = new Criteria();
  3661. $criteria->add(EmpCommentsPeer::ID, $empCommId);
  3662. $criteria->add(EmpCommentsPeer::NEGCOMMENTS, $this->getRequestParameter('negative_comment'));
  3663. $criteria->add(EmpCommentsPeer::NEGMARK, $this->getRequestParameter('negative_mark'));
  3664. $criteria->add(EmpCommentsPeer::EMPCOMMENTS, $this->getRequestParameter('emp_comment'));
  3665.  
  3666. EmpCommentsPeer::doUpdate($criteria);
  3667. }
  3668.  
  3669. function updateDevelopmentPlan($devId) {
  3670. $criteria = new Criteria();
  3671. $criteria->add(DevelopmentPlanPeer::DEVID, $devId);
  3672. $criteria->add(DevelopmentPlanPeer::BOOKONE, $this->getRequestParameter('dev_book1'));
  3673. $criteria->add(DevelopmentPlanPeer::BOOKTWO, $this->getRequestParameter('dev_book2'));
  3674. $criteria->add(DevelopmentPlanPeer::BOOKTHREE, $this->getRequestParameter('dev_book3'));
  3675. $criteria->add(DevelopmentPlanPeer::BOOKFOUR, $this->getRequestParameter('dev_book4'));
  3676. $criteria->add(DevelopmentPlanPeer::BOOKFIVE, $this->getRequestParameter('dev_book5'));
  3677. $criteria->add(DevelopmentPlanPeer::SEMINARONE, $this->getRequestParameter('dev_seminar1'));
  3678. $criteria->add(DevelopmentPlanPeer::SEMINARTWO, $this->getRequestParameter('dev_seminar2'));
  3679. $criteria->add(DevelopmentPlanPeer::SEMINARTHREE, $this->getRequestParameter('dev_seminar3'));
  3680. $criteria->add(DevelopmentPlanPeer::SEMINARFOUR, $this->getRequestParameter('dev_seminar4'));
  3681. $criteria->add(DevelopmentPlanPeer::SEMINARFIVE, $this->getRequestParameter('dev_seminar5'));
  3682. $criteria->add(DevelopmentPlanPeer::ARTICLEONE, $this->getRequestParameter('dev_write1'));
  3683. $criteria->add(DevelopmentPlanPeer::ARTICLETWO, $this->getRequestParameter('dev_write2'));
  3684. $criteria->add(DevelopmentPlanPeer::ARTICLETHREE, $this->getRequestParameter('dev_write3'));
  3685. $criteria->add(DevelopmentPlanPeer::ARTICLEFOUR, $this->getRequestParameter('dev_write4'));
  3686. $criteria->add(DevelopmentPlanPeer::ARTICLEFIVE, $this->getRequestParameter('dev_write5'));
  3687. $criteria->add(DevelopmentPlanPeer::WORKSHOPONE, $this->getRequestParameter('dev_workshop1'));
  3688. $criteria->add(DevelopmentPlanPeer::WORKSHOPTWO, $this->getRequestParameter('dev_workshop2'));
  3689. $criteria->add(DevelopmentPlanPeer::WORKSHOPTHREE, $this->getRequestParameter('dev_workshop3'));
  3690. $criteria->add(DevelopmentPlanPeer::WORKSHOPFOUR, $this->getRequestParameter('dev_workshop4'));
  3691. $criteria->add(DevelopmentPlanPeer::WORKSHOPFIVE, $this->getRequestParameter('dev_workshop5'));
  3692. $criteria->add(DevelopmentPlanPeer::DEVELOPCOMMENTS, $this->getRequestParameter('develop_comment'));
  3693.  
  3694. DevelopmentPlanPeer::doUpdate($criteria);
  3695. }
  3696.  
  3697. function isCore() {
  3698. if ($this->getUser()->getAttribute('empRole') == 'core')
  3699. return true;
  3700. else
  3701. return false;
  3702. }
  3703.  
  3704. function isAdmin() {
  3705. if ($this->getUser()->getAttribute('empRole') == 'admin')
  3706. return true;
  3707. else
  3708. return false;
  3709. }
  3710.  
  3711. function isQm() {
  3712. if ($this->getUser()->getAttribute('empRole') == 'qm')
  3713. return true;
  3714. else
  3715. return false;
  3716. }
  3717.  
  3718. function isHr() {
  3719. if ($this->getUser()->getAttribute('empRole') == 'hr')
  3720. return true;
  3721. else
  3722. return false;
  3723. }
  3724.  
  3725. function isStaff() {
  3726. if ($this->getUser()->getAttribute('empRole') == 'staff')
  3727. return true;
  3728. else
  3729. return false;
  3730. }
  3731.  
  3732. function isAllowed($peId) {
  3733. $teamMembers = $this->getUser()->getAttribute('teamMembers');
  3734. //$teamMembers=GroupwareEmployeesPeer::getAllSubordinatesId($this->getUser()->getAttribute('empId'));
  3735. if (empty($teamMembers)) {
  3736. $teamMembers[] = $this->getUser()->getAttribute('empId');
  3737. }
  3738. $criteria = new Criteria();
  3739. $criteria->add(PeEmployeesPeer::PEID, $peId);
  3740. $results = PeEmployeesPeer::doSelect($criteria);
  3741. if ($results) {
  3742. $currEmpId = $results[0]->getEmpId();
  3743. if (in_array($currEmpId, $teamMembers))
  3744. return true;
  3745. else
  3746. return false;
  3747. }
  3748. else {
  3749. $_SESSION['error_msg'] = 'No Such PE Form found';
  3750. $this->redirect('main/index');
  3751. }
  3752. }
  3753.  
  3754. function isSelf($peId=null, $empId=null) {
  3755. $PeEmployees = new PeEmployeesPeer();
  3756. $self = $PeEmployees->isEmpIdExists($peId, $empId);
  3757. if ($self)
  3758. $this->getUser()->setAttribute('isSelf', true);
  3759. return $self;
  3760. }
  3761.  
  3762. // To check whether Employee already Submitted PE Form in the year.
  3763.  
  3764. function isSubmittedThisYear($peform=null, $empid=null) {
  3765.  
  3766. $criteria = new Criteria();
  3767. if ($peform == "original") {
  3768. $empId = $empid;
  3769. $criteria->add(PeEmployeesPeer::TYPE, ORIGINALCODE);
  3770. } else if ($empid) {
  3771. $empId = $empid;
  3772. if ($empId == $this->getUser()->getAttribute('empId')) {
  3773. $criteria->add(PeEmployeesPeer::TYPE, SELFCODE);
  3774. }
  3775. $criteria1 = new Criteria();
  3776. $criteria1->add(PeEmployeesPeer::EMPID, $empId);
  3777. $criteria1->add(PeEmployeesPeer::STATUSID, array(1, 2), Criteria::IN);
  3778. $criteria1->addDescendingOrderByColumn(PeEmployeesPeer::ISSUEDATE);
  3779. $resultObject = PeEmployeesPeer::doSelect($criteria1);
  3780. if ($resultObject) {
  3781. $issueDate = $resultObject[0]->getIssueDate();
  3782. $tmpDate = explode('-', $issueDate);
  3783. $issueYear = $tmpDate[0];
  3784. $currentYear = date('Y');
  3785. if ($currentYear != $issueYear) {
  3786. return false;
  3787. }
  3788. }
  3789. } else {
  3790. $empId = $this->getUser()->getAttribute('empId');
  3791. $criteria->add(PeEmployeesPeer::TYPE, SELFCODE);
  3792. }
  3793.  
  3794. $criteria->addDescendingOrderByColumn(PeEmployeesPeer::ISSUEDATE);
  3795. $criteria->add(PeEmployeesPeer::EMPID, $empId);
  3796. $resultObject = PeEmployeesPeer::doSelect($criteria);
  3797. if ($resultObject) {
  3798. $issueDate = $resultObject[0]->getIssueDate();
  3799. $peId = $resultObject[0]->getPeId();
  3800. $peStatusId = $resultObject[0]->getStatusId();
  3801. }
  3802. $tmpDate = explode('-', $issueDate);
  3803. $issueYear = $tmpDate[0];
  3804. $currentYear = date('Y');
  3805. if ($currentYear == $issueYear) {
  3806. if ($peStatusId == 1 || $peStatusId == 3)
  3807. return $peId;
  3808. else {
  3809. $_SESSION['warning_msg'] = 'The selected person has already submitted a PE Form this year';
  3810. $this->redirect('main/index');
  3811. }
  3812. }
  3813. else
  3814. return false;
  3815. }
  3816.  
  3817. // To check whether Employee has already Submitted Monthly PE Form this month.
  3818.  
  3819. function isSubmittedThisMonth($empid=null, $date=null) {
  3820. $tmpDate = explode('-', $date);
  3821. $year_month = $tmpDate[0] . "-" . $tmpDate[1];
  3822. $criteria = new Criteria();
  3823. $criteria->add(PeEmployeesPeer::EMPID, $empid);
  3824. $criteria->add(PeEmployeesPeer::ISSUEDATE, $year_month . "%", Criteria::LIKE);
  3825. $criteria->add(PeEmployeesPeer::TYPE, MONTHLYCODE);
  3826. $resultObject = PeEmployeesPeer::doSelect($criteria);
  3827. if ($resultObject) {
  3828. $status = $resultObject[0]->getStatusId();
  3829. $peId = $resultObject[0]->getPeId();
  3830. if ($status == 12) {
  3831. $_SESSION['warning_msg'] = 'The selected person has already saved a PE Form this month';
  3832. $this->redirect('main/PeForm?edit=' . $peId . '&status=monthlysave');
  3833. }
  3834. else
  3835. $_SESSION['warning_msg'] = 'The selected person has already submitted a PE Form this month';
  3836. $this->redirect('main/addPEForm');
  3837. }
  3838. return true;
  3839. }
  3840.  
  3841. function setPeHelpAdmin() {
  3842. $pehelpadmin = new PeHelpAdmin();
  3843. $pehelpadmin->setEmpInfoHelp($this->getRequestParameter('eihelp'));
  3844. $pehelpadmin->setAccomHelp($this->getRequestParameter('achelp'));
  3845. $pehelpadmin->setAddResponsHelp($this->getRequestParameter('arhelp'));
  3846. $pehelpadmin->setQualityHelp($this->getRequestParameter('qlwhelp'));
  3847. $pehelpadmin->setQuantityHelp($this->getRequestParameter('qnwhelp'));
  3848. $pehelpadmin->setCommnHelp($this->getRequestParameter('cmnhelp'));
  3849. $pehelpadmin->setJobKnowHelp($this->getRequestParameter('jkhelp'));
  3850. $pehelpadmin->setMgmntSkillHelp($this->getRequestParameter('mshelp'));
  3851. $pehelpadmin->setSocialEfectHelp($this->getRequestParameter('sehelp'));
  3852. $pehelpadmin->setCustDelightHelp($this->getRequestParameter('cdhelp'));
  3853. $pehelpadmin->setAttendencePunctualHelp($this->getRequestParameter('aphelp'));
  3854. $pehelpadmin->setLeaveMgmntHelp($this->getRequestParameter('lmhelp'));
  3855. $pehelpadmin->setQmsHelp($this->getRequestParameter('qmshelp'));
  3856. $pehelpadmin->setOtherActivityHelp($this->getRequestParameter('oahelp'));
  3857. $pehelpadmin->setObjnotacheivedHelp($this->getRequestParameter('onahelp'));
  3858. $pehelpadmin->setEmpCommentHelp($this->getRequestParameter('echelp'));
  3859. $pehelpadmin->setDevolopeHelp($this->getRequestParameter('dphelp'));
  3860.  
  3861. $pehelpadmin->save();
  3862. return true;
  3863. }
  3864.  
  3865. function updatePeHelpAdmin($helpid) {
  3866. $criteria = new Criteria();
  3867. $criteria->add(PeHelpAdminPeer::HELPADMINID, $helpid);
  3868. if ($this->getRequestParameter('eihelp') != "")
  3869. $criteria->add(PeHelpAdminPeer::EMPINFOHELP, $this->getRequestParameter('eihelp'));
  3870. if ($this->getRequestParameter('achelp') != "")
  3871. $criteria->add(PeHelpAdminPeer::ACCOMHELP, $this->getRequestParameter('achelp'));
  3872. if ($this->getRequestParameter('arhelp') != "")
  3873. $criteria->add(PeHelpAdminPeer::ADDRESPONSHELP, $this->getRequestParameter('arhelp'));
  3874. if ($this->getRequestParameter('qlwhelp') != "")
  3875. $criteria->add(PeHelpAdminPeer::QUALITYHELP, $this->getRequestParameter('qlwhelp'));
  3876. if ($this->getRequestParameter('qnwhelp') != "")
  3877. $criteria->add(PeHelpAdminPeer::QUANTITYHELP, $this->getRequestParameter('qnwhelp'));
  3878. if ($this->getRequestParameter('cmnhelp') != "")
  3879. $criteria->add(PeHelpAdminPeer::COMMNHELP, $this->getRequestParameter('cmnhelp'));
  3880. if ($this->getRequestParameter('jkhelp') != "")
  3881. $criteria->add(PeHelpAdminPeer::JOBKNOWHELP, $this->getRequestParameter('jkhelp'));
  3882. if ($this->getRequestParameter('mshelp') != "")
  3883. $criteria->add(PeHelpAdminPeer::MGMNTSKILLHELP, $this->getRequestParameter('mshelp'));
  3884. if ($this->getRequestParameter('sehelp') != "")
  3885. $criteria->add(PeHelpAdminPeer::SOCIALEFECTHELP, $this->getRequestParameter('sehelp'));
  3886. if ($this->getRequestParameter('cdhelp') != "")
  3887. $criteria->add(PeHelpAdminPeer::CUSTDELIGHTHELP, $this->getRequestParameter('cdhelp'));
  3888. if ($this->getRequestParameter('aphelp') != "")
  3889. $criteria->add(PeHelpAdminPeer::ATTENDENCEPUNCTUALHELP, $this->getRequestParameter('aphelp'));
  3890. if ($this->getRequestParameter('lmhelp') != "")
  3891. $criteria->add(PeHelpAdminPeer::LEAVEMGMNTHELP, $this->getRequestParameter('lmhelp'));
  3892. if ($this->getRequestParameter('qmshelp') != "")
  3893. $criteria->add(PeHelpAdminPeer::QMSHELP, $this->getRequestParameter('qmshelp'));
  3894. if ($this->getRequestParameter('oahelp') != "")
  3895. $criteria->add(PeHelpAdminPeer::OTHERACTIVITYHELP, $this->getRequestParameter('oahelp'));
  3896. if ($this->getRequestParameter('onahelp') != "")
  3897. $criteria->add(PeHelpAdminPeer::OBJNOTACHEIVEDHELP, $this->getRequestParameter('onahelp'));
  3898. if ($this->getRequestParameter('echelp') != "")
  3899. $criteria->add(PeHelpAdminPeer::EMPCOMMENTHELP, $this->getRequestParameter('echelp'));
  3900. if ($this->getRequestParameter('dphelp') != "")
  3901. $criteria->add(PeHelpAdminPeer::DEVOLOPEHELP, $this->getRequestParameter('dphelp'));
  3902.  
  3903. PeHelpAdminPeer::doUpdate($criteria);
  3904. return true;
  3905. }
  3906.  
  3907. function setPeHelpStaff() {
  3908. $pehelpstaff = new PeHelpStaff();
  3909. $pehelpstaff->setEmpInfoHelp($this->getRequestParameter('eihelp'));
  3910. $pehelpstaff->setAccomHelp($this->getRequestParameter('achelp'));
  3911. $pehelpstaff->setAddResponsHelp($this->getRequestParameter('arhelp'));
  3912. $pehelpstaff->setQualityHelp($this->getRequestParameter('qlwhelp'));
  3913. $pehelpstaff->setQuantityHelp($this->getRequestParameter('qnwhelp'));
  3914. $pehelpstaff->setCommnHelp($this->getRequestParameter('cmnhelp'));
  3915. $pehelpstaff->setJobKnowHelp($this->getRequestParameter('jkhelp'));
  3916. $pehelpstaff->setSocialEfectHelp($this->getRequestParameter('sehelp'));
  3917. $pehelpstaff->setCustDelightHelp($this->getRequestParameter('cdhelp'));
  3918. $pehelpstaff->setAttendencePunctualHelp($this->getRequestParameter('aphelp'));
  3919. $pehelpstaff->setLeaveMgmntHelp($this->getRequestParameter('lmhelp'));
  3920. $pehelpstaff->setQmsHelp($this->getRequestParameter('qmshelp'));
  3921. $pehelpstaff->setOtherActivityHelp($this->getRequestParameter('oahelp'));
  3922. $pehelpstaff->setObjnotacheivedHelp($this->getRequestParameter('onahelp'));
  3923. $pehelpstaff->setEmpCommentHelp($this->getRequestParameter('echelp'));
  3924. $pehelpstaff->setDevolopeHelp($this->getRequestParameter('dphelp'));
  3925.  
  3926. $pehelpstaff->save();
  3927. return true;
  3928. }
  3929.  
  3930. function updatePeHelpStaff($helpid) {
  3931. $criteria = new Criteria();
  3932. $criteria->add(PeHelpStaffPeer::HELPSTAFID, $helpid);
  3933. if ($this->getRequestParameter('eihelp') != "")
  3934. $criteria->add(PeHelpStaffPeer::EMPINFOHELP, $this->getRequestParameter('eihelp'));
  3935. if ($this->getRequestParameter('achelp') != "")
  3936. $criteria->add(PeHelpStaffPeer::ACCOMHELP, $this->getRequestParameter('achelp'));
  3937. if ($this->getRequestParameter('arhelp') != "")
  3938. $criteria->add(PeHelpStaffPeer::ADDRESPONSHELP, $this->getRequestParameter('arhelp'));
  3939. if ($this->getRequestParameter('qlwhelp') != "")
  3940. $criteria->add(PeHelpStaffPeer::QUALITYHELP, $this->getRequestParameter('qlwhelp'));
  3941. if ($this->getRequestParameter('qnwhelp') != "")
  3942. $criteria->add(PeHelpStaffPeer::QUANTITYHELP, $this->getRequestParameter('qnwhelp'));
  3943. if ($this->getRequestParameter('cmnhelp') != "")
  3944. $criteria->add(PeHelpStaffPeer::COMMNHELP, $this->getRequestParameter('cmnhelp'));
  3945. if ($this->getRequestParameter('jkhelp') != "")
  3946. $criteria->add(PeHelpStaffPeer::JOBKNOWHELP, $this->getRequestParameter('jkhelp'));
  3947. if ($this->getRequestParameter('sehelp') != "")
  3948. $criteria->add(PeHelpStaffPeer::SOCIALEFECTHELP, $this->getRequestParameter('sehelp'));
  3949. if ($this->getRequestParameter('cdhelp') != "")
  3950. $criteria->add(PeHelpStaffPeer::CUSTDELIGHTHELP, $this->getRequestParameter('cdhelp'));
  3951. if ($this->getRequestParameter('aphelp') != "")
  3952. $criteria->add(PeHelpStaffPeer::ATTENDENCEPUNCTUALHELP, $this->getRequestParameter('aphelp'));
  3953. if ($this->getRequestParameter('lmhelp') != "")
  3954. $criteria->add(PeHelpStaffPeer::LEAVEMGMNTHELP, $this->getRequestParameter('lmhelp'));
  3955. if ($this->getRequestParameter('qmshelp') != "")
  3956. $criteria->add(PeHelpStaffPeer::QMSHELP, $this->getRequestParameter('qmshelp'));
  3957. if ($this->getRequestParameter('oahelp') != "")
  3958. $criteria->add(PeHelpStaffPeer::OTHERACTIVITYHELP, $this->getRequestParameter('oahelp'));
  3959. if ($this->getRequestParameter('onahelp') != "")
  3960. $criteria->add(PeHelpStaffPeer::OBJNOTACHEIVEDHELP, $this->getRequestParameter('onahelp'));
  3961. if ($this->getRequestParameter('echelp') != "")
  3962. $criteria->add(PeHelpStaffPeer::EMPCOMMENTHELP, $this->getRequestParameter('echelp'));
  3963. if ($this->getRequestParameter('dphelp') != "")
  3964. $criteria->add(PeHelpStaffPeer::DEVOLOPEHELP, $this->getRequestParameter('dphelp'));
  3965.  
  3966. PeHelpStaffPeer::doUpdate($criteria);
  3967. return true;
  3968. }
  3969.  
  3970. function setPeHelpQm() {
  3971. $pehelpadmin = new PeHelpQm();
  3972. $pehelpadmin->setEmpInfoHelp($this->getRequestParameter('eihelp'));
  3973. $pehelpadmin->setAccomHelp($this->getRequestParameter('achelp'));
  3974. $pehelpadmin->setAddResponsHelp($this->getRequestParameter('arhelp'));
  3975. $pehelpadmin->setQualityHelp($this->getRequestParameter('qlwhelp'));
  3976. $pehelpadmin->setQuantityHelp($this->getRequestParameter('qnwhelp'));
  3977. $pehelpadmin->setCommnHelp($this->getRequestParameter('cmnhelp'));
  3978. $pehelpadmin->setJobKnowHelp($this->getRequestParameter('jkhelp'));
  3979. $pehelpadmin->setMgmntSkillHelp($this->getRequestParameter('mshelp'));
  3980. $pehelpadmin->setSocialEfectHelp($this->getRequestParameter('sehelp'));
  3981. $pehelpadmin->setCustDelightHelp($this->getRequestParameter('cdhelp'));
  3982. $pehelpadmin->setAttendencePunctualHelp($this->getRequestParameter('aphelp'));
  3983. $pehelpadmin->setLeaveMgmntHelp($this->getRequestParameter('lmhelp'));
  3984. $pehelpadmin->setQmsHelp($this->getRequestParameter('qmshelp'));
  3985. $pehelpadmin->setOtherActivityHelp($this->getRequestParameter('oahelp'));
  3986. $pehelpadmin->setObjnotacheivedHelp($this->getRequestParameter('onahelp'));
  3987. $pehelpadmin->setEmpCommentHelp($this->getRequestParameter('echelp'));
  3988. $pehelpadmin->setDevolopeHelp($this->getRequestParameter('dphelp'));
  3989.  
  3990. $pehelpadmin->save();
  3991. return true;
  3992. }
  3993.  
  3994. function updatePeHelpQm($helpid) {
  3995. $criteria = new Criteria();
  3996. $criteria->add(PeHelpQmPeer::HELPQMID, $helpid);
  3997. if ($this->getRequestParameter('eihelp') != "")
  3998. $criteria->add(PeHelpQmPeer::EMPINFOHELP, $this->getRequestParameter('eihelp'));
  3999. if ($this->getRequestParameter('achelp') != "")
  4000. $criteria->add(PeHelpQmPeer::ACCOMHELP, $this->getRequestParameter('achelp'));
  4001. if ($this->getRequestParameter('arhelp') != "")
  4002. $criteria->add(PeHelpQmPeer::ADDRESPONSHELP, $this->getRequestParameter('arhelp'));
  4003. if ($this->getRequestParameter('qlwhelp') != "")
  4004. $criteria->add(PeHelpQmPeer::QUALITYHELP, $this->getRequestParameter('qlwhelp'));
  4005. if ($this->getRequestParameter('qnwhelp') != "")
  4006. $criteria->add(PeHelpQmPeer::QUANTITYHELP, $this->getRequestParameter('qnwhelp'));
  4007. if ($this->getRequestParameter('cmnhelp') != "")
  4008. $criteria->add(PeHelpQmPeer::COMMNHELP, $this->getRequestParameter('cmnhelp'));
  4009. if ($this->getRequestParameter('jkhelp') != "")
  4010. $criteria->add(PeHelpQmPeer::JOBKNOWHELP, $this->getRequestParameter('jkhelp'));
  4011. if ($this->getRequestParameter('mshelp') != "")
  4012. $criteria->add(PeHelpQmPeer::MGMNTSKILLHELP, $this->getRequestParameter('mshelp'));
  4013. if ($this->getRequestParameter('sehelp') != "")
  4014. $criteria->add(PeHelpQmPeer::SOCIALEFECTHELP, $this->getRequestParameter('sehelp'));
  4015. if ($this->getRequestParameter('cdhelp') != "")
  4016. $criteria->add(PeHelpQmPeer::CUSTDELIGHTHELP, $this->getRequestParameter('cdhelp'));
  4017. if ($this->getRequestParameter('aphelp') != "")
  4018. $criteria->add(PeHelpQmPeer::ATTENDENCEPUNCTUALHELP, $this->getRequestParameter('aphelp'));
  4019. if ($this->getRequestParameter('lmhelp') != "")
  4020. $criteria->add(PeHelpQmPeer::LEAVEMGMNTHELP, $this->getRequestParameter('lmhelp'));
  4021. if ($this->getRequestParameter('qmshelp') != "")
  4022. $criteria->add(PeHelpQmPeer::QMSHELP, $this->getRequestParameter('qmshelp'));
  4023. if ($this->getRequestParameter('oahelp') != "")
  4024. $criteria->add(PeHelpQmPeer::OTHERACTIVITYHELP, $this->getRequestParameter('oahelp'));
  4025. if ($this->getRequestParameter('onahelp') != "")
  4026. $criteria->add(PeHelpQmPeer::OBJNOTACHEIVEDHELP, $this->getRequestParameter('onahelp'));
  4027. if ($this->getRequestParameter('echelp') != "")
  4028. $criteria->add(PeHelpQmPeer::EMPCOMMENTHELP, $this->getRequestParameter('echelp'));
  4029. if ($this->getRequestParameter('dphelp') != "")
  4030. $criteria->add(PeHelpQmPeer::DEVOLOPEHELP, $this->getRequestParameter('dphelp'));
  4031.  
  4032. PeHelpQmPeer::doUpdate($criteria);
  4033. return true;
  4034. }
  4035.  
  4036. function setPeSampleAdmin() {
  4037. $pesampleadmin = new PeSampleAdmin();
  4038. $pesampleadmin->setEmpInfoHelp($this->getRequestParameter('eisample'));
  4039. $pesampleadmin->setAccomHelp($this->getRequestParameter('acsample'));
  4040. $pesampleadmin->setAddResponsHelp($this->getRequestParameter('arsample'));
  4041. $pesampleadmin->setQualityHelp($this->getRequestParameter('qlwsample'));
  4042. $pesampleadmin->setQuantityHelp($this->getRequestParameter('qnwsample'));
  4043. $pesampleadmin->setCommnHelp($this->getRequestParameter('cmnsample'));
  4044. $pesampleadmin->setJobKnowHelp($this->getRequestParameter('jksample'));
  4045. $pesampleadmin->setMgmntSkillHelp($this->getRequestParameter('mssample'));
  4046. $pesampleadmin->setSocialEfectHelp($this->getRequestParameter('sesample'));
  4047. $pesampleadmin->setCustDelightHelp($this->getRequestParameter('cdsample'));
  4048. $pesampleadmin->setAttendencePunctualHelp($this->getRequestParameter('apsample'));
  4049. $pesampleadmin->setLeaveMgmntHelp($this->getRequestParameter('lmsample'));
  4050. $pesampleadmin->setQmsHelp($this->getRequestParameter('qmssample'));
  4051. $pesampleadmin->setOtherActivityHelp($this->getRequestParameter('oasample'));
  4052. $pesampleadmin->setObjnotacheivedHelp($this->getRequestParameter('onasample'));
  4053. $pesampleadmin->setEmpCommentHelp($this->getRequestParameter('ecsample'));
  4054. $pesampleadmin->setDevolopeHelp($this->getRequestParameter('dpsample'));
  4055.  
  4056. $pesampleadmin->save();
  4057. return true;
  4058. }
  4059.  
  4060. function updatePeSampleAdmin($sampleid) {
  4061. $criteria = new Criteria();
  4062. $criteria->add(PeSampleAdminPeer::SAMPLEADMINID, $sampleid);
  4063. if ($this->getRequestParameter('eisample') != "")
  4064. $criteria->add(PeSampleAdminPeer::EMPINFOHELP, $this->getRequestParameter('eisample'));
  4065. if ($this->getRequestParameter('acsample') != "")
  4066. $criteria->add(PeSampleAdminPeer::ACCOMHELP, $this->getRequestParameter('acsample'));
  4067. if ($this->getRequestParameter('arsample') != "")
  4068. $criteria->add(PeSampleAdminPeer::ADDRESPONSHELP, $this->getRequestParameter('arsample'));
  4069. if ($this->getRequestParameter('qlwsample') != "")
  4070. $criteria->add(PeSampleAdminPeer::QUALITYHELP, $this->getRequestParameter('qlwsample'));
  4071. if ($this->getRequestParameter('qnwsample') != "")
  4072. $criteria->add(PeSampleAdminPeer::QUANTITYHELP, $this->getRequestParameter('qnwsample'));
  4073. if ($this->getRequestParameter('cmnsample') != "")
  4074. $criteria->add(PeSampleAdminPeer::COMMNHELP, $this->getRequestParameter('cmnsample'));
  4075. if ($this->getRequestParameter('jksample') != "")
  4076. $criteria->add(PeSampleAdminPeer::JOBKNOWHELP, $this->getRequestParameter('jksample'));
  4077. if ($this->getRequestParameter('mssample') != "")
  4078. $criteria->add(PeSampleAdminPeer::MGMNTSKILLHELP, $this->getRequestParameter('mssample'));
  4079. if ($this->getRequestParameter('sesample') != "")
  4080. $criteria->add(PeSampleAdminPeer::SOCIALEFECTHELP, $this->getRequestParameter('sesample'));
  4081. if ($this->getRequestParameter('cdsample') != "")
  4082. $criteria->add(PeSampleAdminPeer::CUSTDELIGHTHELP, $this->getRequestParameter('cdsample'));
  4083. if ($this->getRequestParameter('apsample') != "")
  4084. $criteria->add(PeSampleAdminPeer::ATTENDENCEPUNCTUALHELP, $this->getRequestParameter('apsample'));
  4085. if ($this->getRequestParameter('lmsample') != "")
  4086. $criteria->add(PeSampleAdminPeer::LEAVEMGMNTHELP, $this->getRequestParameter('lmsample'));
  4087. if ($this->getRequestParameter('qmssample') != "")
  4088. $criteria->add(PeSampleAdminPeer::QMSHELP, $this->getRequestParameter('qmssample'));
  4089. if ($this->getRequestParameter('oasample') != "")
  4090. $criteria->add(PeSampleAdminPeer::OTHERACTIVITYHELP, $this->getRequestParameter('oasample'));
  4091. if ($this->getRequestParameter('onasample') != "")
  4092. $criteria->add(PeSampleAdminPeer::OBJNOTACHEIVEDHELP, $this->getRequestParameter('onasample'));
  4093. if ($this->getRequestParameter('ecsample') != "")
  4094. $criteria->add(PeSampleAdminPeer::EMPCOMMENTHELP, $this->getRequestParameter('ecsample'));
  4095. if ($this->getRequestParameter('dpsample') != "")
  4096. $criteria->add(PeSampleAdminPeer::DEVOLOPEHELP, $this->getRequestParameter('dpsample'));
  4097.  
  4098. PeSampleAdminPeer::doUpdate($criteria);
  4099. return true;
  4100. }
  4101.  
  4102. function setPeSampleStaff() {
  4103. $pesamplestaff = new PeSampleStaff();
  4104. $pesamplestaff->setEmpInfoHelp($this->getRequestParameter('eisample'));
  4105. $pesamplestaff->setAccomHelp($this->getRequestParameter('acsample'));
  4106. $pesamplestaff->setAddResponsHelp($this->getRequestParameter('arsample'));
  4107. $pesamplestaff->setQualityHelp($this->getRequestParameter('qlwsample'));
  4108. $pesamplestaff->setQuantityHelp($this->getRequestParameter('qnwsample'));
  4109. $pesamplestaff->setCommnHelp($this->getRequestParameter('cmnsample'));
  4110. $pesamplestaff->setJobKnowHelp($this->getRequestParameter('jksample'));
  4111. $pesamplestaff->setSocialEfectHelp($this->getRequestParameter('sesample'));
  4112. $pesamplestaff->setCustDelightHelp($this->getRequestParameter('cdsample'));
  4113. $pesamplestaff->setAttendencePunctualHelp($this->getRequestParameter('apsample'));
  4114. $pesamplestaff->setLeaveMgmntHelp($this->getRequestParameter('lmsample'));
  4115. $pesamplestaff->setQmsHelp($this->getRequestParameter('qmssample'));
  4116. $pesamplestaff->setOtherActivityHelp($this->getRequestParameter('oasample'));
  4117. $pesamplestaff->setObjnotacheivedHelp($this->getRequestParameter('onasample'));
  4118. $pesamplestaff->setEmpCommentHelp($this->getRequestParameter('ecsample'));
  4119. $pesamplestaff->setDevolopeHelp($this->getRequestParameter('dpsample'));
  4120.  
  4121. $pesamplestaff->save();
  4122. return true;
  4123. }
  4124.  
  4125. function updatePeSampleStaff($sampleid) {
  4126. $criteria = new Criteria();
  4127. $criteria->add(PeSampleStaffPeer::SAMPLESTAFID, $sampleid);
  4128. if ($this->getRequestParameter('eisample') != "")
  4129. $criteria->add(PeSampleStaffPeer::EMPINFOHELP, $this->getRequestParameter('eisample'));
  4130. if ($this->getRequestParameter('acsample') != "")
  4131. $criteria->add(PeSampleStaffPeer::ACCOMHELP, $this->getRequestParameter('acsample'));
  4132. if ($this->getRequestParameter('arsample') != "")
  4133. $criteria->add(PeSampleStaffPeer::ADDRESPONSHELP, $this->getRequestParameter('arsample'));
  4134. if ($this->getRequestParameter('qlwsample') != "")
  4135. $criteria->add(PeSampleStaffPeer::QUALITYHELP, $this->getRequestParameter('qlwsample'));
  4136. if ($this->getRequestParameter('qnwsample') != "")
  4137. $criteria->add(PeSampleStaffPeer::QUANTITYHELP, $this->getRequestParameter('qnwsample'));
  4138. if ($this->getRequestParameter('cmnsample') != "")
  4139. $criteria->add(PeSampleStaffPeer::COMMNHELP, $this->getRequestParameter('cmnsample'));
  4140. if ($this->getRequestParameter('jksample') != "")
  4141. $criteria->add(PeSampleStaffPeer::JOBKNOWHELP, $this->getRequestParameter('jksample'));
  4142. if ($this->getRequestParameter('sesample') != "")
  4143. $criteria->add(PeSampleStaffPeer::SOCIALEFECTHELP, $this->getRequestParameter('sesample'));
  4144. if ($this->getRequestParameter('cdsample') != "")
  4145. $criteria->add(PeSampleStaffPeer::CUSTDELIGHTHELP, $this->getRequestParameter('cdsample'));
  4146. if ($this->getRequestParameter('apsample') != "")
  4147. $criteria->add(PeSampleStaffPeer::ATTENDENCEPUNCTUALHELP, $this->getRequestParameter('apsample'));
  4148. if ($this->getRequestParameter('lmsample') != "")
  4149. $criteria->add(PeSampleStaffPeer::LEAVEMGMNTHELP, $this->getRequestParameter('lmsample'));
  4150. if ($this->getRequestParameter('qmssample') != "")
  4151. $criteria->add(PeSampleStaffPeer::QMSHELP, $this->getRequestParameter('qmssample'));
  4152. if ($this->getRequestParameter('oasample') != "")
  4153. $criteria->add(PeSampleStaffPeer::OTHERACTIVITYHELP, $this->getRequestParameter('oasample'));
  4154. if ($this->getRequestParameter('onasample') != "")
  4155. $criteria->add(PeSampleStaffPeer::OBJNOTACHEIVEDHELP, $this->getRequestParameter('onasample'));
  4156. if ($this->getRequestParameter('ecsample') != "")
  4157. $criteria->add(PeSampleStaffPeer::EMPCOMMENTHELP, $this->getRequestParameter('ecsample'));
  4158. if ($this->getRequestParameter('dpsample') != "")
  4159. $criteria->add(PeSampleStaffPeer::DEVOLOPEHELP, $this->getRequestParameter('dpsample'));
  4160.  
  4161. PeSampleStaffPeer::doUpdate($criteria);
  4162. return true;
  4163. }
  4164.  
  4165. function setPeSampleQm() {
  4166. $pesampleadmin = new PeSampleQm();
  4167. $pesampleadmin->setEmpInfoHelp($this->getRequestParameter('eisample'));
  4168. $pesampleadmin->setAccomHelp($this->getRequestParameter('acsample'));
  4169. $pesampleadmin->setAddResponsHelp($this->getRequestParameter('arsample'));
  4170. $pesampleadmin->setQualityHelp($this->getRequestParameter('qlwsample'));
  4171. $pesampleadmin->setQuantityHelp($this->getRequestParameter('qnwsample'));
  4172. $pesampleadmin->setCommnHelp($this->getRequestParameter('cmnsample'));
  4173. $pesampleadmin->setJobKnowHelp($this->getRequestParameter('jksample'));
  4174. $pesampleadmin->setMgmntSkillHelp($this->getRequestParameter('mssample'));
  4175. $pesampleadmin->setSocialEfectHelp($this->getRequestParameter('sesample'));
  4176. $pesampleadmin->setCustDelightHelp($this->getRequestParameter('cdsample'));
  4177. $pesampleadmin->setAttendencePunctualHelp($this->getRequestParameter('apsample'));
  4178. $pesampleadmin->setLeaveMgmntHelp($this->getRequestParameter('lmsample'));
  4179. $pesampleadmin->setQmsHelp($this->getRequestParameter('qmssample'));
  4180. $pesampleadmin->setOtherActivityHelp($this->getRequestParameter('oasample'));
  4181. $pesampleadmin->setObjnotacheivedHelp($this->getRequestParameter('onasample'));
  4182. $pesampleadmin->setEmpCommentHelp($this->getRequestParameter('ecsample'));
  4183. $pesampleadmin->setDevolopeHelp($this->getRequestParameter('dpsample'));
  4184.  
  4185. $pesampleadmin->save();
  4186. return true;
  4187. }
  4188.  
  4189. function updatePeSampleQm($sampleid) {
  4190. $criteria = new Criteria();
  4191. $criteria->add(PeSampleQmPeer::SAMPLEQMID, $sampleid);
  4192. if ($this->getRequestParameter('eisample') != "")
  4193. $criteria->add(PeSampleQmPeer::EMPINFOHELP, $this->getRequestParameter('eisample'));
  4194. if ($this->getRequestParameter('acsample') != "")
  4195. $criteria->add(PeSampleQmPeer::ACCOMHELP, $this->getRequestParameter('acsample'));
  4196. if ($this->getRequestParameter('arsample') != "")
  4197. $criteria->add(PeSampleQmPeer::ADDRESPONSHELP, $this->getRequestParameter('arsample'));
  4198. if ($this->getRequestParameter('qlwsample') != "")
  4199. $criteria->add(PeSampleQmPeer::QUALITYHELP, $this->getRequestParameter('qlwsample'));
  4200. if ($this->getRequestParameter('qnwsample') != "")
  4201. $criteria->add(PeSampleQmPeer::QUANTITYHELP, $this->getRequestParameter('qnwsample'));
  4202. if ($this->getRequestParameter('cmnsample') != "")
  4203. $criteria->add(PeSampleQmPeer::COMMNHELP, $this->getRequestParameter('cmnsample'));
  4204. if ($this->getRequestParameter('jksample') != "")
  4205. $criteria->add(PeSampleQmPeer::JOBKNOWHELP, $this->getRequestParameter('jksample'));
  4206. if ($this->getRequestParameter('mssample') != "")
  4207. $criteria->add(PeSampleQmPeer::MGMNTSKILLHELP, $this->getRequestParameter('mssample'));
  4208. if ($this->getRequestParameter('sesample') != "")
  4209. $criteria->add(PeSampleQmPeer::SOCIALEFECTHELP, $this->getRequestParameter('sesample'));
  4210. if ($this->getRequestParameter('cdsample') != "")
  4211. $criteria->add(PeSampleQmPeer::CUSTDELIGHTHELP, $this->getRequestParameter('cdsample'));
  4212. if ($this->getRequestParameter('apsample') != "")
  4213. $criteria->add(PeSampleQmPeer::ATTENDENCEPUNCTUALHELP, $this->getRequestParameter('apsample'));
  4214. if ($this->getRequestParameter('lmsample') != "")
  4215. $criteria->add(PeSampleQmPeer::LEAVEMGMNTHELP, $this->getRequestParameter('lmsample'));
  4216. if ($this->getRequestParameter('qmssample') != "")
  4217. $criteria->add(PeSampleQmPeer::QMSHELP, $this->getRequestParameter('qmssample'));
  4218. if ($this->getRequestParameter('oasample') != "")
  4219. $criteria->add(PeSampleQmPeer::OTHERACTIVITYHELP, $this->getRequestParameter('oasample'));
  4220. if ($this->getRequestParameter('onasample') != "")
  4221. $criteria->add(PeSampleQmPeer::OBJNOTACHEIVEDHELP, $this->getRequestParameter('onasample'));
  4222. if ($this->getRequestParameter('ecsample') != "")
  4223. $criteria->add(PeSampleQmPeer::EMPCOMMENTHELP, $this->getRequestParameter('ecsample'));
  4224. if ($this->getRequestParameter('dpsample') != "")
  4225. $criteria->add(PeSampleQmPeer::DEVOLOPEHELP, $this->getRequestParameter('dpsample'));
  4226.  
  4227. PeSampleQmPeer::doUpdate($criteria);
  4228. return true;
  4229. }
  4230.  
  4231. function getEmployeeRoleType() {
  4232. $formType = PeChangeformPeer::getFormType($this->getUser()->getAttribute('empId'));
  4233. if ($formType != null) {
  4234. switch ($formType) {
  4235. case 'admin':
  4236. return ADMIN;
  4237. break;
  4238. case 'qm':
  4239. return QM;
  4240. break;
  4241. case 'staff':
  4242. return STAFF;
  4243. break;
  4244. }
  4245. } else {
  4246. if ($this->isAdmin()) {
  4247. return 0;
  4248. } elseif ($this->isQm())
  4249. return 1;
  4250. elseif ($this->isStaff()) {
  4251. return 2;
  4252. }
  4253. else
  4254. return false;
  4255. }
  4256. }
  4257.  
  4258. function updatePeStatus($peStatus) {
  4259. $peId = $this->getRequestParameter('peId');
  4260. $criteria = new Criteria();
  4261. $criteria->add(PeEmployeesPeer::PEID, $peId);
  4262. $criteria->add(PeEmployeesPeer::STATUSID, $peStatus);
  4263. $updationStatus = PeEmployeesPeer::doUpdate($criteria);
  4264. if ($updationStatus)
  4265. return true;
  4266. else
  4267. return false;
  4268. }
  4269.  
  4270. function getPostedValues() {
  4271. switch ($this->getRequestParameter('commit')) {
  4272.  
  4273.  
  4274. case 'Add' :
  4275. if ($this->isCore()) {
  4276. $PeId = $this->getRequestParameter('peId');
  4277. $this->setSuggestions($PeId);
  4278. }
  4279. $this->redirect('main/PeForm?view=' . $PeId);
  4280. break;
  4281. case 'Save':
  4282. $success = $this->validateMark();
  4283. if ($success == false) {
  4284. $empId = $this->getRequestParameter('empId');
  4285. $this->getPreForm($empId);
  4286. $this->emp = $this->getUser();
  4287. $this->readonly = false;
  4288. break;
  4289. }
  4290. //added bby renjo for monthly PE
  4291. if ($this->getRequestParameter('perform') == "monthly")
  4292. $peStatus = 12;
  4293. else if ($this->getRequestParameter('perform') == "original")
  4294. $peStatus = 3;
  4295. else
  4296. $peStatus = 1;
  4297.  
  4298. if ($this->getRequestParameter('update')) {
  4299. if ($this->updatePEForm($peStatus)) {
  4300. $peform = $this->getRequestParameter('perform');
  4301. $empid = $this->getRequestParameter('empId');
  4302. $_SESSION['msg'] = 'Successfully saved the PEForm !!';
  4303.  
  4304. $groupwareEmployee = new GroupwareEmployeesPeer();
  4305. $kidName = $groupwareEmployee->getEmployeeName($empid);
  4306. $empName = $groupwareEmployee->getEmployeeName($_SESSION['empId']);
  4307. //if($this->getRequestParameter('perform')=="monthly")
  4308. $peId = $this->getRequestParameter('update');
  4309. //else
  4310. //$peId=$this -> isSubmittedThisYear($peform,$empid);
  4311. //echo $this->getRequestParameter('update');die;
  4312. $logs = new PelogsPeer();
  4313. if ($peStatus == 12)
  4314. $savedEmployeeLog = $logs->getSavedEmployeeFormLog($peId, $kidName, $peform, $empName, 12);
  4315. else
  4316. $savedEmployeeLog=$logs->getSavedEmployeeFormLog($peId, $kidName, $peform, $empName);
  4317. //added by renjo for monthly PE
  4318. if ($peStatus == 12)
  4319. $this->redirect('main/PeForm?edit=' . $peId . '&status=monthlysave');
  4320. else if ($peStatus == 1)
  4321. $this->redirect('main/PeForm?edit=' . $peId . '&value=staffSaved');
  4322. else {
  4323. $this->redirect('main/PeForm?edit=' . $peId . '&status=adminsave');
  4324. }
  4325. }
  4326. else
  4327. $_SESSION['error_msg'] = 'Your updation failed !!!!';
  4328. $this->redirect('main/index');
  4329. }
  4330. else {
  4331. $peform = $this->getRequestParameter('perform');
  4332. $empid = $this->getRequestParameter('empId');
  4333.  
  4334. if ($this->setPEForm($peStatus, $peform, $empid)) { // INSERT VALUES TO DATABASE (NEW PE FORM)
  4335. $_SESSION['msg'] = 'Successfully saved your PEForm !!';
  4336. $empId = $this->getRequestParameter('empId');
  4337. $groupwareEmployee = new GroupwareEmployeesPeer();
  4338. $kidName = $groupwareEmployee->getEmployeeName($empid);
  4339. $empName = $groupwareEmployee->getEmployeeName($_SESSION['empId']);
  4340. $peId = $this->isSubmittedThisYear($peform, $empid);
  4341. $logs = new PelogsPeer();
  4342. $savedEmployeeLog = $logs->getSavedEmployeeFormLog($peId, $kidName, $peform, $empName);
  4343. if ($peStatus == 1)
  4344. $this->redirect('main/PeForm?edit=' . $peId . '&value=staffSaved');
  4345. else
  4346. $this->redirect('main/PeForm?edit=' . $peId . '&status=adminsave');
  4347. }
  4348. else
  4349. $_SESSION['error_msg'] = 'Your insertion failed !!!!';
  4350. $this->redirect('main/index');
  4351. }
  4352. break;
  4353. case 'SavePE':
  4354. $peId = $this->getRequestParameter('update');
  4355. $success = $this->validateMark();
  4356. if ($success == false) {
  4357. $this->redirect('main/PeForm?edit=' . $peId);
  4358. }
  4359. $peStatus = 5;
  4360.  
  4361. if ($this->getRequestParameter('update')) {
  4362. if ($this->updatePEForm($peStatus))
  4363. $_SESSION['msg'] = 'Successfully saved the PEForm !!';
  4364. else
  4365. $_SESSION['error_msg'] = 'Your updation failed !!!!';
  4366. }
  4367. $this->redirect('main/PeForm?edit=' . $peId);
  4368. $peStatus = 5;
  4369. $peId = $this->getRequestParameter('update');
  4370. if ($this->getRequestParameter('update')) {
  4371. if ($this->updatePEForm($peStatus)) {
  4372. $_SESSION['msg'] = 'Successfully saved the PEForm !!';
  4373. $groupwareEmployee = new GroupwareEmployeesPeer();
  4374. $kidName = $groupwareEmployee->getEmployeeName($empId);
  4375. $empName = $groupwareEmployee->getEmployeeName($_SESSION['empId']);
  4376. $logs = new PelogsPeer();
  4377. $savedEmployeeLog = $logs->getSavedEmployeeFormLog($peId, $kidName, '', $empName);
  4378. }
  4379.  
  4380. else
  4381. $_SESSION['error_msg'] = 'Your updation failed !!!!';
  4382. }
  4383. $this->redirect('main/PeForm?edit=' . $peId);
  4384.  
  4385. break;
  4386.  
  4387. case 'Submit':
  4388. //added by renjo for monthl PE (to remove validation)
  4389. if ($this->getRequestParameter('monthlypestatus') == 13) {
  4390. $cmnt = $this->getRequestParameter('empCommId');
  4391. $this->updateEmpComments($cmnt);
  4392. $this->updatePEForm(13);
  4393. $_SESSION['msg'] = 'Successfully added the comments !!';
  4394. $this->redirect('main/index');
  4395. } else if ($this->getRequestParameter('perform') == "monthly") {
  4396. $peStatus = 13;
  4397. $peId = $this->getRequestParameter('update');
  4398. if ($this->updatePEForm($peStatus)) {
  4399. $_SESSION['msg'] = 'Successfully submitted the PEForm !!';
  4400. }
  4401. else
  4402. $_SESSION['error_msg'] = 'Your updation failed !!!!';
  4403. $this->redirect('main/index');
  4404. }else {
  4405. $success = $this->validateMark();
  4406. if ($success == false) {
  4407. $empId = $this->getRequestParameter('empId');
  4408. $this->getPreForm($empId);
  4409. $this->emp = $this->getUser();
  4410. $this->readonly = false;
  4411. break;
  4412. }
  4413. if ($this->getRequestParameter('perform') == "original")
  4414. $peStatus = 4;
  4415. else
  4416. $peStatus = 2;
  4417.  
  4418. $validated = $this->validation();
  4419. if ($validated) {
  4420. if ($this->getRequestParameter('update')) {
  4421. $peform = $this->getRequestParameter('perform');
  4422. $empid = $this->getRequestParameter('empId');
  4423. $groupwareEmployee = new GroupwareEmployeesPeer();
  4424. $kidName = $groupwareEmployee->getEmployeeName($empid);
  4425. $empName = $groupwareEmployee->getEmployeeName($_SESSION['empId']);
  4426. $peId = $this->isSubmittedThisYear($peform, $empid);
  4427. $logs = new PelogsPeer();
  4428. $submittedEmployeeLog = $logs->getSubmittedEmployeeFormLog($peId, $kidName, $peform, $empName);
  4429. if ($this->updatePEForm($peStatus)) {
  4430. $_SESSION['msg'] = 'Successfully submitted the PEForm !!';
  4431. }
  4432. else
  4433. $_SESSION['error_msg'] = 'Your updation failed !!!!';
  4434. $this->redirect('main/index');
  4435. }
  4436. else {
  4437. $peform = $this->getRequestParameter('perform');
  4438. $empid = $this->getRequestParameter('empId');
  4439. if ($empid == $_SESSION['empId']) {
  4440. $type = 0;
  4441. }
  4442.  
  4443. if ($peform == 'original')
  4444. $type = 1;
  4445. else if ($peform == 'self')
  4446. $type = 0;
  4447. if ($this->setPEForm($peStatus, $peform, $empid)) { // INSERT VALUES TO DATABASE (NEW PE FORM)
  4448. $_SESSION['msg'] = 'Successfully submitted the PEForm !!';
  4449. $groupwareEmployee = new GroupwareEmployeesPeer();
  4450. $kidName = $groupwareEmployee->getEmployeeName($empid);
  4451. $empName = $groupwareEmployee->getEmployeeName($_SESSION['empId']);
  4452. $criteria = new Criteria();
  4453. $criteria->add(PeEmployeesPeer::EMPID, $empid);
  4454. $criteria->add(PeEmployeesPeer::TYPE, $type);
  4455. $peidStatus = PeEmployeesPeer::doSelect($criteria);
  4456. foreach ($peidStatus as $results) {
  4457. $peId = $results->getPeId();
  4458. }
  4459. $logs = new PelogsPeer();
  4460. $submittedEmployeeLog = $logs->getSubmittedEmployeeFormLog($peId, $kidName, $peform, $empName);
  4461. }
  4462. else
  4463. $_SESSION['error_msg'] = 'Your insertion failed !!!!';
  4464. $this->redirect('main/index');
  4465. }
  4466. }
  4467. else {
  4468. $_SESSION['error_msg'] = "Please fill all the mandatory fields";
  4469. $empId = $this->getRequestParameter('empId');
  4470. $this->getPreForm($empId);
  4471. $this->emp = $this->getUser();
  4472. $this->readonly = false;
  4473. }
  4474. }
  4475. break;
  4476. case 'Revision':
  4477. if ($this->isCore()) {
  4478. $PeId = $this->getRequestParameter('peId');
  4479. $this->setSuggestions($PeId);
  4480. }
  4481. $peStatus = 5;
  4482. if ($this->updatePeStatus($peStatus)) {
  4483. $_SESSION['msg'] = ' PE form successfully sent for revision !!!';
  4484. $peEmployee = new PeEmployeesPeer();
  4485. $empid = $peEmployee->getEmpId($PeId);
  4486. $groupwareEmployee = new GroupwareEmployeesPeer();
  4487. $kidName = $groupwareEmployee->getEmployeeName($empid);
  4488. $empName = $groupwareEmployee->getEmployeeName($_SESSION['empId']);
  4489. $logs = new PelogsPeer();
  4490. $revisionEmployeeLog = $logs->getRevisionEmployeeFormLog($PeId, $kidName, $empName);
  4491. }
  4492. else
  4493. $_SESSION['error_msg'] = 'Your updation failed !!!!';
  4494. $this->redirect('main/index');
  4495. break;
  4496. case 'Approve':
  4497. if ($this->isCore()) {
  4498. $PeId = $this->getRequestParameter('peId');
  4499. $this->setSuggestions($PeId);
  4500. }
  4501. $peStatus = 11;
  4502. if ($this->updatePeStatus($peStatus)) {
  4503. $_SESSION['msg'] = 'Successfully Approved the PEForm !!';
  4504. $peEmployee = new PeEmployeesPeer();
  4505. $empid = $peEmployee->getEmpId($PeId);
  4506. $groupwareEmployee = new GroupwareEmployeesPeer();
  4507. $kidName = $groupwareEmployee->getEmployeeName($empid);
  4508. $empName = $groupwareEmployee->getEmployeeName($_SESSION['empId']);
  4509. $logs = new PelogsPeer();
  4510. $approveEmployeeLog = $logs->getApproveEmployeeFormLog($PeId, $kidName, $empName);
  4511. }
  4512. else
  4513. $_SESSION['error_msg'] = 'Your updation failed !!!!';
  4514. $this->redirect('main/index');
  4515. break;
  4516. case 'Complete':
  4517. $peStatus = 6;
  4518. if ($this->updatePeStatus($peStatus)) {
  4519. $_SESSION['msg'] = 'Successfully completed the PE discussion.';
  4520. $peEmployee = new PeEmployeesPeer();
  4521. $empid = $peEmployee->getEmpId($PeId);
  4522. $groupwareEmployee = new GroupwareEmployeesPeer();
  4523. $kidName = $groupwareEmployee->getEmployeeName($empid);
  4524. $empName = $groupwareEmployee->getEmployeeName($_SESSION['empId']);
  4525. $logs = new PelogsPeer();
  4526. $approveEmployeeLog = $logs->getApproveEmployeeFormLog($PeId, $kidName, $empName);
  4527. }
  4528. else
  4529. $_SESSION['error_msg'] = 'Your updation failed !!!!';
  4530. $this->redirect('main/index');
  4531. break;
  4532. case 'Edit':
  4533. if ($this->isCore() || $this->isAdmin()) {
  4534. $peId = $this->getRequestParameter('peId');
  4535. $this->redirect('main/PeForm?edit=' . $peId);
  4536. }
  4537. break;
  4538. case 'Accept':
  4539. // Updating employee comments
  4540. $cmnt = $this->getRequestParameter('empCommId');
  4541. $this->updateEmpComments($cmnt);
  4542. $peStatus = 7;
  4543. if ($this->updatePeStatus($peStatus)) {
  4544. $_SESSION['msg'] = 'Successfully Accepted the PEForm !!';
  4545. $PeId = $this->getRequestParameter('peId');
  4546. $peEmployee = new PeEmployeesPeer();
  4547. $empid = $peEmployee->getEmpId($PeId);
  4548. $groupwareEmployee = new GroupwareEmployeesPeer();
  4549. $kidName = $groupwareEmployee->getEmployeeName($empid);
  4550. $empName = $groupwareEmployee->getEmployeeName($_SESSION['empId']);
  4551. $logs = new PelogsPeer();
  4552. $acceptEmployeeLog = $logs->getAcceptEmployeeFormLog($PeId, $kidName);
  4553. }
  4554. else
  4555. $_SESSION['error_msg'] = 'Your updation failed !!!!';
  4556. $this->redirect('main/index');
  4557. break;
  4558. case 'Save Help':
  4559. if ($this->isCore() || $this->isHr()) {
  4560.  
  4561. if (!$this->hasHelp()) {
  4562. $_SESSION['error_msg'] = 'Your updation failed !!!!';
  4563. $this->redirect('main/index');
  4564. }
  4565. $helptype = $this->getRequestParameter('helptype');
  4566. if ($helptype == "admin") {
  4567. $readonlyStatus = $this->getRequestParameter('readonlyStatus');
  4568.  
  4569. if ($this->getRequestParameter('update'))
  4570. $peId = $this->getRequestParameter('update');
  4571. else if ($this->getRequestParameter('peId'))
  4572. $peId = $this->getRequestParameter('peId');
  4573. $c = new Criteria();
  4574. $result_count = PeHelpAdminPeer::doCount($c);
  4575. if ($result_count > 0) {
  4576. $helpid = $this->getRequestParameter('helpid');
  4577. if ($this->updatePeHelpAdmin($helpid))
  4578. $_SESSION['msg'] = 'Successfully updated the Help information for admin !!';
  4579. else
  4580. $_SESSION['error_msg'] = 'Your updation failed !!!!';
  4581. if ($this->isHr()) {
  4582. if ($readonlyStatus)
  4583. $this->redirect('main/AdminPEForm?view=' . $peId);
  4584. else
  4585. $this->redirect('main/AdminPEForm?edit=' . $peId);
  4586. }else {
  4587. if ($readonlyStatus)
  4588. $this->redirect('main/AdminPEForm?view=' . $peId);
  4589. else
  4590. $this->redirect('main/AdminPEForm?edit=' . $peId . '&type=original');
  4591. }
  4592. }else {
  4593. if ($this->setPeHelpAdmin())
  4594. $_SESSION['msg'] = 'Successfully inserted the Help information for admin !!';
  4595. else
  4596. $_SESSION['error_msg'] = 'Your insertion failed !!!!';
  4597. if ($this->isHr()) {
  4598. if ($readonlyStatus)
  4599. $this->redirect('main/AdminPEForm?view=' . $peId);
  4600. else
  4601. $this->redirect('main/AdminPEForm?edit=' . $peId);
  4602. }else {
  4603. if ($readonlyStatus)
  4604. $this->redirect('main/AdminPEForm?view=' . $peId);
  4605. else
  4606. $this->redirect('main/AdminPEForm?edit=' . $peId . '&type=original');
  4607. }
  4608.  
  4609. //$this -> redirect('main/index');
  4610. }
  4611. }
  4612. elseif ($helptype == "staff") {
  4613. $c = new Criteria();
  4614. $result_count = PeHelpStaffPeer::doCount($c);
  4615. if ($result_count > 0) {
  4616. $helpid = $this->getRequestParameter('helpid');
  4617. if ($this->updatePeHelpStaff($helpid))
  4618. $_SESSION['msg'] = 'Successfully updated the Help information for staff !!';
  4619. else
  4620. $_SESSION['error_msg'] = 'Your updation failed !!!!';
  4621. }else {
  4622. $helpid = $this->getRequestParameter('helpid');
  4623. if ($this->setPeHelpStaff())
  4624. $_SESSION['msg'] = 'Successfully inserted the Help information for staff !!';
  4625. else
  4626. $_SESSION['error_msg'] = 'Your insertion failed !!!!';
  4627. }
  4628. }elseif ($helptype == "qm") {
  4629. $c = new Criteria();
  4630. $result_count = PeHelpQmPeer::doCount($c);
  4631. if ($result_count > 0) {
  4632. $helpid = $this->getRequestParameter('helpid');
  4633. if ($this->updatePeHelpQm($helpid))
  4634. $_SESSION['msg'] = 'Successfully updated the Help information !!';
  4635. else
  4636. $_SESSION['error_msg'] = 'Your updation failed !!!!';
  4637. //$this -> redirect('main/index');
  4638. }else {
  4639. if ($this->setPeHelpQm())
  4640. $_SESSION['msg'] = 'Successfully inserted the Help information !!';
  4641. else
  4642. $_SESSION['error_msg'] = 'Your insertion failed !!!!';
  4643. //$this -> redirect('main/index');
  4644. }
  4645. }
  4646. }
  4647. break;
  4648. case 'Save Sample':
  4649. if ($this->isCore() || $this->isHr()) {
  4650.  
  4651. if (!$this->hasSample()) {
  4652. $_SESSION['error_msg'] = 'Your updation failed !!!!';
  4653. $this->redirect('main/index');
  4654. }
  4655. $sampletype = $this->getRequestParameter('sampletype');
  4656. if ($sampletype == "admin") {
  4657. $readonlyStatus = $this->getRequestParameter('readonlyStatus');
  4658. $helptype = $this->getRequestParameter('helptype');
  4659. if ($this->getRequestParameter('update'))
  4660. $peId = $this->getRequestParameter('update');
  4661. else if ($this->getRequestParameter('peId'))
  4662. $peId = $this->getRequestParameter('peId');
  4663. $c = new Criteria();
  4664. $result_count = PeSampleAdminPeer::doCount($c);
  4665. if ($result_count > 0) {
  4666. $sampleid = $this->getRequestParameter('sampleid');
  4667. if ($this->updatePeSampleAdmin($sampleid))
  4668. $_SESSION['msg'] = 'Successfully updated the Sample Form information for admin!!';
  4669. else
  4670. $_SESSION['error_msg'] = 'Your updation failed !!!!';
  4671. //$this -> redirect('main/index');
  4672. if ($this->isHr()) {
  4673. if ($readonlyStatus)
  4674. $this->redirect('main/AdminPEForm?view=' . $peId);
  4675. else
  4676. $this->redirect('main/AdminPEForm?edit=' . $peId);
  4677. }else {
  4678. if ($readonlyStatus)
  4679. $this->redirect('main/AdminPEForm?view=' . $peId);
  4680. else
  4681. $this->redirect('main/AdminPEForm?edit=' . $peId . '&type=original');
  4682. }
  4683. }else {
  4684. if ($this->setPeSampleAdmin())
  4685. $_SESSION['msg'] = 'Successfully inserted the Sample Form information for admin !!';
  4686. else
  4687. $_SESSION['error_msg'] = 'Your insertion failed !!!!';
  4688. //$this -> redirect('main/index');
  4689. if ($this->isHr()) {
  4690. if ($readonlyStatus)
  4691. $this->redirect('main/AdminPEForm?view=' . $peId);
  4692. else
  4693. $this->redirect('main/AdminPEForm?edit=' . $peId);
  4694. }else {
  4695. if ($readonlyStatus)
  4696. $this->redirect('main/AdminPEForm?view=' . $peId);
  4697. else
  4698. $this->redirect('main/AdminPEForm?edit=' . $peId . '&type=original');
  4699. }
  4700. }
  4701. }
  4702. elseif ($sampletype == "staff") {
  4703. $c = new Criteria();
  4704. $result_count = PeSampleStaffPeer::doCount($c);
  4705. if ($result_count > 0) {
  4706. $sampleid = $this->getRequestParameter('sampleid');
  4707. if ($this->updatePeSampleStaff($sampleid))
  4708. $_SESSION['msg'] = 'Successfully updated the Sample Form information for staff !!';
  4709. else
  4710. $_SESSION['error_msg'] = 'Your updation failed !!!!';
  4711. // $this -> redirect('main/index');
  4712. }else {
  4713. if ($this->setPeSampleStaff())
  4714. $_SESSION['msg'] = 'Successfully inserted the Sample Form information for staff !!';
  4715. else
  4716. $_SESSION['error_msg'] = 'Your insertion failed !!!!';
  4717. // $this -> redirect('main/index');
  4718. }
  4719. }elseif ($sampletype == "qm") {
  4720. $c = new Criteria();
  4721. $result_count = PeSampleQmPeer::doCount($c);
  4722. if ($result_count > 0) {
  4723. $sampleid = $this->getRequestParameter('sampleid');
  4724. if ($this->updatePeSampleQm($sampleid))
  4725. $_SESSION['msg'] = 'Successfully updated the Sample Form information !!';
  4726. else
  4727. $_SESSION['error_msg'] = 'Your updation failed !!!!';
  4728. // $this -> redirect('main/index');
  4729. }else {
  4730. if ($this->setPeSampleQm())
  4731. $_SESSION['msg'] = 'Successfully inserted the Sample Form information !!';
  4732. else
  4733. $_SESSION['error_msg'] = 'Your insertion failed !!!!';
  4734. // $this -> redirect('main/index');
  4735. }
  4736. }
  4737. }
  4738. break;
  4739. case 'Re-Submit':
  4740. $success = $this->validateMark();
  4741. if ($success == false) {
  4742. $PeId = $this->getRequestParameter('update');
  4743. $this->redirect('main/PeForm?edit=' . $PeId);
  4744.  
  4745. break;
  4746. }
  4747. if ($this->isCore() || $this->isAdmin()) {
  4748. $peStatus = 4;
  4749. $validated = $this->validation();
  4750. if ($validated) {
  4751. if ($this->updatePEForm($peStatus)) {
  4752. $_SESSION['msg'] = 'Successfully re-submitted the PE Form !!';
  4753. $PeId = $this->getRequestParameter('peId');
  4754. $peEmployee = new PeEmployeesPeer();
  4755. $empid = $peEmployee->getEmpId($PeId);
  4756. $groupwareEmployee = new GroupwareEmployeesPeer();
  4757. $kidName = $groupwareEmployee->getEmployeeName($empid);
  4758. $empName = $groupwareEmployee->getEmployeeName($_SESSION['empId']);
  4759. $logs = new PelogsPeer();
  4760. $resubmitEmployeeLog = $logs->getReSubmitEmployeeFormLog($PeId, $kidName, $empName);
  4761. }
  4762. else
  4763. $_SESSION['error_msg'] = 'Operation failed !!!!';
  4764. $this->redirect('main/index');
  4765. }
  4766. }
  4767. break;
  4768. case 'Certify':
  4769. if ($this->isCore() || $this->isAdmin()) {
  4770. $peStatus = 8;
  4771. if ($this->updatePeStatus($peStatus)) {
  4772. $_SESSION['msg'] = 'Successfully Certified the PEForm !!';
  4773. $PeId = $this->getRequestParameter('peId');
  4774. $peEmployee = new PeEmployeesPeer();
  4775. $empid = $peEmployee->getEmpId($PeId);
  4776. $groupwareEmployee = new GroupwareEmployeesPeer();
  4777. $kidName = $groupwareEmployee->getEmployeeName($empid);
  4778. $empName = $groupwareEmployee->getEmployeeName($_SESSION['empId']);
  4779. $logs = new PelogsPeer();
  4780. $certifyEmployeeLog = $logs->getCertifyEmployeeFormLog($PeId, $kidName, $empName);
  4781. }
  4782. else
  4783. $_SESSION['error_msg'] = 'Operation failed !!!!';
  4784. $this->redirect('main/index');
  4785. }
  4786. break;
  4787. case 'Finalize':
  4788. if ($this->isCore() || $this->isAdmin()) {
  4789. $peStatus = 10;
  4790. if ($this->updatePeStatus($peStatus)) {
  4791. $_SESSION['msg'] = 'Successfully Finalized the PEForm !!';
  4792. $PeId = $this->getRequestParameter('peId');
  4793. $peEmployee = new PeEmployeesPeer();
  4794. $empid = $peEmployee->getEmpId($PeId);
  4795. $groupwareEmployee = new GroupwareEmployeesPeer();
  4796. $kidName = $groupwareEmployee->getEmployeeName($empid);
  4797. $empName = $groupwareEmployee->getEmployeeName($_SESSION['empId']);
  4798. $logs = new PelogsPeer();
  4799. $finalizeEmployeeLog = $logs->getfinalizeEmployeeFormLog($PeId, $kidName, $empName);
  4800. }
  4801. else
  4802. $_SESSION['error_msg'] = 'Operation failed !!!!';
  4803. $this->redirect('main/index');
  4804. }
  4805. break;
  4806. case 'Save Changes':
  4807. if ($this->isHr()) {
  4808. $peStatus = 10;
  4809. if ($this->getRequestParameter('edit'))
  4810. $PeId = $this->getRequestParameter('edit');
  4811. else if ($this->getRequestParameter('update'))
  4812. $PeId = $this->getRequestParameter('update');
  4813. $peEmployee = new PeEmployeesPeer();
  4814. $empid = $peEmployee->getEmpId($PeId);
  4815. $groupwareEmployee = new GroupwareEmployeesPeer();
  4816. $kidName = $groupwareEmployee->getEmployeeName($empid);
  4817. $empName = $groupwareEmployee->getEmployeeName($_SESSION['empId']);
  4818. if ($this->updatePEForm($peStatus)) {
  4819. $logs = new PelogsPeer();
  4820. $logs->getUpdatedByHrFormLog($PeId, $kidName, $empName);
  4821. $_SESSION['msg'] = 'Successfully made changes to PE Form !!';
  4822. $this->redirect('main/PeForm?edit=' . $PeId);
  4823. }
  4824. else
  4825. $_SESSION['error_msg'] = 'Your updation failed !!!!';
  4826. $this->redirect('main/index');
  4827. }else
  4828. $_SESSION['error_msg'] = 'Your updation has failed !!!!';
  4829. $this->redirect('main/index');
  4830. }
  4831. }
  4832.  
  4833. public function executeDeletePEForm(sfWebRequest $request) {
  4834. if ($this->getRequestParameter('peId')) {
  4835. $this->peId = $this->getRequestParameter('peId');
  4836. } else {
  4837. $peId = $this->getRequestparameter('delete');
  4838. $criteria = new Criteria();
  4839. $criteria->add(PeEmployeesPeer::PEID, $peId);
  4840. $result = PeEmployeesPeer::doSelect($criteria);
  4841. if ($result) {
  4842. $peEmpId = $result[0]->getEmpId();
  4843. $peStatusId = $result[0]->getStatusId();
  4844. $petakenBy = $result[0]->getTakenBy();
  4845. }
  4846.  
  4847. if ($peEmpId == $_SESSION['empId'] && ($peStatusId == 3)) {
  4848. $_SESSION['error_msg'] = "You are not authorized to delete the PEForm";
  4849. $this->redirect('main/index');
  4850. }
  4851. if ($this->isCore() && $petakenBy != $_SESSION['empId'] && $peStatusId == 3 && !$this->getRequestparameter('forAdminAssigning') && !$this->coreCheck($petakenBy)) {
  4852. $_SESSION['error_msg'] = "You are not authorized to delete the PEForm";
  4853. $this->redirect('main/index');
  4854. }
  4855.  
  4856. $peEmployeeInstance = new PeEmployeesPeer();
  4857. $empId = $peEmployeeInstance->getEmpId($peId);
  4858. $groupwareEmployee = new GroupwareEmployeesPeer();
  4859. $kidName = $groupwareEmployee->getEmployeeName($empId);
  4860. if (($this->isSelf($peId, $empId) && $this->isStaffSaved($peId)) || ($this->isAdmin() && $this->isAdminSaved($peId)) || $this->getRequestparameter('forAdminAssigning') || ($this->isCore() && $this->isAdminSaved($peId)) || ($this->isAdmin() && $this->isMonthlySaved($peId)) || ($this->isCore() && $this->isMonthlySaved($peId))) {
  4861. if ($this->isSelf($peId, $empId) && $this->isStaffSaved($peId)) {
  4862. $logs = new PelogsPeer();
  4863. $deleteEmployeeLog = $logs->getDeletePELog($peId, $kidName);
  4864. } else if ($this->isAdmin() && $this->isAdminSaved($peId) || $this->isCore() && $this->isAdminSaved($peId)) {
  4865. $peEmployee = new PeEmployeesPeer();
  4866. $empid = $peEmployee->getEmpId($peId);
  4867. $groupwareEmployee = new GroupwareEmployeesPeer();
  4868. $kidName = $groupwareEmployee->getEmployeeName($empid);
  4869. $empName = $groupwareEmployee->getEmployeeName($_SESSION['empId']);
  4870. $logs = new PelogsPeer();
  4871. $approveEmployeeLog = $logs->getDeletePEAdminLog($peId, $kidName, $empName);
  4872. } else if ($this->getRequestparameter('forAdminAssigning')) {
  4873.  
  4874. }
  4875. $this->deleteAccomplishments($peId);
  4876. $this->deleteResponsibilities($peId);
  4877. $this->deleteCommunication($peId);
  4878. $this->deleteSatisfaction($peId);
  4879. $this->deleteDevelopmentPlan($peId);
  4880. $this->deleteJobKnowledge($peId);
  4881. $this->deleteLeaveAttendance($peId);
  4882. $this->deleteManagementSkills($peId);
  4883. $this->deleteOtherActivity($peId);
  4884. $this->deleteQMS($peId);
  4885. $this->deleteQualityQuantity($peId);
  4886. $this->deleteSocialEffectiveness($peId);
  4887. $this->deleteEmpComments($peId);
  4888. $this->deletePeEmployees($peId);
  4889. $_SESSION['msg'] = 'Successfully Deleted the PE Form';
  4890. $this->redirect('main/index');
  4891. } else {
  4892. $_SESSION['error_msg'] = 'You are not authorised to delete the PE Form';
  4893. $this->redirect('main/index');
  4894. }
  4895. }
  4896. }
  4897.  
  4898. function deleteAccomplishments($peId) {
  4899. $criteria = new Criteria();
  4900. $criteria->add(AccomplishmentsPeer::PEID, $peId);
  4901. AccomplishmentsPeer::doDelete($criteria);
  4902. }
  4903.  
  4904. function deleteResponsibilities($peId) {
  4905. $criteria = new Criteria();
  4906. $criteria->add(ResponsibilitiesPeer::PEID, $peId);
  4907. ResponsibilitiesPeer::doDelete($criteria);
  4908. }
  4909.  
  4910. function deleteCommunication($peId) {
  4911. $criteria = new Criteria();
  4912. $criteria->add(CommunicationPeer::PEID, $peId);
  4913. CommunicationPeer::doDelete($criteria);
  4914. }
  4915.  
  4916. function deleteSatisfaction($peId) {
  4917. $criteria = new Criteria();
  4918. $criteria->add(SatisfactionPeer::PEID, $peId);
  4919. SatisfactionPeer::doDelete($criteria);
  4920. }
  4921.  
  4922. function deleteDevelopmentPlan($peId) {
  4923. $criteria = new Criteria();
  4924. $criteria->add(DevelopmentPlanPeer::PEID, $peId);
  4925. DevelopmentPlanPeer::doDelete($criteria);
  4926. }
  4927.  
  4928. function deleteJobKnowledge($peId) {
  4929. $criteria = new Criteria();
  4930. $criteria->add(JobKnowledgePeer::PEID, $peId);
  4931. JobKnowledgePeer::doDelete($criteria);
  4932. }
  4933.  
  4934. function deleteLeaveAttendance($peId) {
  4935. $criteria = new Criteria();
  4936. $criteria->add(LeaveAttendancePeer::PEID, $peId);
  4937. LeaveAttendancePeer::doDelete($criteria);
  4938. }
  4939.  
  4940. function deleteManagementSkills($peId) {
  4941. $criteria = new Criteria();
  4942. $criteria->add(ManagementSkillsPeer::PEID, $peId);
  4943. ManagementSkillsPeer::doDelete($criteria);
  4944. }
  4945.  
  4946. function deleteOtherActivity($peId) {
  4947. $criteria = new Criteria();
  4948. $criteria->add(OtherActivityPeer::PEID, $peId);
  4949. OtherActivityPeer::doDelete($criteria);
  4950. }
  4951.  
  4952. function deleteQMS($peId) {
  4953. $criteria = new Criteria();
  4954. $criteria->add(QMSPeer::PEID, $peId);
  4955. QMSPeer::doDelete($criteria);
  4956. }
  4957.  
  4958. function deleteQualityQuantity($peId) {
  4959. $criteria = new Criteria();
  4960. $criteria->add(QualityQuantityPeer::PEID, $peId);
  4961. QualityQuantityPeer::doDelete($criteria);
  4962. }
  4963.  
  4964. function deleteSocialEffectiveness($peId) {
  4965. $criteria = new Criteria();
  4966. $criteria->add(SocialEffectivenessPeer::PEID, $peId);
  4967. SocialEffectivenessPeer::doDelete($criteria);
  4968. }
  4969.  
  4970. function deleteEmpComments($peId) {
  4971. $criteria = new Criteria();
  4972. $criteria->add(EmpCommentsPeer::PEID, $peId);
  4973. EmpCommentsPeer::doDelete($criteria);
  4974. }
  4975.  
  4976. function deletePeEmployees($peId) {
  4977. $criteria = new Criteria();
  4978. $criteria->add(PeEmployeesPeer::PEID, $peId);
  4979. PeEmployeesPeer::doDelete($criteria);
  4980. }
  4981.  
  4982. function isStaffSaved($peId) {
  4983. $peEmployeesInstance = new PeEmployeesPeer();
  4984. $status = $peEmployeesInstance->getPeStatus($peId, 'saved');
  4985. return $status;
  4986. }
  4987.  
  4988. function isAdminSaved($peId) {
  4989. $peEmployeesInstance = new PeEmployeesPeer();
  4990. $status = $peEmployeesInstance->getPeStatus($peId, 'AdminSaved');
  4991. return $status;
  4992. }
  4993.  
  4994. function isMonthlySaved($peId) {
  4995. $peEmployeesInstance = new PeEmployeesPeer();
  4996. $status = $peEmployeesInstance->getPeStatus($peId, 'MonthlySaved');
  4997. return $status;
  4998. }
  4999.  
  5000. function isStaffAndAdminSaved($empId) {
  5001. $criteria = new Criteria();
  5002. $criteria->add(PeEmployeesPeer::STATUSID, 2);
  5003. $criteria->add(PeEmployeesPeer::EMPID, $empId);
  5004. $statuscount = PeEmployeesPeer::doCount($criteria);
  5005. if ($statuscount) {
  5006. $criteria = new Criteria();
  5007. $criteria->add(PeEmployeesPeer::STATUSID, 3, Criteria::GREATER_EQUAL);
  5008. $criteria->add(PeEmployeesPeer::EMPID, $empId);
  5009. $status_count = PeEmployeesPeer::doCount($criteria);
  5010. }
  5011. return $status_count;
  5012. }
  5013.  
  5014. // Function to display the Pe Notification for each employee's home page
  5015. function getPeNotification($number =null) {
  5016. $i = 0;
  5017. $displayCount = PAGE;
  5018.  
  5019. if ($this->isStaff() || $this->isQm()) {
  5020. $empId = $this->getUser()->getAttribute('empId');
  5021. $customCriteria = ' WHERE pe1.empId in(' . $empId . ') ';
  5022. } else {
  5023. $customCriteria = '';
  5024. }
  5025.  
  5026. // $customCriteria .= ' AND
  5027. // pe1.STATUSID = (SELECT
  5028. // MAX(pe2.STATUSID)
  5029. // FROM
  5030. // PE_Employees pe2
  5031. // WHERE
  5032. // pe1.EMPID=pe2.EMPID
  5033. // )';
  5034.  
  5035. $criteria = new Criteria();
  5036. $con = Propel::getConnection();
  5037. $sql = 'SELECT
  5038. COUNT(*) AS NO
  5039. FROM
  5040. PE_Employees pe1
  5041. JOIN PE_Dates ped
  5042. ON (pe1.REVIEWDATE >= ped.YEAR AND ped.NAME = \'Dashboard\')
  5043. ' . $customCriteria . '
  5044. ORDER BY
  5045. pe1.ISSUEDATE DESC';
  5046. $stmt = $con->prepare($sql);
  5047. $stmt->execute();
  5048. if ($results = $stmt->fetch()) {
  5049. $noOfPeForms = $results['NO'];
  5050. if ($noOfPeForms % $displayCount == 0)
  5051. $this->noOfNotifications = $noOfPeForms / $displayCount;
  5052. else {
  5053. $reminder = $noOfPeForms % $displayCount;
  5054. $noOfPeForms = $noOfPeForms - $reminder;
  5055. $this->noOfNotifications = ($noOfPeForms / $displayCount) + 1;
  5056. }
  5057. }
  5058. if ($number <= $this->noOfNotifications && $number != 0) {
  5059. $this->flag = true;
  5060. } else {
  5061. $this->flag = false;
  5062. }
  5063. $sql = 'SELECT
  5064. pe1.PEID,pe1.EMPID,pe1.STATUSID,pe1.ISSUEDATE
  5065. FROM
  5066. PE_Employees pe1
  5067. JOIN PE_Dates ped
  5068. ON (pe1.REVIEWDATE >= ped.YEAR AND ped.NAME = \'Dashboard\')
  5069. ' . $customCriteria . '
  5070. ORDER BY
  5071. pe1.ISSUEDATE DESC';
  5072.  
  5073. $stmt = $con->prepare($sql);
  5074. $stmt->execute();
  5075. $criteriaTwo = new Criteria();
  5076. $resultObject = PeStatusPeer::doSelect($criteriaTwo);
  5077. if ($resultObject) {
  5078. foreach ($resultObject as $result) {
  5079. $peStatusArray[$result->getStatusId()] = $result->getStatus();
  5080. }
  5081. }
  5082. while ($results = $stmt->fetch()) {
  5083. $GroupWareEmployeeInstance = new GroupwareEmployeesPeer();
  5084. $EmployeeName = $GroupWareEmployeeInstance->getEmployeeName($results['EMPID']);
  5085. $links = link_to($EmployeeName, 'main/PeForm?view=' . $results['PEID']);
  5086. $htmls .= '<tr>';
  5087. $htmls .= '<td><b>' . $links . '</b></td>';
  5088. $htmls .= '<td>' . $results['ISSUEDATE'] . '</td>';
  5089. $htmls .= '<td><span>' . $peStatusArray[$results['STATUSID']] . '</span></td>';
  5090. $htmls .= '</tr>';
  5091. $i++;
  5092. if ($number == null && $i == $displayCount)
  5093. break;
  5094. else if ($number != null && $i <= $displayCount * ($number - 1)) {
  5095. $htmls = '';
  5096. } else if ($i >= $displayCount * $number && $number != null) {
  5097. break;
  5098. }
  5099. }
  5100. $this->html = $htmls;
  5101. }
  5102.  
  5103. function getPeAdminNotification($number =null) {
  5104. $i = 0;
  5105. if ($this->isAdmin()) {
  5106. $displayCount = PAGE;
  5107. // $teamMembers = $this->getUser()->getAttribute('teamMembers');
  5108. $teamMembers = GroupwareEmployeesPeer::getAllSubordinatesId($this->getUser()->getAttribute('empId'));
  5109. $teamMembers[] = $this->getUser()->getAttribute('empId');
  5110. $members = implode(',', $teamMembers);
  5111. //echo "<pre>";print_r($members);die;
  5112. $customCriteria = ' WHERE pe1.empId in(' . $members . ') ';
  5113. $adminName = $this->getUser()->getAttribute('empName');
  5114. $criteria = new Criteria();
  5115. $con = Propel::getConnection();
  5116.  
  5117. // $customCriteria .= 'and
  5118. // pe1.STATUSID = (SELECT
  5119. // MAX(pe2.STATUSID)
  5120. // FROM
  5121. // PE_Employees pe2
  5122. // WHERE
  5123. // pe1.EMPID=pe2.EMPID
  5124. // ) && pe1.STATUSID!=1';
  5125.  
  5126.  
  5127. /* Code to find the number of records */
  5128. $sql = 'SELECT
  5129. COUNT(*) AS NO
  5130. FROM
  5131. PE_Employees pe1
  5132. JOIN PE_Dates ped
  5133. ON (pe1.REVIEWDATE >= ped.YEAR AND ped.NAME = \'Dashboard\')
  5134. ' . $customCriteria . '
  5135. ORDER BY
  5136. pe1.ISSUEDATE DESC';
  5137. $stmt = $con->prepare($sql);
  5138. $stmt->execute();
  5139. if ($results = $stmt->fetch()) {
  5140. $noOfPeForms = $results['NO'];
  5141. if ($noOfPeForms % $displayCount == 0)
  5142. $this->noOfNotifications = $noOfPeForms / $displayCount;
  5143. else {
  5144. $reminder = $noOfPeForms % $displayCount;
  5145. $noOfPeForms = $noOfPeForms - $reminder;
  5146. $this->noOfNotifications = ($noOfPeForms / $displayCount) + 1;
  5147. }
  5148. }
  5149. if ($number <= $this->noOfNotifications && $number != 0) {
  5150. $this->flag = true;
  5151. } else {
  5152. $this->flag = false;
  5153. }
  5154.  
  5155. $sql = 'SELECT
  5156. pe1.PEID,pe1.EMPID,pe1.STATUSID,pe1.ISSUEDATE
  5157. FROM
  5158. PE_Employees pe1
  5159. JOIN PE_Dates ped
  5160. ON (pe1.REVIEWDATE >= ped.YEAR AND ped.NAME = \'Dashboard\')
  5161. ' . $customCriteria . '
  5162. ORDER BY
  5163. pe1.ISSUEDATE DESC';
  5164.  
  5165. $stmt = $con->prepare($sql);
  5166. $stmt->execute();
  5167. // $stmt->execute();
  5168. $criteriaTwo = new Criteria();
  5169. $resultObject = PeStatusPeer::doSelect($criteriaTwo);
  5170. if ($resultObject) {
  5171. foreach ($resultObject as $result) {
  5172. $peStatusArray[$result->getStatusId()] = $result->getStatus();
  5173. }
  5174. }
  5175. while ($results = $stmt->fetch()) {
  5176. $GroupWareEmployeeInstance = new GroupwareEmployeesPeer();
  5177. $EmployeeName = $GroupWareEmployeeInstance->getEmployeeName($results['EMPID']);
  5178.  
  5179. switch ($results['STATUSID']) {
  5180. case '1':$links = $EmployeeName;
  5181. break;
  5182. case '2':
  5183. $links = '<b><i>'.link_to($EmployeeName, 'main/PeForm?view=' . $results['PEID']).'</i></b>';
  5184. break;
  5185. default :
  5186. $links = '<b><i>'.link_to($EmployeeName, 'main/PeForm?view=' . $results['PEID']).'</i></b>';
  5187. }
  5188.  
  5189.  
  5190. $htmls .= '<tr>';
  5191. $htmls .= '<td>' . $links . '</td>';
  5192. $htmls .= '<td>' . $results['ISSUEDATE'] . '</td>';
  5193. $htmls .= '<td><span>' . $peStatusArray[$results['STATUSID']] . '</span></td>';
  5194. $htmls .= '</tr>';
  5195. $i++;
  5196. if ($number == null && $i == $displayCount)
  5197. break;
  5198. else if ($number != null && $i <= $displayCount * ($number - 1)) {
  5199. $htmls = '';
  5200. } else if ($i >= $displayCount * $number && $number != null) {
  5201. break;
  5202. }
  5203. }
  5204. $this->html = $htmls;
  5205. }
  5206. }
  5207.  
  5208. function getPeCoreNotification($number=null) {
  5209. if ($this->isCore() || $this->isHr()) {
  5210. $i = 0;
  5211. $c = 1;
  5212. $customCriteria = '';
  5213. $displayCount = PAGE;
  5214. $criteria = new Criteria();
  5215. $con = Propel::getConnection();
  5216. // $customCriteria = 'WHERE
  5217. // pe1.STATUSID = (SELECT
  5218. // MAX(pe2.STATUSID)
  5219. // FROM
  5220. // PE_Employees pe2
  5221. // WHERE
  5222. // pe1.EMPID=pe2.EMPID
  5223. // )&& pe1.STATUSID !=3 && pe1.STATUSID !=1';
  5224. $sql = 'SELECT
  5225. COUNT(*) AS NO
  5226. FROM
  5227. PE_Employees pe1
  5228. JOIN PE_Dates ped
  5229. ON (pe1.REVIEWDATE >= ped.YEAR AND ped.NAME = \'Dashboard\')
  5230. ' . $customCriteria . '
  5231. ORDER BY
  5232. pe1.ISSUEDATE DESC';
  5233. $stmt = $con->prepare($sql);
  5234. $stmt->execute();
  5235.  
  5236. if ($results = $stmt->fetch()) {
  5237. $noOfPeForms = $results['NO'];
  5238. if ($noOfPeForms % $displayCount == 0)
  5239. $this->noOfNotifications = $noOfPeForms / $displayCount;
  5240. else {
  5241. $reminder = $noOfPeForms % $displayCount;
  5242. $noOfPeForms = $noOfPeForms - $reminder;
  5243. $this->noOfNotifications = ($noOfPeForms / $displayCount) + 1;
  5244. }
  5245. }
  5246. if ($number <= $this->noOfNotifications && $number != 0) {
  5247. $this->flag = true;
  5248. } else {
  5249. $this->flag = false;
  5250. }
  5251.  
  5252. $sql = 'SELECT
  5253. pe1.PEID,pe1.EMPID,pe1.STATUSID,pe1.ISSUEDATE
  5254. FROM
  5255. PE_Employees pe1
  5256. JOIN PE_Dates ped
  5257. ON (pe1.REVIEWDATE >= ped.YEAR AND ped.NAME = \'Dashboard\')
  5258. ' . $customCriteria . '
  5259. ORDER BY
  5260. pe1.ISSUEDATE DESC';
  5261.  
  5262. $stmt = $con->prepare($sql);
  5263. $stmt->execute();
  5264. $criteriaTwo = new Criteria();
  5265. $resultObject = PeStatusPeer::doSelect($criteriaTwo);
  5266. if ($resultObject) {
  5267. foreach ($resultObject as $result) {
  5268. $peStatusArray[$result->getStatusId()] = $result->getStatus();
  5269. }
  5270. }
  5271. while ($results = $stmt->fetch()) {
  5272. $GroupWareEmployeeInstance = new GroupwareEmployeesPeer();
  5273. $EmployeeName = $GroupWareEmployeeInstance->getEmployeeName($results['EMPID']);
  5274.  
  5275. $htmls .= '<tr>';
  5276. if(!in_array($results['STATUSID'], array('1', '3', '12'))) {
  5277. $htmls .= '<td><b><i>' . link_to($EmployeeName, 'main/PeForm?view=' . $results['PEID']) . '</i></b></td>';
  5278. } else {
  5279. $htmls .= '<td>' . $EmployeeName . '</td>';
  5280. }
  5281.  
  5282.  
  5283. $htmls .= '<td>' . $results['ISSUEDATE'] . '</td>';
  5284. $htmls .= '<td><span>' . $peStatusArray[$results['STATUSID']] . '</span></td>';
  5285. $htmls .= '</tr>';
  5286. $i++;
  5287. if ($number == null && $i == $displayCount)
  5288. break;
  5289. else if ($number != null && $i <= $displayCount * ($number - 1)) {
  5290. $htmls = '';
  5291. } else if ($i >= $displayCount * $number && $number != null) {
  5292. break;
  5293. }
  5294. }
  5295. $this->html = $htmls;
  5296. }
  5297. }
  5298.  
  5299. function setSuggestions($PeId) {
  5300. $suggestion = $this->getRequestParameter('suggestion');
  5301. foreach ($suggestion as $suggestions) {
  5302. if ($suggestions != '') {
  5303. $pesuggestions = new PeSuggestions();
  5304. $pesuggestions->setPeId($PeId);
  5305. $pesuggestions->setSuggestion($suggestions);
  5306. $pesuggestions->save();
  5307. }
  5308. }
  5309. return true;
  5310. }
  5311.  
  5312. //function to get suggestions
  5313. function getSuggestions($PeId) {
  5314. $c = new Criteria();
  5315. $c->add(PeSuggestionsPeer::PEID, $PeId);
  5316. $emplsuggestion = PeSuggestionsPeer::doSelect($c);
  5317. foreach ($emplsuggestion as $result) {
  5318. $empl_sugg[] = $result->getSuggestion();
  5319. }
  5320.  
  5321. $this->empsugg = $empl_sugg;
  5322. }
  5323.  
  5324. function isEditable($peId) {
  5325.  
  5326. $empId = $this->getUser()->getAttribute('empId');
  5327. $empName = $this->getUser()->getAttribute('empName');
  5328. $criteria = new Criteria();
  5329. $criteria->add(PeEmployeesPeer::PEID, $peId);
  5330. $result = PeEmployeesPeer::doSelect($criteria);
  5331. // echo "<pre>";print_r($result);exit;
  5332. if ($result) {
  5333. $peStatusId = $result[0]->getStatusId();
  5334. $evaluator = $result[0]->getTakenBy();
  5335. $petype = $result[0]->getType();
  5336. $peEmpId = $result[0]->getEmpId();
  5337. }
  5338. if (($this->isStaff() || $this->isQm()) && ($peStatusId == 1))
  5339. return true;
  5340. else if ($this->isAdmin() && $this->isAllowed($peId)) {
  5341. switch ($peStatusId) {
  5342. case 1:
  5343. if ($petype == SELFCODE && ($empId == $peEmpId))
  5344. return true;
  5345. else
  5346. return false;
  5347. break;
  5348. case 2:return false;
  5349. break;
  5350. case 3:
  5351. if ($empId != $peEmpId)
  5352. return true;
  5353. else
  5354. return false;
  5355. break;
  5356. case 5:
  5357. return true;
  5358. break;
  5359. //added by renjo for monthly PE
  5360. case 12:
  5361. case 13:
  5362. if ($empId != $peEmpId)
  5363. return true;
  5364. else
  5365. return false;
  5366. break;
  5367. default:
  5368. return false;
  5369. break;
  5370. }
  5371. }
  5372. else if ($this->isCore()) {
  5373. switch ($peStatusId) {
  5374. case 2:
  5375. case 3: if ($evaluator == $empId || $this->coreCheck($evaluator))
  5376. return true;
  5377. else
  5378. return false;
  5379. break;
  5380. /*
  5381. if($evaluator==$empId)
  5382. return true;
  5383. else
  5384. return false;
  5385. break; */
  5386. case 5:
  5387. //added by renjo for monthly PE
  5388. case 12://return false;
  5389. case 13:
  5390. if ($evaluator == $empId)
  5391. return true;
  5392. else
  5393. return false;
  5394. break;
  5395. default:
  5396. return false;
  5397. break;
  5398. }
  5399. }else if ($this->isHr()) {
  5400. switch ($peStatusId) {
  5401. case 10:
  5402. case 13:
  5403. return true;
  5404. break;
  5405. default:
  5406. return false;
  5407. break;
  5408. }
  5409. }
  5410. else
  5411. return false;
  5412. }
  5413.  
  5414. function isViewable($peId) {
  5415. $empId = $this->getUser()->getAttribute('empId');
  5416. $emp_name = $this->getUser()->getAttribute('empName');
  5417. $criteria = new Criteria();
  5418. $criteria->add(PeEmployeesPeer::PEID, $peId);
  5419. $result = PeEmployeesPeer::doSelect($criteria);
  5420. if ($result) {
  5421. $peStatusId = $result[0]->getStatusId();
  5422. $evaluator = $result[0]->getTakenBy();
  5423. $petype = $result[0]->getType();
  5424. $pe_empid = $result[0]->getEmpId();
  5425. $pe_issuedate = $result[0]->getIssueDate();
  5426. }
  5427. if ($this->isAdmin() && $this->isAllowed($peId)) {
  5428. switch ($peStatusId) {
  5429. case 1:
  5430. if ($petype == SELFCODE && ($empId == $pe_empid))
  5431. return true;
  5432. else
  5433. return false;
  5434. break;
  5435. case 2:
  5436. if ($petype == SELFCODE && ($empId == $pe_empid)) {
  5437. return true;
  5438. } else {
  5439. $PeEmployeeInstance = new PeEmployeesPeer();
  5440. $PeValues = $PeEmployeeInstance->getPestatusvalues('', $pe_empid, ORIGINALCODE, $pe_issuedate);
  5441. if ($PeValues) {
  5442. foreach ($PeValues as $values) {
  5443. $peStatusOforiginal = $values->getStatusId();
  5444. }
  5445. if ($peStatusOforiginal >= 6) {
  5446. return true;
  5447. break;
  5448. } else {
  5449. $_SESSION['error_msg'] = 'You will be authorized to view this self evaluation after Core approves the PE Form';
  5450. $this->redirect('main/index');
  5451. break;
  5452. }
  5453. } else {
  5454. $_SESSION['error_msg'] = 'You will be authorized to view this self evaluation after Core approves the PE Form';
  5455. $this->redirect('main/index');
  5456. break;
  5457. return false;
  5458. break;
  5459. }
  5460. }
  5461. case 3:
  5462. case 4:
  5463. case 5:
  5464. case 11:
  5465. if ($empId != $pe_empid)
  5466. return true;
  5467. else
  5468. return false;
  5469. break;
  5470. case 6: $this->getUser()->setAttribute('status', 6);
  5471. return true;
  5472. break;
  5473. case 7:
  5474. return true;
  5475. break;
  5476. default:
  5477. return true;
  5478. break;
  5479. }
  5480. }
  5481. if ($this->isCore()) {
  5482. switch ($peStatusId) {
  5483. case 1:
  5484. return false;
  5485. break;
  5486. case 2:
  5487. return true;
  5488. break;
  5489. case 3: /* if($evaluator==$empId || $this->coreCheck($evaluator)) */
  5490. return true;
  5491. break;
  5492. // if($evaluator==$empId)
  5493. // return true;
  5494. // else
  5495. // return false;
  5496. // break;
  5497. default:
  5498. return true;
  5499. break;
  5500. }
  5501. }
  5502. if (($this->isStaff()) && $this->isAllowed($peId)) {
  5503. switch ($peStatusId) {
  5504. case 1:
  5505. return true;
  5506. break;
  5507. case 2:
  5508. return true;
  5509. break;
  5510. case 6:
  5511. return true;
  5512. break;
  5513. case 7:
  5514. return true;
  5515. break;
  5516. case 8:
  5517. return true;
  5518. break;
  5519. case 9:
  5520. return true;
  5521. break;
  5522. case 10:
  5523. return true;
  5524. break;
  5525. //added by renjo for monthly PE
  5526. case 13:return true;
  5527. break;
  5528. default:
  5529. return false;
  5530. break;
  5531. }
  5532. }
  5533. if ($this->isQm()) {
  5534. switch ($peStatusId) {
  5535. default:
  5536. return true;
  5537. break;
  5538. }
  5539. }
  5540. if ($this->isHr()) {
  5541. switch ($peStatusId) {
  5542. case 1:
  5543. return false;
  5544. break;
  5545. case 3:
  5546. return false;
  5547. break;
  5548. default:
  5549. return true;
  5550. break;
  5551. }
  5552. }
  5553. }
  5554.  
  5555. /**
  5556. * Function to get employee supervisor
  5557. * @param $empId
  5558. * set variable immediateSupervisor,immediateSupervisorId
  5559. * set variable nextSupervisor, nextSupervisorId
  5560. * set variable takenBy,takenById
  5561. * return true
  5562. */
  5563. function getEmpSupervisor($empId) {
  5564. $groupwareEmployee = new GroupwareEmployeesPeer();
  5565. $this->immediateSupervisorId = $groupwareEmployee->getEmployeeAdminId($empId);
  5566. $this->immediateSupervisor = $groupwareEmployee->getEmployeeAdmin($empId);
  5567. $this->nextSupervisorId = $groupwareEmployee->getEmployeeAdminId($this->immediateSupervisorId);
  5568. $this->nextSupervisor = $groupwareEmployee->getEmployeeAdmin($this->immediateSupervisorId);
  5569. /* To check for employee assignment */
  5570. $criteria = new Criteria();
  5571. $criteria->add(PeAssignedadminPeer::EMPLOYEE, $empId);
  5572. $result = PeAssignedadminPeer::doSelect($criteria);
  5573. if ($result) {
  5574. $assignedAdmin = $result[0]->getNewAdmin();
  5575. if ($assignedAdmin == $this->getUser()->getAttribute('empId')) {
  5576. $this->takenById = $assignedAdmin;
  5577. $this->takenBy = $groupwareEmployee->getEmployeeName($this->takenById);
  5578. } else if ($empId == $this->getUser()->getAttribute('empId')) {
  5579. // $this->takenById = $groupwareEmployee->getEmployeeAdminId($empId);
  5580. // $this->takenBy = $groupwareEmployee->getEmployeeAdmin($empId);
  5581. $this->takenById = $assignedAdmin;
  5582. $this->takenBy = $groupwareEmployee->getEmployeeName($assignedAdmin);
  5583. } else {
  5584. $this->takenById = $this->getUser()->getAttribute('empId');
  5585. $this->takenBy = $this->getUser()->getAttribute('empName');
  5586. }
  5587. } else if ($empId == $this->getUser()->getAttribute('empId')) {
  5588. if ($result) {
  5589. $this->takenById = $result[0]->getNewAdmin();
  5590. $this->takenBy = $groupwareEmployee->getEmployeeAdmin($this->takenById);
  5591. } else {
  5592. $this->takenById = $this->immediateSupervisorId;
  5593. $this->takenBy = $this->immediateSupervisor;
  5594. }
  5595. } else if ($this->isCore()) {
  5596. $this->takenById = $this->getUser()->getAttribute('empId');
  5597. $this->takenBy = $this->getUser()->getAttribute('empName');
  5598. } else if ($this->immediateSupervisorId == $this->getUser()->getAttribute('empId')) {
  5599. $this->takenById = $this->immediateSupervisorId;
  5600. $this->takenBy = $this->immediateSupervisor;
  5601. } else {
  5602. $_SESSION['error_msg'] = 'You are not authorized to evaluate the employee';
  5603. $this->redirect('main/index');
  5604. }
  5605. return true;
  5606. }
  5607.  
  5608. /**
  5609. *
  5610. */
  5611. function getEmpSupervisorforMonthly($empId) {
  5612. $groupwareEmployee = new GroupwareEmployeesPeer();
  5613. $immediateSupervisorId = $groupwareEmployee->getEmployeeAdminId($empId);
  5614. $nextSupervisorId = $groupwareEmployee->getEmployeeAdminId($immediateSupervisorId);
  5615.  
  5616. /* To check for employee assignment */
  5617. $criteria = new Criteria();
  5618. $criteria->add(PeAssignedadminPeer::EMPLOYEE, $empId);
  5619. $result = PeAssignedadminPeer::doSelect($criteria);
  5620. if ($result) {
  5621. $assignedAdmin = $result[0]->getNewAdmin();
  5622. if ($assignedAdmin == $this->getUser()->getAttribute('empId')) {
  5623. $this->takenById = $assignedAdmin;
  5624. $this->takenBy = $groupwareEmployee->getEmployeeName($this->takenById);
  5625. } else if ($empId == $this->getUser()->getAttribute('empId')) {
  5626. // $this->takenById = $groupwareEmployee->getEmployeeAdminId($empId);
  5627. // $this->takenBy = $groupwareEmployee->getEmployeeAdmin($empId);
  5628. $this->takenById = $assignedAdmin;
  5629. $this->takenBy = $groupwareEmployee->getEmployeeName($assignedAdmin);
  5630. } else {
  5631. $this->takenById = $this->getUser()->getAttribute('empId');
  5632. $this->takenBy = $this->getUser()->getAttribute('empName');
  5633. }
  5634. } else if ($empId == $this->getUser()->getAttribute('empId')) {
  5635. if ($result) {
  5636. $this->takenById = $result[0]->getNewAdmin();
  5637. $this->takenBy = $groupwareEmployee->getEmployeeAdmin($this->takenById);
  5638. } else {
  5639. $this->takenById = $this->immediateSupervisorId;
  5640. $this->takenBy = $this->immediateSupervisor;
  5641. }
  5642. } else if ($this->isCore()) {
  5643. $this->takenById = $this->getUser()->getAttribute('empId');
  5644. $this->takenBy = $this->getUser()->getAttribute('empName');
  5645. } else if ($immediateSupervisorId == $this->getUser()->getAttribute('empId')) {
  5646. $this->takenById = $immediateSupervisorId;
  5647. $this->takenBy = $this->immediateSupervisor;
  5648. } else {
  5649. $_SESSION['error_msg'] = 'You are not authorized to evaluate the employee';
  5650. $this->redirect('main/index');
  5651. }
  5652. $employee["supervisor"] = $immediateSupervisorId;
  5653. $employee["nextsupervisor"] = $nextSupervisorId;
  5654. $employee["takenby"] = $this->takenById;
  5655. return $employee;
  5656. }
  5657.  
  5658. /**
  5659. *
  5660. */
  5661. function hasHelp() {
  5662. $helpArray = array('eihelp', 'achelp', 'arhelp',
  5663. 'qlwhelp', 'qnwhelp', 'cmnhelp',
  5664. 'jkhelp', 'mshelp', 'sehelp',
  5665. 'cdhelp', 'aphelp', 'lmhelp',
  5666. 'qmshelp', 'oahelp', 'onahelp',
  5667. 'echelp', 'dphelp'
  5668. );
  5669. foreach ($helpArray as $help) {
  5670. if (!$this->getRequestParameter($help))
  5671. continue;
  5672. else
  5673. return true;
  5674. }
  5675. return false;
  5676. }
  5677.  
  5678. function hasSample() {
  5679. $sampleArray = array('eisample', 'acsample', 'arsample',
  5680. 'qlwsample', 'qnwsample', 'cmnsample',
  5681. 'jksample', 'mssample', 'sesample',
  5682. 'cdsample', 'apsample', 'lmsample',
  5683. 'qmssample', 'oasample', 'onasample',
  5684. 'ecsample', 'dpsample'
  5685. );
  5686. foreach ($sampleArray as $sample) {
  5687. if (!$this->getRequestParameter($sample))
  5688. continue;
  5689. else
  5690. return true;
  5691. }
  5692. return false;
  5693. }
  5694.  
  5695. /**
  5696. *
  5697. * Range
  5698. * |xxxxxxxxxxxx|
  5699. * $von $bis
  5700. * Case 1:|----------------xxxxxxx|
  5701. * Case 2: |xxx---|
  5702. * Case 3: |xxxxxxx|
  5703. * Case 4: |---xxxxxxxxxxxxxx----------|
  5704. * aus :|-------| |-------|
  5705. *
  5706. */
  5707. public function betweenRangeCriteria($von=null, $bis=null, $von_feld=null, $bis_feld=null) {
  5708. $startDate = strtotime($von);
  5709. $endDate = strtotime($bis);
  5710. $newStartDate = strtotime($von_feld);
  5711. $newEndDate = strtotime($bis_feld);
  5712.  
  5713. if (($newEndDate < $startDate) || ($endDate < $newStartDate))
  5714. return true;
  5715. else
  5716. return false;
  5717. }
  5718.  
  5719. public function betweenRangeCriteriaAssign($oldStartDate=null, $oldEndDate=null) {
  5720.  
  5721. $startDate = strtotime($oldStartDate);
  5722. $endDate = strtotime($oldEndDate);
  5723. $currentDate = strtotime(date('Y-m-d'));
  5724.  
  5725.  
  5726. if (($currentDate >= $startDate) && ($currentDate <= $endDate))
  5727. return true;
  5728. else
  5729. return false;
  5730. }
  5731.  
  5732. function qmCheck($empId) {
  5733. $criteria = new Criteria();
  5734. $criteria->add(GroupwareEmployeesPeer::TITLE, array('Quality Manager'), Criteria::IN);
  5735. $criteria->add(GroupwareEmployeesPeer::ID, $empId);
  5736. if (GroupwareEmployeesPeer::doCount($criteria))
  5737. return true;
  5738. else
  5739. return false;
  5740. }
  5741.  
  5742. function adminCheck($empId) {
  5743.  
  5744. //********************* code TO CHECK ADMIN or NOT*************************
  5745. /* $criteria = new Criteria();
  5746. $criteria->add(GroupwareEmployeesPeer::ID,$empId);
  5747. $results = GroupwareEmployeesPeer::doSelect($criteria);
  5748. foreach($results as $user){
  5749. $empId = $user -> getId();
  5750. } */
  5751. $criteria = new Criteria();
  5752. $criteria->add(GroupwareTeamsPeer::ADMIN_ID, $empId);
  5753. $result = GroupwareTeamsPeer::doSelect($criteria);
  5754. if ($result)
  5755. return true;
  5756. else
  5757. return false;
  5758. }
  5759.  
  5760. function staffCheck($empId) {
  5761.  
  5762. //********************* code TO CHECK ADMIN or NOT*************************
  5763.  
  5764. if ($this->qmCheck($empId)) {
  5765. return false;
  5766. }
  5767. else
  5768. return true;
  5769. }
  5770.  
  5771. /* Function to check whether the employee has sufficient experience to submit the PE form */
  5772.  
  5773. function checkExpToSubmitPE($empId) {
  5774.  
  5775. $preExp = 0;
  5776. // $empId = $this->getUser()->getAttribute('empId');
  5777. $criteria = new Criteria();
  5778. $criteria->add(GroupwarePreExperiencePeer::ID, $empId);
  5779. $resultSet = GroupwarePreExperiencePeer::doSelect($criteria);
  5780. if ($resultSet) {
  5781. $preExp = $resultSet[0]->getExperience();
  5782. }
  5783. $expInMonth = $this->experienceInMonth($empId);
  5784. if ($expInMonth >= 6) {
  5785. $totalExp = $preExp + $expInMonth;
  5786. if ($totalExp < 14) {
  5787. if ($this->getUser()->getAttribute('empRole') == 'admin' || $this->getUser()->getAttribute('empRole') == 'core') {
  5788. $_SESSION['error_msg'] = 'The selected employee hasn\'t the sufficient experience to conduct the PE';
  5789. return false;
  5790. }
  5791. $_SESSION['error_msg'] = 'You are not allowed to submit the PE form as you don\'t have the sufficient experience in Poornam Info Vision.';
  5792.  
  5793. $this->redirect('main/index');
  5794. }
  5795. } else {
  5796. if ($this->getUser()->getAttribute('empRole') == 'admin' || $this->getUser()->getAttribute('empRole') == 'core') {
  5797. $_SESSION['error_msg'] = 'The selected employee hasn\'t the sufficient experience to conduct the PE';
  5798. return false;
  5799. }
  5800. $_SESSION['error_msg'] = 'You are not allowed to submit the PE form as you don\'t have the sufficient experience in Poornam Info Vision.';
  5801. $this->redirect('main/index');
  5802. }
  5803. return true;
  5804. }
  5805.  
  5806. /* Function to calculate employee's experience in month */
  5807.  
  5808. function experienceInMonth($empId) {
  5809. $criteria = new Criteria();
  5810. $criteria->add(GroupwareDatesPeer::EMPID, $empId);
  5811. $criteria->add(GroupwareDatesPeer::DATECODE, 'HD');
  5812. $results = GroupwareDatesPeer::doSelect($criteria);
  5813. foreach ($results as $result) {
  5814. $empJoined = $result->getEmpdate();
  5815. }
  5816.  
  5817. // **************** to calculate employees experience *****************
  5818.  
  5819. $nowT = mktime(0, 0, 0, date("m") + 1, "01", date("Y"));
  5820. $currentDate = date('Y-m-d', $nowT);
  5821. $empJoined = GroupwareEmployeesPeer::getEmployeeUl($empId, $currentDate, $empJoined);
  5822. $currentDateArray = explode('-', $currentDate);
  5823. $empJoinedArray = explode('-', $empJoined);
  5824. if ($empJoinedArray[0] != 0) {
  5825. $currentYear = $currentDateArray[0];
  5826. $currentMonth = $currentDateArray[1];
  5827. $currentDay = $currentDateArray[2];
  5828. $empJoinedYear = $empJoinedArray[0];
  5829. $empJoinedMonth = $empJoinedArray[1];
  5830. $empJoinedDay = $empJoinedArray[2];
  5831.  
  5832. if ($empJoinedDay > JOINDATELIMIT) {
  5833. if (($empJoinedMonth + 1) > 12) {
  5834. $empJoinedMonth = 1;
  5835. $empJoinedYear++;
  5836. } else {
  5837. $empJoinedMonth+=1;
  5838. }
  5839. $empJoinedMonth = date('m', mktime(0, 0, 0, $empJoinedMonth, 1, $empJoinedYear));
  5840. $empJoinedDay = date('d', mktime(0, 0, 0, $empJoinedMonth, 1, $empJoinedYear));
  5841. } else {
  5842. $empJoinedDay = date('d', mktime(0, 0, 0, $empJoinedMonth, 1, $empJoinedYear));
  5843. }
  5844. $currentTime = mktime(0, 0, 0, $currentMonth, $currentDay, $currentYear);
  5845. $empJoinedTime = mktime(0, 0, 0, $empJoinedMonth, $empJoinedDay, $empJoinedYear);
  5846. // 60*60*24
  5847. $totalmnths = (int) (($currentTime - $empJoinedTime) / 2628000);
  5848. }
  5849. return $totalmnths;
  5850. }
  5851.  
  5852. function checkRangeCriteria($selectedYear) {
  5853.  
  5854. $this->current_empid = $this->getUser()->getAttribute('empId');
  5855. $assignAdminIdarray = array();
  5856. $criteria = new Criteria();
  5857. if ($this->role == "admin") {
  5858. $c1 = $criteria->getNewCriterion(PeAssignedadminPeer::ASSIGNEDBY, $this->current_empid);
  5859. $c2 = $criteria->getNewCriterion(PeAssignedadminPeer::NEWADMIN, $this->current_empid);
  5860. $c1->addOr($c2);
  5861. $criteria->add($c1);
  5862. }
  5863. $resultSet = PeAssignedAdminPeer::doSelect($criteria);
  5864. if ($resultSet) {
  5865. foreach ($resultSet as $results) {
  5866. $startDate = $results->getStartDate();
  5867. $endDate = $results->getEndDate();
  5868. $assignAdminId = $results->getAssignAdminId();
  5869. $tmpDate1 = explode('-', $startDate);
  5870. $startYear = $tmpDate1[0];
  5871. $tmpDate2 = explode('-', $endDate);
  5872. $endYear = $tmpDate2[0];
  5873. if (($selectedYear >= $startYear) && ($selectedYear <= $endYear)) {
  5874. if ($startYear != $selectedYear) {
  5875. $assignAdminIdarray[] = $assignAdminId;
  5876. }
  5877. }
  5878. }
  5879. return $assignAdminIdarray;
  5880. }
  5881. }
  5882.  
  5883. function coreCheck($empId) {
  5884. $criteria = new Criteria();
  5885. $criteria->add(GroupwareEmployeesPeer::RESIGNED, 'n');
  5886. $criteria->add(GroupwareEmployeesPeer::GRADE, array('MEG'), Criteria::IN);
  5887. $criteria->add(GroupwareEmployeesPeer::ID, $empId);
  5888. if (GroupwareEmployeesPeer::doCount($criteria))
  5889. return true;
  5890. else
  5891. return false;
  5892. }
  5893.  
  5894. }
Add Comment
Please, Sign In to add comment