Advertisement
Guest User

Untitled

a guest
Jul 14th, 2016
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 378.93 KB | None | 0 0
  1. <?php
  2.  
  3. /**
  4. * Short description for file
  5. *
  6. * Long description (if any) ...
  7. *
  8. * PHP version 5
  9. *
  10. * The license text...
  11. *
  12. * @category PHP
  13. * @package Roster
  14. * @author vineet singh
  15. * @license a
  16. * @version CVS: $Id:$
  17. * @link http://pear.php.net/package/Roster
  18. * @see References to other sections (if any)...
  19. */
  20.  
  21. /**
  22. * Short description for class
  23. *
  24. * Long description (if any) ...
  25. *
  26. * @category PHP
  27. * @package Roster
  28. * @author vineet singh
  29. * @license a
  30. * @version Release: @package_version@
  31. * @link http://pear.php.net/package/Roster
  32. * @see References to other sections (if any)...
  33. */
  34. class Reports extends CFormModel {
  35.  
  36. /**
  37. * Short description for function
  38. *
  39. * Long description (if any) ...
  40. *
  41. * @param string $className Parameter description (if any) ...
  42. * @return string Return description (if any) ...
  43. * @access public
  44. * @static
  45. */
  46. public static function model($className = __CLASS__) {
  47. return parent::model($className);
  48. }
  49.  
  50. /**
  51. * Short description for function
  52. *
  53. * Long description (if any) ...
  54. *
  55. * @return string Return description (if any) ...
  56. * @access public
  57. */
  58. public function primaryKey() {
  59. return 'id';
  60. }
  61.  
  62. /**
  63. * Short description for function
  64. *
  65. * Long description (if any) ...
  66. *
  67. * @return string Return description (if any) ...
  68. * @access public
  69. */
  70. public function getCollectionName() {
  71. return 'users';
  72. }
  73.  
  74. /**
  75. * Short description for function
  76. *
  77. * Long description (if any) ...
  78. *
  79. * @param date $to_date Parameter description (if any) ...
  80. * @param date $from_date Parameter description (if any) ...
  81. * @return mixed Return description (if any) ...
  82. * @access public
  83. * @static
  84. */
  85. public static function calculate_experience($to_date, $from_date) {
  86. $interval = date_diff(date_create(date('Y-m-d', $to_date)), date_create(date('Y-m-d', $from_date)));
  87. $diff = $interval->format("Years:%Y,Months:%M,Days:%d");
  88. $a_out = array();
  89. array_walk(explode(',', $diff), function($val, $key) use(&$a_out) {
  90. $v = explode(':', $val);
  91. $a_out[$v[0]] = $v[1];
  92. });
  93.  
  94. return $a_out;
  95. }
  96.  
  97. /**
  98. * Short description for function
  99. *
  100. * Long description (if any) ...
  101. *
  102. * @param array $post_data Parameter description (if any) ...
  103. * @param unknown $tenant_id Parameter description (if any) ...
  104. * @return array Return description (if any) ...
  105. * @access public
  106. * @static
  107. */
  108. public static function getExperienceRoster($post_data, $tenant_id = null) {
  109. $return = array();
  110. //$sr_no=1;
  111. $filter = $post_data['filter_id'];
  112. $users = UserMongo::model()->getUsersByFilter($filter, $tenant_id, $post_data['active_inactive']);
  113. $output = array();
  114.  
  115. foreach ($users as $key => $user) {
  116. $total_past_y = 0;
  117. $total_past_m = 0;
  118. $total_cur_y = 0;
  119. $total_cur_m = 0;
  120. $total_ex_m = 0;
  121. $total_ex_y = 0;
  122. $user_name = $user['personal']['firstname'] . " " . $user['personal']['lastname'];
  123. $employee_number = (isset($user['personal']['employee_no'])) ? $user['personal']['employee_no'] : "N.A.";
  124. $user_post = $user->getCurrentPosition($tenant_id);
  125. $job_title = $user_post['designation'];
  126. $department = $user_post['department'];
  127. $business_unit = $user_post['business_unit'];
  128. if (isset($user['past_work']) && !empty($user['past_work'])) {
  129. foreach ($user['past_work'] as $key => $work) {
  130. $diff_work = self::calculate_experience($work['to_date']->sec, $work['from_date']->sec);
  131. $total_past_y += intval($diff_work['Years']);
  132. $total_past_m += intval($diff_work['Months']);
  133. }
  134.  
  135. if ($total_past_m > 12) {
  136. $total_past_y += intval($total_past_m / 12);
  137. $total_past_m = $total_past_m % 12;
  138. }
  139. $past_work_ex = $total_past_y . "y " . $total_past_m . "m";
  140. } else {
  141. $past_work_ex = "";
  142. }
  143. if (isset($user->doj->sec) && $user->doj->sec != "") {
  144. $diff_cur_work = self::calculate_experience(time(), $user->doj->sec);
  145. $total_cur_y = $diff_cur_work['Years'];
  146. $total_cur_m = $diff_cur_work['Months'];
  147. $cur_work_ex = $total_cur_y . "y " . $total_cur_m . "m";
  148. } else {
  149. $cur_work_ex = "";
  150. }
  151. if (!empty($user['past_work'])) {
  152.  
  153. $total_ex_m = intval($total_past_m) + intval($total_cur_m);
  154. $total_ex_y = intval($total_past_y) + intval($total_cur_y);
  155. if ($total_ex_m > 12) {
  156. $total_ex_y += intval($total_ex_m / 12);
  157. $total_ex_m = $total_ex_m % 12;
  158. }
  159. $total_ex = $total_ex_y . "y " . $total_ex_m . "m";
  160. } elseif (!empty($user['designation'])) {
  161. $total_ex = $total_cur_y . "y " . $total_cur_m . "m";
  162. } else {
  163. $total_ex = "";
  164. }
  165.  
  166.  
  167. // $action_checkbox = "<input type=\"checkbox\" name=\"roster_action\" value=\"\">";
  168.  
  169. $output[] = array(
  170. // $action_checkbox,
  171. $employee_number,
  172. $user_name,
  173. $job_title,
  174. $department,
  175. $business_unit,
  176. $past_work_ex,
  177. $cur_work_ex,
  178. $total_ex
  179. );
  180. } // EOF foreach
  181. // echo "<pre>"; print_r($output); exit("</pre> \n exited here ");
  182. $cols = array(
  183. // "<input type=\\\"checkbox\\\" name=\\\"roster_action\\\" value=\\\"\\\">",
  184. //'Sr No',
  185. 'Employee ID',
  186. 'Name',
  187. 'Job Title',
  188. 'Department',
  189. 'Business Unit',
  190. 'Past Experience',
  191. 'Current Experience',
  192. 'Total Experience'
  193. );
  194.  
  195. $roster_type = "Experience Report";
  196. $filenameexport = $roster_type;
  197. $final_output = array('output' => $output,
  198. 'cols' => $cols,
  199. 'filenameexport' => $filenameexport);
  200. return $final_output;
  201. }
  202.  
  203. // EOF function
  204.  
  205. /**
  206. * Short description for function
  207. *
  208. * Long description (if any) ...
  209. *
  210. * @param array $post_data Parameter description (if any) ...
  211. * @param unknown $tenant_id Parameter description (if any) ...
  212. * @param unknown $user_id Parameter description (if any) ...
  213. * @return array Return description (if any) ...
  214. * @access public
  215. * @static
  216. */
  217. public static function getLeavesCredited($post_data, $tenant_id = null, $user_id = null) {
  218. $return = array();
  219. //$sr_no=1;
  220. $filter = $post_data['filter_id'];
  221. $users = UserMongo::model()->getUsersByFilter($filter, $tenant_id, $post_data['active_inactive']);
  222. $output = array();
  223. $leaves = Leaves::model()->getTenantLeaveListWithoutCompoff($tenant_id);
  224.  
  225. $index = 0;
  226. foreach ($users as $key => $user) {
  227. $user_name = $user['personal']['firstname'] . " " . $user['personal']['lastname'];
  228. $employee_number = (isset($user['personal']['employee_no'])) ? $user['personal']['employee_no'] : "N.A.";
  229. $user_post = $user->getCurrentPosition($tenant_id);
  230. $job_title = $user_post['designation'];
  231. $department = $user_post['department'];
  232. $business_unit = $user_post['business_unit'];
  233. // $action_checkbox = "<input type=\"checkbox\" name=\"roster_action\" value=\"\">";
  234. $leaves_user_allowed = Leaves::model()->getLeaveListWithoutCompOff($tenant_id, $user->user_id);
  235. unset($userleaves);
  236. foreach ($leaves as $leave_id => $leave) {
  237. if (array_key_exists($leave_id, $leaves_user_allowed)) {
  238. $userleaves[] = LeavesHelper::individualLeaveBalance($user->user_id, $tenant_id, $leave_id);
  239. } else {
  240. $userleaves[] = array(
  241. 'leave_name' => 'NA',
  242. 'balance' => 'NA',
  243. 'total' => 'NA',
  244. 'prevBalance' => 'NA'
  245. );
  246. }
  247. }
  248. $output[] = array(
  249. // $action_checkbox,
  250. $employee_number,
  251. $user_name,
  252. $job_title,
  253. $department,
  254. $business_unit,
  255. );
  256. for ($i = 0; $i < count($userleaves); $i++) {
  257. array_push($output[$index], $userleaves[$i]['total']);
  258. }
  259. $index++;
  260. } // EOF foreach user
  261.  
  262. $cols = array(
  263. // "<input type=\\\"checkbox\\\" name=\\\"roster_action\\\" value=\\\"\\\">",
  264. //'Sr No',
  265. 'Employee ID',
  266. 'Name',
  267. 'Job Title',
  268. 'Department',
  269. 'Business Unit',
  270. );
  271.  
  272. foreach ($leaves as $leave_id => $leave_name) {
  273. array_push($cols, $leave_name);
  274. }
  275. $roster_type = "Leaves-Credited";
  276. $filenameexport = $roster_type;
  277. $final_output = array('output' => $output,
  278. 'cols' => $cols,
  279. 'filenameexport' => $filenameexport);
  280. return $final_output;
  281. }
  282.  
  283. // EOF function
  284.  
  285. /**
  286. * Short description for function
  287. *
  288. * Long description (if any) ...
  289. *
  290. * @param array $post_data Parameter description (if any) ...
  291. * @param unknown $tenant_id Parameter description (if any) ...
  292. * @param unknown $user_id Parameter description (if any) ...
  293. * @return array Return description (if any) ...
  294. * @access public
  295. * @static
  296. */
  297. public static function getLeavesNew($post_data, $tenant_id = null, $user_id = null, $from, $to) {
  298. $return = array();
  299. $filter = $post_data['filter_id'];
  300. $users = UserMongo::model()->getUsersByFilter($filter, $tenant_id, $post_data['active_inactive']);
  301. $output = array();
  302. // $leaves = TenantLeaves::model()->findAllByAttributes(array('tenant_id'=>$tenant_id));
  303. // $leaves = Leaves::getLeaveList(null,null,true);
  304. $leavesModel = Leaves::model()->tenant($tenant_id)->findAll();
  305. foreach ($leavesModel as $key => $value) {
  306. $leaves[$value->id] = $value->name;
  307. }
  308. $index = 0;
  309.  
  310. $begin = new DateTime($from);
  311. $end = new DateTime($to);
  312. $end = $end->modify('+1 day');
  313. $interval = new DateInterval('P1D');
  314. $daterange = new DatePeriod($begin, $interval, $end);
  315.  
  316. $from = strtotime($from);
  317. $to = strtotime($to);
  318.  
  319. $criteria = new EMongoCriteria();
  320.  
  321. foreach ($users as $key => $user) {
  322. $totalDays = 0;
  323. $workingDays = 0;
  324. $workingDaysCount = 0;
  325. $appliedOn = "";
  326. $leaveType = "";
  327. $fromDate = "";
  328. $toDate = "";
  329. $totalDays = "";
  330. $workingDays = "";
  331. $isHalfDay = "";
  332. $isUnpaid = "";
  333. $approvedBy = "";
  334. $approvalDate = "";
  335. $user_name = $user['personal']['firstname'] . " " . $user['personal']['lastname'];
  336. $employee_number = (isset($user['personal']['employee_no'])) ? $user['personal']['employee_no'] : "N.A.";
  337. $user_post = $user->getCurrentPosition($tenant_id);
  338. $job_title = $user_post['designation'];
  339. $department = $user_post['department'];
  340.  
  341. $criteria->from_date('>=', new MongoDate($from));
  342. $criteria->from_date('<=', new MongoDate($to));
  343. $criteria->user_id = $user->id;
  344. $userLeaves = UserLeaves::model()->tenant($tenant_id)->findAll($criteria);
  345. if (!empty($userLeaves)) {
  346. foreach ($userLeaves as $userLeave) {
  347. $leaveMessage = $userLeave->message();
  348. if ($userLeave->status == UserLeaves::STATUS_APPROVED) {
  349. $approvedBy = $leaveMessage->getLeaveApprover();
  350. if (isset($leaveMessage->last_modified->sec)) {
  351. $approvalDate = date("Y-m-d", $leaveMessage->last_modified->sec);
  352. }
  353.  
  354. $appliedOn = date("d-m-Y", $userLeave->created->sec);
  355. $leaveType = ($userLeave->leave_id == "unpaid") ? "Unpaid Leave" : $leaves[$userLeave->leave_id];
  356. $fromDate = date("Y-m-d", $userLeave->from_date->sec);
  357. $toDate = date("Y-m-d", $userLeave->to_date->sec);
  358.  
  359. $totalDays = count($leaveMessage->attachments["items"]["total_days"]);
  360. $isUnpaid = ($userLeave->isUnpaid == UserLeaves::LEAVE_PAID ) ? "Paid" : "Unpaid";
  361. $workingDays = RandomHelper::getWorkingDays($userLeave->from_date->sec, $userLeave->to_date->sec, $user->id, $tenant_id);
  362. $workingDaysCount = $totalDays;
  363. if($userLeave->is_half_day == UserLeaves::HALF_DAY_YES)
  364. {
  365. $isHalfDay = "Half Day";
  366. $totalDays = "0.5";
  367. $workingDaysCount = "0.5";
  368. }
  369. else{
  370. $isHalfDay = "Full Day";
  371. }
  372. $output[] = array(
  373. $employee_number,
  374. $user_name,
  375. $job_title,
  376. $department,
  377. $appliedOn,
  378. $leaveType,
  379. $fromDate,
  380. $toDate,
  381. $totalDays,
  382. $workingDaysCount,
  383. $isHalfDay,
  384. $isUnpaid,
  385. $approvedBy,
  386. $approvalDate
  387. );
  388. }
  389. }
  390. }
  391.  
  392.  
  393. $index++;
  394. } // EOF foreach user
  395.  
  396. $cols = array(
  397. // "<input type=\\\"checkbox\\\" name=\\\"roster_action\\\" value=\\\"\\\">",
  398. //'Sr No',
  399. 'Employee ID',
  400. 'Name',
  401. 'Job Title',
  402. 'Department',
  403. 'Applied on||date on which leave application request was created/made',
  404. 'Leave Type||this is the type of leave applied',
  405. 'From||date from which leave duration begins',
  406. 'To||date on which leave duration ends',
  407. 'Total Days||total days covered during leave period including holidays, weekly offs and working days',
  408. 'Working Days||total working days covered in leave period',
  409. 'Is it Half-day||this column says whether this is a half-day leave or not',
  410. 'Paid/Unpaid||here you\'ll see if it\'s been counted as a paid or an unpaid leave',
  411. 'Approved by||leave was approved by the person mentioned in this column',
  412. 'Approval date||leave was approved on the date mentioned here',
  413. );
  414.  
  415.  
  416. $roster_type = "New Leave Report";
  417. $filenameexport = $roster_type;
  418. $final_output = array('output' => $output,
  419. 'cols' => $cols,
  420. 'filenameexport' => $filenameexport);
  421. return $final_output;
  422. }
  423.  
  424. // EOF function
  425.  
  426. /**
  427. * Short description for function
  428. *
  429. * Long description (if any) ...
  430. *
  431. * @param array $post_data Parameter description (if any) ...
  432. * @param unknown $tenant_id Parameter description (if any) ...
  433. * @param unknown $user_id Parameter description (if any) ...
  434. * @return array Return description (if any) ...
  435. * @access public
  436. * @static
  437. */
  438. public static function getLeavesTaken($post_data, $tenant_id, $from, $to) {
  439. $return = array();
  440. if(date('Y-m',strtotime($to)) == date('Y-m'))
  441. {
  442. $to = date('Y-m')."-".date('t', strtotime($from));
  443. }
  444. //$for_month = "2015-08";
  445. //$sr_no=1;
  446. $filter = $post_data['filter_id'];
  447. $users = UserMongo::model()->getUsersByFilter($filter, $tenant_id, $post_data['active_inactive']);
  448. $output = array();
  449. // $leaves = Leaves::model()->getLeaveList($tenant_id, $user_id);
  450. $leaves = Leaves::model()->getTenantLeaveListWithoutCompoff($tenant_id);
  451. $index = 0;
  452. foreach ($users as $key => $user) {
  453. $user_name = $user['personal']['firstname'] . " " . $user['personal']['lastname'];
  454. $employee_number = (isset($user['personal']['employee_no'])) ? $user['personal']['employee_no'] : "N.A.";
  455. $user_post = $user->getCurrentPosition($tenant_id);
  456. $job_title = $user_post['designation'];
  457. $department = $user_post['department'];
  458. $business_unit = $user_post['business_unit'];
  459. $action_checkbox = "<input type=\"checkbox\" name=\"roster_action\" value=\"\">";
  460. $leaves_user_allowed = Leaves::model()->getLeaveListWithoutCompOff($tenant_id, $user->user_id);
  461. unset($userleaves);
  462. foreach ($leaves as $leave_id => $leave) {
  463. //$userleaves[] = LeavesHelper::individualLeaveBalance($user->user_id, $tenant_id, $leave_id);
  464. /*if (array_key_exists($leave_id, $leaves_user_allowed)) {
  465. $userleaves[] = LeavesHelper::individualLeaveBalance($user->user_id, $tenant_id, $leave_id, $from, $to);
  466. } else {
  467. $userleaves[] = array(
  468. 'leave_name' => 'NA',
  469. 'balance' => 'NA',
  470. 'total' => 'NA',
  471. 'prevBalance' => 'NA'
  472. );
  473. }*/
  474. $leaves_approved = UserLeaves::model()->user_approved_leave($user->id, $leave_id)->forMonth(null, $from, $to)->paid()->findAll();
  475. //$leaves_approved = UserLeaves::model()->user_approved_leave($user->id, $leave_id)->forMonth($for_month)->paid()->findAll();
  476. $total_days = 0;
  477. foreach ($leaves_approved as $le)
  478. {
  479. $wekly_off_days = RandomHelper::getWorkingDays($le->from_date->sec, $le->to_date->sec, $le->user_id, $le->tenant_id);
  480. if (!empty($wekly_off_days))
  481. {
  482. if ($le->is_half_day == UserLeaves::HALF_DAY_YES)
  483. {
  484. $total_days += 0.5;
  485. }
  486. }
  487. else
  488. {
  489. if ($total_days > 0)
  490. {
  491. $total_days -= 0.5;
  492. }
  493. }
  494. }
  495. $counter = 0;
  496. $total_data_of_leaves = UserLeaves::getCountOfMonths($user->id, $leave_id,null, 1, $from, $to);
  497. //$total_data_of_leaves = UserLeaves::getCountOfMonths($user->id, $leave_id,$for_month, 1);
  498. if ($total_data_of_leaves > 0)
  499. {
  500. $counter = $total_data_of_leaves - $total_days;
  501. }
  502. else
  503. {
  504. $counter = $total_data_of_leaves;
  505. }
  506. $userleaves[] = $counter;
  507. }
  508. $output[] = array(
  509. // $action_checkbox,
  510. $employee_number,
  511. $user_name,
  512. $job_title,
  513. $department,
  514. $business_unit,
  515. );
  516. for ($i = 0; $i < count($userleaves); $i++) {
  517. /* if ($userleaves[$i]['total'] != "NA") {
  518. $prev_bal_leaves = (isset($userleaves[$i]['prevBalance'])) ? $userleaves[$i]['prevBalance'] : 0;
  519. $total_leaves_with_prev = $userleaves[$i]['total'] + $userleaves[$i]['prevBalance'];
  520. $newfinal = $total_leaves_with_prev - $userleaves[$i]['balance'];
  521. } else {
  522. $newfinal = "NA";
  523. }*/
  524. $newfinal = $userleaves[$i];
  525. array_push($output[$index], $newfinal);
  526. }
  527. $index++;
  528. } // EOF foreach user
  529.  
  530.  
  531.  
  532. $cols = array(
  533. // "<input type=\\\"checkbox\\\" name=\\\"roster_action\\\" value=\\\"\\\">",
  534. //'Sr No',
  535. 'Employee ID',
  536. 'Name',
  537. 'Job Title',
  538. 'Department',
  539. 'Business Unit',
  540. );
  541.  
  542. foreach ($leaves as $leave_id => $leave_name) {
  543. array_push($cols, $leave_name);
  544. }
  545.  
  546. $roster_type = "Leaves-Taken-or-Used";
  547. $filenameexport = $roster_type;
  548. $final_output = array('output' => $output,
  549. 'cols' => $cols,
  550. 'filenameexport' => $filenameexport);
  551. return $final_output;
  552. }
  553.  
  554. // EOF function
  555.  
  556. /**
  557. * Short description for function
  558. *
  559. * Long description (if any) ...
  560. *
  561. * @param array $post_data Parameter description (if any) ...
  562. * @param unknown $tenant_id Parameter description (if any) ...
  563. * @param unknown $user_id Parameter description (if any) ...
  564. * @return array Return description (if any) ...
  565. * @access public
  566. * @static
  567. */
  568. public static function getLeavesBalance($post_data, $tenant_id, $user_id = null) {
  569. $return = array();
  570. //$sr_no=1;
  571. $filter = $post_data['filter_id'];
  572. $users = UserMongo::model()->getUsersByFilter($filter, $tenant_id, $post_data['active_inactive']);
  573. $output = array();
  574. //$leaves = Leaves::model()->getLeaveList($tenant_id, $user_id);
  575. $leaves = Leaves::model()->getTenantLeaveListWithoutCompoff($tenant_id);
  576. $index = 0;
  577. foreach ($users as $key => $user) {
  578. $user_name = $user['personal']['firstname'] . " " . $user['personal']['lastname'];
  579. $employee_number = (isset($user['personal']['employee_no'])) ? $user['personal']['employee_no'] : "N.A.";
  580. $user_post = $user->getCurrentPosition($tenant_id);
  581. $job_title = $user_post['designation'];
  582. $department = $user_post['department'];
  583. $business_unit = $user_post['business_unit'];
  584. $leaves_user_allowed = Leaves::model()->getLeaveListWithoutCompOff($tenant_id, $user->user_id);
  585. $action_checkbox = "<input type=\"checkbox\" name=\"roster_action\" value=\"\">";
  586. unset($userleaves);
  587. foreach ($leaves as $leave_id => $leave) {
  588. // echo "<pre>"; print_r($leaves); exit("</pre> \n exited here ");
  589. //$userleaves[] = LeavesHelper::IndividualLeaveBalance($user->user_id, $tenant_id, $leave_id);
  590. if (array_key_exists($leave_id, $leaves_user_allowed)) {
  591. $userleaves[] = LeavesHelper::individualLeaveBalance($user->user_id, $tenant_id, $leave_id);
  592. } else {
  593. $userleaves[] = array(
  594. 'leave_name' => 'NA',
  595. 'balance' => 'NA',
  596. 'total' => 'NA',
  597. 'prevBalance' => 'NA'
  598. );
  599. }
  600. }
  601.  
  602. $output[] = array(
  603. // $action_checkbox,
  604. $employee_number,
  605. $user_name,
  606. $job_title,
  607. $department,
  608. $business_unit,
  609. );
  610. for ($i = 0; $i < count($userleaves); $i++) {
  611. array_push($output[$index], $userleaves[$i]['balance']);
  612. }
  613. $index++;
  614. } // EOF foreach user
  615. // echo "<pre>"; print_r($output); exit("</pre> \n exited here ");
  616. $leaves = Leaves::model()->getTenantLeaveListWithoutCompoff($tenant_id);
  617. $cols = array(
  618. // "<input type=\\\"checkbox\\\" name=\\\"roster_action\\\" value=\\\"\\\">",
  619. //'Sr No',
  620. 'Employee ID',
  621. 'Name',
  622. 'Job Title',
  623. 'Department',
  624. 'Business Unit',
  625. );
  626.  
  627. foreach ($leaves as $leave_id => $leave_name) {
  628. array_push($cols, $leave_name);
  629. }
  630. $roster_type = "Leaves-Balance";
  631. $filenameexport = $roster_type;
  632. $final_output = array('output' => $output,
  633. 'cols' => $cols,
  634. 'filenameexport' => $filenameexport);
  635. return $final_output;
  636. }
  637.  
  638. // EOF function
  639.  
  640. /**
  641. * Short description for function
  642. *
  643. * Long description (if any) ...
  644. *
  645. * @param array $post_data Parameter description (if any) ...
  646. * @param unknown $tenant_id Parameter description (if any) ...
  647. * @param unknown $user_id Parameter description (if any) ...
  648. * @return array Return description (if any) ...
  649. * @access public
  650. * @static
  651. */
  652. public static function getLeavesSummary($post_data, $tenant_id, $user_id = null) {
  653. /* $name = "leavesSummary_{$tenant_id}_all";
  654. $cache = Yii::app()->cache->get($name);
  655. if (isset($cache) && !empty($cache)) {
  656. return $cache;
  657. } else { */
  658.  
  659. $return = array();
  660. //$sr_no=1;
  661. $userleaves = array();
  662. $filter = $post_data['filter_id'];
  663. $users = UserMongo::model()->getUsersByFilter($filter, $tenant_id, $post_data['active_inactive']);
  664. $output = array();
  665. //$leaves = Leaves::model()->getLeaveList($tenant_id, $user_id);
  666. $leaves = Leaves::model()->getTenantLeaveListWithoutCompoff($tenant_id);
  667. /* removing compoff from the list */
  668. if (isset($leaves) && !empty($leaves)) {
  669. foreach ($leaves as $key => $leave) {
  670. if ($leave != "Compensatory Off") {
  671. $output_userleaves[$key] = $leave;
  672. }
  673. }
  674. $leaves = $output_userleaves;
  675. }
  676. /* removing compoff from the list */
  677. $index = 0;
  678. foreach ($users as $key => $user) {
  679. $user_name = $user['personal']['firstname'] . " " . $user['personal']['lastname'];
  680. $employee_number = (isset($user['personal']['employee_no'])) ? $user['personal']['employee_no'] : "N.A.";
  681. $user_post = $user->getCurrentPosition($tenant_id);
  682. $job_title = $user_post['designation'];
  683. $department = $user_post['department'];
  684. $business_unit = $user_post['business_unit'];
  685. $leaves_user_allowed = Leaves::model()->getLeaveListWithoutCompOff($tenant_id, $user->user_id);
  686. $action_checkbox = "<input type=\"checkbox\" name=\"roster_action\" value=\"\">";
  687. unset($userleaves);
  688. foreach ($leaves as $leave_id => $leave) {
  689. //$userleaves[] = LeavesHelper::individualLeaveBalance($user->user_id, $tenant_id, $leave_id);
  690. if (array_key_exists($leave_id, $leaves_user_allowed)) {
  691. $userleaves[] = LeavesHelper::individualLeaveBalance($user->user_id, $tenant_id, $leave_id);
  692. } else {
  693. $userleaves[] = array(
  694. 'leave_name' => 'NA',
  695. 'balance' => 'NA',
  696. 'total' => 'NA',
  697. 'prevBalance' => 'NA'
  698. );
  699. }
  700. }
  701.  
  702.  
  703. $output[] = array(
  704. // $action_checkbox,
  705. $employee_number,
  706. $user_name,
  707. );
  708. if (isset($userleaves)) {
  709. for ($i = 0; $i < count($userleaves); $i++) {
  710. for ($j = 0; $j < 3; $j++) {
  711. switch ($j) {
  712. case 0:
  713. $column = $userleaves[$i]['total'];
  714. break;
  715. case 1:
  716. if ($userleaves[$i]['total'] != "NA") {
  717. $column = $userleaves[$i]['total'] - $userleaves[$i]['balance'] + $userleaves[$i]['prevBalance'];
  718. } else {
  719. $column = "NA";
  720. }
  721. break;
  722. case 2:
  723. $column = $userleaves[$i]['balance'];
  724. break;
  725. }
  726. array_push($output[$index], $column);
  727. }
  728. //array_push($output[$index], $column);
  729. }
  730. }
  731. $index++;
  732. } // EOF foreach user
  733.  
  734.  
  735. $cols = array(
  736. // "<input type=\\\"checkbox\\\" name=\\\"roster_action\\\" value=\\\"\\\">",
  737. //'Sr No',
  738. 'Employee ID',
  739. 'Name',
  740. );
  741. foreach ($leaves as $leave_id => $leave_name) {
  742. for ($i = 0; $i < 3; $i++) {
  743. switch ($i) {
  744. case 0:
  745. $colname = $leave_name . "\\n(Credited)";
  746. break;
  747. case 1:
  748. $colname = $leave_name . "\\n(Taken)";
  749. break;
  750. case 2:
  751. $colname = $leave_name . "\\n(Balance)";
  752. break;
  753. }
  754. array_push($cols, $colname);
  755. }
  756. }
  757. $roster_type = "Leaves-Summary";
  758. $filenameexport = $roster_type;
  759. $final_output = array('output' => $output,
  760. 'cols' => $cols,
  761. 'filenameexport' => $filenameexport);
  762. // Yii::app()->cache->set($name, $final_output, 0);
  763. return $final_output;
  764. // }
  765. }
  766.  
  767. // EOF function
  768.  
  769. /**
  770. * Short description for function
  771. *
  772. * Long description (if any) ...
  773. *
  774. * @param array $post_data Parameter description (if any) ...
  775. * @param unknown $tenant_id Parameter description (if any) ...
  776. * @return array Return description (if any) ...
  777. * @access public
  778. * @static
  779. */
  780. public static function getBirthdayRoster($post_data, $tenant_id = null) {
  781. $return = array();
  782. $filter = $post_data['filter_id'];
  783. $users = UserMongo::model()->getUsersByFilter($filter, $tenant_id, $post_data['active_inactive']);
  784. $output = array();
  785. foreach ($users as $key => $user) {
  786. $user_name = $user['personal']['firstname'] . " " . $user['personal']['lastname'];
  787. $employee_number = (isset($user['personal']['employee_no'])) ? $user['personal']['employee_no'] : "N.A.";
  788. $user_post = $user->getCurrentPosition($tenant_id);
  789. $job_title = $user_post['designation'];
  790. $department = $user_post['department'];
  791. $business_unit = $user_post['business_unit'];
  792. if (isset($user['personal']['dob']->sec)) {
  793. $user_dob = date("Y-m-d", $user['personal']['dob']->sec);
  794. if (($timestamp = strtotime($user_dob)) !== false) {
  795. $php_date = getdate($timestamp);
  796. $dob_year = date("Y", $timestamp);
  797. $dob_month = date("M", $timestamp);
  798. $dob_day = date("d", $timestamp);
  799. $age = date("Y") - date("Y", $timestamp) . " y ";
  800. $age .= (date("m") > date("m", $timestamp)) ? date("m") - date("m", $timestamp) : date("m") - date("m", $timestamp) + 12;
  801. $age .= " m";
  802. $no_days_remain = self::days_till_birthday(date("d", $timestamp) . " " . date("M", $timestamp));
  803. }
  804. } else {
  805. $dob_year = "N.A.";
  806. $dob_month = "N.A.";
  807. $dob_day = "N.A.";
  808. $age = "N.A.";
  809. $no_days_remain = "N.A.";
  810. }
  811.  
  812. // $action_checkbox = "<input type=\"checkbox\" name=\"roster_action\" value=\"\">";
  813.  
  814. $output[] = array(
  815. // $action_checkbox,
  816. $employee_number,
  817. $user_name,
  818. $job_title,
  819. $department,
  820. $business_unit,
  821. $dob_day,
  822. $dob_month,
  823. $dob_year,
  824. $age,
  825. $no_days_remain,
  826. );
  827. } // EOF foreach
  828. // echo "<pre>"; print_r($output); exit("</pre> \n exited here ");
  829. $cols = array(
  830. // "<input type=\\\"checkbox\\\" name=\\\"roster_action\\\" value=\\\"\\\">",
  831. //'SR NO',
  832. 'Employee ID',
  833. 'Name',
  834. 'Job Title',
  835. 'Department',
  836. 'Business Unit',
  837. 'Day',
  838. 'Month',
  839. 'Year',
  840. 'Age',
  841. 'Days Remain'
  842. );
  843.  
  844. $filenameexport = "Birthday-Data";
  845. $final_output = array('output' => $output,
  846. 'cols' => $cols,
  847. 'filenameexport' => $filenameexport);
  848. return $final_output;
  849. }
  850.  
  851. // EOF function
  852.  
  853. /**
  854. * Short description for function
  855. *
  856. * Long description (if any) ...
  857. *
  858. * @param array $post_data Parameter description (if any) ...
  859. * @param unknown $tenant_id Parameter description (if any) ...
  860. * @return array Return description (if any) ...
  861. * @access public
  862. * @static
  863. */
  864. /*public static function getCustomRoster($post_data, $tenant_id = null) {
  865. //echo "<pre>"; print_r($post_data); exit("</pre> \n exited here");
  866. $fields_arrary = explode("|", $post_data['fields']);
  867. $return = array();
  868. $filter = $post_data['filter_id'];
  869. $users = UserMongo::model()->getUsersByFilter($filter, $tenant_id, $post_data['active_inactive']);
  870. $output = array();
  871. $idx = 0;
  872. foreach ($users as $key => $user) {
  873. // echo "<pre>"; print_r($user); exit("</pre> \n exited here ");
  874. foreach ($fields_arrary as $fields_key => $fields_value) {
  875. $a = array('');
  876. $a = explode("->", $fields_value);
  877. switch ($a[1]) {
  878. case 'cur_address':
  879. $cur_add = "";
  880. $cur_add .= (isset($user[$a[0]]['address'][0]['address'])) ? $user[$a[0]]['address'][0]['address'] : "";
  881. $cur_add .= (isset($user[$a[0]]['address'][0]['city'])) ? $user[$a[0]]['address'][0]['city'] : "";
  882. $cur_add .= (isset($user[$a[0]]['address'][0]['state'])) ? $user[$a[0]]['address'][0]['state'] : "";
  883. $op[$idx][] = $cur_add;
  884. break;
  885.  
  886. case 'additional_contact':
  887. $add_con = "";
  888. // echo "<pre>"; print_r($a); echo("</pre>");
  889. // echo "<pre>"; print_r($user['contact']['additional_contact']); exit("</pre> \n exited here ");
  890. foreach ($user['contact']['additional_contact'] as $key => $value) {
  891. if (isset($value)) {
  892. if ($value['type'] == $a[2]) {
  893. $add_con .= (isset($value['value'])) ? $value['value'] : "";
  894. $add_con .= ",";
  895. }
  896. }
  897. }
  898. $add_con = rtrim($add_con, ",");
  899. $op[$idx][] = $add_con;
  900. break;
  901.  
  902. case 'per_address':
  903. $per_add = "";
  904. $per_add .= (isset($user[$a[0]]['address'][0]['address'])) ? $user[$a[0]]['address'][0]['address'] : "";
  905. $per_add .= (isset($user[$a[0]]['address'][0]['city'])) ? $user[$a[0]]['address'][0]['city'] : "";
  906. $per_add .= (isset($user[$a[0]]['address'][0]['state'])) ? $user[$a[0]]['address'][0]['state'] : "";
  907. $op[$idx][] = $per_add;
  908. break;
  909.  
  910. case 'dob':
  911. $dob = (isset($user['personal']['dob']->sec)) ? date("d-M-Y", $user['personal']['dob']->sec) : "";
  912.  
  913. $op[$idx][] = $dob;
  914. break;
  915.  
  916. case 'gender':
  917. // echo "<pre>"; print_r($a); exit("</pre> \n exited here ");
  918. if (isset($user['personal']['gender'])) {
  919. switch ($user['personal']['gender']) {
  920. case 1:
  921. $gender = "Male";
  922. break;
  923. case 2:
  924. $gender = "Female";
  925. break;
  926. default:
  927. $gender = "";
  928. break;
  929. }
  930. } else {
  931. $gender = "";
  932. }
  933.  
  934. $op[$idx][] = $gender;
  935. break;
  936.  
  937. case 'marital_status':
  938. // echo "<pre>"; print_r($a); exit("</pre> \n exited here ");
  939. if (isset($user['personal']['marital_status'])) {
  940. switch ($user['personal']['marital_status']) {
  941. case 1:
  942. $marital_status = "Married";
  943. break;
  944. case 2:
  945. $marital_status = "Single";
  946. break;
  947. default:
  948. $marital_status = "";
  949. break;
  950. }
  951. } else {
  952. $marital_status = "";
  953. }
  954.  
  955. $op[$idx][] = $marital_status;
  956. break;
  957.  
  958. case 'anniversary_date':
  959. $anniversary_date = (isset($user['personal']['anniversary_date']->sec)) ? date("d-M-Y", $user['personal']['anniversary_date']->sec) : "";
  960.  
  961. $op[$idx][] = $anniversary_date;
  962. break;
  963.  
  964. case 'office_location':
  965. // echo "<pre>"; print_r($a); exit("</pre> \n exited here ");
  966. $tentaoffice_obj = TenantOffices::model()->findAllByAttributes(array('id' => $user[$a[0]][$a[1]]));
  967. if (isset($tentaoffice_obj) && !empty($tentaoffice_obj)) {
  968. $city = City::model()->findByPk($tentaoffice_obj[0]['city']);
  969. // echo "<pre>"; print_r($city); exit("</pre> \n exited here ");
  970. $office_location = (isset($city) && isset($city->name)) ? $city->name : "";
  971. } else {
  972. $office_location = "Not Found";
  973. }
  974.  
  975. $op[$idx][] = $office_location;
  976. break;
  977.  
  978. default:
  979. $op[$idx][] = $user[$a[0]][$a[1]];
  980. break;
  981. }
  982. }
  983.  
  984. $idx += 1;
  985. } // EOF foreach
  986. // echo "<pre>"; print_r($output); echo("</pre>");
  987. // echo "<pre>"; print_r($op[11]); exit("</pre> \n exited here ");
  988. $custom_roster_data = self::loadCustomRosterFilter();
  989. $cols = array(
  990. // "<input type=\\\"checkbox\\\" name=\\\"roster_action\\\" value=\\\"\\\">",
  991. );
  992.  
  993. $fields_arrary = explode("|", $post_data['fields']);
  994. $idx = 0;
  995. foreach ($fields_arrary as $fields_key => $fields_value) {
  996. $a = array('');
  997. $a = explode("->", $fields_value);
  998. if (isset($a[2])) {
  999. $colname = $custom_roster_data[$a[0]][$a[1]][$a[2]];
  1000. } else {
  1001.  
  1002. $colname = $custom_roster_data[$a[0]][$a[1]];
  1003. }
  1004.  
  1005. array_push($cols, $colname);
  1006. }
  1007. $filenameexport = "Custom Roster";
  1008. $final_output = array('output' => $op,
  1009. 'cols' => $cols,
  1010. 'filenameexport' => $filenameexport
  1011. );
  1012. return $final_output;
  1013. }
  1014.  
  1015. // EOF function Name month day list P A WO H L AdjL
  1016.  
  1017. /**
  1018. * Short description for function
  1019. *
  1020. * Long description (if any) ...
  1021. *
  1022. * @param array $post_data Parameter description (if any) ...
  1023. * @param unknown $tenant_id Parameter description (if any) ...
  1024. * @param unknown $from Parameter description (if any) ...
  1025. * @param unknown $to Parameter description (if any) ...
  1026. * @return array Return description (if any) ...
  1027. * @access public
  1028. * @static
  1029. */
  1030. public static function getCustomRoster($post_data, $tenant_id = null) {
  1031. $fields_arrary = explode("|", $post_data['fields']);
  1032. if(in_array("company->inactive", $fields_arrary)){
  1033. $post_data['active_inactive'] = 2;
  1034. if (($key = array_search('company->inactive', $fields_arrary)) !== false) {
  1035. unset($fields_arrary[$key]);
  1036. array_values($fields_arrary);
  1037. }
  1038. }
  1039. $return = array();
  1040. $filter = $post_data['filter_id'];
  1041. $tenant_id = Yii::app()->user->getTenantId();
  1042. $users = UserMongo::model()->getUsersByFilter($filter, $tenant_id, $post_data['active_inactive']);
  1043. $output = array();
  1044. $idx = 0;
  1045. foreach ($users as $key => $user) {
  1046. // echo "<pre>"; print_r($user); exit("</pre> \n exited here ");
  1047. foreach ($fields_arrary as $fields_key => $fields_value) {
  1048. $a = array('');
  1049. $a = explode("->", $fields_value);
  1050. switch ($a[1]) {
  1051. case 'cur_address':
  1052. $current = array();
  1053. $contact_details = $user->contact;
  1054. $current['address'] = (isset($contact_details['address'][0]['address']) && $contact_details['address'][0]['address'] != "") ? $contact_details['address'][0]['address'] : "";
  1055. $current['city'] = (isset($contact_details['address'][0]['city']) && $contact_details['address'][0]['city'] != "") ? City::getCityById($contact_details['address'][0]['city']) : "";
  1056. $current['state'] = (isset($contact_details['address'][0]['state']) && $contact_details['address'][0]['state'] != "") ? State::getStateById($contact_details['address'][0]['state']) : "";
  1057. $current['country'] = (isset($contact_details['address'][0]['country']) && $contact_details['address'][0]['country'] != "") ? Country::getCountryById($contact_details['address'][0]['country']) : "";
  1058. $current['pincode'] = (isset($contact_details['address'][0]['pincode']) && $contact_details['address'][0]['pincode'] != "") ? $contact_details['address'][0]['pincode'] : "";
  1059. $op[$idx][] = implode(", ", $current);
  1060. break;
  1061.  
  1062. case 'additional_contact':
  1063. $add_con = "";
  1064. foreach ($user['contact']['additional_contact'] as $key => $value) {
  1065. if (isset($value)) {
  1066. if ($value['type'] == $a[2]) {
  1067. $add_con .= (isset($value['value'])) ? $value['value'] : "";
  1068. $add_con .= ",";
  1069. }
  1070. }
  1071. }
  1072. $add_con = rtrim($add_con, ",");
  1073. $op[$idx][] = $add_con;
  1074. break;
  1075.  
  1076. case 'per_address':
  1077. $permanent = array();
  1078. $contact_details = $user->contact;
  1079. $permanent['address'] = (isset($contact_details['address'][1]['address']) && $contact_details['address'][1]['address'] != "") ? $contact_details['address'][1]['address'] : "";
  1080. $permanent['city'] = (isset($contact_details['address'][1]['city']) && $contact_details['address'][1]['city'] != "") ? City::getCityById($contact_details['address'][1]['city']) : "";
  1081. $permanent['state'] = (isset($contact_details['address'][1]['state']) && $contact_details['address'][1]['state'] != "") ? State::getStateById($contact_details['address'][1]['state']) : "";
  1082. $permanent['country'] = (isset($contact_details['address'][1]['country']) && $contact_details['address'][1]['country'] != "") ? Country::getCountryById($contact_details['address'][1]['country']) : "";
  1083. $permanent['pincode'] = (isset($contact_details['address'][1]['pincode']) && $contact_details['address'][1]['pincode'] != "") ? $contact_details['address'][1]['pincode'] : "";
  1084. $op[$idx][] = implode(", ", $permanent);
  1085. break;
  1086. case 'custom_fields':
  1087. $cus_field = "";
  1088.  
  1089. if (isset($user->personal->custom_fields[$a[2]]))
  1090. {
  1091. if ($user->personal->custom_fields[$a[2]] == "1")
  1092. {
  1093. $cus_field .= 'Yes';
  1094. }
  1095. else if ($user->personal->custom_fields[$a[2]] == "0" || $user->personal->custom_fields[$a[2]] == "")
  1096. {
  1097. $cus_field .= 'No';
  1098. }
  1099. else
  1100. {
  1101. $cus_field .= (is_array($user->personal->custom_fields[$a[2]])) ? implode(", ", $user->personal->custom_fields[$a[2]]) : $user->personal->custom_fields[$a[2]];
  1102. }
  1103. }
  1104. else
  1105. {
  1106. if (isset($user->payroll_profile->custom_fields[$a[2]]))
  1107. {
  1108. if ($user->payroll_profile->custom_fields[$a[2]] == "1")
  1109. {
  1110. $cus_field .= "Yes";
  1111. } else {
  1112. $cus_field .= "No";
  1113. }
  1114. } else {
  1115. $cus_field .= "No";
  1116. }
  1117. }
  1118.  
  1119. $op[$idx][] = $cus_field;
  1120. break;
  1121.  
  1122. case 'dob':
  1123. $dob = (isset($user['personal']['dob']->sec)) ? date("d-M-Y", $user['personal']['dob']->sec) : "";
  1124. $op[$idx][] = $dob;
  1125. break;
  1126.  
  1127. case 'deactivate_date':
  1128. $deactivate_date = (isset($user['deactivate_date']->sec)) ? date("d-M-Y", $user['deactivate_date']->sec) : "";
  1129. $op[$idx][] = $deactivate_date;
  1130. break;
  1131.  
  1132. case 'manager':
  1133. $direct_manager = (isset($user->manager_id) && $user->manager_id != "") ? UserMongo::getFullnameById($user->manager_id) : "No Direct Manager";
  1134. $op[$idx][] = $direct_manager;
  1135. break;
  1136.  
  1137. case 'dotted_manager':
  1138. $dotted_line_manager = (isset($user->dotted_line_manager) && $user->dotted_line_manager != "") ? UserMongo::getFullnameById($user->dotted_line_manager) : "No Dotted Manager";
  1139. $op[$idx][] = $dotted_line_manager;
  1140. break;
  1141.  
  1142. case 'emp_type':
  1143. $emp_type = (isset($user['personal']['type'])) ? TenantUserTypes::getTypesNameById($user['personal']['type']) : "";
  1144. $op[$idx][] = $emp_type;
  1145. break;
  1146.  
  1147. case 'probation':
  1148. $probation = (isset($user->probation_period)) ? ProbationPeriod::getProbationNameById($user->probation_period) : "";
  1149. $op[$idx][] = $probation;
  1150. break;
  1151.  
  1152. case 'emp_id':
  1153. $emp_id = (isset($user['personal']['employee_no'])) ? $user['personal']['employee_no'] : "";
  1154. $op[$idx][] = $emp_id;
  1155. break;
  1156.  
  1157. case 'confirmation':
  1158. //Date of confirmation
  1159. if(isset($user->date_of_confirmation) && $user->date_of_confirmation != ""){
  1160. $date_confirmation = (isset($user->date_of_confirmation->sec)) ? date('d-m-Y',$user->date_of_confirmation->sec) : $user->date_of_confirmation;
  1161. } else {
  1162. if(isset($user->doj->sec,$user->probation_period) && $user->probation_period != "")
  1163. {
  1164. $prb = ProbationPeriod::model()->tenant()->findByPk($user->probation_period);
  1165. if(isset($prb) && !empty($prb))
  1166. {
  1167. $number_of_days = $prb->number_of_days + 1;
  1168. $date = strtotime(date("Y-m-d", $user->doj->sec) . " +".$number_of_days ."days");
  1169. $date_confirmation = date('d-m-Y' ,$date);
  1170. }
  1171. }
  1172. else{
  1173. $date_confirmation = (isset($user->doj->sec)) ? date('d-m-Y',$user->doj->sec) : "";
  1174. }
  1175. }
  1176. $op[$idx][] = $date_confirmation;
  1177. break;
  1178.  
  1179. case 'pf_number':
  1180. $pf_number = (isset($user->pf_number)) ? $user->pf_number : "";
  1181. $op[$idx][] = $pf_number;
  1182. break;
  1183.  
  1184. case 'esic_number':
  1185. $esic_number = (isset($user->esic_number)) ? $user->esic_number : "";
  1186. $op[$idx][] = $esic_number;
  1187. break;
  1188.  
  1189. case 'uan_number':
  1190. $uan_number = (isset($user->uan_number)) ? $user->uan_number : "";
  1191. $op[$idx][] = $uan_number;
  1192. break;
  1193.  
  1194. case 'emergency_contact_person':
  1195. $emergency_contact_person = (isset($user->emergency_contact_person)) ? $user->emergency_contact_person : "";
  1196. $op[$idx][] = $emergency_contact_person;
  1197. break;
  1198.  
  1199. case 'emergency_contact_number':
  1200. $emergency_contact_number = (isset($user->emergency_contact_number)) ? $user->emergency_contact_number : "";
  1201. $op[$idx][] = $emergency_contact_number;
  1202. break;
  1203.  
  1204. case 'ctc':
  1205. $ctc_data = Ctc::model()->tenant($user->tenant_id)->user($user->id)->find();
  1206. if(isset($ctc_data) && !empty($ctc_data)){
  1207. $ctc = $ctc_data->getCtc();
  1208. }else{
  1209. $ctc = "N.A.";
  1210. }
  1211. $op[$idx][] = $ctc;
  1212. break;
  1213.  
  1214. case 'email':
  1215. $email = "";
  1216. $user_sql_data = User::model()->tenant()->findByPk($user->user_id);
  1217. if(isset($user_sql_data) && !empty($user_sql_data)){
  1218. $email = (isset($user_sql_data->selfservice) && $user_sql_data->selfservice == User::EMPLOYEE_SELFSERVICE_YES) ? $user_sql_data->email : "";
  1219. }
  1220. $op[$idx][] = $email;
  1221. break;
  1222.  
  1223. case 'gender':
  1224. // echo "<pre>"; print_r($a); exit("</pre> \n exited here ");
  1225. if (isset($user['personal']['gender'])) {
  1226. switch ($user['personal']['gender']) {
  1227. case 1:
  1228. $gender = "Male";
  1229. break;
  1230. case 2:
  1231. $gender = "Female";
  1232. break;
  1233. default:
  1234. $gender = "";
  1235. break;
  1236. }
  1237. } else {
  1238. $gender = "";
  1239. }
  1240.  
  1241. $op[$idx][] = $gender;
  1242. break;
  1243.  
  1244. case 'marital_status':
  1245. // echo "<pre>"; print_r($a); exit("</pre> \n exited here ");
  1246. if (isset($user['personal']['marital_status'])) {
  1247. switch ($user['personal']['marital_status']) {
  1248. case 1:
  1249. $marital_status = "Married";
  1250. break;
  1251. case 2:
  1252. $marital_status = "Single";
  1253. break;
  1254. default:
  1255. $marital_status = "";
  1256. break;
  1257. }
  1258. } else {
  1259. $marital_status = "";
  1260. }
  1261.  
  1262. $op[$idx][] = $marital_status;
  1263. break;
  1264.  
  1265. case 'anniversary_date':
  1266. $anniversary_date = (isset($user['personal']['anniversary_date']->sec)) ? date("d-M-Y", $user['personal']['anniversary_date']->sec) : "";
  1267.  
  1268. $op[$idx][] = $anniversary_date;
  1269. break;
  1270.  
  1271. case 'doj':
  1272. $doj = (isset($user['doj']->sec)) ? date("d-M-Y", $user['doj']->sec) : "";
  1273. $op[$idx][] = $doj;
  1274. break;
  1275.  
  1276. case 'department':
  1277. $user_post = $user->getCurrentPosition($tenant_id);
  1278. $department = (isset($user_post['department']) && $user_post['department'] != "") ? $user_post['department'] : "N.A.";
  1279. $op[$idx][] = $department;
  1280. break;
  1281.  
  1282. case 'designation':
  1283. $user_post = $user->getCurrentPosition($tenant_id);
  1284. $job_title = (isset($user_post['designation']) && $user_post['designation'] != "") ? $user_post['designation'] : "N.A.";
  1285. $op[$idx][] = $job_title;
  1286. break;
  1287.  
  1288. case 'tenure':
  1289. $diff_cur_work = self::calculate_experience(time(), $user->doj->sec);
  1290. $total_cur_y = $diff_cur_work['Years'];
  1291. $total_cur_m = $diff_cur_work['Months'];
  1292. $cur_work_ex = $total_cur_y . "y " . $total_cur_m . "m";
  1293. $op[$idx][] = $cur_work_ex;
  1294. break;
  1295.  
  1296. case 'dependents':
  1297. if (isset($user['dependents']) && !empty($user['dependents'])) {
  1298. $user_dependent = "";
  1299. foreach ($user['dependents'] as $key => $dependents) {
  1300. $dep_name = (isset($dependents['first_name'],$dependents['last_name'])) ? ucfirst($dependents['first_name'])." ".$dependents['last_name'] ." - " : "N.A.";
  1301. $dep_relation = (isset($dependents['relation_type'])) ? $dependents['relation_type'] ." - " : "N.A.";
  1302. $get_dep_age = (isset($dependents['dob']->sec)) ? self::calculate_experience(time(), $dependents['dob']->sec) : "N.A.";
  1303. $age_dep = (isset($get_dep_age) && $get_dep_age != "N.A.") ? $get_dep_age['Years']."y ".$get_dep_age['Months']."m" : "N.A.";
  1304. if(isset($dep_name) && $dep_name != "N.A."){
  1305. $user_dependent = (isset($user_dependent) && $user_dependent != "") ? $user_dependent . "<br/>". $dep_name ." ". $dep_relation ." ". $age_dep : $dep_name ." ". $dep_relation ." ". $age_dep;
  1306. }
  1307. }
  1308. } else {
  1309. $user_dependent = "N.A.";
  1310. }
  1311. $op[$idx][] = $user_dependent;
  1312. break;
  1313.  
  1314. case 'band':
  1315. $user_post = $user->getCurrentPosition($tenant_id);
  1316. $band = (isset($user_post['band']) && $user_post['band'] != "") ? $user_post['band'] : "N.A.";
  1317. $op[$idx][] = $band;
  1318. break;
  1319.  
  1320. case 'grade':
  1321. $user_post = $user->getCurrentPosition($tenant_id);
  1322. $grade = (isset($user_post['grade']) && $user_post['grade'] != "") ? $user_post['grade'] : "N.A.";
  1323. $op[$idx][] = $grade;
  1324. break;
  1325.  
  1326. case 'business_unit':
  1327. $user_post = $user->getCurrentPosition($tenant_id);
  1328. $business_unit = (isset($user_post['business_unit']) && $user_post['business_unit'] != "") ? $user_post['business_unit'] : "N.A.";
  1329. $op[$idx][] = $business_unit;
  1330. break;
  1331.  
  1332. case 'parent_company_id':
  1333. $company_name = SubTenantProfile::getGroupCompanyNameId($user->getIsSubCompany());
  1334. $parent_company = (isset($company_name) && $company_name != "") ? $company_name : "N.A.";
  1335. $op[$idx][] = $parent_company;
  1336. break;
  1337.  
  1338. case 'office_location':
  1339. if (isset($user->personal->office_location) && !empty($user->personal->office_location)) {
  1340. $office_location = TenantOffices::getTenantOfficeLocationsNameWithCountryById($user->personal->office_location);
  1341. } else {
  1342. $office_location = "NA";
  1343. }
  1344. $op[$idx][] = $office_location;
  1345. break;
  1346.  
  1347. case 'office_area':
  1348. if (isset($user->personal->office_location) && !empty($user->personal->office_location)) {
  1349. $office_location_area = TenantOffices::getTenantOfficeLocationsArea($user->personal->office_location);
  1350. } else {
  1351. $office_location_area = "NA";
  1352. }
  1353. $op[$idx][] = $office_location_area;
  1354. break;
  1355. case 'office_city':
  1356. if (isset($user->personal->office_location) && !empty($user->personal->office_location)) {
  1357. $office_location_city = TenantOffices::getTenantOfficeLocationsCity($user->personal->office_location);
  1358. } else {
  1359. $office_location_city = "NA";
  1360. }
  1361. $op[$idx][] = $office_location_city;
  1362. break;
  1363. case 'office_state':
  1364. if (isset($user->personal->office_location) && !empty($user->personal->office_location)) {
  1365. $office_location_state = TenantOffices::getTenantOfficeLocationsState($user->personal->office_location);
  1366. } else {
  1367. $office_location_state = "NA";
  1368. }
  1369. $op[$idx][] = $office_location_state;
  1370. break;
  1371. case 'office_country':
  1372. if (isset($user->personal->office_location) && !empty($user->personal->office_location)) {
  1373. $office_location_country = TenantOffices::getTenantOfficeLocationsCountry($user->personal->office_location);
  1374. } else {
  1375. $office_location_country = "NA";
  1376. }
  1377. $op[$idx][] = $office_location_country;
  1378. break;
  1379. case 'shift':
  1380. $shift_name = "";
  1381. $timestamp = time();
  1382. $user_shift_planner = UserShiftPlanner::getUserShift($user->id, $timestamp, null, 1);
  1383. if(isset($user_shift_planner) && !empty($user_shift_planner)){
  1384. $tenant_shift = TenantShift::getTenantShift($user_shift_planner['shift_id'],$user->tenant_id);
  1385. if(isset($tenant_shift) && !empty($tenant_shift)){
  1386. $shift_name = $tenant_shift->shift_name . " (". AttendanceHelper::getFormatedTime($tenant_shift->begin_time) ."-". AttendanceHelper::getFormatedTime($tenant_shift->end_time).")";
  1387. }
  1388. }
  1389. $op[$idx][] = $shift_name;
  1390. break;
  1391. case 'policy':
  1392. $policy_name = "";
  1393. $timestamp = time();
  1394. $user_shift_planner = UserShiftPlanner::getUserShift($user->id, $timestamp, null, 1);
  1395. if(isset($user_shift_planner) && !empty($user_shift_planner)){
  1396. $attendance_policy = AttendancePolicy::getAttendancePolicy($user_shift_planner['policy_id'],$user->tenant_id);
  1397. if(isset($attendance_policy) && !empty($attendance_policy)){
  1398. $policy_name = $attendance_policy->policy_name;
  1399. }
  1400. }
  1401. $op[$idx][] = $policy_name;
  1402. break;
  1403. case 'weeklyoff':
  1404. $weeklyoff = "";
  1405. $timestamp = time();
  1406. $user_shift_planner = UserShiftPlanner::getUserShift($user->id, $timestamp, null, 1);
  1407. if(isset($user_shift_planner) && !empty($user_shift_planner)){
  1408. $user_weekly_off = WeeklyOff::getWeeklyOff($user_shift_planner['weekly_off_id'],$user->tenant_id);
  1409. if(isset($user_weekly_off) && !empty($user_weekly_off)){
  1410. $non_working_days = $user_weekly_off->getNonWorkingDays();
  1411. $weeklyoff = $user_weekly_off->weekly_off_name . " (". $non_working_days.")";
  1412. }
  1413. }
  1414. $op[$idx][] = $weeklyoff;
  1415. break;
  1416. case 'location_type':
  1417. $tentaoffice_obj_typ = TenantOffices::model()->findByAttributes(array('id' => $user->personal->office_location));
  1418. if (isset($tentaoffice_obj_typ) && !empty($tentaoffice_obj_typ)) {
  1419. $type_loc = (isset($tentaoffice_obj_typ->location_type) && $tentaoffice_obj_typ->location_type != "") ? '('. TenantLocationTypes::getTypesNameById($tentaoffice_obj_typ->location_type).')' :"";
  1420. $office_location_type = $type_loc;
  1421. } else {
  1422. $office_location_type = "";
  1423. }
  1424. $op[$idx][] = $office_location_type;
  1425. break;
  1426.  
  1427. default:
  1428. $op[$idx][] = $user[$a[0]][$a[1]];
  1429. break;
  1430. }
  1431. }
  1432.  
  1433. $idx += 1;
  1434. } // EOF foreach
  1435. // echo "<pre>"; print_r($output); echo("</pre>");
  1436. // echo "<pre>"; print_r($op[11]); exit("</pre> \n exited here ");
  1437. $custom_roster_data = self::loadCustomRosterFilter();
  1438. $cols = array(
  1439. // "<input type=\\\"checkbox\\\" name=\\\"roster_action\\\" value=\\\"\\\">",
  1440. );
  1441.  
  1442. $fields_arrary = explode("|", $post_data['fields']);
  1443. if (($key = array_search('company->inactive', $fields_arrary)) !== false) {
  1444. unset($fields_arrary[$key]);
  1445. array_values($fields_arrary);
  1446. }
  1447. $idx = 0;
  1448. foreach ($fields_arrary as $fields_key => $fields_value) {
  1449. $a = array('');
  1450. $a = explode("->", $fields_value);
  1451. if (isset($a[2])) {
  1452. $colname = $custom_roster_data[$a[0]][$a[1]][$a[2]];
  1453. } else {
  1454.  
  1455. $colname = $custom_roster_data[$a[0]][$a[1]];
  1456. }
  1457.  
  1458. array_push($cols, $colname);
  1459. }
  1460. $filenameexport = "Custom Roster";
  1461. $final_output = array('output' => $op,
  1462. 'cols' => $cols,
  1463. 'filenameexport' => $filenameexport
  1464. );
  1465. // echo '<pre>';
  1466. // print_r($final_output); exit;
  1467. return $final_output;
  1468. }
  1469.  
  1470. // EOF function Name month day list P A WO H L AdjL
  1471.  
  1472. /**
  1473. * Short description for function
  1474. *
  1475. * Long description (if any) ...
  1476. *
  1477. * @param array $post_data Parameter description (if any) ...
  1478. * @param unknown $tenant_id Parameter description (if any) ...
  1479. * @param unknown $from Parameter description (if any) ...
  1480. * @param unknown $to Parameter description (if any) ...
  1481. * @return array Return description (if any) ...
  1482. * @access public
  1483. * @static
  1484. */
  1485. public static function getAttendanceSummaryRoster($post_data, $tenant_id = null, $from = null, $to = null) {
  1486. $return = array();
  1487. $index = 0;
  1488. $output = array();
  1489. $finaldata = array();
  1490.  
  1491. $filter = $post_data['filter_id'];
  1492. $users = UserMongo::model()->getUsersByFilter($filter, $tenant_id, $post_data['active_inactive']);
  1493.  
  1494. $begin = new DateTime($from);
  1495. $end = new DateTime($to);
  1496. $end = $end->modify('+1 day');
  1497. $interval = new DateInterval('P1D');
  1498. $daterange = new DatePeriod($begin, $interval, $end);
  1499. $from = strtotime($from);
  1500. $to = strtotime($to);
  1501.  
  1502. $criteria = new EMongoCriteria();
  1503. $criteria->shift_date('>=', new MongoDate($from));
  1504. $criteria->shift_date('<=', new MongoDate($to));
  1505.  
  1506. foreach ($users as $key => $user) {
  1507. $user_name = $user['personal']['firstname'] . " " . $user['personal']['lastname'];
  1508. $employee_number = (isset($user['personal']['employee_no'])) ? $user['personal']['employee_no'] : "N.A.";
  1509. $criteria->user_id = $user->id;
  1510. $userAttendanceLogsold = UserAttendanceLog::model()->tenant($tenant_id)->findAll($criteria);
  1511. if(isset($userAttendanceLogsold) && !empty($userAttendanceLogsold)){
  1512. foreach ($userAttendanceLogsold as $key_each => $value_each) {
  1513. if(isset($value_each->shift_date->sec)){
  1514. $date_each = date("d", $value_each->shift_date->sec);
  1515. $userAttendanceLogs[$date_each] = $value_each;
  1516. }
  1517. }
  1518. }
  1519. // echo "<pre>"; print_r($userAttendanceLogs); exit("</pre> \n exited here \n");
  1520. $present = 0;
  1521. $absent = 0;
  1522. $weeklyoff_count = 0;
  1523. $holiday_count = 0;
  1524. $leave_count = 0;
  1525. $unpaidleave_count = 0;
  1526. $return = array();
  1527. $output[] = array(
  1528. $employee_number,
  1529. $user_name,
  1530. );
  1531. $jindex = 0;
  1532. foreach ($daterange as $date) {
  1533. $yindex = $date->format("d");
  1534. $unpaidFlag = false;
  1535. if (isset($userAttendanceLogs[$yindex])) {
  1536. if ($date->format("d") == date("d", $userAttendanceLogs[$yindex]->shift_date->sec)) {
  1537. $date = date("d", $userAttendanceLogs[$yindex]->shift_date->sec);
  1538. if (isset($userAttendanceLogs[$yindex]->attendance_status)) {
  1539. $status = $userAttendanceLogs[$yindex]->attendance_status;
  1540.  
  1541. if ($status == UserAttendance::ATTENDANCE_STATUS_ABSENT)
  1542. {
  1543. $checkBothClockInClockOut = false;
  1544. $checkOnlyClockIn = false;
  1545. // Get policy_id to check policy for markin / markout / markboth
  1546. $shift_planner_id = $userAttendanceLogs[$yindex]->shift_planner;
  1547. // Get shift planner
  1548. $useShiftPlanner = UserShiftPlanner::model()->user($user->id)->findByPk($shift_planner_id);
  1549. if (!empty($useShiftPlanner))
  1550. {
  1551. $policy_id = $useShiftPlanner->policy_id;
  1552. }
  1553. else
  1554. {
  1555. $policy_id = "";
  1556. }
  1557.  
  1558. // Get user policy using policy Id.
  1559. $attendancePolicy = AttendancePolicy::getAttendancePolicy($policy_id, $tenant_id);
  1560. if (!empty($attendancePolicy))
  1561. {
  1562. if ($attendancePolicy->markin_policy->status == MarkinPolicy::MARKIN_BOTH)
  1563. {
  1564. $checkBothClockInClockOut = true;
  1565. $checkOnlyClockIn = false;
  1566. }
  1567. else if ($attendancePolicy->markin_policy->status == MarkinPolicy::MARKIN_IN)
  1568. {
  1569. $checkBothClockInClockOut = false;
  1570. $checkOnlyClockIn = true;
  1571. }
  1572. }
  1573.  
  1574. if ($checkBothClockInClockOut)
  1575. {
  1576. if(($userAttendanceLogs[$yindex]->punchin_time != '') && ($userAttendanceLogs[$yindex]->punchout_time != ''))
  1577. {
  1578. $status = UserAttendanceLog::ATTENDANCE_STATUS_PRESENT;
  1579. }
  1580. else
  1581. {
  1582. $status = UserAttendanceLog::ATTENDANCE_STATUS_ABSENT;
  1583. }
  1584. }
  1585. else if ($checkOnlyClockIn)
  1586. {
  1587. if(($userAttendanceLogs[$yindex]->punchin_time != ''))
  1588. {
  1589. $status = UserAttendanceLog::ATTENDANCE_STATUS_PRESENT;
  1590. }
  1591. else
  1592. {
  1593. $status = UserAttendanceLog::ATTENDANCE_STATUS_ABSENT;
  1594. }
  1595. }
  1596. else
  1597. {
  1598. $status = UserAttendanceLog::ATTENDANCE_STATUS_ABSENT;
  1599. }
  1600. }
  1601. elseif ($status == UserAttendance::ATTENDANCE_STATUS_PRESENT)
  1602. {
  1603. $status = UserAttendanceLog::ATTENDANCE_STATUS_PRESENT;
  1604. }
  1605. // ***************************** <END> *****************************
  1606.  
  1607. /*
  1608. // OLD CODE Commented
  1609. if ($status == UserAttendance::ATTENDANCE_STATUS_ABSENT) {
  1610. $status = UserAttendanceLog::ATTENDANCE_STATUS_ABSENT;
  1611. } elseif ($status == UserAttendance::ATTENDANCE_STATUS_PRESENT) {
  1612. $status = UserAttendanceLog::ATTENDANCE_STATUS_PRESENT;
  1613. }
  1614. */
  1615.  
  1616. $weeklyoff = $userAttendanceLogs[$yindex]->is_weekly_off->status;
  1617. $holiday = $userAttendanceLogs[$yindex]->is_holiday->status;
  1618. $leave = $userAttendanceLogs[$yindex]->in_leave->status;
  1619. $leave_revoked = false;
  1620. if (isset($userAttendanceLogs[$yindex]->in_leave->leave_id)) {
  1621. $unpaidLeave = UserLeaves::model()->findByPk($userAttendanceLogs[$yindex]->in_leave->leave_id);
  1622. if ($unpaidLeave->isUnpaid == UserLeaves::LEAVE_UNPAID) {
  1623. $unpaidleave_count++;
  1624. $unpaidFlag = true;
  1625. } else {
  1626. $unpaidFlag = false;
  1627. }
  1628. if ($unpaidLeave->status == UserLeaves::STATUS_REVOKED || $unpaidLeave->status == UserLeaves::STATUS_REJECTED)
  1629. {
  1630. $leave_revoked = true;
  1631. }
  1632. } else {
  1633. $unpaidFlag = false;
  1634. }
  1635. if (isset($weeklyoff) && $weeklyoff == "1") {
  1636. $status = "W";
  1637. $weeklyoff_count++;
  1638. } elseif (isset($holiday) && $holiday == "1") {
  1639. $status = "H";
  1640. $holiday_count++;
  1641. } elseif ((isset($leave)) && ($leave == "1") && ($leave_revoked == false)) {
  1642. $status = "<font color = #0033FF><b>L</b></font>";
  1643. $leave_count++;
  1644. } elseif ($status == UserAttendanceLog::ATTENDANCE_STATUS_PRESENT || $status == UserAttendanceLog::ATTENDANCE_STATUS_PENDING) {
  1645. $status = "<font color = #009900><b>P</b></font>";
  1646. $present++;
  1647. } /* elseif ($status == UserAttendanceLog::ATTENDANCE_STATUS_PENDING) {
  1648. $status = "n";
  1649. } */ elseif ($status == UserAttendanceLog::ATTENDANCE_STATUS_ABSENT || $status == UserAttendance::ATTENDANCE_STATUS_ABSENT) {
  1650. $status = "<font color = #FF0000><b>A</b></font>";
  1651. $absent++;
  1652. } else {
  1653. $status = "";
  1654. }
  1655. } else {
  1656. $status = "";
  1657. }
  1658. $jindex++;
  1659. } else {
  1660. $status = "-";
  1661. }
  1662. } else {
  1663. $status = "-";
  1664. }
  1665. if ($unpaidFlag) {
  1666. $status = "U";
  1667. }
  1668. array_push($output[$index], $status);
  1669. } // my good loop
  1670.  
  1671. array_push($output[$index], $present);
  1672. array_push($output[$index], $absent);
  1673. array_push($output[$index], $weeklyoff_count);
  1674. array_push($output[$index], $leave_count);
  1675. array_push($output[$index], $unpaidleave_count);
  1676. $index++;
  1677. } // EOF foreach all user
  1678.  
  1679. $flag = true;
  1680. $cols = array(
  1681. // 'Name||Column displays the Name of the employees.'
  1682. 'Employee ID',
  1683. 'Name||Column displays the Name of the employees.'
  1684. );
  1685.  
  1686. foreach ($daterange as $date) {
  1687. $finaldatacols = $date->format("d") . "<br>" . substr((String) $date->format("D"), 0, 2);
  1688. array_push($cols, $finaldatacols);
  1689. }
  1690.  
  1691. array_push($cols, 'P||Column displays the total number days when an employee was Present in the specified duration.');
  1692. array_push($cols, 'A||Column displays the total number of days when an employee was Absent in the specified duration.');
  1693. array_push($cols, 'W||Column displays the total number of Weekly Offs assigned to an employee in the specified duration.');
  1694. array_push($cols, 'L||Column displays the total number of days when an employee was on a Leave in the specified duration.');
  1695. array_push($cols, 'U||Column displays the total number of days when an employee was on a Unpaid Leave in the specified duration.');
  1696.  
  1697. $roster_type = "Attendance-Summary";
  1698. $date = date('d-m-Y', $from) . "-to-" . date('d-m-Y', $to);
  1699. $filenameexport = $roster_type . "_" . $date;
  1700. $final_output = array('output' => $output,
  1701. 'cols' => $cols,
  1702. 'filenameexport' => $filenameexport);
  1703. return $final_output;
  1704. }
  1705.  
  1706. // EOF function
  1707.  
  1708. /**
  1709. * Short description for function
  1710. *
  1711. * Long description (if any) ...
  1712. *
  1713. * @param array $post_data Parameter description (if any) ...
  1714. * @param unknown $tenant_id Parameter description (if any) ...
  1715. * @param unknown $from Parameter description (if any) ...
  1716. * @param unknown $to Parameter description (if any) ...
  1717. * @return array Return description (if any) ...
  1718. * @access public
  1719. * @static
  1720. */
  1721. public static function getAbsenteesSummaryRoster($post_data, $tenant_id = null, $from = null, $to = null) {
  1722. $return = array();
  1723. $index = 0;
  1724. $filter = $post_data['filter_id'];
  1725. $users = UserMongo::model()->getUsersByFilter($filter, $tenant_id, $post_data['active_inactive']);
  1726. $output = array();
  1727. $finaldata = array();
  1728. $begin = new DateTime($from);
  1729. $end = new DateTime($to);
  1730. $end = $end->modify('+1 day');
  1731. $interval = new DateInterval('P1D');
  1732. $daterange = new DatePeriod($begin, $interval, $end);
  1733. $from = strtotime($from);
  1734. $to = strtotime($to);
  1735. $criteria = new EMongoCriteria();
  1736. $criteria->shift_date('>=', new MongoDate($from));
  1737. $criteria->shift_date('<=', new MongoDate($to));
  1738. foreach ($users as $key => $user) {
  1739. $user_name = $user['personal']['firstname'] . " " . $user['personal']['lastname'];
  1740. $employee_number = (isset($user['personal']['employee_no'])) ? $user['personal']['employee_no'] : "N.A.";
  1741. $user_post = $user->getCurrentPosition($tenant_id);
  1742. $job_title = $user_post['designation'];
  1743. $department = $user_post['department'];
  1744. $business_unit = $user_post['business_unit'];
  1745. $criteria->user_id = $user->id;
  1746. $userAttendanceLogs = UserAttendanceLog::model()->tenant($tenant_id)->findAll($criteria);
  1747. $present = 0;
  1748. $absent = 0;
  1749. $weeklyoff_count = 0;
  1750. $holiday_count = 0;
  1751. $leave_count = 0;
  1752. $counter_var = 0;
  1753. $present_count = 0;
  1754. $return = array();
  1755. $output[] = array(
  1756. $employee_number,
  1757. $user_name,
  1758. $job_title,
  1759. $department,
  1760. );
  1761.  
  1762. foreach ($userAttendanceLogs as $key => $userAttendance) {
  1763. if (!empty($userAttendance)) {
  1764. $status = $userAttendance->attendance_status;
  1765. if ($status == UserAttendance::ATTENDANCE_STATUS_ABSENT) {
  1766. $status = UserAttendanceLog::ATTENDANCE_STATUS_ABSENT;
  1767. } elseif ($status == UserAttendance::ATTENDANCE_STATUS_PRESENT) {
  1768. $status = UserAttendanceLog::ATTENDANCE_STATUS_PRESENT;
  1769. }
  1770. if ($status == UserAttendanceLog::ATTENDANCE_STATUS_ABSENT) {
  1771. $weeklyoff = $userAttendance->is_weekly_off->status;
  1772. $leave = $userAttendance->in_leave->status;
  1773. $holiday = $userAttendance->is_holiday->status;
  1774. if (is_null($weeklyoff) || $weeklyoff == IsWeeklyOff::WEEKLYOFF_YES) {
  1775. continue;
  1776. } elseif (is_null($leave) || $leave == InLeave::INLEAVE_YES) {
  1777. continue;
  1778. } elseif (is_null($holiday) || $holiday == IsHoliday::HOLIDAY_YES) {
  1779. continue;
  1780. } else {
  1781. $absent++;
  1782. }
  1783. } // EOF abset status if
  1784. } // EOF !empty if
  1785. } // EOF userattendance foreach
  1786. array_push($output[$index++], $absent);
  1787. } // EOF foreach all user
  1788. $flag = true;
  1789. $cols = array(
  1790. 'Employee ID',
  1791. 'Name||Column displays the Name of the employees.',
  1792. 'Job Title||Column displays the Job Tittle of the particular employee.',
  1793. 'Department||Column displays the Department to which the employee belongs.',
  1794. 'Absent Count||Column displays the total number of days when an employee was Absent in the specified duration.',
  1795. );
  1796. $roster_type = "Absentees-Summary";
  1797. $date = date('d-m-Y', $from) . "-to-" . date('d-m-Y', $to);
  1798. $filenameexport = $roster_type . "_" . $date;
  1799. $final_output = array('output' => $output,
  1800. 'cols' => $cols,
  1801. 'filenameexport' => $filenameexport);
  1802. return $final_output;
  1803. }
  1804.  
  1805. // EOF function
  1806.  
  1807. /**
  1808. * Short description for function
  1809. *
  1810. * Long description (if any) ...
  1811. *
  1812. * @param array $post_data Parameter description (if any) ...
  1813. * @param unknown $tenant_id Parameter description (if any) ...
  1814. * @param unknown $from Parameter description (if any) ...
  1815. * @param unknown $to Parameter description (if any) ...
  1816. * @return array Return description (if any) ...
  1817. * @access public
  1818. * @static
  1819. */
  1820. public static function getAttendanceLocationSummaryRoster($post_data, $tenant_id = null, $from = null, $to = null) {
  1821. $return = array();
  1822. $index = 0;
  1823. $filter = $post_data['filter_id'];
  1824. $users = UserMongo::model()->getUsersByFilter($filter, $tenant_id, $post_data['active_inactive']);
  1825. $output = array();
  1826. $finaldata = array();
  1827. $begin = new DateTime($from);
  1828. $end = new DateTime($to);
  1829. $end = $end->modify('+1 day');
  1830. $interval = new DateInterval('P1D');
  1831. $daterange = new DatePeriod($begin, $interval, $end);
  1832. $from = strtotime($from);
  1833. $to = strtotime($to);
  1834. $criteria = new EMongoCriteria();
  1835. $criteria->shift_date('>=', new MongoDate($from));
  1836. $criteria->shift_date('<=', new MongoDate($to));
  1837. foreach ($users as $key => $user) {
  1838. $user_name = $user['personal']['firstname'] . " " . $user['personal']['lastname'];
  1839. $employee_number = (isset($user['personal']['employee_no'])) ? $user['personal']['employee_no'] : "N.A.";
  1840. $user_post = $user->getCurrentPosition($tenant_id);
  1841. $job_title = $user_post['designation'];
  1842. $department = $user_post['department'];
  1843. $business_unit = $user_post['business_unit'];
  1844. $criteria->user_id = $user->id;
  1845. $UserAttendanceLogs = UserAttendanceLog::model()->tenant($tenant_id)->findAll($criteria);
  1846. $office = 0;
  1847. $home = 0;
  1848. $out = 0;
  1849. $return = array();
  1850. $output[] = array(
  1851. $employee_number,
  1852. $user_name,
  1853. $job_title,
  1854. $department,
  1855. );
  1856. $jindex = 0;
  1857. foreach ($daterange as $date) {
  1858. if (isset($UserAttendanceLogs[$jindex])) {
  1859. $date = date("d", $UserAttendanceLogs[$jindex]->shift_date->sec);
  1860. if (isset($UserAttendanceLogs[$jindex]->shift_planner)) {
  1861. $timestamp = $UserAttendanceLogs[$jindex]->shift_date->sec;
  1862. $data = UserShiftPlanner::getUserShift($user->id, $timestamp, $tenant_id);
  1863. $shift_obj = TenantShift::getTenantShift($data['shift_id'], $tenant_id);
  1864.  
  1865.  
  1866. $request = Request::getAttendanceRequestnew($UserAttendanceLogs[$jindex]->user_id, $shift_obj->is_next_day, $UserAttendanceLogs[$jindex]->shift_date->sec);
  1867.  
  1868. if (!empty($request)) {
  1869. //$request_location_array = AttendanceRequestForm::loadLocation();
  1870. //$request_location = $request_location_array[$request->attendance->request_from];
  1871. if ($request->attendance->request_from == UserAttendance::WORK_FROM_OFFICE) {
  1872. $office++;
  1873. }
  1874. if ($request->attendance->request_from == UserAttendance::WORK_FROM_HOME) {
  1875. $home++;
  1876. }
  1877. if ($request->attendance->request_from == UserAttendance::WORK_OUT_DUTY) {
  1878. $out++;
  1879. }
  1880. }
  1881. } else {
  1882. $office++;
  1883. }
  1884. }
  1885. /* array_push($output[$index], $status); */
  1886. $jindex++;
  1887. } // my good loop
  1888. array_push($output[$index], $office);
  1889. array_push($output[$index], $out);
  1890. array_push($output[$index], $home);
  1891. $index++;
  1892. } // EOF foreach all user
  1893. $flag = true;
  1894. $cols = array(
  1895. 'Employee ID',
  1896. 'Name||Column displays the Name of the employees.',
  1897. 'Job Title||Column displays the Job Tittle of the particular employee.',
  1898. 'Department||Column displays the Department to which the employee belongs.',
  1899. 'Office Days||Column displays the total number of days where attendance location is Office in the specified duration.',
  1900. 'Field Duty Days||Column displays the total number of days where attendance location is Out - Duty in the specified duration.',
  1901. 'Home Days||Column displays the total number of days where attendance location is Home in the specified duration.',
  1902. );
  1903. $roster_type = "Attendance-Location-Summary";
  1904. $date = date('d-m-Y', $from) . "-to-" . date('d-m-Y', $to);
  1905. $filenameexport = $roster_type . "_" . $date;
  1906.  
  1907. $final_output = array('output' => $output,
  1908. 'cols' => $cols,
  1909. 'filenameexport' => $filenameexport);
  1910. return $final_output;
  1911. }
  1912.  
  1913. // EOF function
  1914.  
  1915. /**
  1916. * Short description for function
  1917. *
  1918. * Long description (if any) ...
  1919. *
  1920. * @param array $post_data Parameter description (if any) ...
  1921. * @param unknown $tenant_id Parameter description (if any) ...
  1922. * @param unknown $from Parameter description (if any) ...
  1923. * @param unknown $to Parameter description (if any) ...
  1924. * @return array Return description (if any) ...
  1925. * @access public
  1926. * @static
  1927. */
  1928. public static function getOverTimeSummaryRoster($post_data, $tenant_id = null, $from = null, $to = null) {
  1929. $return = array();
  1930. $index = 0;
  1931. $filter = $post_data['filter_id'];
  1932. $users = UserMongo::model()->getUsersByFilter($filter, $tenant_id, $post_data['active_inactive']);
  1933. $output = array();
  1934. $finaldata = array();
  1935. $begin = new DateTime($from);
  1936. $end = new DateTime($to);
  1937. $end = $end->modify('+1 day');
  1938. $interval = new DateInterval('P1D');
  1939. $daterange = new DatePeriod($begin, $interval, $end);
  1940. $from = strtotime($from);
  1941. $to = strtotime($to);
  1942. $criteria = new EMongoCriteria();
  1943. $criteria->shift_date('>=', new MongoDate($from));
  1944. $criteria->shift_date('<=', new MongoDate($to));
  1945. foreach ($users as $key => $user) {
  1946. $user_name = $user['personal']['firstname'] . " " . $user['personal']['lastname'];
  1947. $employee_number = (isset($user['personal']['employee_no'])) ? $user['personal']['employee_no'] : "N.A.";
  1948. $user_post = $user->getCurrentPosition($tenant_id);
  1949. $job_title = $user_post['designation'];
  1950. $department = $user_post['department'];
  1951. $business_unit = $user_post['business_unit'];
  1952. $criteria->user_id = $user->id;
  1953. $userAttendanceLogs = UserAttendanceLog::model()->tenant($tenant_id)->findAll($criteria);
  1954. $overtime = 0;
  1955. $overtimesum = 0;
  1956. $return = array();
  1957. $output[] = array(
  1958. $employee_number,
  1959. $user_name,
  1960. $job_title,
  1961. $department,
  1962. );
  1963. $jindex = 0;
  1964. foreach ($daterange as $date) {
  1965. if (isset($userAttendanceLogs[$jindex])) {
  1966. if (isset($userAttendanceLogs[$jindex]->over_time) && $userAttendanceLogs[$jindex]->over_time != '0') {
  1967. $shift_date = $userAttendanceLogs[$jindex]->shift_date->sec;
  1968. $user_id = $user->id;
  1969. $logCalc = AttendanceHelper::logCalculator($user_id, $shift_date, $tenant_id);
  1970.  
  1971. $overtimesum = $logCalc['rosterOverTimeSec'];
  1972. // $overtimesum += strtotime($overtimedata);
  1973. $overtime++;
  1974. }
  1975. }
  1976. /* array_push($output[$index], $status); */
  1977. $jindex++;
  1978. } // my good loop
  1979. if ($overtime != 0) {
  1980. // $avgtime = $overtimesum / $overtime;
  1981. $finalavg = RandomHelper::sec2hms($overtimesum);
  1982. } else {
  1983. $avgtime = '0';
  1984. $finalavg = "0:00";
  1985. }
  1986. array_push($output[$index], $overtime);
  1987. array_push($output[$index], $finalavg);
  1988. $index++;
  1989. } // EOF foreach all user
  1990. $flag = true;
  1991. $cols = array(
  1992. 'Employee ID',
  1993. 'Name||Column displays the Name of the employees.',
  1994. 'Job Title||Column displays the Job Tittle of the particular employee.',
  1995. 'Department||Column displays the Department to which the employee belongs.',
  1996. 'No of Over Time Days||Column displays the total number of days when there is an overtime recorded in the attendance logs for the employee in the specified duration.',
  1997. 'Average Over Time||Column dsiplays the average amount of time by which an employee is working over time in the specified duration.'
  1998. );
  1999. $roster_type = "Overtime-Summary";
  2000. $date = date('d-m-Y', $from) . "-to-" . date('d-m-Y', $to);
  2001. $filenameexport = $roster_type . "_" . $date;
  2002.  
  2003. $final_output = array('output' => $output,
  2004. 'cols' => $cols,
  2005. 'filenameexport' => $filenameexport);
  2006. return $final_output;
  2007. }
  2008.  
  2009. // EOF function
  2010.  
  2011. /**
  2012. * Short description for function
  2013. *
  2014. * Long description (if any) ...
  2015. *
  2016. * @param array $post_data Parameter description (if any) ...
  2017. * @param unknown $tenant_id Parameter description (if any) ...
  2018. * @param unknown $from Parameter description (if any) ...
  2019. * @param unknown $to Parameter description (if any) ...
  2020. * @return array Return description (if any) ...
  2021. * @access public
  2022. * @static
  2023. */
  2024. public static function getWorkDurationSummaryRoster($post_data, $tenant_id = null, $from = null, $to = null) {
  2025.  
  2026. $return = array();
  2027. $output = array();
  2028. $finaldata = array();
  2029. $index = 0;
  2030. $totalDays = 0;
  2031.  
  2032. $filter = $post_data['filter_id'];
  2033. $begin = new DateTime($from);
  2034. $end = new DateTime($to);
  2035. $end = $end->modify('+1 day');
  2036. $interval = new DateInterval('P1D');
  2037. $daterange = new DatePeriod($begin, $interval, $end);
  2038. $from = strtotime($from);
  2039. $to = strtotime($to);
  2040. $criteria = new EMongoCriteria();
  2041. $criteria->shift_date('>=', new MongoDate($from));
  2042. $criteria->shift_date('<=', new MongoDate($to));
  2043.  
  2044.  
  2045. $users = UserMongo::model()->getUsersByFilter($filter, $tenant_id, $post_data['active_inactive']);
  2046.  
  2047. foreach ($users as $key => $user) {
  2048. $user_name = $user['personal']['firstname'] . " " . $user['personal']['lastname'];
  2049. $employee_number = (isset($user['personal']['employee_no'])) ? $user['personal']['employee_no'] : "N.A.";
  2050. $user_post = $user->getCurrentPosition($tenant_id);
  2051. $job_title = $user_post['designation'];
  2052. $department = $user_post['department'];
  2053. $business_unit = $user_post['business_unit'];
  2054.  
  2055. $criteria->user_id = $user->id;
  2056. $userAttendanceLogs = UserAttendanceLog::model()->tenant($tenant_id)->findAll($criteria);
  2057. // echo "<pre>"; print_r($userAttendanceLogs); exit("</pre> \n exited here ");
  2058. $total = 0;
  2059. $totaltime = 0;
  2060. $isholiday = 0;
  2061. $isweeklyoff = 0;
  2062. $jindex = 0;
  2063. $return = array();
  2064.  
  2065. $totalWorkDuration = 0;
  2066. $totalDays = 0;
  2067. $totalWorkedDays = 0;
  2068. $workingDaysCount = 0;
  2069. $totalWorkDurationSc = 0;
  2070. $totalWorkDurationTimeStamp = 0;
  2071.  
  2072. $output[] = array(
  2073. $employee_number,
  2074. $user_name,
  2075. $job_title,
  2076. $department,
  2077. );
  2078.  
  2079. foreach ($daterange as $date) {
  2080.  
  2081. if (isset($userAttendanceLogs[$jindex])) {
  2082. $status = $userAttendanceLogs[$jindex]->attendance_status;
  2083. if ($status == UserAttendance::ATTENDANCE_STATUS_ABSENT) {
  2084. $status = UserAttendanceLog::ATTENDANCE_STATUS_ABSENT;
  2085. } elseif ($status == UserAttendance::ATTENDANCE_STATUS_PRESENT) {
  2086. $status = UserAttendanceLog::ATTENDANCE_STATUS_PRESENT;
  2087. }
  2088. if ($status == UserAttendanceLog::ATTENDANCE_STATUS_PRESENT || $status == UserAttendanceLog::ATTENDANCE_STATUS_PENDING) {
  2089. if (isset($userAttendanceLogs[$jindex]->total_duration) && $userAttendanceLogs[$jindex]->total_duration != 0) {
  2090. $totalWorkDurationTimeStamp += $userAttendanceLogs[$jindex]->total_duration;
  2091. $workingDaysCount++;
  2092. $totalWorkedDays++;
  2093. }
  2094. }
  2095. }
  2096. $jindex++;
  2097. $totalDays++;
  2098. } // my good loop
  2099.  
  2100. if (isset($totalWorkDurationTimeStamp) && $workingDaysCount != 0) {
  2101. $totalWorkedHr = RandomHelper::sec2hms($totalWorkDurationTimeStamp);
  2102. $week = $totalDays / 7;
  2103. $weeklyAverageNo = $totalWorkDurationTimeStamp / $week;
  2104. $weeklyAverage = RandomHelper::sec2hms($weeklyAverageNo);
  2105. // echo "<pre>"; print_r($weeklyAverage); exit("</pre> \n exited here ");
  2106. $daillyAverage = $totalWorkDurationTimeStamp / $workingDaysCount;
  2107. $daillyAverage = RandomHelper::sec2hms($daillyAverage);
  2108. } else {
  2109. $totalWorkedHr = 0;
  2110. $weeklyAverage = 0;
  2111. $daillyAverage = 0;
  2112. }
  2113.  
  2114. array_push($output[$index], $totalWorkedHr);
  2115. array_push($output[$index], $weeklyAverage);
  2116. array_push($output[$index], $daillyAverage);
  2117.  
  2118.  
  2119.  
  2120. $index++;
  2121. // break;
  2122. } // EOF foreach all user
  2123.  
  2124. $cols = array(
  2125. 'Employee ID',
  2126. 'Name||Column displays the Name of the employees.',
  2127. 'Job Title||Column displays the Job Tittle of the particular employee.',
  2128. 'Department||Column displays the Department to which the employee belongs.',
  2129. 'Total worked hours||Column displays the total worked hours for the specified duration.',
  2130. 'Weekly Average||Column displays the weekly average work hours duration of the employee in the specified duration.',
  2131. 'Daily Average||Column displays the daily average work hours duration of the employee in the specified duration.'
  2132. );
  2133.  
  2134. $roster_type = "Work-Duration-Summary";
  2135. $date = date('d-m-Y', $from) . "-to-" . date('d-m-Y', $to);
  2136. $filenameexport = $roster_type . "_" . $date;
  2137.  
  2138. $final_output = array('output' => $output,
  2139. 'cols' => $cols,
  2140. 'filenameexport' => $filenameexport);
  2141. return $final_output;
  2142. }
  2143.  
  2144. // EOF function
  2145.  
  2146. /**
  2147. * Short description for function
  2148. *
  2149. * Long description (if any) ...
  2150. *
  2151. * @param array $post_data Parameter description (if any) ...
  2152. * @param unknown $tenant_id Parameter description (if any) ...
  2153. * @param unknown $from Parameter description (if any) ...
  2154. * @param unknown $to Parameter description (if any) ...
  2155. * @return array Return description (if any) ...
  2156. * @access public
  2157. * @static
  2158. */
  2159. public static function getLatemarkDateWiseRoster($post_data, $tenant_id = null, $from = null, $to = null) {
  2160. $return = array();
  2161. $index = 0;
  2162. $filter = $post_data['filter_id'];
  2163. $users = UserMongo::model()->getUsersByFilter($filter, $tenant_id, $post_data['active_inactive']);
  2164. $output = array();
  2165. $finaldata = array();
  2166. $begin = new DateTime($from);
  2167. $end = new DateTime($to);
  2168. $end = $end->modify('+1 day');
  2169. $interval = new DateInterval('P1D');
  2170. $daterange = new DatePeriod($begin, $interval, $end);
  2171. $from = strtotime($from);
  2172. $to = strtotime($to);
  2173. $criteria = new EMongoCriteria();
  2174. foreach ($daterange as $date) {
  2175. $todaydate = strtotime($date->format("d-m-Y"));
  2176. $criteria->shift_date('==', new MongoDate($todaydate));
  2177. $criteria->coming_late_by('!=', null);
  2178. $UserAttendanceLogs = UserAttendanceLog::model()->tenant($tenant_id)->findAll($criteria);
  2179.  
  2180. foreach ($UserAttendanceLogs as $logs) {
  2181. $userid = $logs->user_id;
  2182. $usermodel = UserMongo::model()->tenant($tenant_id)->findByPk($userid);
  2183. if (array_key_exists($usermodel->user_id, $users)) {
  2184. $user_name = $usermodel->getFullname();
  2185. $employee_number = (isset($usermodel['personal']['employee_no'])) ? $usermodel['personal']['employee_no'] : "N.A.";
  2186. $user_post = $usermodel->getCurrentPosition($tenant_id);
  2187. $job_title = $user_post['designation'];
  2188. $department = $user_post['department'];
  2189. $business_unit = $user_post['business_unit'];
  2190. $present = 0;
  2191. $absent = 0;
  2192. $weeklyoff_count = 0;
  2193. $holiday_count = 0;
  2194. $leave_count = 0;
  2195. $return = array();
  2196.  
  2197. $jindex = 0;
  2198.  
  2199. if (isset($logs) && $logs != null) {
  2200. if (isset($logs->coming_late_by) && $logs->coming_late_by != null) {
  2201. if (isset($logs->punchin_timestamp->sec) && $logs->punchin_timestamp->sec != null) {
  2202. $punchin_timestamp = (isset($logs->punchin_timestamp->sec) && $logs->punchin_timestamp->sec != null) ? date("H:i", $logs->punchin_timestamp->sec) : "-";
  2203. } else {
  2204. $punchin_timestamp = (isset($logs->punchin_timestamp) && $logs->punchin_timestamp != null) ? date("H:i", $logs->punchin_timestamp) : "-";
  2205. }
  2206. if (isset($logs->punchout_timestamp->sec) && $logs->punchout_timestamp->sec != null) {
  2207. $punchout_timestamp = (isset($logs->punchout_timestamp->sec) && $logs->punchout_timestamp->sec != null) ? date("H:i", $logs->punchout_timestamp->sec) : "-";
  2208. } else {
  2209. if (!is_object($logs->punchout_timestamp)) {
  2210. $punchout_timestamp = (isset($logs->punchout_timestamp) && $logs->punchout_timestamp != null) ? date("H:i", $logs->punchout_timestamp) : "-";
  2211. }
  2212. }
  2213. $coming_late_bydata = (isset($logs->coming_late_by) && $logs->coming_late_by != null) ? $logs->coming_late_by : "-";
  2214. $coming_late_by = str_replace('.', ':', $coming_late_bydata);
  2215. $new_come_late = explode(":", $coming_late_by);
  2216. if(isset($new_come_late[0],$new_come_late[1]) && ($new_come_late[0] < 10 || $new_come_late[1] < 10))
  2217. {
  2218. $new_come_late_hrs = ($new_come_late[0] < 10) ? "0".$new_come_late[0] : $new_come_late[0];
  2219. $new_come_late_mins = ($new_come_late[1] < 10) ? "0".$new_come_late[1] : $new_come_late[1];
  2220. $coming_late_by = $new_come_late_hrs . ":".$new_come_late_mins;
  2221. }
  2222. // $date = date("d", $logs->shift_date->sec);
  2223. } else {
  2224. $punchin_timestamp = "-";
  2225. $punchout_timestamp = "-";
  2226. $coming_late_by = "-";
  2227. }
  2228. $attdate = date("d-M-Y", $logs->shift_date->sec);
  2229. $attdateday = date("l", $logs->shift_date->sec);
  2230. /* $attdate = $attdateonly.','. $attdateday; */
  2231. $output[] = array($attdate);
  2232. // array_push($output[$index], $attdate);
  2233. array_push($output[$index], $attdateday);
  2234. array_push($output[$index], $employee_number);
  2235. array_push($output[$index], $user_name);
  2236. array_push($output[$index], $job_title);
  2237. array_push($output[$index], $department);
  2238. array_push($output[$index], $punchin_timestamp);
  2239. array_push($output[$index], $punchout_timestamp);
  2240. array_push($output[$index], $coming_late_by);
  2241. }
  2242.  
  2243. $index++;
  2244. }//check users if
  2245. } // EOF foreach for all logs
  2246. } // EOF foreach all date
  2247. $flag = true;
  2248. $cols = array(
  2249. 'Date||Column displays all the Dates selected in the specified duration.',
  2250. 'Day||Column displays the Particular Day corresponding to the date.',
  2251. 'Employee ID',
  2252. 'Name||Column displays the Name of the employees.',
  2253. 'Job Title||Column displays the Job Tittle of the particular employee.',
  2254. 'Department||Column displays the Department to which the employee belongs.',
  2255. 'Punch In Time||Column displays the Time when the employee is suppose to start his Shift.',
  2256. 'Punch Out Time||Column displays the Time at which the particular employee started his Shift.',
  2257. 'Coming Late By||Column displays the Time by which the employee was late by on the particular date.'
  2258. );
  2259.  
  2260. $roster_type = "LateMark-Datewise";
  2261. $date = date('d-m-Y', $from) . "-to-" . date('d-m-Y', $to);
  2262. $filenameexport = $roster_type . "_" . $date;
  2263. $final_output = array('output' => $output,
  2264. 'cols' => $cols,
  2265. 'filenameexport' => $filenameexport);
  2266. return $final_output;
  2267. }
  2268.  
  2269. // EOF function
  2270.  
  2271. /**
  2272. * Short description for function
  2273. *
  2274. * Long description (if any) ...
  2275. *
  2276. * @param array $post_data Parameter description (if any) ...
  2277. * @param unknown $tenant_id Parameter description (if any) ...
  2278. * @param unknown $from Parameter description (if any) ...
  2279. * @param unknown $to Parameter description (if any) ...
  2280. * @return array Return description (if any) ...
  2281. * @access public
  2282. * @static
  2283. */
  2284. public static function getAbsenteesDatewiseRoster($post_data, $tenant_id = null, $from = null, $to = null) {
  2285. $return = array();
  2286. $index = 0;
  2287. $filter = $post_data['filter_id'];
  2288. $users = UserMongo::model()->getUsersByFilter($filter, $tenant_id, $post_data['active_inactive']);
  2289. $output = array();
  2290. $finaldata = array();
  2291. $begin = new DateTime($from);
  2292. $end = new DateTime($to);
  2293. $end = $end->modify('+1 day');
  2294. $interval = new DateInterval('P1D');
  2295. $daterange = new DatePeriod($begin, $interval, $end);
  2296. $from = strtotime($from);
  2297. $to = strtotime($to);
  2298. $criteria = new EMongoCriteria();
  2299. foreach ($daterange as $date) {
  2300. $todaydate = strtotime($date->format("d-m-Y"));
  2301. $criteria->shift_date('==', new MongoDate($todaydate));
  2302. $userAttendanceLogs = UserAttendanceLog::model()->tenant($tenant_id)->findAll($criteria);
  2303. foreach ($userAttendanceLogs as $logs) {
  2304. $status = $logs->attendance_status;
  2305. if ($status == UserAttendanceLog::ATTENDANCE_STATUS_ABSENT && $status == UserAttendance::ATTENDANCE_STATUS_ABSENT) { // echo "<pre>"; print_r($status);
  2306. $weeklyoff = $logs->is_weekly_off->status;
  2307. $leave = $logs->in_leave->status;
  2308. $holiday = $logs->is_holiday->status;
  2309. if (is_null($weeklyoff) || $weeklyoff == IsWeeklyOff::WEEKLYOFF_YES) {
  2310. continue;
  2311. } elseif (is_null($leave) || $leave == InLeave::INLEAVE_YES) {
  2312. continue;
  2313. } elseif (is_null($holiday) || $holiday == IsHoliday::HOLIDAY_YES) {
  2314. continue;
  2315. } else {
  2316.  
  2317.  
  2318. $userid = $logs->user_id;
  2319. $usermodel = UserMongo::model()->tenant($tenant_id)->findByPk($userid);
  2320. if (array_key_exists($usermodel->user_id, $users)) {
  2321. $employee_id = $usermodel->personal->employee_no;
  2322. $user_name = $usermodel->getFullname();
  2323. $user_post = $usermodel->getCurrentPosition($tenant_id);
  2324. $job_title = (isset($user_post['designation']) && $user_post['designation'] != null) ? $user_post['designation'] : "-";
  2325. $department = (isset($user_post['department']) && $user_post['department'] != null) ? $user_post['department'] : "-";
  2326. $business_unit = (isset($user_post['business_unit']) && $user_post['business_unit'] != null) ? $user_post['business_unit'] : "-";
  2327. $present = 0;
  2328. $absent = 0;
  2329. $weeklyoff_count = 0;
  2330. $holiday_count = 0;
  2331. $leave_count = 0;
  2332. $return = array();
  2333. $jindex = 0;
  2334. $attdate = date("d-M-Y", $logs->shift_date->sec);
  2335. $attdateday = date("l", $logs->shift_date->sec);
  2336. /* $attdate = $attdateonly.','. $attdateday; */
  2337. $output[] = array($attdate);
  2338. array_push($output[$index], $attdateday);
  2339. array_push($output[$index], $employee_id);
  2340. array_push($output[$index], $user_name);
  2341. array_push($output[$index], $job_title);
  2342. array_push($output[$index], $department);
  2343. $index++;
  2344. }
  2345. }
  2346. } // EOF user if
  2347. } // EOF foreach logs
  2348. } // EOF foreach all date
  2349. $flag = true;
  2350. $cols = array(
  2351. 'Date||Column displays all the Dates selected in the specified duration.',
  2352. 'Day||Column displays the Particular Day corresponding to the date.',
  2353. 'Employee ID||Employee id',
  2354. 'Name||Column displays the Name of the employees.',
  2355. 'Job Title||Column displays the Job Tittle of the particular employee.',
  2356. 'Department||Column displays the Department to which the employee belongs.'
  2357. );
  2358.  
  2359. $roster_type = "Absentees-Datewise-Summary";
  2360. $date = date('d-m-Y', $from) . "-to-" . date('d-m-Y', $to);
  2361. $filenameexport = $roster_type . "_" . $date;
  2362. $final_output = array('output' => $output,
  2363. 'cols' => $cols,
  2364. 'filenameexport' => $filenameexport);
  2365. return $final_output;
  2366. }
  2367.  
  2368. // EOF function
  2369.  
  2370. /**
  2371. * Short description for function
  2372. *
  2373. * Long description (if any) ...
  2374. *
  2375. * @param array $post_data Parameter description (if any) ...
  2376. * @param unknown $tenant_id Parameter description (if any) ...
  2377. * @param unknown $from Parameter description (if any) ...
  2378. * @param unknown $to Parameter description (if any) ...
  2379. * @return array Return description (if any) ...
  2380. * @access public
  2381. * @static
  2382. */
  2383. public static function getLateMarksSummaryRoster($post_data, $tenant_id = null, $from = null, $to = null) {
  2384.  
  2385. $return = array();
  2386. $index = 0;
  2387. $output = array();
  2388. $finaldata = array();
  2389.  
  2390. $filter = $post_data['filter_id'];
  2391. $users = UserMongo::model()->getUsersByFilter($filter, $tenant_id, $post_data['active_inactive']);
  2392.  
  2393. $begin = new DateTime($from);
  2394. $end = new DateTime($to);
  2395. $end = $end->modify('+1 day');
  2396. $interval = new DateInterval('P1D');
  2397. $daterange = new DatePeriod($begin, $interval, $end);
  2398. $from = strtotime($from);
  2399. $to = strtotime($to);
  2400.  
  2401. $criteria = new EMongoCriteria();
  2402. $criteria->shift_date('>=', new MongoDate($from));
  2403. $criteria->shift_date('<=', new MongoDate($to));
  2404.  
  2405. foreach ($users as $key => $user) {
  2406.  
  2407. $user_name = $user['personal']['firstname'] . " " . $user['personal']['lastname'];
  2408. $user_post = $user->getCurrentPosition($tenant_id);
  2409. $job_title = $user_post['designation'];
  2410. $department = $user_post['department'];
  2411. $business_unit = $user_post['business_unit'];
  2412. $employee_number = (isset($user['personal']['employee_no'])) ? $user['personal']['employee_no'] : "N.A.";
  2413. $criteria->user_id = $user->id;
  2414. $userAttendanceLogs = UserAttendanceLog::model()->tenant($tenant_id)->findAll($criteria);
  2415.  
  2416. $present = 0;
  2417. $absent = 0;
  2418. $comingLateCounter = 0;
  2419. $weeklyoff_count = 0;
  2420. $holiday_count = 0;
  2421. $leave_count = 0;
  2422. $cominglatetotal = 0;
  2423. $punchintimetotal = 0;
  2424. $punchInCounter = 0;
  2425. $jindex = 0;
  2426. $timeInTotalSec = 0;
  2427. $punchInTimeStamp = 0;
  2428. $avgLateBy = 0;
  2429. $comingLateBy = 0;
  2430. $return = array();
  2431.  
  2432. $output[] = array(
  2433. $employee_number,
  2434. $user_name,
  2435. $job_title,
  2436. $department,
  2437. );
  2438.  
  2439. foreach ($daterange as $date) {
  2440. if (isset($userAttendanceLogs[$jindex])) {
  2441. if (isset($userAttendanceLogs[$jindex]->punchin_timestamp->sec) && $userAttendanceLogs[$jindex]->punchin_timestamp->sec != null) {
  2442. $shift_date = $userAttendanceLogs[$jindex]->shift_date->sec;
  2443. $user_id = $user->id;
  2444. $logCalc = AttendanceHelper::logCalculator($user_id, $shift_date, $tenant_id);
  2445. // $comingLateBy += $logCalc["rosterLateBySec"];
  2446. // echo "<pre>"; print_r($logCalc); exit("</pre> \n exited here \n");
  2447. $punchInTimeStamp += $logCalc["rosterClockInSec"];
  2448. // echo "<pre>"; print_r($punchInTimeStamp); exit("</pre> \n exited here ");
  2449. $punchInCounter++;
  2450. }
  2451.  
  2452.  
  2453. if (isset($userAttendanceLogs[$jindex]->coming_late_by) && $userAttendanceLogs[$jindex]->coming_late_by != null) {
  2454. /* $shift_date = $userAttendanceLogs[$jindex]->shift_date->sec;
  2455. $user_id = $user->id;
  2456. $logCalc = AttendanceHelper::logCalculator($user_id,$shift_date,$tenant_id); */
  2457. if (isset($logCalc["rosterLateBySec"])) {
  2458.  
  2459. $comingLateBy += $logCalc["rosterLateBySec"];
  2460. $comingLateCounter++;
  2461. }
  2462. // echo "<pre>"; print_r($logCalc); exit("</pre> \n exited here \n");
  2463. }
  2464. }
  2465. $jindex++;
  2466. } // my good loop
  2467.  
  2468. if (isset($comingLateBy) && $comingLateCounter != 0) {
  2469. $avgLateBy = $comingLateBy / $comingLateCounter;
  2470. $avgLateBy = RandomHelper::sec2hms($avgLateBy);
  2471. } else {
  2472. $avgLateBy = "00:00";
  2473. }
  2474.  
  2475. if (isset($punchInTimeStamp) && $punchInCounter != 0) {
  2476. $avgPunchInTimeSec = $punchInTimeStamp / $punchInCounter;
  2477. $avgPunchInTime = RandomHelper::sec2hms($avgPunchInTimeSec);
  2478. } else {
  2479. $avgpunchintime = 0;
  2480. $avgPunchInTime = '00:00';
  2481. }
  2482. array_push($output[$index], $comingLateCounter);
  2483. array_push($output[$index], $avgLateBy);
  2484. array_push($output[$index], $avgPunchInTime);
  2485.  
  2486. $index++;
  2487. // break;
  2488. } // EOF foreach all user
  2489. $flag = true;
  2490. $cols = array(
  2491. 'Employee ID ||Column to display employee id',
  2492. 'Name||Column displays the Name of the employees.',
  2493. 'Job Title||Column displays the Job Tittle of the particular employee.',
  2494. 'Department||Column displays the Department to which the employee belongs.',
  2495. 'No Of Late Mark Days||Column displays the the total number of days when the employees attendance logs show clock-in time more than grace time specified in policy.',
  2496. 'Average Late By||Column displays what is the average duration by which an employee is late by in the specified duration.',
  2497. 'Average Clock In Time||Column displays the average clock-in time of the employee for the specified duration.'
  2498. );
  2499. $roster_type = "Latemark-Summary";
  2500. $date = date('d-m-Y', $from) . "-to-" . date('d-m-Y', $to);
  2501. $filenameexport = $roster_type . "_" . $date;
  2502.  
  2503. $final_output = array('output' => $output,
  2504. 'cols' => $cols,
  2505. 'filenameexport' => $filenameexport);
  2506. return $final_output;
  2507. }
  2508.  
  2509. //EOF function
  2510.  
  2511. /**
  2512. * Short description for function
  2513. *
  2514. * Long description (if any) ...
  2515. *
  2516. * @param array $post_data Parameter description (if any) ...
  2517. * @param unknown $tenant_id Parameter description (if any) ...
  2518. * @param unknown $from Parameter description (if any) ...
  2519. * @param unknown $to Parameter description (if any) ...
  2520. * @return array Return description (if any) ...
  2521. * @access public
  2522. * @static
  2523. */
  2524. public static function getEarlyClockOutSummaryRoster($post_data, $tenant_id = null, $from = null, $to = null) {
  2525. $return = array();
  2526. $index = 0;
  2527. $output = array();
  2528. $finaldata = array();
  2529.  
  2530. $filter = $post_data['filter_id'];
  2531. $users = UserMongo::model()->getUsersByFilter($filter, $tenant_id, $post_data['active_inactive']);
  2532.  
  2533. $begin = new DateTime($from);
  2534. $end = new DateTime($to);
  2535. $end = $end->modify('+1 day');
  2536. $interval = new DateInterval('P1D');
  2537. $daterange = new DatePeriod($begin, $interval, $end);
  2538. $from = strtotime($from);
  2539. $to = strtotime($to);
  2540.  
  2541. $criteria = new EMongoCriteria();
  2542. $criteria->shift_date('>=', new MongoDate($from));
  2543. $criteria->shift_date('<=', new MongoDate($to));
  2544.  
  2545. foreach ($users as $key => $user) {
  2546.  
  2547. $user_name = $user['personal']['firstname'] . " " . $user['personal']['lastname'];
  2548. $user_post = $user->getCurrentPosition($tenant_id);
  2549. $job_title = $user_post['designation'];
  2550. $department = $user_post['department'];
  2551. $business_unit = $user_post['business_unit'];
  2552. $criteria->user_id = $user->id;
  2553. $employee_number = (isset($user['personal']['employee_no'])) ? $user['personal']['employee_no'] : "N.A.";
  2554. $userAttendanceLogs = UserAttendanceLog::model()->tenant($tenant_id)->findAll($criteria);
  2555.  
  2556. $present = 0;
  2557. $absent = 0;
  2558. $goingearly = 0;
  2559. $weeklyoff_count = 0;
  2560. $holiday_count = 0;
  2561. $leave_count = 0;
  2562. $goingearlytotal = 0;
  2563. $totalpunchout = 0;
  2564. $punchouttimetotal = 0;
  2565. $return = array();
  2566. $output[] = array(
  2567. $employee_number,
  2568. $user_name,
  2569. $job_title,
  2570. $department,
  2571. );
  2572. foreach ($userAttendanceLogs as $userAttendanceLog) {
  2573. if (isset($userAttendanceLog)) {
  2574. if (isset($userAttendanceLog->shift_date->sec)) {
  2575.  
  2576. $shift_date = $userAttendanceLog->shift_date->sec;
  2577. $user_id = $user->id;
  2578. $logCalc = AttendanceHelper::logCalculator($user_id, $shift_date, $tenant_id);
  2579. // echo "<pre>"; print_r($logCalc); exit("</pre> \n exited here ");
  2580. if (isset($userAttendanceLog->punchout_time) && $userAttendanceLog->punchout_time != null) {
  2581. $punchouttimetotal += $logCalc["rosterClockOutSec"];
  2582. $totalpunchout++;
  2583. }
  2584.  
  2585. if (!empty($logCalc["total_duration"])) {
  2586. if ($logCalc["total_duration"] < $logCalc["rosterShiftSeconds"]) {
  2587. $goingearlytotal += $logCalc["rosterShiftSeconds"] - $logCalc["total_duration"];
  2588. $goingearly++;
  2589. }
  2590. }
  2591. }
  2592. }
  2593. } // my good loop
  2594. if (isset($goingearlytotal) && $goingearlytotal != 0) {
  2595.  
  2596. $avgtime = $goingearlytotal / $goingearly;
  2597.  
  2598. $finalavg = RandomHelper::sec2hms($avgtime);
  2599. //echo "<pre>"; print_r($avgtime); exit("</pre> \n exited here");
  2600. } else {
  2601. $avgtime = 0;
  2602. $finalavg = '00:00';
  2603. }
  2604. if (isset($punchouttimetotal) && $punchouttimetotal != 0) {
  2605. // $totalpunchoutdur = date('H.i', $punchouttimetotal);
  2606. $avgpunchouttime = $punchouttimetotal / $totalpunchout;
  2607. $finalavgpunchout = RandomHelper::sec2hms($avgpunchouttime);
  2608.  
  2609. // echo "<pre>"; print_r($finalavgpunchin); exit("</pre> \n exited here");
  2610. } else {
  2611.  
  2612. $finalavgpunchout = '00:00';
  2613. }
  2614. array_push($output[$index], $goingearly);
  2615. array_push($output[$index], $finalavg);
  2616. array_push($output[$index], $finalavgpunchout);
  2617. $index++;
  2618. // break;
  2619. } // EOF foreach all user
  2620. $flag = true;
  2621. $cols = array(
  2622. 'Employee ID||Column to display Employee id',
  2623. 'Name||Column displays the Name of the employees.',
  2624. 'Job Title||Column displays the Job Tittle of the particular employee.',
  2625. 'Department||Column displays the Department to which the employee belongs.',
  2626. 'No Of Early Clock Out Days||Column displays the Number of days the employee has clocked out early.',
  2627. 'Average Of Early Clock Out||Column displays the average by which an employee clocks out early in the specified duration.',
  2628. 'Average Of Clock Out Time||Column displays a simple average of the clock-out times recorded for the specified duration.'
  2629. );
  2630. $roster_type = "Early-Clockout-Summary";
  2631. $date = date('d-m-Y', $from) . "-to-" . date('d-m-Y', $to);
  2632. $filenameexport = $roster_type . "_" . $date;
  2633.  
  2634. $final_output = array('output' => $output,
  2635. 'cols' => $cols,
  2636. 'filenameexport' => $filenameexport);
  2637. return $final_output;
  2638. }
  2639.  
  2640. //EOF function
  2641.  
  2642. /**
  2643. * Short description for function
  2644. *
  2645. * Long description (if any) ...
  2646. *
  2647. * @param array $post_data Parameter description (if any) ...
  2648. * @param unknown $tenant_id Parameter description (if any) ...
  2649. * @param unknown $from Parameter description (if any) ...
  2650. * @param unknown $to Parameter description (if any) ...
  2651. * @return array Return description (if any) ...
  2652. * @access public
  2653. * @static
  2654. */
  2655. public static function getEarlyClockOutDatewiseRoster($post_data, $tenant_id = null, $from = null, $to = null) {
  2656. $return = array();
  2657. $output = array();
  2658. $finaldata = array();
  2659. $index = 0;
  2660. $filter = $post_data['filter_id'];
  2661. $users = UserMongo::model()->getUsersByFilter($filter, $tenant_id, $post_data['active_inactive']);
  2662. //echo "<pre>"; print_r($users); exit("</pre> \n exited here");
  2663.  
  2664. $begin = new DateTime($from);
  2665. $end = new DateTime($to);
  2666. $end = $end->modify('+1 day');
  2667. $interval = new DateInterval('P1D');
  2668. $daterange = new DatePeriod($begin, $interval, $end);
  2669. $from = strtotime($from);
  2670. $to = strtotime($to);
  2671.  
  2672. $criteria = new EMongoCriteria();
  2673. foreach ($daterange as $date) {
  2674. $todaydate = strtotime($date->format("d-m-Y"));
  2675. $criteria->shift_date('==', new MongoDate($todaydate));
  2676. // $criteria->going_early_by('!=', null);
  2677. $UserAttendanceLogs = UserAttendanceLog::model()->tenant($tenant_id)->findAll($criteria);
  2678.  
  2679. foreach ($UserAttendanceLogs as $logs) {
  2680. $userid = $logs->user_id;
  2681. $usermodel = UserMongo::model()->tenant($tenant_id)->findByPk($userid);
  2682.  
  2683. if (array_key_exists($usermodel->user_id, $users)) {
  2684.  
  2685. $user_name = $usermodel->getFullname();
  2686. $user_post = $usermodel->getCurrentPosition($tenant_id);
  2687. $job_title = $user_post['designation'];
  2688. $department = $user_post['department'];
  2689. $business_unit = $user_post['business_unit'];
  2690. $employee_number = (isset($user['personal']['employee_no'])) ? $user['personal']['employee_no'] : "N.A.";
  2691. $present = 0;
  2692. $absent = 0;
  2693. $weeklyoff_count = 0;
  2694. $holiday_count = 0;
  2695. $leave_count = 0;
  2696. $jindex = 0;
  2697. $return = array();
  2698.  
  2699. $shift_date = $logs->shift_date->sec;
  2700. $user_id = $usermodel->id;
  2701. $logCalc = AttendanceHelper::logCalculator($user_id, $shift_date, $tenant_id);
  2702. if (!empty($logCalc["total_duration"])) {
  2703. if ($logCalc["total_duration"] < $logCalc["rosterShiftSeconds"]) {
  2704. if (isset($logs->shift_planner)) {
  2705. $begin_time = date("H:i", $logCalc["rosterShiftBegin"]);
  2706. $end_time = date("H:i", $logCalc["rosterShiftEnd"]);
  2707. $going_early_by = $logCalc["rosterShiftSeconds"] - $logCalc["total_duration"];
  2708. $going_early_by = RandomHelper::sec2hms($going_early_by);
  2709. } else {
  2710. $begin_time = "-";
  2711. $end_time = "-";
  2712. }
  2713.  
  2714. // $going_early_bydata = (isset($logs->going_early_by) && $logs->going_early_by != null) ? $logs->going_early_by : "-";
  2715. // $going_early_by = str_replace('.', ':', $going_early_bydata);
  2716. $attdate = date("d-M-Y", $logs->shift_date->sec);
  2717. $attdateday = date("l", $logs->shift_date->sec);
  2718. $output[] = array($attdate);
  2719.  
  2720. array_push($output[$index], $employee_number);
  2721. array_push($output[$index], $attdateday);
  2722. array_push($output[$index], $user_name);
  2723. array_push($output[$index], $job_title);
  2724. array_push($output[$index], $department);
  2725. array_push($output[$index], $begin_time);
  2726. array_push($output[$index], $end_time);
  2727. array_push($output[$index], $going_early_by);
  2728. $index++;
  2729. }
  2730. }
  2731. } // EOF foreach for all logs
  2732. }
  2733. } // EOF foreach all date
  2734. $flag = true;
  2735. $cols = array(
  2736. 'Employee ID ||Column to display Employee id ',
  2737. 'Date||Column displays all the Dates selected in the specified duration.',
  2738. 'Day||Column displays the Particular Day corresponding to the date.',
  2739. 'Name||Column displays the Name of the employees.',
  2740. 'Job Title||Column displays the Job Tittle of the particular employee.',
  2741. 'Department||Column displays the Department to which the employee belongs.',
  2742. 'Shift Begin Time||Column displays the Time when the employee shift starts.',
  2743. 'Shift End Time||Column displays the Time when the employee shift ',
  2744. 'Going Early By||Column displays the Time by which the employee is leaving early than the stipulated time.'
  2745. );
  2746.  
  2747. $roster_type = "Early-Clockout-Datewise-Summary";
  2748. $date = date('d-m-Y', $from) . "-to-" . date('d-m-Y', $to);
  2749. $filenameexport = $roster_type . "_" . $date;
  2750. $final_output = array('output' => $output,
  2751. 'cols' => $cols,
  2752. 'filenameexport' => $filenameexport);
  2753. return $final_output;
  2754. }
  2755.  
  2756. // EOF function
  2757.  
  2758. /**
  2759. * Short description for function
  2760. *
  2761. * Long description (if any) ...
  2762. *
  2763. * @param array $post_data Parameter description (if any) ...
  2764. * @param unknown $tenant_id Parameter description (if any) ...
  2765. * @param unknown $from Parameter description (if any) ...
  2766. * @param unknown $to Parameter description (if any) ...
  2767. * @return array Return description (if any) ...
  2768. * @access public
  2769. * @static
  2770. */
  2771. public static function getOverTimeDatewiseRoster($post_data, $tenant_id = null, $from = null, $to = null) {
  2772. $return = array();
  2773. $index = 0;
  2774. $filter = $post_data['filter_id'];
  2775. $users = UserMongo::model()->getUsersByFilter($filter, $tenant_id, $post_data['active_inactive']);
  2776. $output = array();
  2777. $finaldata = array();
  2778. $begin = new DateTime($from);
  2779. $end = new DateTime($to);
  2780. $end = $end->modify('+1 day');
  2781. $interval = new DateInterval('P1D');
  2782. $daterange = new DatePeriod($begin, $interval, $end);
  2783. $from = strtotime($from);
  2784. $to = strtotime($to);
  2785. $criteria = new EMongoCriteria();
  2786. foreach ($daterange as $date) {
  2787. $todaydate = strtotime($date->format("d-m-Y"));
  2788. $criteria->shift_date('==', new MongoDate($todaydate));
  2789. $criteria->over_time('!=', 0);
  2790. $UserAttendanceLogs = UserAttendanceLog::model()->tenant($tenant_id)->findAll($criteria);
  2791.  
  2792. foreach ($UserAttendanceLogs as $logs) {
  2793. $userid = $logs->user_id;
  2794. $usermodel = UserMongo::model()->tenant($tenant_id)->findByPk($userid);
  2795. if (array_key_exists($usermodel->user_id, $users)) {
  2796. $user_name = $usermodel->getFullname();
  2797. $user_post = $usermodel->getCurrentPosition($tenant_id);
  2798. $job_title = $user_post['designation'];
  2799. $department = $user_post['department'];
  2800. $business_unit = $user_post['business_unit'];
  2801. $employee_number = (isset($user['personal']['employee_no'])) ? $user['personal']['employee_no'] : "N.A.";
  2802. $present = 0;
  2803. $absent = 0;
  2804. $weeklyoff_count = 0;
  2805. $holiday_count = 0;
  2806. $leave_count = 0;
  2807. $return = array();
  2808.  
  2809. $jindex = 0;
  2810.  
  2811. if (isset($logs)) {
  2812. if (isset($logs->shift_planner)) {
  2813. $timestamp = $logs->shift_date->sec;
  2814. $logs->shift_date->sec;
  2815. $data = UserShiftPlanner::getUserShift($usermodel->id, $timestamp, $tenant_id);
  2816. $shift_obj = TenantShift::getTenantShift($data['shift_id'], $tenant_id);
  2817. $begin_time = (isset($shift_obj->begin_time) && $shift_obj->begin_time != null) ? $shift_obj->begin_time : null;
  2818. $new_come_begin_time = explode(":", $begin_time);
  2819. if(isset($new_come_begin_time[0],$new_come_begin_time[1]) && ($new_come_begin_time[0] < 10 || $new_come_begin_time[1] < 10))
  2820. {
  2821. $new_come_begin_time_hrs = ($new_come_begin_time[0] < 10) ? "0".$new_come_begin_time[0] : $new_come_begin_time[0];
  2822. $new_come_begin_time_mins = ($new_come_begin_time[1] < 10) ? "0".$new_come_begin_time[1] : $new_come_begin_time[1];
  2823. $begin_time = $new_come_begin_time_hrs . ":".$new_come_begin_time_mins;
  2824. }
  2825. $end_time = (isset($shift_obj->end_time) && $shift_obj->end_time != null) ? $shift_obj->end_time : null;
  2826. $new_come_end_time = explode(":", $end_time);
  2827. if(isset($new_come_end_time[0],$new_come_end_time[1]) && ($new_come_end_time[0] < 10 || $new_come_end_time[1] < 10))
  2828. {
  2829. $new_come_end_time_hrs = ($new_come_end_time[0] < 10) ? "0".$new_come_end_time[0] : $new_come_end_time[0];
  2830. $new_come_end_time_mins = ($new_come_end_time[1] < 10) ? "0".$new_come_end_time[1] : $new_come_end_time[1];
  2831. $end_time = $new_come_end_time_hrs . ":".$new_come_end_time_mins;
  2832. }
  2833. } else {
  2834. $begin_time = "-";
  2835. $end_time = "-";
  2836. }
  2837. $over_time = (isset($logs->over_time) && $logs->over_time != null) ? $logs->over_time : "-";
  2838. $attdate = date("d-M-Y", $logs->shift_date->sec);
  2839. $attdateday = date("l", $logs->shift_date->sec);
  2840. /* $attdate = $attdateonly.','. $attdateday; */
  2841. $output[] = array($attdate);
  2842. // array_push($output[$index], $attdate);
  2843. array_push($output[$index], $employee_number);
  2844. array_push($output[$index], $attdateday);
  2845. array_push($output[$index], $user_name);
  2846. array_push($output[$index], $job_title);
  2847. array_push($output[$index], $department);
  2848. array_push($output[$index], $begin_time);
  2849. array_push($output[$index], $end_time);
  2850. array_push($output[$index], $over_time);
  2851. }
  2852.  
  2853. $index++;
  2854. } //EOF user IF
  2855. } // EOF foreach for all logs
  2856. } // EOF foreach all date
  2857. $flag = true;
  2858. $cols = array(
  2859. 'Employee ID ||Column to display employee ',
  2860. 'Date||Column displays all the Dates selected in the specified duration.',
  2861. 'Day||Column displays the Particular Day corresponding to the date.',
  2862. 'Name||Column displays the Name of the employees.',
  2863. 'Job Title||Column displays the Job Tittle of the particular employee.',
  2864. 'Department||Column displays the Department to which the employee belongs.',
  2865. 'Shift Begin Time||Column displays the Time when the employee shift starts.',
  2866. 'Shift End Time||Column displays the Time when the employee shift ',
  2867. 'Over Time Duration||Column displays the Time by which the employee is doing overtime on that particular day.'
  2868. );
  2869.  
  2870. $roster_type = "Overtime-Datewise-Summary";
  2871. $date = date('d-m-Y', $from) . "-to-" . date('d-m-Y', $to);
  2872. $filenameexport = $roster_type . "_" . $date;
  2873. $final_output = array('output' => $output,
  2874. 'cols' => $cols,
  2875. 'filenameexport' => $filenameexport);
  2876. return $final_output;
  2877. }
  2878.  
  2879. // EOF function
  2880.  
  2881. /**
  2882. * Short description for function
  2883. *
  2884. * Long description (if any) ...
  2885. *
  2886. * @param array $post_data Parameter description (if any) ...
  2887. * @param unknown $tenant_id Parameter description (if any) ...
  2888. * @return array Return description (if any) ...
  2889. * @access public
  2890. * @static
  2891. */
  2892. public static function getAttendanceRoster($post_data, $tenant_id = null) {
  2893. $return = array();
  2894. //$sr_no=1;
  2895. $filter = $post_data['filter_id'];
  2896. $users = UserMongo::model()->getUsersByFilter($filter, $tenant_id, $post_data['active_inactive']);
  2897. // echo "<pre>"; print_r($users); exit("</pre> \n exited here ");
  2898. $output = array();
  2899. foreach ($users as $key => $user) {
  2900. $user_name = $user['personal']['firstname'] . " " . $user['personal']['lastname'];
  2901. $user_post = $user->getCurrentPosition($tenant_id);
  2902. $job_title = $user_post['designation'];
  2903. $department = $user_post['department'];
  2904. $business_unit = $user_post['business_unit'];
  2905. $date = strtotime(date('Y-m-d'));
  2906. $employee_number = $user['personal']['employee_no'];
  2907. $userShift = UserShift::getUserShift($user->id, $user->tenant_id);
  2908. if (!empty($userShift)) {
  2909. if ($userShift['type'] == UserShift::ROTATING_SHIFT) {
  2910. $userShift = UserShiftPlanner::getUserShift($user->id, $date, $user->tenant_id);
  2911. $weekly_obj = WeeklyOff::getWeeklyOff($userShift['weekly_off_id'], $user->tenant_id);
  2912. } else {
  2913. $get_weekly_obj = UserWeeklyOff::getUserWeeklyOffByUserId($user->id, $user->tenant_id);
  2914. if (isset($get_weekly_obj->weekly_off_id)) {
  2915. $weekly_obj = WeeklyOff::getWeeklyOff($get_weekly_obj->weekly_off_id, $user->tenant_id);
  2916. } else {
  2917. $weekly_obj = "";
  2918. }
  2919. }
  2920.  
  2921. // echo "<pre>"; print_r($weekly_obj); echo("</pre>"); exit();
  2922. $weekly_name = (isset($weekly_obj->weekly_off_name)) ? $weekly_obj->weekly_off_name : "";
  2923. $shift_obj = TenantShift::getTenantShift($userShift['shift_id'], $user->tenant_id);
  2924. $shift_name = (isset($shift_obj->shift_name)) ? $shift_obj->shift_name : "";
  2925. $policy_obj = AttendancePolicy::getAttendancePolicy($userShift['policy_id'], $user->tenant_id);
  2926. $policy_name = (isset($policy_obj->policy_name)) ? $policy_obj->policy_name : "";
  2927. if (isset($userShift['clocking_priority']['clocking_priority'])) {
  2928. switch ($userShift['clocking_priority']['clocking_priority']) {
  2929. case 0:
  2930. $clocking_priority = "Web";
  2931. break;
  2932. case 1:
  2933. $clocking_priority = "Hardware";
  2934. break;
  2935.  
  2936. default:
  2937. $clocking_priority = "Web";
  2938. break;
  2939. }
  2940. }
  2941. /**/
  2942. if(isset($userShift->controls['clocking_warning']) && $userShift->controls['clocking_warning'] == 1)
  2943. {
  2944. $clocking_warning_check = "ON";
  2945. }
  2946. else{
  2947. $clocking_warning_check = "OFF";
  2948. }
  2949. if(isset($userShift->controls['absent_warning']) && $userShift->controls['absent_warning'] == 1)
  2950. {
  2951. $absent_warning_check = "ON";
  2952. }
  2953. else{
  2954. $absent_warning_check = "OFF";
  2955. }
  2956.  
  2957.  
  2958. if ($userShift->clocking_priority->clocking_priority == 0 && !empty($userShift->ip_restriction)) {
  2959. $all_names = "";
  2960. if (!is_array($userShift->ip_restriction)) {
  2961. $userShift->ip_restriction = array($userShift->ip_restriction);
  2962. }
  2963. foreach ($userShift->ip_restriction as $key => $restriction) {
  2964. $ip_name = AttendanceIp::getNameById($restriction);
  2965. $ip_only_name = $ip_name['name'];
  2966. $new_array[$restriction]['name'] = $ip_name['name'];
  2967. $new_array[$restriction]['ip_from'] = $ip_name['ip_from'];
  2968. $new_array[$restriction]['ip_to'] = (isset($ip_name['ip_to']) && $ip_name['ip_to'] != "") ? $ip_name['ip_to'] : "N.A.";
  2969. $all_names = $all_names . $ip_only_name . ", ";
  2970. }
  2971. $all_names = substr_replace($all_names, "", -2);
  2972. }
  2973. else{
  2974. $all_names = "N.A.";
  2975. }
  2976. /**/
  2977. } // EOF empty if check
  2978. else {
  2979. $get_weekly_obj = UserWeeklyOff::getUserWeeklyOffByUserId($user->id, $user->tenant_id);
  2980. if (isset($get_weekly_obj->weekly_off_id)) {
  2981. $weekly_obj = WeeklyOff::getWeeklyOff($get_weekly_obj->weekly_off_id, $user->tenant_id);
  2982. $weekly_name = (isset($weekly_obj->weekly_off_name)) ? $weekly_obj->weekly_off_name : "";
  2983. } else {
  2984. $weekly_obj = "";
  2985. $weekly_name = "";
  2986. }
  2987. $shift_name = "";
  2988. $policy_name = "";
  2989. // $weekly_name = "";
  2990. $clocking_priority = "";
  2991. $clocking_warning_check = "";
  2992. $absent_warning_check = "";
  2993. $all_names = "N.A.";
  2994. // $action_checkbox = "<input type=\"checkbox\" name=\"roster_action\" value=\"\">";
  2995. }
  2996. $output[] = array(
  2997. // $action_checkbox,
  2998. $employee_number,
  2999. $user_name,
  3000. $job_title,
  3001. $department,
  3002. $business_unit,
  3003. $clocking_priority,
  3004. $shift_name,
  3005. $policy_name,
  3006. $weekly_name,
  3007. $all_names,
  3008. $clocking_warning_check,
  3009. $absent_warning_check,
  3010. );
  3011. } // EOF foreach
  3012. //echo "<pre>"; print_r($output); exit("</pre> \n exited here ");
  3013. $cols = array(
  3014. // "<input type=\\\"checkbox\\\" name=\\\"roster_action\\\" value=\\\"\\\">",
  3015. //'Sr No',
  3016. 'Employee ID ||Column displays employee id',
  3017. 'Name||Column displays the Name of the employees.',
  3018. 'Job Title||Column displays the Job Tittle of the particular employee.',
  3019. 'Department||Column displays the Department to which the employee belongs.',
  3020. 'Business Unit||Column displays the Business Unit to which the employee belongs.',
  3021. 'Clocking Priority||Column displays the details of employees Clocking Source.',
  3022. 'Shift Name||Column displays the details of the Shift assigned to the employee.',
  3023. 'Policy Name||Column displays the details of the Policy assigned to the employee.',
  3024. 'Weekly Off Name||Column displays the details of Weekly off type assigned to the employee.',
  3025. 'IP restriction Name||Column displays the details of IP restriction assigned to the employee.',
  3026. 'Clock-in reminder||Column displays whether clock-in reminder will be sent or not.',
  3027. 'Absent reminder||Column displays whether Absent reminder will be sent or not.',
  3028. );
  3029. $roster_type = "Attendance-Assignments";
  3030. $filenameexport = $roster_type;
  3031.  
  3032. $final_output = array('output' => $output,
  3033. 'cols' => $cols,
  3034. 'filenameexport' => $filenameexport);
  3035. return $final_output;
  3036. }
  3037.  
  3038. // EOF function
  3039.  
  3040. /**
  3041. * Short description for function
  3042. *
  3043. * Long description (if any) ...
  3044. *
  3045. * @param array $post_data Parameter description (if any) ...
  3046. * @param unknown $tenant_id Parameter description (if any) ...
  3047. * @param unknown $from Parameter description (if any) ...
  3048. * @param unknown $to Parameter description (if any) ...
  3049. * @return array Return description (if any) ...
  3050. * @access public
  3051. * @static
  3052. */
  3053. public static function getDailyAttendanceRoster($post_data, $tenant_id = null, $from = null, $to = null) {
  3054. $from = $from." 00:00:00";
  3055. $to = $to." 23:59:59";
  3056. $return = array();
  3057. $output = array();
  3058. $finaldata = array();
  3059. $index = 0;
  3060. $status_msg = "";
  3061. $todays_day = date("d");
  3062. $filter = $post_data['filter_id'];
  3063. $criteria = new EMongoCriteria();
  3064. $criteria->shift_date('>=', new MongoDate(strtotime($from)));
  3065. $criteria->shift_date('<=', new MongoDate(strtotime($to)));
  3066. $users = UserMongo::model()->getUsersByFilter($filter, $tenant_id, $post_data['active_inactive']);
  3067.  
  3068. $begin = new DateTime($from);
  3069. $end = new DateTime($to);
  3070. $end = $end->modify('+1 day');
  3071. $interval = new DateInterval('P1D');
  3072. $daterange = new DatePeriod($begin, $interval, $end);
  3073. $from = strtotime($from);
  3074. $to = strtotime($to);
  3075. $clockInSec = 0;
  3076. $clockOutSec = 0;
  3077. foreach ($users as $user)
  3078. {
  3079. // Getting users details...
  3080. $usermodel = UserMongo::model()->tenant($tenant_id)->findByPk($user->id);
  3081.  
  3082. $user_name = "";
  3083. $job_title_department = "";
  3084.  
  3085. $user_name = $usermodel->getFullname();
  3086. $employee_no = (isset($usermodel->personal->employee_no) && !empty($usermodel->personal->employee_no)) ? $usermodel->personal->employee_no : "N.A.";
  3087. $user_post = $usermodel->getCurrentPosition($tenant_id);
  3088. $job_title = $user_post['designation'];
  3089. $department = $user_post['department'];
  3090. $job_title_department = $job_title . "({$department})";
  3091.  
  3092. $criteria->user_id('==', $user->id);
  3093. $userAttendanceLogs = UserAttendanceLog::model()->tenant($tenant_id)->findAll($criteria);
  3094. $user_shift_id = '';
  3095. $user_policy_id = '';
  3096.  
  3097. foreach ($userAttendanceLogs as $key => $userAttendanceLog)
  3098. {
  3099. if (isset($userAttendanceLog))
  3100. {
  3101. $unpaidFlag = false;
  3102. $userid = $userAttendanceLog->user_id;
  3103.  
  3104. $shift_date = $userAttendanceLog->shift_date->sec;
  3105. $user_shift_planner = UserShiftPlanner::model()->findByPk($userAttendanceLog->shift_planner);
  3106.  
  3107. if ($user_shift_planner->shift_id != $user_shift_id)
  3108. {
  3109. $tenant_shift = TenantShift::model()->findByPk($user_shift_planner->shift_id);
  3110. }
  3111. $user_shift_id = $user_shift_planner->shift_id;
  3112.  
  3113. if ($user_shift_planner->policy_id != $user_policy_id)
  3114. {
  3115. $attendance_policy = AttendancePolicy::model()->findByPk($user_shift_planner->policy_id);
  3116. }
  3117. $user_policy_id = $user_shift_planner->policy_id;
  3118.  
  3119. /**/
  3120. //$shift_name = $logCalc["rosterShiftName"];
  3121. $shift_name = (isset($tenant_shift->shift_name) && $tenant_shift->shift_name != "") ? $tenant_shift->shift_name : "N.A.";
  3122. //$policy_name = $logCalc["rosterPolicyName"];
  3123. $policy_name = (isset($attendance_policy->policy_name) && $attendance_policy->policy_name != "") ? $attendance_policy->policy_name : "N.A.";
  3124.  
  3125. /*$clockInSec = (isset($logCalc["punchin_time"])) ? AttendanceHelper::getFormatedTime($logCalc["punchin_time"]) : "N.A.";
  3126. ;
  3127. $clockOutSec = (isset($logCalc["punchout_time"])) ? AttendanceHelper::getFormatedTime($logCalc["punchout_time"]) : "N.A.";
  3128. ;*/
  3129. $clockInSec = (isset($userAttendanceLog["punchin_time"]) && $userAttendanceLog["punchin_time"] != null) ? AttendanceHelper::getFormatedTime($userAttendanceLog["punchin_time"]) : "N.A.";
  3130. ;
  3131. $clockOutSec = (isset($userAttendanceLog["punchout_time"]) && $userAttendanceLog["punchout_time"] != null) ? AttendanceHelper::getFormatedTime($userAttendanceLog["punchout_time"]) : "N.A.";
  3132. ;
  3133.  
  3134. /*if (isset($logCalc["rosterOverTimeSec"])) {
  3135. if ($logCalc["rosterOverTimeSec"] > 0) {
  3136. $overTimeSec = RandomHelper::sec2hms($logCalc["rosterOverTimeSec"]);
  3137. } else {
  3138. $overTimeSec = "0:00";
  3139. }
  3140. } else {
  3141. $overTimeSec = "0:00";
  3142. }*/
  3143. $total_duration = (isset($userAttendanceLog["total_work_duration"]) && $userAttendanceLog["total_work_duration"] != null) ? AttendanceHelper::getFormatedTimeNewHrs($userAttendanceLog["total_work_duration"]) : "0:00";
  3144. //$lateBySec = (isset($logCalc["rosterLateBySec"])) ? RandomHelper::sec2hms($logCalc["rosterLateBySec"]) : "0:00";
  3145. $lateBySec = (isset($userAttendanceLog["coming_late_by"]) && $userAttendanceLog["coming_late_by"] != null) ? AttendanceHelper::getFormatedTimeNewHrs($userAttendanceLog["coming_late_by"]) : "0:00";
  3146. $overTimeSec = (isset($userAttendanceLog["over_time"]) && $userAttendanceLog["over_time"] != null) ? AttendanceHelper::getFormatedTimeNewHrs($userAttendanceLog["over_time"]) : "0:00";
  3147. ;
  3148. ////// status
  3149.  
  3150.  
  3151. $date = date("d", $shift_date);
  3152. if (isset($userAttendanceLog->attendance_status))
  3153. {
  3154. $status = $userAttendanceLog->attendance_status;
  3155. if ($status == UserAttendance::ATTENDANCE_STATUS_ABSENT) {
  3156. $status = UserAttendanceLog::ATTENDANCE_STATUS_ABSENT;
  3157. } elseif ($status == UserAttendance::ATTENDANCE_STATUS_PRESENT) {
  3158. $status = UserAttendanceLog::ATTENDANCE_STATUS_PRESENT;
  3159. }
  3160.  
  3161. $weeklyoff = $userAttendanceLog->is_weekly_off->status;
  3162. $holiday = $userAttendanceLog->is_holiday->status;
  3163. $leave = $userAttendanceLog->in_leave->status;
  3164.  
  3165. if (isset($userAttendanceLog->in_leave->leave_id))
  3166. {
  3167. $unpaidLeave = UserLeaves::model()->findByPk($userAttendanceLog->in_leave->leave_id);
  3168. if (isset($unpaidLeave->isUnpaid) && $unpaidLeave->isUnpaid == UserLeaves::LEAVE_UNPAID) {
  3169. $unpaidFlag = true;
  3170. } else {
  3171. $unpaidFlag = false;
  3172. }
  3173. } else {
  3174. $unpaidFlag = false;
  3175. }
  3176. $present_or_not = '';
  3177. if (isset($weeklyoff) && $weeklyoff == "1")
  3178. {
  3179. $status = "W";
  3180. }
  3181. elseif (isset($holiday) && $holiday == "1")
  3182. {
  3183. $status = "H";
  3184. }
  3185. elseif (isset($leave) && $leave == "1")
  3186. {
  3187. if ($status == UserAttendanceLog::ATTENDANCE_STATUS_PRESENT || $status == UserAttendanceLog::ATTENDANCE_STATUS_PENDING)
  3188. {
  3189. $present_or_not = 'Present ';
  3190. }
  3191. $status = "L";
  3192. }
  3193. elseif ($status == UserAttendanceLog::ATTENDANCE_STATUS_PRESENT || $status == UserAttendanceLog::ATTENDANCE_STATUS_PENDING)
  3194. {
  3195. $status = "P";
  3196. } /* elseif ($status == UserAttendanceLog::ATTENDANCE_STATUS_PENDING) {
  3197. $status = "n";
  3198. } */
  3199. elseif ($status == UserAttendanceLog::ATTENDANCE_STATUS_ABSENT || $status == UserAttendance::ATTENDANCE_STATUS_ABSENT)
  3200. {
  3201. $status = "A";
  3202. }
  3203. else
  3204. {
  3205. $status = "";
  3206. }
  3207. }
  3208. else
  3209. {
  3210. $status = "";
  3211. }
  3212.  
  3213. if ($unpaidFlag)
  3214. {
  3215. $status = "U";
  3216. }
  3217.  
  3218. switch ($status)
  3219. {
  3220. case 'P':
  3221. $status_msg = "Present";
  3222. break;
  3223. case 'A':
  3224. $status_msg = "Absent";
  3225. break;
  3226. case 'W':
  3227. $status_msg = "Weekly Off";
  3228. break;
  3229. case 'H':
  3230. $status_msg = "Holiday" . '(' . $userAttendanceLog->is_holiday->holiday_name . ')';
  3231. break;
  3232. case 'L':
  3233. case 'U':
  3234.  
  3235. //in leave
  3236. $leave_id = $userAttendanceLog->in_leave->leave_id;
  3237. $userLeaves = UserLeaves::model()->tenant()->findByPk($leave_id);
  3238. if (!empty($userLeaves))
  3239. {
  3240. $tenantLeave = $userLeaves->leaveType();
  3241. $leave_type = (isset($tenantLeave->name))? $tenantLeave->name : 'Unpaid Leave';
  3242.  
  3243. if ($userLeaves->is_half_day == UserLeaves::HALF_DAY_NO) {
  3244.  
  3245. $wired_msg = $present_or_not."On Leave" . ' (' . $leave_type . ')';
  3246. } else {
  3247. $wired_msg = $present_or_not."HalfDay Leave" . ' (' . $leave_type . ')';
  3248. }
  3249. }
  3250. $status_msg = $wired_msg;
  3251. break;
  3252.  
  3253. default:
  3254. $status_msg = "-";
  3255. break;
  3256. }
  3257.  
  3258. ////// status
  3259. $attdate = date("d-M-Y", $shift_date);
  3260. $attdateday = date("l", $shift_date);
  3261. $attdate_day = $attdate . "(" . substr($attdateday, 0, 3) . ")";
  3262. $output[] = array($attdate_day);
  3263.  
  3264. array_push($output[$index], $employee_no, $user_name, $job_title_department, $shift_name, $policy_name, $clockInSec, $clockOutSec, $total_duration, $lateBySec, $overTimeSec, $status_msg);
  3265.  
  3266. /*
  3267. array_push($output[$index], $user_name);
  3268. array_push($output[$index], $job_title_department);
  3269. array_push($output[$index], $shift_name);
  3270. array_push($output[$index], $policy_name);
  3271. array_push($output[$index], $clockInSec);
  3272. array_push($output[$index], $clockOutSec);
  3273. array_push($output[$index], $total_duration);
  3274. array_push($output[$index], $lateBySec);
  3275. array_push($output[$index], $overTimeSec);
  3276. array_push($output[$index], $status_msg);
  3277. */
  3278. $index++;
  3279. }
  3280. } // EOF foreach all date
  3281. // break;
  3282. } // EOF foreach for users count...
  3283. $flag = true;
  3284. $cols = array(
  3285. 'Date||Column displays Date.',
  3286. 'Employee ID||Column displays Employee Number.',
  3287. 'Name||Column displays Name.',
  3288. 'Job Title||Column displays Job Title.',
  3289. 'Shift Name||Column displays Shift Name.',
  3290. 'Policy Name||Column displays Policy Name.',
  3291. 'Clock In||Column displays Clock In.',
  3292. 'Clock Out||Column displays Clock Out.',
  3293. 'Work Duration||Column displays Work Duration.',
  3294. 'Late by||Column displays Late By.',
  3295. 'Overtime||Column displays Overtime.',
  3296. 'Status||Column displays Status.'
  3297. );
  3298.  
  3299. $roster_type = "Daily-Attendance-Report";
  3300. $date = date('d-m-Y', $from) . "-to-" . date('d-m-Y', $to);
  3301. $filenameexport = $roster_type . "_" . $date;
  3302. $final_output = array('output' => $output,
  3303. 'cols' => $cols,
  3304. 'filenameexport' => $filenameexport);
  3305. return $final_output;
  3306. }
  3307.  
  3308. // EOF function
  3309.  
  3310. /**
  3311. * Short description for function
  3312. *
  3313. * Long description (if any) ...
  3314. *
  3315. * @param array $post_data Parameter description (if any) ...
  3316. * @param unknown $tenant_id Parameter description (if any) ...
  3317. * @param unknown $from Parameter description (if any) ...
  3318. * @param unknown $to Parameter description (if any) ...
  3319. * @return array Return description (if any) ...
  3320. * @access public
  3321. * @static
  3322. */
  3323. public static function getCompleteAttendanceSummaryRoster($post_data, $tenant_id = null, $from = null, $to = null) {
  3324. $return = array();
  3325. $output = array();
  3326. $finaldata = array();
  3327. $index = 0;
  3328.  
  3329. $status_msg = "";
  3330. $todays_day = date("d");
  3331. $filter = $post_data['filter_id'];
  3332. $criteria = new EMongoCriteria();
  3333. $criteria->shift_date('>=', new MongoDate(strtotime($from)));
  3334. $criteria->shift_date('<=', new MongoDate(strtotime($to)));
  3335. $users = UserMongo::model()->getUsersByFilter($filter, $tenant_id, $post_data['active_inactive']);
  3336.  
  3337. $begin = new DateTime($from);
  3338. $end = new DateTime($to);
  3339. $end = $end->modify('+1 day');
  3340. $interval = new DateInterval('P1D');
  3341. $daterange = new DatePeriod($begin, $interval, $end);
  3342. $from = strtotime($from);
  3343. $to = strtotime($to);
  3344.  
  3345. foreach ($users as $user) {
  3346. $employee_id = $user->personal->employee_no;
  3347. $jindex = 0;
  3348. $present_count = 0;
  3349. $absent_count = 0;
  3350. $leave_count = 0;
  3351. $unpaid_leaves_count = 0;
  3352. $weeklyoff_count = 0;
  3353. $holiday_count = 0;
  3354. $totalWorkDurationTimeStamp = 0;
  3355. $workingDaysCount = 0;
  3356. $comingLateBy = 0;
  3357. $comingLateCounter = 0;
  3358. $goingearly = 0;
  3359. $goingearlytotal = 0;
  3360. $overTimeSecCounter = 0;
  3361. $overTimeSec = 0;
  3362. $unpaidleave_count = 0;
  3363. $shift_name = "";
  3364. $policy_name = "";
  3365. $weeklyOffName = "";
  3366. $clockingPriority = "";
  3367. $criteria->user_id('==', $user->id);
  3368. $userAttendanceLogs = UserAttendanceLog::model()->tenant($tenant_id)->findAll($criteria);
  3369. $unpaidFlag = false;
  3370. $user_name = "";
  3371. $job_title_department = "";
  3372. $userid = $user->id;
  3373. $usermodel = UserMongo::model()->tenant($tenant_id)->findByPk($userid);
  3374. $user_name = $usermodel->getFullname();
  3375. $user_post = $usermodel->getCurrentPosition($tenant_id);
  3376. $job_title = $user_post['designation'];
  3377. $department = $user_post['department'];
  3378. $job_title_department = $job_title . "({$department})";
  3379. $user_id = $usermodel->id;
  3380. // echo "<pre>"; print_r($userAttendanceLogs); //exit("</pre> \n exited here ");
  3381. foreach ($daterange as $date) {
  3382. if (isset($userAttendanceLogs[$jindex])) {
  3383. $shift_date = $userAttendanceLogs[$jindex]->shift_date->sec;
  3384. $logCalc = AttendanceHelper::logCalculator($user_id, $shift_date, $tenant_id, true);
  3385. // echo "<pre>"; print_r($logCalc); //exit("</pre> \n exited here \n");
  3386. $shift_name = (isset($logCalc["rosterShiftName"])) ? $logCalc["rosterShiftName"] : "";
  3387. $policy_name = $logCalc["rosterPolicyName"];
  3388. $weeklyOffName = (isset($logCalc["rosterWeeklyOffName"])) ? $logCalc["rosterWeeklyOffName"] : "";
  3389. $clockingPriority = (isset($logCalc["rosterClockingPriority"])) ? $logCalc["rosterClockingPriority"] : "";
  3390.  
  3391. ////// status
  3392.  
  3393. if (isset($userAttendanceLogs[$jindex]->attendance_status)) {
  3394. $status = $userAttendanceLogs[$jindex]->attendance_status;
  3395.  
  3396. if ($status == UserAttendance::ATTENDANCE_STATUS_ABSENT) {
  3397. $status = UserAttendanceLog::ATTENDANCE_STATUS_ABSENT;
  3398. } elseif ($status == UserAttendance::ATTENDANCE_STATUS_PRESENT) {
  3399. $status = UserAttendanceLog::ATTENDANCE_STATUS_PRESENT;
  3400. }
  3401.  
  3402. $weeklyoff = $userAttendanceLogs[$jindex]->is_weekly_off->status;
  3403. $holiday = $userAttendanceLogs[$jindex]->is_holiday->status;
  3404. $leave = $userAttendanceLogs[$jindex]->in_leave->status;
  3405. if (isset($userAttendanceLogs[$jindex]->in_leave->leave_id)) {
  3406. $unpaidLeave = UserLeaves::model()->findByPk($userAttendanceLogs[$jindex]->in_leave->leave_id);
  3407. if ($unpaidLeave->isUnpaid == UserLeaves::LEAVE_UNPAID) {
  3408. $unpaidleave_count++;
  3409. }
  3410. }
  3411. if (isset($weeklyoff) && $weeklyoff == "1") {
  3412. $weeklyoff_count++;
  3413. } elseif (isset($holiday) && $holiday == "1") {
  3414. $holiday_count++;
  3415. } elseif (isset($leave) && $leave == "1") {
  3416. $leave_count++;
  3417. } elseif ($status == UserAttendanceLog::ATTENDANCE_STATUS_PRESENT || $status == UserAttendanceLog::ATTENDANCE_STATUS_PENDING) {
  3418. $present_count++;
  3419. } /* elseif ($status == UserAttendanceLog::ATTENDANCE_STATUS_PENDING) {
  3420. $status = "n";
  3421. } */ elseif ($status == UserAttendanceLog::ATTENDANCE_STATUS_ABSENT || $status == UserAttendance::ATTENDANCE_STATUS_ABSENT) {
  3422. $absent_count++;
  3423. }
  3424. }
  3425.  
  3426. ////// status
  3427. /// attendance
  3428.  
  3429. if ($status == UserAttendanceLog::ATTENDANCE_STATUS_PRESENT || $status == UserAttendanceLog::ATTENDANCE_STATUS_PENDING) {
  3430. if (isset($userAttendanceLogs[$jindex]->total_duration) && $userAttendanceLogs[$jindex]->total_duration != 0) {
  3431. $totalWorkDurationTimeStamp += $userAttendanceLogs[$jindex]->total_duration;
  3432. $workingDaysCount++;
  3433. }
  3434. }
  3435.  
  3436.  
  3437. if (isset($userAttendanceLogs[$jindex]->coming_late_by) && $userAttendanceLogs[$jindex]->coming_late_by != null) {
  3438. if (isset($logCalc["rosterLateBySec"])) {
  3439.  
  3440. // echo $userAttendanceLogs[$jindex]->coming_late_by . "<br>";
  3441. // echo $logCalc["rosterLateBySec"] . "<br>";
  3442. $comingLateBy += $logCalc["rosterLateBySec"];
  3443. $comingLateCounter++;
  3444. }
  3445. }
  3446.  
  3447. if (isset($userAttendanceLogs[$jindex]->over_time) && $userAttendanceLogs[$jindex]->over_time != '0') {
  3448.  
  3449. $overTimeSec += $logCalc['rosterOverTimeSec'];
  3450. $overTimeSecCounter++;
  3451. }
  3452. if (!empty($logCalc["total_duration"])) {
  3453. if ($logCalc["total_duration"] < $logCalc["rosterShiftSeconds"]) {
  3454. $goingearlytotal += $logCalc["rosterShiftSeconds"] - $logCalc["total_duration"];
  3455. $goingearly++;
  3456. }
  3457. }
  3458.  
  3459.  
  3460.  
  3461. $attdate = date("d-M-Y", $shift_date);
  3462. $attdateday = date("l", $shift_date);
  3463. $attdate_day = $attdate . "(" . substr($attdateday, 0, 3) . ")";
  3464. /// attendance
  3465. $jindex++;
  3466. } // EOF if isset
  3467. } // EOF foreach all date
  3468. if (isset($totalWorkDurationTimeStamp)) {
  3469. $totalWorkedHr = RandomHelper::sec2hms($totalWorkDurationTimeStamp);
  3470. if ($workingDaysCount > 0) {
  3471.  
  3472. $daillyAverage = $totalWorkDurationTimeStamp / $workingDaysCount;
  3473. $daillyAverage = RandomHelper::sec2hms($daillyAverage);
  3474. } else {
  3475. $daillyAverage = 0;
  3476. $daillyAverage = "0:00";
  3477. }
  3478. } else {
  3479. $totalWorkedHr = 0;
  3480. $weeklyAverage = 0;
  3481. $daillyAverage = 0;
  3482. }
  3483. if (isset($comingLateBy) && $comingLateCounter != 0) {
  3484. $avgLateBy = $comingLateBy / $comingLateCounter;
  3485. $avgLateBy = RandomHelper::sec2hms($avgLateBy);
  3486. } else {
  3487. $avgLateBy = "00:00";
  3488. }
  3489.  
  3490. if (isset($goingearlytotal) && $goingearlytotal != 0) {
  3491. $avgtime = $goingearlytotal / $goingearly;
  3492. $finalavg = RandomHelper::sec2hms($avgtime);
  3493. } else {
  3494. $avgtime = 0;
  3495. $finalavg = '00:00';
  3496. }
  3497.  
  3498. if ($overTimeSec != 0) {
  3499. $overTimeSec = $overTimeSec / $overTimeSecCounter;
  3500. $overTimeSec = RandomHelper::sec2hms($overTimeSec);
  3501. } else {
  3502. $overTimeSec = "0";
  3503. }
  3504. $output[] = array($employee_id);
  3505. array_push($output[$index], $user_name);
  3506.  
  3507. array_push($output[$index], $job_title_department);
  3508. array_push($output[$index], $shift_name);
  3509. array_push($output[$index], $policy_name);
  3510. array_push($output[$index], $weeklyOffName);
  3511. array_push($output[$index], $clockingPriority);
  3512. array_push($output[$index], $present_count);
  3513. array_push($output[$index], $absent_count);
  3514. array_push($output[$index], $leave_count);
  3515. array_push($output[$index], $unpaid_leaves_count);
  3516. // array_push($output[$index], $overTimeSec);
  3517. array_push($output[$index], $totalWorkedHr);
  3518. array_push($output[$index], $daillyAverage);
  3519. array_push($output[$index], $comingLateCounter);
  3520. array_push($output[$index], $avgLateBy);
  3521. array_push($output[$index], $goingearly);
  3522. array_push($output[$index], $finalavg);
  3523. array_push($output[$index], $overTimeSecCounter);
  3524. array_push($output[$index], $overTimeSec);
  3525. $index++;
  3526. // break;
  3527. } // EOF user foreach
  3528. $flag = true;
  3529. $cols = array(
  3530. 'Employee ID||Employee id',
  3531. 'Name||Name',
  3532. 'Job Title||Job Title',
  3533. 'Shift||Shift Assinged',
  3534. 'Policy||Policy Name',
  3535. 'Weekly Off||Weekly off Name',
  3536. 'Mode||The method by which employee clocks in and out, either Web/Online or Biometric/Hardware.',
  3537. 'Present||Total days when employee was marked Present.',
  3538. 'Absent||Total days when employee was marked Absent.',
  3539. 'Leaves||Total leaves taken by employee during this period.',
  3540. 'Unpaid||Unpaid leaves taken during this period.',
  3541. 'Total Worked Hours||Total number of hours employee has worked during this period.',
  3542. 'Daily Avg. Work Duration||An average of daily work duration for this period.',
  3543. 'Late Marks||Total number of days when employee was marked late to work.',
  3544. 'Avg. Late By||Average number of hours by which employee was on late marked days during this period.',
  3545. 'Early Clock Outs||Number of days when employee clocked out before completing shift duration.',
  3546. 'Avg. Early Clock Out by||Average number of hours by which employee clocked out on days marked as Early clock out.',
  3547. 'Over Time Days||Number of days when employee clocked over time hours during this period.',
  3548. 'Avg. Over Time||Average number of hours by which employee worked over time during this period.'
  3549. );
  3550.  
  3551. $roster_type = "Complete-Attendance-Summary";
  3552. $date = date('d-m-Y', $from) . "-to-" . date('d-m-Y', $to);
  3553. $filenameexport = $roster_type . "_" . $date;
  3554. $final_output = array('output' => $output,
  3555. 'cols' => $cols,
  3556. 'filenameexport' => $filenameexport);
  3557. return $final_output;
  3558. }
  3559.  
  3560. // EOF function
  3561.  
  3562. /**
  3563. * Short description for function
  3564. *
  3565. * Long description (if any) ...
  3566. *
  3567.  
  3568. * @param string $birth_day_month Parameter description (if any) ...
  3569. * @return number Return description (if any) ...
  3570. * @access public
  3571. * @static
  3572. */
  3573. public static function days_till_birthday($birth_day_month) {
  3574. $bts = strtotime($birth_day_month . " " . date("y"));
  3575. $ts = time();
  3576. if ($bts < $ts) {
  3577. $bts = strtotime($birth_day_month . " " . date("y", strtotime("+1 year")));
  3578. }
  3579. return round(($bts - $ts) / 86400);
  3580. }
  3581.  
  3582. /**
  3583. * Short description for function
  3584. *
  3585. * Long description (if any) ...
  3586. *
  3587. * @return array Return description (if any) ...
  3588. * @access public
  3589. * @static
  3590. */
  3591. public static function loadFilters() {
  3592. $filters = array();
  3593. $userMongo = UserMongo::model()->tenant()->findByAttributes(array('user_id' => Yii::app()->user->id));
  3594. if(Yii::app()->cache->executeCommand("hget", array(Yii::app()->user->getTenantId().":".Yii::app()->user->id,"Owner")) && Yii::app()->session['menu_owner'])
  3595. {
  3596. //$filters['ALL'] = array('ALL_0' => 'All Employees');
  3597. // $filters['Designations'] = self::getAllDesignations();
  3598. // $filters['Departments'] = UserDepartments::getAllDepartments();
  3599. // $filters['Locations'] = TenantOffices::getTenantOfficeLocation();
  3600. // $filters['Employee Type'] = TenantUserTypes::getTenantTypes();
  3601. }
  3602. /* if(isset($userMongo) && !empty($userMongo))
  3603. {*/
  3604. elseif($userMongo->checkManager())
  3605. {
  3606. $filters['ALL'] = array('ALL_0' => 'All Reportees');
  3607. $filters['Reportees'] = $userMongo->getManagedUsersForRosters();
  3608. }
  3609. // }
  3610. // $filters['Shift'] = TenantShift::getTenantShiftArray();
  3611. return $filters;
  3612. }
  3613.  
  3614. /**
  3615. * Short description for function
  3616. *
  3617. * Long description (if any) ...
  3618. *
  3619. * @return array Return description (if any) ...
  3620. * @access public
  3621. * @static
  3622. */
  3623. public static function loadCustomRosterFilter() {
  3624. $roster_attribute_labels = array();
  3625. $usermongo_obj = new UserMongo;
  3626. $roster_attribute_labels = $usermongo_obj::model()->rosterAttributeLabels();
  3627. // echo "<pre>"; print_r($roster_attribute_labels); exit("</pre> \n exited here ");
  3628. return $roster_attribute_labels;
  3629. /* //remove later
  3630. $embedded_documents = $usermongo_obj::model()->embeddedDocuments();
  3631. foreach ($embedded_documents as $model_name => $model) {
  3632. $m = new $model;
  3633. $filters[$model_name] = $m->attributes;
  3634. // echo "<pre>"; print_r($filters); exit("</pre> \n exited here ");
  3635. } */
  3636. }
  3637.  
  3638. /**
  3639. * Short description for function
  3640. *
  3641. * Long description (if any) ...
  3642. *
  3643. * @return array Return description (if any) ...
  3644. * @access public
  3645. * @static
  3646. */
  3647. public static function getAllDesignations() {
  3648. $desigs = UserDesignations::model()->tenant()->findAll();
  3649. $collection = array();
  3650. foreach ($desigs as $desig) {
  3651. $collection['DESG_' . $desig->id] = $desig->designation_name;
  3652. }
  3653. return $collection;
  3654. }
  3655.  
  3656. /**
  3657. * Short description for function
  3658. *
  3659. * Long description (if any) ...
  3660. *
  3661. * @param unknown $tenant_id Parameter description (if any) ...
  3662. * @return object Return description (if any) ...
  3663. * @access public
  3664. */
  3665. public function tenant($tenant_id = null) {
  3666. $this->getDbCriteria()->mergeWith(array(
  3667. 'conditions' => array(
  3668. 'tenant_id' => array('==' => ($tenant_id == null) ? Yii::app()->user->getTenantId() : $tenant_id),
  3669. ),
  3670. 'sort' => array(
  3671. 'unit_name' => EMongoCriteria::SORT_ASC,
  3672. ),
  3673. ));
  3674. return $this;
  3675. }
  3676.  
  3677. public static function getLeavesCarriedForwardBalance($post_data, $tenant_id = null, $from = null, $to = null) {
  3678. //$tenat_leave = Leaves::model()->tenant($tenant_id)->findAll();
  3679. //echo "<pre>"; print_r($tenat_leave); exit("\n exited in " . __FILE__ . " @ " . __LINE__. "</pre>");
  3680. $return = array();
  3681. //$sr_no=1;
  3682. $filter = $post_data['filter_id'];
  3683. $users = UserMongo::model()->getUsersByFilter($filter, $tenant_id, $post_data['active_inactive']);
  3684. $output = array();
  3685. $leaves = Leaves::model()->getTenantLeaveList($tenant_id);
  3686.  
  3687. $index = 0;
  3688. foreach ($users as $key => $user) {
  3689. $employee_number = (isset($user['personal']['employee_no'])) ? $user['personal']['employee_no'] : "N.A.";
  3690. $user_name = $user['personal']['firstname'] . " " . $user['personal']['lastname'];
  3691. $user_post = $user->getCurrentPosition($tenant_id);
  3692. $job_title = $user_post['designation'];
  3693. $department = $user_post['department'];
  3694. $business_unit = $user_post['business_unit'];
  3695. // $action_checkbox = "<input type=\"checkbox\" name=\"roster_action\" value=\"\">";
  3696. $leaves_user_allowed = Leaves::model()->getLeaveList($tenant_id, $user->user_id);
  3697. unset($userleaves);
  3698. foreach ($leaves as $leave_id => $leave) {
  3699. if (array_key_exists($leave_id, $leaves_user_allowed)) {
  3700. $userleaves[] = LeavesHelper::individualLeaveBalance($user->user_id, $tenant_id, $leave_id);
  3701. } else {
  3702. $userleaves[] = array(
  3703. 'leave_name' => 'NA',
  3704. 'balance' => 'NA',
  3705. 'total' => 'NA',
  3706. 'prevBalance' => 'NA'
  3707. );
  3708. }
  3709. }
  3710. $output[] = array(
  3711. // $action_checkbox,
  3712. $employee_number,
  3713. $user_name,
  3714. $job_title,
  3715. $department,
  3716. $business_unit,
  3717. );
  3718. for ($i = 0; $i < count($userleaves); $i++) {
  3719. array_push($output[$index], $userleaves[$i]['prevBalance']);
  3720. }
  3721. $index++;
  3722. } // EOF foreach user
  3723.  
  3724. $cols = array(
  3725. // "<input type=\\\"checkbox\\\" name=\\\"roster_action\\\" value=\\\"\\\">",
  3726. //'Sr No',
  3727. 'Employee ID',
  3728. 'Name',
  3729. 'Job Title',
  3730. 'Department',
  3731. 'Business Unit',
  3732. );
  3733.  
  3734. foreach ($leaves as $leave_id => $leave_name) {
  3735. array_push($cols, $leave_name);
  3736. }
  3737. $roster_type = "Leaves-Credited";
  3738. $filenameexport = $roster_type;
  3739. $final_output = array('output' => $output,
  3740. 'cols' => $cols,
  3741. 'filenameexport' => $filenameexport);
  3742. return $final_output;
  3743. }
  3744.  
  3745. public static function getEmployeeExitReport($post_data, $tenant_id = null,$from, $to) {
  3746. $return = array();
  3747. $filter = $post_data['filter_id'];
  3748. $users = UserMongo::model()->getUsersByFilter($filter, $tenant_id, 3);
  3749.  
  3750. $output = array();
  3751. foreach ($users as $key => $user) {
  3752. $employee_number = (isset($user['personal']['employee_no'])) ? $user['personal']['employee_no'] : "N.A.";
  3753. $user_name = $user['personal']['firstname'] . " " . $user['personal']['lastname'];
  3754. $user_post = $user->getCurrentPosition($tenant_id);
  3755. $job_title = $user_post['designation'];
  3756. $department = $user_post['department'];
  3757. $business_unit = $user_post['business_unit'];
  3758.  
  3759. if (isset($user->deactivate_date) && $user->deactivate_date->sec != null) {
  3760. // checking whether it is in range
  3761. $deactivateDate = date('Y-m-d',$user->deactivate_date->sec);
  3762. $deactivation_Begin = date('Y-m-d', strtotime($from));
  3763. $deactivation_End = date('Y-m-d', strtotime($to));
  3764. if (($deactivateDate > $deactivation_Begin) && ($deactivateDate < $deactivation_End))
  3765. {
  3766. // checking whether it is in range
  3767. if (isset($user->doj) && isset($user->deactivate_date)) {
  3768. $doj = new DateTime(date("Y-m-d", $user->doj->sec)); // or your date as well
  3769. $deactivate_date = new DateTime(date("Y-m-d", $user->deactivate_date->sec));
  3770. $interval = $doj->diff($deactivate_date);
  3771. $final_exp = $interval->format('%y years %m months and %d days');
  3772. $job_experience = $final_exp;
  3773. } else {
  3774. $job_experience = "NA";
  3775. }
  3776. if (isset($user->deactivate_reason)) {
  3777. $deactivateReason = UserDeactivate::model()->tenant()->findByPk($user->deactivate_reason);
  3778. $exit_type = (isset($deactivateReason->type) && $deactivateReason->type == UserDeactivate::USER_DEACTIVATE_TERMINATED) ? "Terminated" : "Resigned";
  3779. $exit_reason = (isset($deactivateReason->value) && $deactivateReason->value != null) ? $deactivateReason->value : "NA";
  3780. } else {
  3781. $exit_type = "NA";
  3782. $exit_reason = "NA";
  3783. }
  3784. $doj = (isset($user->doj) && $user->doj != null) ? date('d/m/Y', $user->doj->sec) : "NA";
  3785. $exit_date = (isset($user->deactivate_date) && $user->deactivate_date != null) ? date('d/m/Y', $user->deactivate_date->sec) : "NA";
  3786. $deactivate_by = (isset($user->deactivate_by) && $user->deactivate_by != null) ? UserMongo::getFullnameById($user->deactivate_by) : "NA";
  3787. $deactivate_on = (isset($user->deactivate_created_on) && $user->deactivate_created_on != null) ? date('d/m/Y', $user->deactivate_created_on->sec) : "NA";
  3788. // } else {
  3789. // $dob_year = "N.A.";
  3790. // $dob_month = "N.A.";
  3791. // $dob_day = "N.A.";
  3792. // $age = "N.A.";
  3793. // $no_days_remain = "N.A.";
  3794. // }
  3795. // $action_checkbox = "<input type=\"checkbox\" name=\"roster_action\" value=\"\">";
  3796. $output[] = array(
  3797. $employee_number,
  3798. $user_name,
  3799. $job_title,
  3800. $department,
  3801. $business_unit,
  3802. $doj,
  3803. $job_experience,
  3804. $exit_date,
  3805. $exit_type,
  3806. $exit_reason,
  3807. $deactivate_by,
  3808. $deactivate_on,
  3809. );
  3810. }
  3811. }
  3812. } // EOF foreach
  3813. // echo "<pre>"; print_r($output); exit("</pre> \n exited here ");
  3814. $cols = array(
  3815. // "<input type=\\\"checkbox\\\" name=\\\"roster_action\\\" value=\\\"\\\">",
  3816. //'SR NO',
  3817. 'Employee ID',
  3818. 'Name',
  3819. 'Job Title',
  3820. 'Department',
  3821. 'Business Unit',
  3822. 'Joining Date',
  3823. 'Job experience',
  3824. 'Exit Date',
  3825. 'Exit Type',
  3826. 'Exit Reason',
  3827. 'Deactivated by',
  3828. 'Deactivated on'
  3829. );
  3830.  
  3831. $filenameexport = "Employee-Deactivated-Data";
  3832. $final_output = array('output' => $output,
  3833. 'cols' => $cols,
  3834. 'filenameexport' => $filenameexport);
  3835. return $final_output;
  3836. }
  3837.  
  3838. /**
  3839.  
  3840. * Short description for function
  3841. *
  3842. * Long description (if any) ...
  3843. *
  3844. * @param array $post_data Parameter description (if any) ...
  3845. * @param unknown $tenant_id Parameter description (if any) ...
  3846. * @param unknown $user_id Parameter description (if any) ...
  3847. * @return array Return description (if any) ...
  3848. * @access public
  3849. * @static
  3850. */
  3851. public static function getUnpaidLeavesTaken($post_data, $tenant_id, $from, $to) {
  3852.  
  3853. $return = array();
  3854. //$sr_no=1;
  3855. $filter = $post_data['filter_id'];
  3856. $users = UserMongo::model()->getUsersByFilter($filter, $tenant_id, $post_data['active_inactive']);
  3857. $output = array();
  3858. $leave_settings = TenantLeavesSettings::model()->findByAttributes(array('tenant_id' => $tenant_id));
  3859. // $leaves = Leaves::model()->getLeaveList($tenant_id, $user_id);
  3860. if(isset($leave_settings->unpaid_refresh) && $leave_settings->unpaid_refresh == TenantLeavesSettings::FINANCIAL_UNPAID_REFRESH){
  3861. $tenantProfile = TenantProfile::model()->tenant($tenant_id)->find();
  3862. $year_to_pass = date('Y');
  3863. $month_list = $tenantProfile->getMonthList('Y-m','M', $year_to_pass);
  3864. }
  3865. else{
  3866. $tenantProfile = TenantProfile::model()->tenant($tenant_id)->find();
  3867. $month_list = $tenantProfile->getMonthListCalendar('Y-m','M');
  3868. }
  3869. //$leaves = Leaves::model()->getTenantLeaveList($tenant_id);
  3870. $index = 0;
  3871. foreach ($users as $key => $user) {
  3872. $employee_number = (isset($user['personal']['employee_no'])) ? $user['personal']['employee_no'] : "N.A.";
  3873. $user_name = $user['personal']['firstname'] . " " . $user['personal']['lastname'];
  3874. $user_post = $user->getCurrentPosition($tenant_id);
  3875. $job_title = $user_post['designation'];
  3876. $department = $user_post['department'];
  3877. $business_unit = $user_post['business_unit'];
  3878. // $action_checkbox = "<input type=\"checkbox\" name=\"roster_action\" value=\"\">";
  3879. // $leaves_user_allowed = Leaves::model()->getLeaveList($tenant_id, $user->user_id);
  3880. // unset($userleaves);
  3881. $check_total = 0;
  3882. foreach ($month_list as $for_month => $month){
  3883. $leaves_approved = UserLeaves::model()->user_approved_leave($user->id)->forMonth($for_month)->unpaid()->findAll();
  3884. $total_days = 0;
  3885. foreach ($leaves_approved as $le){
  3886. $wekly_off_days = RandomHelper::getWorkingDays($le->from_date->sec, $le->to_date->sec, $le->user_id, $le->tenant_id);
  3887. if (!empty($wekly_off_days)){
  3888. if ($le->is_half_day == UserLeaves::HALF_DAY_YES){
  3889. $total_days += 0.5;
  3890. }
  3891. }
  3892. else{
  3893. if ($total_days > 0){
  3894. $total_days -= 0.5;
  3895. }
  3896. }
  3897. }
  3898. /**/
  3899. $counter = 0;
  3900. $counter_new = 0;
  3901. $counter = UserLeaves::getCountOfMonthsUnpaid($user->id, $for_month);
  3902. if ($counter > 0)
  3903. {
  3904. $counter = $counter - $total_days;
  3905. }
  3906. else
  3907. {
  3908. $counter = $counter;
  3909. }
  3910. $check_total += $counter;
  3911. }
  3912. //
  3913.  
  3914. $output[] = array(
  3915. // $action_checkbox,
  3916. $employee_number,
  3917. $user_name,
  3918. $job_title,
  3919. $department,
  3920. $business_unit,
  3921. $check_total,
  3922. );
  3923. // for ($i = 0; $i < count($userleaves); $i++) {
  3924. // $newfinal = $userleaves[$i];
  3925. // array_push($output[$index], $newfinal);
  3926. // }
  3927. $index++;
  3928. } // EOF foreach user
  3929.  
  3930.  
  3931.  
  3932. $cols = array(
  3933. // "<input type=\\\"checkbox\\\" name=\\\"roster_action\\\" value=\\\"\\\">",
  3934. //'Sr No',
  3935. 'Employee ID',
  3936. 'Name',
  3937. 'Job Title',
  3938. 'Department',
  3939. 'Business Unit',
  3940. 'Unpaid Leaves'
  3941. );
  3942.  
  3943. // foreach ($leaves as $leave_id => $leave_name) {
  3944. // array_push($cols, $leave_name);
  3945. // }
  3946.  
  3947. $roster_type = "Leaves-Taken-or-Used";
  3948. $filenameexport = $roster_type;
  3949. $final_output = array('output' => $output,
  3950. 'cols' => $cols,
  3951. 'filenameexport' => $filenameexport);
  3952.  
  3953. return $final_output;
  3954. }
  3955.  
  3956. // EOF function
  3957.  
  3958.  
  3959. public static function getSummaryMonth($post_data, $tenant_id, $from, $to) {
  3960. $for_date = date('Y-m', strtotime($from));
  3961. $return = array();
  3962. $deactivated_user = 0;
  3963. $bank_details_user = 0;
  3964. $no_bank_details_user = 0;
  3965. $fandfamount = 0;
  3966. $bankamount = 0;
  3967. $nobankamount = 0;
  3968. $current_month = date("m");
  3969. //$sr_no=1;
  3970. $filter = $post_data['filter_id'];
  3971. $userSalarySlip = UserSalarySlip::model()->tenant($tenant_id)->findAllByAttributes(array('for_month' => $for_date));
  3972. foreach ($userSalarySlip as $salaryslip) {
  3973. //$users = UserMongo::model()->getUsersByFilter($filter, $tenant_id,$post_data['active_inactive']);
  3974. $users = UserMongo::model()->tenant($tenant_id)->findByPk($salaryslip->user_id);
  3975. if (isset($users) && !empty($users)) {
  3976. $employee_code = (isset($users->personal->employee_no) && $users->personal->employee_no != "") ? $users->personal->employee_no : "N.A.";
  3977. /*if (isset($users->deactivate_date) && $users->deactivate_date != null && date('m', $users->deactivate_date->sec) == $current_month) {
  3978. $deactivated_user++;
  3979. $fandfamount += $salaryslip->total_net;
  3980. } */if (isset($users->banking) && isset($users->banking->bank_name) && isset($users->banking->bank_account)) {
  3981. $bank_details_user++;
  3982. $bankamount += $salaryslip->total_net;
  3983. } elseif (empty($users->banking) && !isset($users->banking->bank_name) && !isset($users->banking->bank_account)) {
  3984. $no_bank_details_user++;
  3985. $nobankamount += $salaryslip->total_net;
  3986. }
  3987. }
  3988. }
  3989.  
  3990. $output = array();
  3991. $index = 0;
  3992. $particulars_name = array("Bank List", "No Bank List");
  3993. foreach ($particulars_name as $key => $particular) {
  3994. if ($particular == "Bank List") {
  3995. $employee_count = $bank_details_user;
  3996. $amount = $bankamount;
  3997. } elseif ($particular == "No Bank List") {
  3998. $employee_count = $no_bank_details_user;
  3999. $amount = $nobankamount;
  4000. } /*else {
  4001. $employee_count = $deactivated_user;
  4002. $amount = $fandfamount;
  4003. }*/
  4004. $output[] = array(
  4005. $particular,
  4006. $employee_count,
  4007. $amount,
  4008. );
  4009. }
  4010.  
  4011. $cols = array(
  4012. 'Particulars',
  4013. 'Employees Count',
  4014. 'Amount',
  4015. );
  4016.  
  4017.  
  4018.  
  4019. $roster_type = "payroll-summary-month".$for_date;
  4020. $filenameexport = $roster_type;
  4021. $final_output = array('output' => $output,
  4022. 'cols' => $cols,
  4023. 'filenameexport' => $filenameexport);
  4024. return $final_output;
  4025. }
  4026.  
  4027. public static function getBankListMonth($post_data, $tenant_id, $from, $to) {
  4028. $for_date = date('Y-m', strtotime($from));
  4029. $return = array();
  4030. $output = array();
  4031. $current_month = date("m");
  4032. $filter = $post_data['filter_id'];
  4033. $userSalarySlip = UserSalarySlip::model()->tenant($tenant_id)->findAllByAttributes(array('for_month' => $for_date));
  4034. foreach ($userSalarySlip as $salaryslip) {
  4035. //$users = UserMongo::model()->getUsersByFilter($filter, $tenant_id,$post_data['active_inactive']);
  4036. //$users = UserMongo::model()->tenant($tenant_id)->findByPk($salaryslip->user_id);
  4037. if($post_data['active_inactive'] == 1)
  4038. {
  4039. $users = UserMongo::model()->tenant($tenant_id)->active()->findByPk($salaryslip->user_id);
  4040. }
  4041. else if($post_data['active_inactive'] == 2)
  4042. {
  4043. $users = UserMongo::model()->tenant($tenant_id)->disabled()->findByPk($salaryslip->user_id);
  4044. }
  4045. else
  4046. {
  4047. $users = UserMongo::model()->tenant($tenant_id)->findByPk($salaryslip->user_id);
  4048. }
  4049. if (isset($users) && !empty($users)) {
  4050. $office_location = TenantOffices::model()->tenant($tenant_id)->findByAttributes(array('id' => $users->personal->office_location));
  4051. $employee_code = (isset($users->personal->employee_no) && $users->personal->employee_no != "") ? $users->personal->employee_no : "N.A.";
  4052. if (isset($office_location) && !empty($office_location) && isset($office_location->city) && $office_location->city != "") {
  4053. $city_name = City::model()->findByPk($office_location->city);
  4054. if (isset($city_name) && !empty($city_name)) {
  4055. $office_location_name = $city_name->name;
  4056. } else {
  4057. $office_location_name = "N.A";
  4058. }
  4059. } else {
  4060. $office_location_name = "N.A";
  4061. }
  4062. if (isset($users->banking) && isset($users->banking->bank_name) && $users->banking->bank_name != "" && isset($users->banking->bank_account) && $users->banking->bank_account != "") {
  4063. $account_number = $users->banking->bank_account;
  4064. $account_bank_name = $users->banking->bank_name;
  4065. $account_branch_name = (isset($users->banking->bank_branch) && $users->banking->bank_branch != "") ? $users->banking->bank_branch : "N.A.";
  4066. //$account_bank_branch = (isset($users->banking->bank_branch) && $users->banking->bank_branch != "") ? $users->banking->bank_branch : "N.A.";
  4067. $ifsc_code = (isset($users->banking->bank_ifsc) && $users->banking->bank_ifsc != "") ? $users->banking->bank_ifsc : "N.A.";
  4068. $net_salary = $salaryslip->total_net;
  4069. $full_name = $users->getFullname();
  4070. $output[] = array(
  4071. $employee_code,
  4072. $full_name,
  4073. $office_location_name,
  4074. $account_number,
  4075. $account_bank_name,
  4076. $account_branch_name,
  4077. $ifsc_code,
  4078. $net_salary,
  4079. );
  4080. }
  4081. }
  4082. }
  4083.  
  4084.  
  4085. $cols = array(
  4086. 'Employee Code',
  4087. 'Employee Name',
  4088. 'Location',
  4089. 'Account Number',
  4090. 'Bank Name',
  4091. 'Bank Branch',
  4092. 'IFSC Code',
  4093. 'Net Salary',
  4094. );
  4095.  
  4096.  
  4097.  
  4098. $roster_type = "payroll-Bank-List-month".$for_date;
  4099. $filenameexport = $roster_type;
  4100. $final_output = array('output' => $output,
  4101. 'cols' => $cols,
  4102. 'filenameexport' => $filenameexport);
  4103. return $final_output;
  4104. }
  4105.  
  4106. public static function getNoBankListMonth($post_data, $tenant_id, $from, $to) {
  4107. $for_date = date('Y-m', strtotime($from));
  4108. $return = array();
  4109. $output = array();
  4110.  
  4111. $current_month = date("m");
  4112. $filter = $post_data['filter_id'];
  4113. $userSalarySlip = UserSalarySlip::model()->tenant($tenant_id)->findAllByAttributes(array('for_month' => $for_date));
  4114. foreach ($userSalarySlip as $salaryslip) {
  4115. //$users = UserMongo::model()->tenant($tenant_id)->findByPk($salaryslip->user_id);
  4116. if($post_data['active_inactive'] == 1)
  4117. {
  4118. $users = UserMongo::model()->tenant($tenant_id)->active()->findByPk($salaryslip->user_id);
  4119. }
  4120. else if($post_data['active_inactive'] == 2)
  4121. {
  4122. $users = UserMongo::model()->tenant($tenant_id)->disabled()->findByPk($salaryslip->user_id);
  4123. }
  4124. else
  4125. {
  4126. $users = UserMongo::model()->tenant($tenant_id)->findByPk($salaryslip->user_id);
  4127. }
  4128. if (isset($users) && !empty($users)) {
  4129. $office_location = TenantOffices::model()->tenant($tenant_id)->findByAttributes(array('id' => $users->personal->office_location));
  4130. $employee_code = (isset($users->personal->employee_no) && $users->personal->employee_no != "") ? $users->personal->employee_no : "N.A.";
  4131. if (isset($office_location) && !empty($office_location) && isset($office_location->city) && $office_location->city != "") {
  4132. $city_name = City::model()->findByPk($office_location->city);
  4133. if (isset($city_name) && !empty($city_name)) {
  4134. $office_location_name = $city_name->name;
  4135. } else {
  4136. $office_location_name = "N.A";
  4137. }
  4138. } else {
  4139. $office_location_name = "N.A";
  4140. }
  4141. if ((isset($users->banking->bank_name) || !isset($users->banking->bank_name)) && $users->banking->bank_name == "" && (isset($users->banking->bank_account) || !isset($users->banking->bank_account)) && $users->banking->bank_account == "") {
  4142. $account_number = $users->banking->bank_account;
  4143. $account_bank_name = "Cheque Payment";
  4144. $account_branch_name = (isset($users->banking->bank_branch) && $users->banking->bank_branch != "") ? $users->banking->bank_branch : "N.A.";
  4145. $net_salary = $salaryslip->total_net;
  4146. $full_name = $users->getFullname();
  4147. $output[] = array(
  4148. $employee_code,
  4149. $full_name,
  4150. $office_location_name,
  4151. $account_number,
  4152. $account_bank_name,
  4153. $net_salary,
  4154. );
  4155. }
  4156. }
  4157. }
  4158. $cols = array(
  4159. 'Employee Code',
  4160. 'Employee Name',
  4161. 'Location',
  4162. 'Account Number',
  4163. 'Bank Name',
  4164. 'Net Salary',
  4165. );
  4166.  
  4167.  
  4168.  
  4169. $roster_type = "payroll-No-Bank-List-month".$for_date;
  4170. $filenameexport = $roster_type;
  4171. $final_output = array('output' => $output,
  4172. 'cols' => $cols,
  4173. 'filenameexport' => $filenameexport);
  4174. return $final_output;
  4175. }
  4176.  
  4177. public static function getFandFListMonth($post_data, $tenant_id, $from, $to) {
  4178. $for_date = date('Y-m', strtotime($from));
  4179. $return = array();
  4180. $output = array();
  4181.  
  4182. $current_month = date("m");
  4183. $filter = $post_data['filter_id'];
  4184. $userSalarySlip = UserSalarySlip::model()->tenant($tenant_id)->findAllByAttributes(array('for_month' => $for_date));
  4185. foreach ($userSalarySlip as $salaryslip) {
  4186. //$users = UserMongo::model()->tenant($tenant_id)->findByPk($salaryslip->user_id);
  4187. if($post_data['active_inactive'] == 1)
  4188. {
  4189. $users = UserMongo::model()->tenant($tenant_id)->active()->findByPk($salaryslip->user_id);
  4190. }
  4191. else if($post_data['active_inactive'] == 2)
  4192. {
  4193. $users = UserMongo::model()->tenant($tenant_id)->disabled()->findByPk($salaryslip->user_id);
  4194. }
  4195. else
  4196. {
  4197. $users = UserMongo::model()->tenant($tenant_id)->findByPk($salaryslip->user_id);
  4198. }
  4199. if (isset($users) && !empty($users)) {
  4200. $office_location = TenantOffices::model()->tenant($tenant_id)->findByAttributes(array('id' => $users->personal->office_location));
  4201. if (isset($office_location) && !empty($office_location) && isset($office_location->city) && $office_location->city != "") {
  4202. $city_name = City::model()->findByPk($office_location->city);
  4203. if (isset($city_name) && !empty($city_name)) {
  4204. $office_location_name = $city_name->name;
  4205. } else {
  4206. $office_location_name = "N.A";
  4207. }
  4208. } else {
  4209. $office_location_name = "N.A";
  4210. }
  4211. if (isset($users->deactivate_date) && $users->deactivate_date != null && date('m', $users->deactivate_date->sec) == $current_month) {
  4212. $net_salary = $salaryslip->total_net;
  4213. $employee_code = (isset($users->personal->employee_no) && $users->personal->employee_no != "") ? $users->personal->employee_no : "N.A.";
  4214. $full_name = $users->getFullname();
  4215. $output[] = array(
  4216. $employee_code,
  4217. $full_name,
  4218. $office_location_name,
  4219. $net_salary,
  4220. );
  4221. }
  4222. }
  4223. }
  4224. $cols = array(
  4225. 'Employee Code',
  4226. 'Employee Name',
  4227. 'Location',
  4228. 'Net Salary',
  4229. );
  4230.  
  4231.  
  4232.  
  4233. $roster_type = "payroll-FandF-List-month".$for_date;
  4234. $filenameexport = $roster_type;
  4235. $final_output = array('output' => $output,
  4236. 'cols' => $cols,
  4237. 'filenameexport' => $filenameexport);
  4238. return $final_output;
  4239. }
  4240.  
  4241. public static function getTDSReportMonth($post_data, $tenant_id, $from, $to) {
  4242. $for_date = date('Y-m', strtotime($from));
  4243. $return = array();
  4244. $output = array();
  4245.  
  4246. $current_month = date("m");
  4247. $filter = $post_data['filter_id'];
  4248. $active_inactive = (!empty($post_data['active_inactive'])) ? $post_data['active_inactive'] : '';
  4249. $userSalarySlip = UserSalarySlip::model()->tenant($tenant_id)->findAllByAttributes(array('for_month' => $for_date));
  4250. foreach ($userSalarySlip as $salaryslip) {
  4251. //$users = UserMongo::model()->tenant($tenant_id)->findByPk($salaryslip->user_id);
  4252. if($active_inactive == 1)
  4253. {
  4254. $users = UserMongo::model()->tenant($tenant_id)->active()->findByPk($salaryslip->user_id);
  4255. }
  4256. else if($active_inactive == 2)
  4257. {
  4258. $users = UserMongo::model()->tenant($tenant_id)->disabled()->findByPk($salaryslip->user_id);
  4259. }
  4260. else
  4261. {
  4262. $users = UserMongo::model()->tenant($tenant_id)->findByPk($salaryslip->user_id);
  4263. }
  4264.  
  4265. $gross_salary = (isset($salaryslip->total_gross)) ? $salaryslip->total_gross : 0;
  4266.  
  4267. if (isset($users) && !empty($users)) {
  4268. $full_name = $users->getFullname();
  4269. $office_location = TenantOffices::model()->tenant($tenant_id)->findByAttributes(array('id' => $users->personal->office_location));
  4270. $employee_code = (isset($users->personal->employee_no) && $users->personal->employee_no != "") ? $users->personal->employee_no : "N.A.";
  4271. if (isset($office_location) && !empty($office_location) && isset($office_location->city) && $office_location->city != "") {
  4272. $city_name = City::model()->findByPk($office_location->city);
  4273. if (isset($city_name) && !empty($city_name)) {
  4274. $office_location_name = $city_name->name;
  4275. } else {
  4276. $office_location_name = "N.A";
  4277. }
  4278. } else {
  4279. $office_location_name = "N.A";
  4280. }
  4281. $pan_number = (isset($users->banking->bank_pan_num) && $users->banking->bank_pan_num != "") ? $users->banking->bank_pan_num : "N.A.";
  4282. //$total_tds = (isset($salaryslip->tds) && $salaryslip->tds != "") ? $salaryslip->tds : "N.A.";
  4283. $total_tds = $salaryslip->tds;
  4284. $education_cess_cal = $total_tds * 0.03;
  4285. $education_cess = PayrollHelper::roundingValues(Items::ROUND_TO_TWO_DIGITS, $education_cess_cal);
  4286. $income_tax = $total_tds - $education_cess;
  4287. $surcharges =0;
  4288.  
  4289. if($income_tax > 0)
  4290. {
  4291. $output[] = array(
  4292. $employee_code,
  4293. $full_name,
  4294. $office_location_name,
  4295. $pan_number,
  4296. $gross_salary,
  4297. $income_tax,
  4298. $education_cess,
  4299. $surcharges,
  4300. $total_tds,
  4301. );
  4302. }
  4303. }
  4304. }
  4305. $cols = array(
  4306. 'Employee Code',
  4307. 'Employee Name',
  4308. 'Location',
  4309. 'PAN Number',
  4310. 'Gross',
  4311. 'Income Tax',
  4312. 'Education Cess',
  4313. 'Surcharge',
  4314. 'Total Income Tax',
  4315. );
  4316.  
  4317.  
  4318.  
  4319. $roster_type = "payroll-TDS-Report-List-month".$for_date;
  4320. $filenameexport = $roster_type;
  4321. $final_output = array('output' => $output,
  4322. 'cols' => $cols,
  4323. 'filenameexport' => $filenameexport);
  4324. return $final_output;
  4325. }
  4326.  
  4327. public static function getPTReportMonth($post_data, $tenant_id, $from, $to) {
  4328. $for_date = date('Y-m', strtotime($from));
  4329. $month = date('m', strtotime($from));
  4330. $return = array();
  4331. $output = array();
  4332.  
  4333. $current_month = date("m");
  4334. $filter = $post_data['filter_id'];
  4335. $active_inactive = (!empty($post_data['active_inactive'])) ? $post_data['active_inactive'] : '';
  4336. $userSalarySlip = UserSalarySlip::model()->tenant($tenant_id)->findAllByAttributes(array('for_month' => $for_date));
  4337. foreach ($userSalarySlip as $salaryslip) {
  4338. //$users = UserMongo::model()->tenant($tenant_id)->findByPk($salaryslip->user_id);
  4339. if($active_inactive == 1)
  4340. {
  4341. $users = UserMongo::model()->tenant($tenant_id)->active()->findByPk($salaryslip->user_id);
  4342. }
  4343. else if($active_inactive == 2)
  4344. {
  4345. $users = UserMongo::model()->tenant($tenant_id)->disabled()->findByPk($salaryslip->user_id);
  4346. }
  4347. else
  4348. {
  4349. $users = UserMongo::model()->tenant($tenant_id)->findByPk($salaryslip->user_id);
  4350. }
  4351. if (isset($users) && !empty($users)) {
  4352. $full_name = $users->getFullname();
  4353. $office_location = TenantOffices::model()->tenant($tenant_id)->findByAttributes(array('id' => $users->personal->office_location));
  4354. $employee_code = (isset($users->personal->employee_no) && $users->personal->employee_no != "") ? $users->personal->employee_no : "N.A.";
  4355. if (isset($office_location) && !empty($office_location) && isset($office_location->city) && $office_location->city != "") {
  4356. $city_name = City::model()->findByPk($office_location->city);
  4357. if (isset($city_name) && !empty($city_name)) {
  4358. $office_location_name = $city_name->name;
  4359. } else {
  4360. $office_location_name = "N.A";
  4361. }
  4362. } else {
  4363. $office_location_name = "N.A";
  4364. }
  4365. foreach ($salaryslip->items as $item) {
  4366. if ($item->variable_name == "professional_tax") {
  4367. //print_r($item);
  4368. //$d = new DateTime($this->for_month);
  4369. $professional_tax = $item->max_value_month;
  4370.  
  4371. if ($office_location->state == "1927" && $month == "02")
  4372. {
  4373. $professional_tax = (isset($professional_tax) && $professional_tax > 0 && $professional_tax == 200) ? $professional_tax + 100 : $professional_tax;
  4374. }
  4375. } else {
  4376. $professional_tax = "N.A.";
  4377. }
  4378. }
  4379.  
  4380. // Do not show the employees in the report whose PT is ZERO - KT - 9th March 2015
  4381. if($professional_tax > 0)
  4382. {
  4383. $output[] = array(
  4384. $employee_code,
  4385. $full_name,
  4386. $office_location_name,
  4387. $professional_tax,
  4388. );
  4389. }
  4390.  
  4391. }
  4392. }
  4393. $cols = array(
  4394. 'Employee Code',
  4395. 'Employee Name',
  4396. 'Location',
  4397. 'Professional Tax',
  4398. );
  4399.  
  4400.  
  4401.  
  4402. $roster_type = "payroll-PT-Report-month".$for_date;
  4403. $filenameexport = $roster_type;
  4404. $final_output = array('output' => $output,
  4405. 'cols' => $cols,
  4406. 'filenameexport' => $filenameexport);
  4407. return $final_output;
  4408. }
  4409.  
  4410. public static function getPFReportMonth($post_data, $tenant_id, $from, $to) {
  4411. $for_date = date('Y-m', strtotime($from));
  4412. $return = array();
  4413. $output = array();
  4414.  
  4415. $current_month = date("m");
  4416. $filter = $post_data['filter_id'];
  4417. $userSalarySlip = UserSalarySlip::model()->tenant($tenant_id)->findAllByAttributes(array('for_month' => $for_date));
  4418. $tenantProfile = TenantProfile::model()->tenant($tenant_id)->find();
  4419. if(!empty($tenantProfile))
  4420. {
  4421. if(isset($tenantProfile->pf_edli) && $tenantProfile->pf_edli == TenantProfile::ACTIVE){
  4422. $edli_value = 6500;
  4423. }
  4424. else{
  4425. if(strtotime($for_date) > strtotime('2014-10')){
  4426. $edli_value = 15000;
  4427. }
  4428. else{
  4429. $edli_value = 6500;
  4430. }
  4431. }
  4432. }
  4433. foreach ($userSalarySlip as $salaryslip) {
  4434. $employees_contribution = 0;
  4435. $edli = 0;
  4436. $employees_contribution_pf = 0;
  4437. $total_pension = 0;
  4438. $voluntary_pf = 0;
  4439. $total_pf = 0;
  4440. $administartive_amount = 0;
  4441. $insurance_fund = 0;
  4442. $inspection_charges = 0;
  4443. $final_amount = 0;
  4444. $basic_eps = 0;
  4445. $accountnooneepf = 0;
  4446. $accountnotenepf = 0;
  4447. $accountnotwo = 0;
  4448. $accountnotwentyone = 0;
  4449. $accountnotwentytwo = 0;
  4450. //$users = UserMongo::model()->tenant($tenant_id)->findByPk($salaryslip->user_id);
  4451. if($post_data['active_inactive'] == 1)
  4452. {
  4453. $users = UserMongo::model()->tenant($tenant_id)->active()->findByPk($salaryslip->user_id);
  4454. }
  4455. else if($post_data['active_inactive'] == 2)
  4456. {
  4457. $users = UserMongo::model()->tenant($tenant_id)->disabled()->findByPk($salaryslip->user_id);
  4458. }
  4459. else
  4460. {
  4461. $users = UserMongo::model()->tenant($tenant_id)->findByPk($salaryslip->user_id);
  4462. }
  4463. if (isset($users) && !empty($users)) {
  4464. $full_name = $users->getFullname();
  4465. $employee_id = $users->personal->employee_no;
  4466. $doj = (isset($users->doj->sec))? date('d/m/Y', $users->doj->sec) : 'N.A.';
  4467. $date_of_exit = (isset($users->deactivate_date->sec))? date('d/m/Y', $users->deactivate_date->sec) : 'N.A.';
  4468. $date_of_exit_month = (isset($users->deactivate_date->sec))? date('Y-m', $users->deactivate_date->sec) : 'N.A.';
  4469. $dob = (isset($users->personal->dob->sec) && $users->personal->dob->sec != "") ? date('d/m/Y', $users->personal->dob->sec) : "N.A.";
  4470. $doj = (isset($users->doj->sec) && $users->doj->sec != "") ? date('d/m/Y', $users->doj->sec) : "N.A.";
  4471. $doj_month = (isset($users->doj->sec) && $users->doj->sec != "") ? date('Y-m', $users->doj->sec) : "N.A.";
  4472. $employee_code = (isset($users->personal->employee_no) && $users->personal->employee_no != "") ? $users->personal->employee_no : "N.A.";
  4473. $gender = (isset($users->personal->gender) && $users->personal->gender == UserPersonal::GENDER_MALE) ? "M" : "F";
  4474. // Calculate Age from Date of Birth
  4475. // if($dob != '')
  4476. // {
  4477. // $from = new DateTime($dob);
  4478. // $to = new DateTime('today');
  4479. // $age = $from->diff($to)->y;
  4480. // }
  4481. // else
  4482. // {
  4483. // $age = 'N.A.';
  4484. // }
  4485.  
  4486. // Get employee father name.
  4487. $emp_father_name = '';
  4488. $emp_husband_name = '';
  4489. $display_realation_name = '';
  4490.  
  4491. if (isset($users->dependents) && count($users->dependents) > 0)
  4492. {
  4493. foreach ($users->dependents as $key => $value_dependent)
  4494. {
  4495. if ($value_dependent->relation_type == "Father")
  4496. {
  4497. $emp_father_first_name = (isset($value_dependent->first_name))? $value_dependent->first_name : '';
  4498. $emp_father_last_name = (isset($value_dependent->last_name))? $value_dependent->last_name : '';
  4499. $emp_father_name = $emp_father_first_name." ".$emp_father_last_name;
  4500. }
  4501. if ($value_dependent->relation_type == "Husband")
  4502. {
  4503. $emp_husband_first_name = (isset($value_dependent->first_name))? $value_dependent->first_name : '';
  4504. $emp_husband_last_name = (isset($value_dependent->last_name))? $value_dependent->last_name : '';
  4505. $emp_husband_name = $emp_father_first_name." ".$emp_father_last_name;
  4506. }
  4507. }
  4508. }
  4509. if(isset($emp_husband_name) && $emp_husband_name != ""){
  4510. $display_realation_name = (isset($emp_husband_name) && $emp_husband_name != "") ? $emp_husband_name : "N.A.";
  4511. $relation_type = 'S';
  4512. }else{
  4513. $display_realation_name = (isset($emp_father_name) && $emp_father_name != "") ? $emp_father_name : "N.A.";
  4514. $relation_type = (isset($emp_father_name) && $emp_father_name != "") ? 'F' : "N.A.";
  4515. }
  4516.  
  4517. $office_location = TenantOffices::model()->tenant($tenant_id)->findByAttributes(array('id' => $users->personal->office_location));
  4518. if (isset($office_location) && !empty($office_location) && isset($office_location->city) && $office_location->city != "") {
  4519. $city_name = City::model()->findByPk($office_location->city);
  4520. if (isset($city_name) && !empty($city_name)) {
  4521. $office_location_name = $city_name->name;
  4522. } else {
  4523. $office_location_name = "N.A";
  4524. }
  4525. } else {
  4526. $office_location_name = "N.A";
  4527. }
  4528. foreach ($salaryslip->items as $item) {
  4529. if ($item->variable_name == "basic") {
  4530. if(isset($tenantProfile->is_pf_restricted) && $tenantProfile->is_pf_restricted == TenantProfile::ACTIVE){
  4531. $basic = $item->max_value_month;
  4532. $basic = ($basic > 15000) ? 15000 : $basic;
  4533. }else{
  4534. $basic = $item->max_value_month;
  4535. }
  4536. }
  4537.  
  4538. if ($item->variable_name == "provident_fund") {
  4539. // basic basic_eps 3 conditions
  4540. // if age is greater than 58 years then 0 else basic
  4541. // if not existing PF member and basic > 15000 then basic_eps = 0
  4542. // if basic > 15000 then basic_eps = 15000 as max limit is 15000
  4543. $age = RandomHelper::CalculateAge(date('Y-m-d',$users->personal->dob->sec));
  4544. $basic_eps = $basic;
  4545. if($age > 58){
  4546. $basic_eps = 0;
  4547. }
  4548. if(isset($user->existing_pf_member) && $user->existing_pf_member == 0 && $basic > 15000){
  4549. $basic_eps = 0;
  4550. }
  4551. if($basic > 15000){
  4552. $basic_eps = 15000;
  4553. }
  4554. // basic basic_eps 3 conditions
  4555.  
  4556. $employees_contribution = $item->max_value_month;
  4557.  
  4558. $eps_contribution = ($basic_eps > 0) ? ($basic_eps * 8.33)/100 : 0;
  4559. $eps_contribution = PayrollHelper::roundingValues(Items::ROUND_TO_HIGEST_INTEGER,$eps_contribution);
  4560.  
  4561. $diff_epf_eps = $employees_contribution - $eps_contribution;
  4562.  
  4563. $lop_days = $salaryslip->lop;
  4564.  
  4565. $arrear_basic = 0; //differnece of basic after salary increment
  4566.  
  4567. $arrears_epf_wages = 0;
  4568.  
  4569. $arrears_epf_ee_wages = 0;
  4570.  
  4571. $arrears_epf_er_wages = 0;
  4572.  
  4573. $arrears_eps = 0;
  4574.  
  4575. if(strtotime($for_date) != strtotime($doj_month)){
  4576. $display_realation_name = "";
  4577. $relation_type = "";
  4578. $dob = "";
  4579. $gender = "";
  4580. $doj = "";
  4581. }
  4582. if(isset($date_of_exit) && strtotime($for_date) == strtotime($date_of_exit_month)){
  4583. $reason_of_exit = "C";
  4584. }else{
  4585. $date_of_exit = "";
  4586. $reason_of_exit = "";
  4587. }
  4588. // $employee_pf = (12 * $basic) / 100;
  4589. // $epf = ($employees_contribution/12) * 3.67;
  4590. // $eps = ($employees_contribution/12) * 8.33;
  4591. $lop_edli = 0;
  4592. if ($salaryslip->lop > 0) {
  4593. $lop_edli = ($edli_value / $salaryslip->total_working_days) * $salaryslip->lop;
  4594. } else {
  4595. $lop_edli = ($edli_value / $salaryslip->total_working_days) * ($salaryslip->total_working_days - $salaryslip->effective_working_days);
  4596. }
  4597.  
  4598. // Show E. D. L. I. is equal to BASIC if basic < 6500 - KT 9th March 2015
  4599. if($basic < $edli_value){
  4600. $edli = $basic;
  4601. }
  4602. else{
  4603. $edli = ($edli_value - $lop_edli);
  4604. }
  4605.  
  4606. // $total_pension = ($edli * 8.33) / 100;
  4607. // $employees_contribution_pf = ($employees_contribution - $total_pension);
  4608. // $voluntary_pf = 0;
  4609. // if(strtotime($for_date) >= strtotime('2015-01'))
  4610. // {
  4611. // $administartive_amount = ($basic * 0.85) / 100;
  4612. // }
  4613. // else{
  4614. // $administartive_amount = ($basic * 1.1) / 100;
  4615. // }
  4616. // $insurance_fund = ($edli * 0.5) / 100;
  4617. // $inspection_charges = ($edli * 0.01) / 100;
  4618. // $total_pf = $employees_contribution + $employees_contribution_pf + $total_pension + $voluntary_pf;
  4619. // $final_amount = $total_pf + $administartive_amount + $insurance_fund + $inspection_charges;
  4620. }
  4621. }
  4622.  
  4623. // Do not show the row if $employees_contribution is ZERO
  4624. if($employees_contribution > 0)
  4625. {
  4626.  
  4627. // Account no1 EPF(employee total pf + employeers diff btw epf and eps)
  4628. $accountnooneepf += ($employees_contribution + $diff_epf_eps);
  4629. // Account no1 EPF(employee total pf + employeers diff btw epf and eps)
  4630. //Account number 10 = sum of all emp EPS
  4631. $accountnotenepf += $eps_contribution;
  4632. //Account number 10 = sum of all emp EPS
  4633. //Account number 2 = PF admin charges
  4634. $accountnotwo += ($basic * 0.85) / 100;
  4635. //Account number 2 = PF admin charges
  4636. //Account number 21 = 0.5% on edli wages
  4637. $accountnotwentyone += ($edli * 0.5) / 100;
  4638. //Account number 21 = 0.5% on edli wages
  4639. //Account number 22 = 0.01% on edli wages
  4640. $accountnotwentytwo += ($edli * 0.01) / 100;
  4641. //Account number 22 = 0.01% on edli wages
  4642.  
  4643. $pf_account_number = (isset($users->pf_number) && $users->pf_number != null) ? $users->pf_number : "N.A.";
  4644. $employee_code_pf_exp = explode('/', $pf_account_number);
  4645. $employee_code_pf = (isset($employee_code_pf_exp[4]) && $employee_code_pf_exp[4] != "") ? $employee_code_pf_exp[4] : "";
  4646. $output[] = array(
  4647. $employee_id,
  4648. $employee_code_pf,
  4649. $full_name,
  4650. $basic,
  4651. $basic_eps,
  4652. $employees_contribution,
  4653. $employees_contribution,
  4654. $eps_contribution,
  4655. $eps_contribution,
  4656. $diff_epf_eps,
  4657. $diff_epf_eps,
  4658. $lop_days,
  4659. 0,
  4660. $arrears_epf_wages,
  4661. $arrears_epf_ee_wages,
  4662. $arrears_epf_er_wages,
  4663. $arrears_eps,
  4664. $display_realation_name,
  4665. $relation_type,
  4666. $dob,
  4667. $gender,
  4668. $doj,
  4669. $doj,
  4670. $date_of_exit,
  4671. $date_of_exit,
  4672. $reason_of_exit,
  4673. );
  4674. }
  4675. }
  4676. }
  4677. $cols = array(
  4678. 'Employee ID',
  4679. 'Employee Code',
  4680. 'Employee Name',
  4681. 'EPF Wages', //that month earned basic
  4682. 'EPS Wages', // basic amount 3 conditions
  4683. 'EPF Contribution (EE Share) due',
  4684. 'EPF Contribution (EE Share) being remitted',
  4685. 'EPS Contribution due',
  4686. 'EPS Contribution being remitted',
  4687. 'Diff EPF and EPS contribution (ER share) due',
  4688. 'Diff EPF and EPS contribution (ER share) being remitted',
  4689. 'NCP Days',
  4690. 'Refund Of Advances',
  4691. 'Arrear EPF Wages',
  4692. 'Arrear EPF EE share',
  4693. 'Arrear EPF ER share',
  4694. 'Arrear EPS',
  4695. 'Fathers/Husbands Name',
  4696. 'Relationship with the Member',
  4697. 'Date of Birth',
  4698. 'Gender',
  4699. 'Date of Joining EPF',
  4700. 'Date of Joining EPS',
  4701. 'Date of Exit EPF',
  4702. 'Date of Exit EPS',
  4703. 'Reason For Leaving',
  4704. );
  4705.  
  4706.  
  4707.  
  4708. $roster_type = "payroll-PF-Report-month".$for_date;
  4709. $filenameexport = $roster_type;
  4710. $final_output = array('output' => $output,
  4711. 'cols' => $cols,
  4712. 'filenameexport' => $filenameexport);
  4713. return $final_output;
  4714. }
  4715.  
  4716. public static function getSalaryRegisterMonth($post_data, $tenant_id, $from, $to) {
  4717. $for_date = date('Y-m', strtotime($from));
  4718. $return = array();
  4719. $output = array();
  4720. $index = 0;
  4721. $current_month = date("m");
  4722. $filter = $post_data['filter_id'];
  4723. $active_inactive = (!empty($post_data['active_inactive'])) ? $post_data['active_inactive'] : '';
  4724. /*get filter users*/
  4725. $filter_users = UserMongo::model()->getUsersByFilter($filter, $tenant_id, $active_inactive);
  4726. $filtered_users =array();
  4727. foreach ($filter_users as $key_filter_user => $value_filter_user) {
  4728. $filtered_users[] = $value_filter_user->id;
  4729. }
  4730. /*get filter users*/
  4731. /**/
  4732. $tenant_salary_structure = SalaryStructure::model()->tenant($tenant_id)->findAll();
  4733. foreach ($tenant_salary_structure as $salstructure) {
  4734. foreach ($salstructure->items as $key => $i) {
  4735. if($i->type == Items::ITEM_TYPE_INCOME){
  4736. $claims_to_be_made[] = array(
  4737. "id" => $i->id,
  4738. "label" => $i->label,
  4739. "variable_name" => $i->variable_name,
  4740. "declared_value" => 0.0,
  4741. "map_to" => $i->map_to,
  4742. );
  4743. }
  4744. }
  4745. }
  4746. foreach ($tenant_salary_structure as $salstructure) {
  4747. foreach ($salstructure->items as $key => $i) {
  4748. if($i->type == Items::ITEM_TYPE_BALANCING_INCOME){
  4749. $claims_to_be_made[] = array(
  4750. "id" => $i->id,
  4751. "label" => $i->label,
  4752. "variable_name" => $i->variable_name,
  4753. "declared_value" => 0.0,
  4754. "map_to" => $i->map_to,
  4755. );
  4756. }
  4757. }
  4758. }
  4759. $claims_to_be_made = array_map("unserialize", array_unique(array_map("serialize", $claims_to_be_made)));
  4760. $taken = array();
  4761. foreach ($claims_to_be_made as $key => $item) {
  4762. if (isset($item['variable_name']) && $item['variable_name'] != null) {
  4763. if (!in_array($item['variable_name'], $taken)) {
  4764. $taken[] = $item['variable_name'];
  4765. } else {
  4766. unset($claims_to_be_made[$key]);
  4767. }
  4768. }
  4769. }
  4770. /**/
  4771. $userSalarySlip = UserSalarySlip::model()->tenant($tenant_id)->findAllByAttributes(array('for_month' => $for_date));
  4772. foreach ($userSalarySlip as $salaryslip) {
  4773. if(in_array($salaryslip->user_id, $filtered_users)){
  4774. //$users = UserMongo::model()->tenant($tenant_id)->findByPk($salaryslip->user_id);
  4775. if($active_inactive == 1)
  4776. {
  4777. $users = UserMongo::model()->tenant($tenant_id)->active()->findByPk($salaryslip->user_id);
  4778. }
  4779. else if($active_inactive == 2)
  4780. {
  4781. $users = UserMongo::model()->tenant($tenant_id)->disabled()->findByPk($salaryslip->user_id);
  4782. }
  4783. else
  4784. {
  4785. $users = UserMongo::model()->tenant($tenant_id)->findByPk($salaryslip->user_id);
  4786. }
  4787. if (isset($users) && !empty($users)) {
  4788. $user_post = $users->getCurrentPosition($tenant_id);
  4789. $job_title = $user_post['designation'];
  4790. $department = $user_post['department'];
  4791. $business_unit = $user_post['business_unit'];
  4792. $full_name = $users->getFullname();
  4793. $date_of_joining = date('Y-m-d', $users->doj->sec);
  4794. $quit_date = (isset($users->deactivate_date->sec) && $users->deactivate_date->sec != "") ? date('Y-m-d', $users->deactivate_date->sec) : "N.A.";
  4795. $office_location = TenantOffices::model()->tenant($tenant_id)->findByAttributes(array('id' => $users->personal->office_location));
  4796. $state_value = (isset($office_location->state) && $office_location->state != "") ? $office_location->state : null;
  4797. $bank_account_number = (isset($users->banking->bank_account) && $users->banking->bank_account != "") ? $users->banking->bank_account : "N.A.";
  4798. $bank_name = (isset($users->banking->bank_name) && $users->banking->bank_name != "") ? $users->banking->bank_name : "N.A.";
  4799. $pan_number = (isset($users->banking->bank_pan_num) && $users->banking->bank_pan_num != "") ? $users->banking->bank_pan_num : "N.A.";
  4800. $employee_code = (isset($users->personal->employee_no) && $users->personal->employee_no != "") ? $users->personal->employee_no : "N.A.";
  4801.  
  4802. if (isset($office_location) && !empty($office_location) && isset($office_location->city) && $office_location->city != "") {
  4803. $city_name = City::model()->findByPk($office_location->city);
  4804. if (isset($city_name) && !empty($city_name)) {
  4805. $office_location_name = $city_name->name;
  4806. } else {
  4807. $office_location_name = "N.A";
  4808. }
  4809. } else {
  4810. $office_location_name = "N.A";
  4811. }
  4812. $esic = 0;
  4813. $professional_tax = 0;
  4814. $hra = 0;
  4815. $conveyance = 0;
  4816. $special_allowance = 0;
  4817. $lta = 0;
  4818. $medical = 0;
  4819. $pf = 0;
  4820. $check_month = date('m',strtotime($salaryslip->for_month));
  4821. $get_final_value = array();
  4822. /**/
  4823. foreach ($salaryslip->items as $item) {
  4824. if ($item->variable_name == "professional_tax") {
  4825. //$professional_tax = $item->actual_value_month;
  4826. if($check_month == "02" && $state_value == "1927")
  4827. {
  4828. $professional_tax = (isset($state_value) && $state_value == "1927" && $item->actual_value_month != 300 && $item->actual_value_month > 0 && $item->actual_value_month != 175) ? $item->actual_value_month + 100 : $item->actual_value_month;
  4829. }
  4830. else{
  4831. $professional_tax =$item->actual_value_month;
  4832. }
  4833. }
  4834. if ($item->variable_name == "provident_fund") {
  4835. $pf =$item->actual_value_month;
  4836. }
  4837. if ($item->variable_name == "esic") {
  4838. $esic =$item->actual_value_month;
  4839. }
  4840. }
  4841. /**/
  4842. foreach ($claims_to_be_made as $key => $value) {
  4843. foreach ($salaryslip->items as $item) {
  4844. if($value['variable_name'] == $item->variable_name)
  4845. {
  4846. $get_final_value[$item->variable_name] = $item->actual_value_month;
  4847. }
  4848. }
  4849. }
  4850. $lwf = 0;
  4851. /*foreach ($claims_to_be_made as $key => $value) {
  4852. if($value['variable_name'] == "lwf"){
  4853. if (isset($salaryslip->lwf) && $salaryslip->lwf != null) {
  4854. $get_final_value['lwf'] = $salaryslip->lwf;
  4855. }
  4856. else{
  4857. $lwf = "N.A.";
  4858. }
  4859. }
  4860. }*/
  4861. $present_days = $salaryslip->effective_working_days;
  4862. $loan = (isset($salaryslip->loan_deduction)) ? $salaryslip->loan_deduction : 0;
  4863. if (isset($salaryslip->loan) && !empty($salaryslip->loan)) {
  4864. $loan = "";
  4865. foreach ($salaryslip->loan as $key => $value) {
  4866. $loan_name = UserLoan::model()->tenant()->findByPk($value['id']);
  4867. if(isset($loan_name) && !empty($loan_name)){
  4868. $amount = PayrollHelper::roundingValues(Items::ROUND_TO_TWO_DIGITS,$value['loan_deduction']);
  4869. $loan = $loan .$loan_name->loan_name ." (" . $amount ."),";
  4870. }
  4871. }
  4872. $loan = rtrim($loan, ",");
  4873. }
  4874. $advance = (isset($salaryslip->advance_deduction)) ? $salaryslip->advance_deduction : 0;
  4875. /**/
  4876. if(isset($salaryslip->advance_deduction) && !empty($salaryslip->advance_deduction))
  4877. {
  4878. $advance = 0;
  4879. foreach ($salaryslip->advance_deduction as $key => $value) {
  4880. $advance_name = UserAdvances::model()->tenant()->findByPk($value['id']);
  4881. if(isset($advance_name) && !empty($advance_name)){
  4882. $amount = PayrollHelper::roundingValues(Items::ROUND_TO_TWO_DIGITS,$value['amount']);
  4883. $advance = $advance .$advance_name->advance_name ." (" . $amount ."),";
  4884. }
  4885. }
  4886. if($advance != 0){
  4887. $advance = rtrim($advance, ",");
  4888. }
  4889. }
  4890. else{
  4891. $advance = 0;
  4892. }
  4893.  
  4894. /**/
  4895. //$total_days = $salaryslip->total_working_days;
  4896. //$present_days = $salaryslip->total_working_days;
  4897. // $base_salary = $salaryslip->total_gross;
  4898. // $bonus = $salaryslip->total_transactions;
  4899. // $gross_salary = $base_salary;
  4900.  
  4901. $base_salary = ($salaryslip->total_gross - $salaryslip->total_transactions);
  4902. if($salaryslip->total_working_days != $salaryslip->effective_working_days){
  4903. $base_salary = PayrollHelper::roundingValues(Items::ROUND_TO_TWO_DIGITS,($base_salary/$salaryslip->effective_working_days) * $salaryslip->total_working_days);
  4904. }
  4905. $bonus = $salaryslip->total_transactions;
  4906. $gross_salary = $salaryslip->total_gross;
  4907.  
  4908. $incometax = $salaryslip->tds;
  4909.  
  4910. $total_deductions = $salaryslip->total_deductions + $incometax;
  4911. $net_salary = $gross_salary - $total_deductions;
  4912. $arrears_days = 0;
  4913.  
  4914. $output[] = array(
  4915. $employee_code,
  4916. $full_name,
  4917. $date_of_joining,
  4918. $quit_date,
  4919. $present_days,
  4920. $arrears_days,
  4921. $job_title,
  4922. $department,
  4923. $business_unit,
  4924. $office_location_name,
  4925. $bank_account_number,
  4926. $bank_name,
  4927. $base_salary,
  4928. $pan_number,
  4929. /*$basic,
  4930. $hra,
  4931. $conveyance,
  4932. $lta,
  4933. $medical,
  4934. $special_allowance,*/
  4935. /* $lta_taxable,
  4936. $lta_non_taxable,
  4937. $medical_taxable,
  4938. $medical_non_taxable, */
  4939.  
  4940. );
  4941. /*echo "<pre>"; print_r($get_final_value); exit("\n exited in " . __FILE__ . " @ " . __LINE__. "</pre>");
  4942. $matching_records = array();
  4943. foreach ($claims_to_be_made as $key_claims => $value_claims)
  4944. {
  4945. foreach ($get_final_value as $key_final_value => $value_final_value) {
  4946. if($key_final_value == $value_claims['variable_name']){
  4947. $matching_records[$value_claims['variable_name']] = $value_final_value;
  4948. }
  4949. }
  4950. }*/
  4951. $count_of_claims = count($claims_to_be_made);
  4952. $claims_key_value_array = array();
  4953. $diff_in_two_arrays = array();
  4954. $tempArray = array();
  4955. foreach ($claims_to_be_made as $key_make_new => $value_make_new) {
  4956. $claims_key_value_array[$value_make_new['variable_name']] = $value_make_new['variable_name'];
  4957. }
  4958. $diff_in_two_arrays = array_diff_key($claims_key_value_array, $get_final_value);
  4959. if(isset($diff_in_two_arrays) && !empty($diff_in_two_arrays))
  4960. {
  4961. foreach ($diff_in_two_arrays as $key => $value) {
  4962. $get_final_value[$key] = 0;
  4963. }
  4964. }
  4965. foreach ($get_final_value as $key_fv => $value) {
  4966. foreach(array_keys($claims_key_value_array) as $key)
  4967. {
  4968. $tempArray[$key] = $get_final_value[$key];
  4969. }
  4970. $get_final_value = $tempArray;
  4971. }
  4972. /*foreach ($sal_str_deduction as $key_income => $value_income) {
  4973. $abc = count($value_income);
  4974. if($abc != 12)
  4975. {
  4976. $i = 1;
  4977. foreach ($month_list as $key => $value) {
  4978. if($i <= (12 - $abc)){
  4979. $sal_str_deduction[$key_income][$key] = 0.00;
  4980. $i++;
  4981. }
  4982. }
  4983. }
  4984. foreach(array_keys($month_list) as $key)
  4985. {
  4986. $tempArray[$key] = $sal_str_deduction[$key_income][$key];
  4987. }
  4988. $sal_str_deduction[$key_income] = $tempArray;
  4989. }*/
  4990.  
  4991. foreach ($get_final_value as $key_matching => $value_matching) {
  4992. array_push($output[$index], (isset($value_matching)) ? $value_matching : 0);
  4993. }
  4994. //array_push($output[$index],$base_salary);
  4995. array_push($output[$index],$bonus);
  4996. array_push($output[$index],$gross_salary);
  4997. array_push($output[$index],$incometax);
  4998. array_push($output[$index],$professional_tax);
  4999. array_push($output[$index],$esic);
  5000. array_push($output[$index],$pf);
  5001. array_push($output[$index],$lwf);
  5002. array_push($output[$index],$loan);
  5003. array_push($output[$index],$advance);
  5004. array_push($output[$index],$total_deductions);
  5005. array_push($output[$index],$net_salary);
  5006. $index++;
  5007. //echo "<pre>"; print_r($output); exit("\n exited in " . __FILE__ . " @ " . __LINE__. "</pre>");
  5008. }
  5009. }
  5010. }
  5011. $cols = array(
  5012. 'Employee Code',
  5013. 'Employee Name',
  5014. 'Joining Date',
  5015. 'Quit Date',
  5016. 'Present Days',
  5017. 'Arrears Days',
  5018. 'Designation',
  5019. 'Department',
  5020. 'Business Unit',
  5021. 'Location',
  5022. 'Saving Account Number',
  5023. 'Bank Name',
  5024. 'Base Salary',
  5025. 'PAN Number',
  5026. /*'Basic Salary',
  5027. 'House Rent Allowances',
  5028. 'Conveyance Allowances',
  5029. 'LTA',
  5030. 'Medical',
  5031. 'Special Allowances',*/
  5032. /* 'LT Expenses Taxable',
  5033. 'LT Expenses Allowance',
  5034. 'Medical Taxable',
  5035. 'Medical Non Taxable', */
  5036.  
  5037. );
  5038. foreach ($claims_to_be_made as $value) {
  5039. $finaldatacols = $value['label'];
  5040. array_push($cols, $finaldatacols);
  5041. }
  5042.  
  5043. //array_push($cols,'Base Salary');
  5044. array_push($cols,'Bonus');
  5045. array_push($cols,'Gross Salary');
  5046. array_push($cols,'Income Tax');
  5047. array_push($cols,'Professional Tax');
  5048. array_push($cols,'Statutory ESIC');
  5049. array_push($cols,'Statutory PF');
  5050. array_push($cols,'LWF');
  5051. array_push($cols,'Loan');
  5052. array_push($cols,'Advance');
  5053. array_push($cols,'Total Deduction');
  5054. array_push($cols,'Net Salary');
  5055. $roster_type = "payroll-Salary-Register-month-" .$for_date;
  5056. $filenameexport = $roster_type;
  5057. $final_output = array('output' => $output,
  5058. 'cols' => $cols,
  5059. 'filenameexport' => $filenameexport);
  5060. return $final_output;
  5061. }
  5062.  
  5063. public static function getESICReportMonth($post_data, $tenant_id, $from, $to)
  5064. {
  5065. $tenant_profile = TenantProfile::model()->tenant()->find();
  5066. $cal_esic_on_gross = (isset($tenant_profile->cal_esic_on_gross))? $tenant_profile->cal_esic_on_gross : 0;
  5067.  
  5068. $for_date = date('Y-m', strtotime($from));
  5069. $return = array();
  5070. $output = array();
  5071. $employees_contribution = "N.A.";
  5072. $employeers_contribution = "N.A.";
  5073. $total = "N.A.";
  5074. $total_no_days = "N.A.";
  5075. $current_month = date("m");
  5076. $filter = $post_data['filter_id'];
  5077. $userSalarySlip = UserSalarySlip::model()->tenant($tenant_id)->findAllByAttributes(array('for_month' => $for_date));
  5078. foreach ($userSalarySlip as $salaryslip) {
  5079.  
  5080. //$users = UserMongo::model()->tenant($tenant_id)->findByPk($salaryslip->user_id);
  5081. if($post_data['active_inactive'] == 1)
  5082. {
  5083. $users = UserMongo::model()->tenant($tenant_id)->active()->findByPk($salaryslip->user_id);
  5084. }
  5085. else if($post_data['active_inactive'] == 2)
  5086. {
  5087. $users = UserMongo::model()->tenant($tenant_id)->disabled()->findByPk($salaryslip->user_id);
  5088. }
  5089. else
  5090. {
  5091. $users = UserMongo::model()->tenant($tenant_id)->findByPk($salaryslip->user_id);
  5092. }
  5093.  
  5094. // Getting user gross salary - 9th March 2015
  5095. $gross_salary = $salaryslip->total_gross;
  5096.  
  5097. $total_transactions = (isset($salaryslip->total_transactions))? $salaryslip->total_transactions : 0;
  5098. // Minus Extra payment from gross salary if any
  5099. if($total_transactions > 0)
  5100. {
  5101. $gross_salary = $gross_salary - $total_transactions;
  5102. }
  5103.  
  5104. if (isset($users) && !empty($users)) {
  5105. $cal_esic = false;
  5106. foreach ($salaryslip->items as $item) {
  5107. /* if ($item->type == Items::ITEM_TYPE_INCOME) {
  5108. $all_items_total += $item->actual_value_month;
  5109. } */
  5110. if ($item->variable_name == "esic") {
  5111. $cal_esic = true;
  5112. $employees_contribution_sal = $item->actual_value_month;
  5113. }
  5114. if ($item->variable_name == "basic") {
  5115. $basic = $item->actual_value_month;
  5116. }
  5117. if($item->variable_name == 'provident_fund')
  5118. {
  5119. $pf = $item->actual_value_month;
  5120. }
  5121. }
  5122. if ($cal_esic) {
  5123. $all_items_total = 0;
  5124. $full_name = $users->getFullname();
  5125. $doj = date('Y-m-d', $users->doj->sec);
  5126. $office_location = TenantOffices::model()->tenant($tenant_id)->findByAttributes(array('id' => $users->personal->office_location));
  5127. $employee_code = (isset($users->personal->employee_no) && $users->personal->employee_no != "") ? $users->personal->employee_no : "N.A.";
  5128. if (isset($office_location) && !empty($office_location) && isset($office_location->city) && $office_location->city != "") {
  5129. $city_name = City::model()->findByPk($office_location->city);
  5130. if (isset($city_name) && !empty($city_name)) {
  5131. $office_location_name = $city_name->name;
  5132. } else {
  5133. $office_location_name = "N.A";
  5134. }
  5135. } else {
  5136. $office_location_name = "N.A";
  5137. }
  5138.  
  5139. $employees_contribution = $employees_contribution_sal;
  5140. $original_esic = $employees_contribution / 0.0175;
  5141. $employeers_contribution = number_format($original_esic * 0.0475);
  5142. $total = number_format($employees_contribution + $employeers_contribution);
  5143.  
  5144. // Calculate "GROSS + PF (Employeer) + EMPLOYEERS ESIC"
  5145. // If checkbox in Payroll setting is checked for "Calculate ESIC on Gross" - KT - 9th March 2015
  5146. if($cal_esic_on_gross == TenantProfile::ACTIVE)
  5147. {
  5148. $gross_salary = $gross_salary + $pf + $employeers_contribution;
  5149. }
  5150.  
  5151. $esic_account_number = (isset($users->esic_number) && $users->esic_number != null) ? $users->esic_number : "N.A.";
  5152. $total_no_days = (isset($salaryslip->effective_working_days)) ? $salaryslip->effective_working_days : "N.A.";
  5153. $output[] = array(
  5154. $employee_code,
  5155. $full_name,
  5156. $doj,
  5157. $office_location_name,
  5158. $esic_account_number,
  5159. $total_no_days,
  5160. PayrollHelper::roundingValues(Items::ROUND_TO_TWO_DIGITS, $gross_salary),
  5161. PayrollHelper::roundingValues(Items::ROUND_TO_TWO_DIGITS, $employees_contribution),
  5162. PayrollHelper::roundingValues(Items::ROUND_TO_TWO_DIGITS, $employeers_contribution),
  5163. PayrollHelper::roundingValues(Items::ROUND_TO_TWO_DIGITS, $total),
  5164. );
  5165. }
  5166. }
  5167. }
  5168. $cols = array(
  5169. 'Employee Code',
  5170. 'Employee Name',
  5171. 'Date Of Joining',
  5172. 'Location',
  5173. 'ESIC Account No',
  5174. 'Number Of Working Days',
  5175. 'Gross',
  5176. 'Employees Contribution',
  5177. 'Employeers Contribution',
  5178. 'Total',
  5179. );
  5180.  
  5181.  
  5182.  
  5183. $roster_type = "Payroll-ESIC-Report-month".$for_date;
  5184. $filenameexport = $roster_type;
  5185. $final_output = array('output' => $output,
  5186. 'cols' => $cols,
  5187. 'filenameexport' => $filenameexport);
  5188. return $final_output;
  5189. }
  5190.  
  5191. public static function getAttendanceSummaryRosterPayroll($post_data, $tenant_id = null, $from = null, $to = null) {
  5192. $return = array();
  5193. $index = 0;
  5194. $output = array();
  5195. $finaldata = array();
  5196. $final_output = array();
  5197. $filter = $post_data['filter_id'];
  5198. $users = RunPayroll::getWithoutFNFUsers($filter, $tenant_id, $post_data['month_year']);
  5199.  
  5200. $begin = new DateTime($from);
  5201. $end = new DateTime($to);
  5202. $end = $end->modify('+1 day');
  5203. $interval = new DateInterval('P1D');
  5204. $daterange = new DatePeriod($begin, $interval, $end);
  5205. $from = strtotime($from);
  5206. $to = strtotime($to);
  5207.  
  5208. $criteria = new EMongoCriteria();
  5209. $criteria->shift_date('>=', new MongoDate($from));
  5210. $criteria->shift_date('<=', new MongoDate($to));
  5211. foreach ($users as $key => $user) {
  5212. if (!isset($user->fandf_done) || ($user->fandf_done != USermongo::PROCESS_FANDF_PENDING && $user->fandf_done != Usermongo::STATUS_NOACTIVE && $user->fandf_done != Usermongo::PROCESS_FANDF_ACTIVE)) {
  5213. $user_name = $user['personal']['firstname'] . " " . $user['personal']['lastname'];
  5214. $criteria->user_id = $user->id;
  5215. $userAttendanceLogs = UserAttendanceLog::model()->tenant($tenant_id)->findAll($criteria);
  5216. //echo "<pre>"; print_r($userAttendanceLogs); exit("</pre> \n exited here \n");
  5217. $present = 0;
  5218. $absent = 0;
  5219. $weeklyoff_count = 0;
  5220. $holiday_count = 0;
  5221. $leave_count = 0;
  5222. $unpaidleave_count = 0;
  5223. $return = array();
  5224. $output[] = array(
  5225. $user_name,
  5226. );
  5227. $jindex = 0;
  5228. foreach ($daterange as $date) {
  5229. $unpaidFlag = false;
  5230. if (isset($userAttendanceLogs[$jindex])) {
  5231. if ($date->format("d") == date("d", $userAttendanceLogs[$jindex]->shift_date->sec)) {
  5232. $date = date("d", $userAttendanceLogs[$jindex]->shift_date->sec);
  5233. if (isset($userAttendanceLogs[$jindex]->attendance_status)) {
  5234. $status = $userAttendanceLogs[$jindex]->attendance_status;
  5235.  
  5236. if ($status == UserAttendance::ATTENDANCE_STATUS_ABSENT) {
  5237. $status = UserAttendanceLog::ATTENDANCE_STATUS_ABSENT;
  5238. } elseif ($status == UserAttendance::ATTENDANCE_STATUS_PRESENT) {
  5239. $status = UserAttendanceLog::ATTENDANCE_STATUS_PRESENT;
  5240. }
  5241. $weeklyoff = $userAttendanceLogs[$jindex]->is_weekly_off->status;
  5242. $holiday = $userAttendanceLogs[$jindex]->is_holiday->status;
  5243. $leave = $userAttendanceLogs[$jindex]->in_leave->status;
  5244. if (isset($userAttendanceLogs[$jindex]->in_leave->leave_id)) {
  5245. $unpaidLeave = UserLeaves::model()->findByPk($userAttendanceLogs[$jindex]->in_leave->leave_id);
  5246. if (isset($unpaidLeave) && $unpaidLeave != null) {
  5247. if ($unpaidLeave->isUnpaid == UserLeaves::LEAVE_UNPAID) {
  5248. $unpaidleave_count++;
  5249. $unpaidFlag = true;
  5250. } else {
  5251. $unpaidFlag = false;
  5252. }
  5253. }
  5254. } else {
  5255. $unpaidFlag = false;
  5256. }
  5257. if (isset($weeklyoff) && $weeklyoff == "1") {
  5258. $status = "W";
  5259. $weeklyoff_count++;
  5260. } elseif (isset($holiday) && $holiday == "1") {
  5261. $status = "H";
  5262. $holiday_count++;
  5263. } elseif (isset($leave) && $leave == "1") {
  5264. $status = "L";
  5265. $leave_count++;
  5266. } elseif ($status == UserAttendanceLog::ATTENDANCE_STATUS_PRESENT || $status == UserAttendanceLog::ATTENDANCE_STATUS_PENDING) {
  5267. $status = "P";
  5268. $present++;
  5269. } /* elseif ($status == UserAttendanceLog::ATTENDANCE_STATUS_PENDING) {
  5270. $status = "n";
  5271. } */ elseif ($status == UserAttendanceLog::ATTENDANCE_STATUS_ABSENT || $status == UserAttendance::ATTENDANCE_STATUS_ABSENT) {
  5272. $status = "A";
  5273. $absent++;
  5274. } else {
  5275. $status = "";
  5276. }
  5277. } else {
  5278. $status = "";
  5279. }
  5280. $jindex++;
  5281. } else {
  5282. $status = "-";
  5283. }
  5284. } else {
  5285. $status = "-";
  5286. }
  5287. if ($unpaidFlag) {
  5288. $status = "U";
  5289. }
  5290. array_push($output[$index], $status);
  5291. } // my good loop
  5292.  
  5293. array_push($output[$index], $present);
  5294. array_push($output[$index], $absent);
  5295. array_push($output[$index], $weeklyoff_count);
  5296. array_push($output[$index], $leave_count);
  5297. array_push($output[$index], $unpaidleave_count);
  5298. $index++;
  5299. } // EOF foreach all user
  5300. $flag = true;
  5301. $cols = array(
  5302. // 'Name||Column displays the Name of the employees.'
  5303. 'Name||Column displays the Name of the employees.'
  5304. );
  5305.  
  5306. foreach ($daterange as $date) {
  5307. $finaldatacols = $date->format("d") . "<br>" . substr((String) $date->format("D"), 0, 2);
  5308. array_push($cols, $finaldatacols);
  5309. }
  5310.  
  5311. array_push($cols, 'P||Column displays the total number days when an employee was Present in the specified duration.');
  5312. array_push($cols, 'A||Column displays the total number of days when an employee was Absent in the specified duration.');
  5313. array_push($cols, 'W||Column displays the total number of Weekly Offs assigned to an employee in the specified duration.');
  5314. array_push($cols, 'L||Column displays the total number of days when an employee was on a Leave in the specified duration.');
  5315. array_push($cols, 'U||Column displays the total number of days when an employee was on a Unpaid Leave in the specified duration.');
  5316.  
  5317. $roster_type = "Attendance-Summary";
  5318. $date = date('d-m-Y', $from) . "-to-" . date('d-m-Y', $to);
  5319. $filenameexport = $roster_type . "_" . $date;
  5320. $final_output = array('output' => $output,
  5321. 'cols' => $cols,
  5322. 'filenameexport' => $filenameexport);
  5323. }
  5324. return $final_output;
  5325. }
  5326.  
  5327. public static function getMasterCtcReport($post_data, $tenant_id, $from, $to) {
  5328. $for_date = date('Y-m', strtotime($from));
  5329. $return = array();
  5330. $output = array();
  5331.  
  5332. $current_month = date("m");
  5333. $filter = $post_data['filter_id'];
  5334. $gratuity_show = false;
  5335. /**/
  5336. $tenant_salary_structure = SalaryStructure::model()->tenant($tenant_id)->findAll();
  5337. foreach ($tenant_salary_structure as $salstructure) {
  5338. foreach ($salstructure->items as $key => $i) {
  5339. if($i->variable_name == "gratuity")
  5340. {
  5341. $gratuity_show = true;
  5342. }
  5343. $claims_to_be_made[] = array(
  5344. "id" => $i->id,
  5345. "label" => $i->label,
  5346. "variable_name" => $i->variable_name,
  5347. "declared_value" => 0.0,
  5348. "map_to" => $i->map_to
  5349. );
  5350. }
  5351. }
  5352. $claims_to_be_made = array_map("unserialize", array_unique(array_map("serialize", $claims_to_be_made)));
  5353. /**/
  5354. //$users_all = UserMongo::model()->tenant($tenant_id)->findAll();
  5355. $users_all = UserMongo::model()->getUsersByFilter($filter, $tenant_id, $post_data['active_inactive']);
  5356. foreach ($users_all as $users) {
  5357. if (isset($users) && !empty($users)) {
  5358. $user_sql = UserMongoView::model()->tenant($tenant_id)->findByAttributes(array('user_id'=>$users->user_id));
  5359. if (isset($user_sql) && !empty($user_sql)) {
  5360. $email_id_sql = (isset($user_sql->email) && $user_sql->email != "") ? $user_sql->email : "N.A.";
  5361. } else {
  5362. $email_id_sql = "N.A.";
  5363. }
  5364. $user_post = $users->getCurrentPosition($tenant_id);
  5365. $job_title = $user_post['designation'];
  5366. $department = $user_post['department'];
  5367. $business_unit = $user_post['business_unit'];
  5368. if (isset($users->personal->gender) && $users->personal->gender != "") {
  5369. $gender = ($users->personal->gender == "1") ? "Male" : "Female";
  5370. } else {
  5371. $gender = "N.A.";
  5372. }
  5373. $dob = (isset($users->personal->dob->sec) && $users->personal->dob->sec != "") ? date('Y-m-d', $users->personal->dob->sec) : "N.A.";
  5374. if (isset($users->dependents) && count($users->dependents) > 0) {
  5375. foreach ($users->dependents as $key => $value_dependent) {
  5376. if ($value_dependent->relation_type == "Father") {
  5377. $emp_father_name = $value_dependent->first_name;
  5378. }
  5379. }
  5380. }
  5381. $emp_father_name = (isset($emp_father_name) && $emp_father_name != "") ? $emp_father_name : "N.A.";
  5382. $full_name = $users->getFullname();
  5383. $date_of_joining = date('Y-m-d', $users->doj->sec);
  5384. $quit_date = (isset($users->deactivate_date->sec) && $users->deactivate_date->sec != "") ? date('Y-m-d', $users->deactivate_date->sec) : "N.A.";
  5385. $office_location = TenantOffices::model()->tenant($tenant_id)->findByAttributes(array('id' => $users->personal->office_location));
  5386. $bank_account_number = (isset($users->banking->bank_account) && $users->banking->bank_account != "") ? $users->banking->bank_account : "N.A.";
  5387. $bank_name = (isset($users->banking->bank_name) && $users->banking->bank_name != "") ? $users->banking->bank_name : "N.A.";
  5388. $pan_number = (isset($users->banking->bank_pan_num) && $users->banking->bank_pan_num != "") ? $users->banking->bank_pan_num : "N.A.";
  5389. $pf_number = (isset($users->pf_number) && $users->pf_number != "") ? $users->pf_number : "N.A.";
  5390. $esic_number = (isset($users->esic_number) && $users->esic_number != "") ? $users->esic_number : "N.A.";
  5391. $employee_code = (isset($users->personal->employee_no) && $users->personal->employee_no != "") ? $users->personal->employee_no : "N.A.";
  5392. if (isset($office_location) && !empty($office_location) && isset($office_location->city) && $office_location->city != "") {
  5393. $city_name = City::model()->findByPk($office_location->city);
  5394. if (isset($city_name) && !empty($city_name)) {
  5395. $office_location_name = $city_name->name;
  5396. } else {
  5397. $office_location_name = "N.A";
  5398. }
  5399. } else {
  5400. $office_location_name = "N.A";
  5401. }
  5402. /**/
  5403. $for_month = date('Y-m');
  5404. $year = date('Y');
  5405. $month = ($year + 1) . "-03";
  5406. $where = "1";
  5407. $taxCalculator = new TaxCalculator($users->id, $tenant_id, $year, $month, 0.0, $where);
  5408. $professional_tax = 0;
  5409. $deduction_total = $taxCalculator->getItemsTotal(Items::ITEM_TYPE_DEDUCTIONS);
  5410. foreach ($deduction_total as $key => $value) {
  5411. $professional_tax += $value['professional_tax'];
  5412. foreach ($value as $keys => $value_name) {
  5413. if ($keys == "professional_tax") {
  5414. $office_location = TenantOffices::model()->findByPk($users->personal->office_location);
  5415. if ($office_location->state == "1927" && date('m', strtotime($key)) == "02") {
  5416. $professional_tax = (isset($professional_tax) && $professional_tax > 0) ? $professional_tax + 100 : 0;
  5417. } elseif ($office_location->state == "1926" && date('m', strtotime($key)) == "03") {
  5418. $professional_tax = (isset($professional_tax) && $professional_tax > 0) ? $professional_tax + 4 : 0;
  5419. }
  5420. }
  5421. }
  5422. }
  5423.  
  5424.  
  5425. $salaryCalculator = new SalCalculator($users->id, $tenant_id, $for_month, '', '', '', 1);
  5426. $ctc_proration = $salaryCalculator->userSalarySlip;
  5427. if (isset($ctc_proration) && !empty($ctc_proration)) {
  5428. $basic = 0;
  5429. $hra = 0;
  5430. $conveyance = 0;
  5431. $medical = 0;
  5432. $lta = 0;
  5433. $special_allowance = 0;
  5434. $base_salary = 0;
  5435. $bonus = 0;
  5436. $gross_salary = 0;
  5437. $incometax = 0;
  5438. //$professional_tax = 0;
  5439. $esic = 0;
  5440. $pf = 0;
  5441. $total_deductions = 0;
  5442. $net_salary = 0;
  5443. $esic_is_yes_no = 'No';
  5444. $bonus_allowance = 0;
  5445. $laptop_allowance = 0;
  5446. foreach ($ctc_proration->items as $item) {
  5447. /* if ($item->variable_name == "professional_tax") {
  5448. $professional_tax = $item->max_value_month;
  5449. } */
  5450. if ($item->variable_name == "basic") {
  5451. $basic = $item->max_value_year;
  5452. }
  5453. if ($item->variable_name == "hra") {
  5454. $hra = $item->max_value_year;
  5455. }
  5456. if ($item->variable_name == "conveyance") {
  5457. $conveyance = $item->max_value_year;
  5458. }
  5459. if ($item->variable_name == "special_allowance") {
  5460. $special_allowance = $item->max_value_year;
  5461. }
  5462. if ($item->variable_name == "lta") {
  5463. $lta = $item->max_value_year;
  5464. }
  5465. if ($item->variable_name == "medical") {
  5466. $medical = $item->max_value_year;
  5467. }
  5468. if ($item->variable_name == "provident_fund") {
  5469. $pf = $item->max_value_year;
  5470. }
  5471. if ($item->variable_name == "esic") {
  5472. $esic_is_yes_no = 'Yes';
  5473. $esic = $item->max_value_year;
  5474. }
  5475. if ($item->variable_name == "bonus_allowance") {
  5476. $bonus_allowance = $item->max_value_year;
  5477. }
  5478. if ($item->variable_name == "laptop_allowance") {
  5479. $laptop_allowance = $item->max_value_year;
  5480. }
  5481. }
  5482. } else {
  5483. $esic_is_yes_no = 'No';
  5484. $basic = "N.A.";
  5485. $hra = "N.A.";
  5486. $conveyance = "N.A.";
  5487. $medical = "N.A.";
  5488. $lta = "N.A.";
  5489. $special_allowance = "N.A.";
  5490. $base_salary = "N.A.";
  5491. $bonus = "N.A.";
  5492. $gross_salary = "N.A.";
  5493. $incometax = "N.A.";
  5494. $professional_tax = "N.A.";
  5495. $esic = "N.A.";
  5496. $pf = "N.A.";
  5497. $total_deductions = "N.A.";
  5498. $net_salary = "N.A.";
  5499. $bonus_allowance = "N.A.";
  5500. $laptop_allowance = "N.A.";
  5501. }
  5502. if($gratuity_show && $basic > 0)
  5503. {
  5504. $gratuity = $basic * 0.0481;
  5505. }
  5506. else{
  5507. $gratuity = "N.A.";
  5508. }
  5509. /**/
  5510. $basic = (isset($basic)) ? $basic : "N.A.";
  5511. $hra = (isset($hra)) ? $hra : "N.A.";
  5512. $conveyance = (isset($conveyance)) ? $conveyance : "N.A.";
  5513. $special_allowance = (isset($special_allowance)) ? $special_allowance : "N.A.";
  5514. $lta = (isset($lta)) ? $lta : "N.A.";
  5515. $medical = (isset($medical)) ? $medical : "N.A.";
  5516. $pf = (isset($pf)) ? $pf : "N.A.";
  5517. $base_salary = $salaryslip->total_gross;
  5518. $gross_salary = $base_salary + $bonus;
  5519. $incometax = $salaryslip->tds;
  5520. $esic = (isset($esic) && $esic != "") ? $esic : 0;
  5521. $bonus_allowance = (isset($bonus_allowance) && $bonus_allowance != "") ? $bonus_allowance : 0;
  5522. $laptop_allowance = (isset($laptop_allowance) && $laptop_allowance != "") ? $laptop_allowance : 0;
  5523. $total_ctc = $ctc_proration->ctc;
  5524.  
  5525. $output[] = array(
  5526. $employee_code,
  5527. $full_name,
  5528. $date_of_joining,
  5529. $gender,
  5530. $dob,
  5531. $quit_date,
  5532. $job_title,
  5533. $department,
  5534. $business_unit,
  5535. $office_location_name,
  5536. $bank_account_number,
  5537. $bank_name,
  5538. $pan_number,
  5539. $pf_number,
  5540. $esic_number,
  5541. $email_id_sql,
  5542. $esic_is_yes_no,
  5543. $emp_father_name,
  5544. $basic,
  5545. $hra,
  5546. $conveyance,
  5547. $medical,
  5548. $lta,
  5549. $bonus_allowance,
  5550. $laptop_allowance,
  5551. $gratuity,
  5552. $special_allowance,
  5553. // $professional_tax,
  5554. $esic,
  5555. $pf,
  5556. $total_ctc,
  5557. );
  5558. }
  5559. }
  5560. $cols = array(
  5561. 'Employee Code',
  5562. 'Employee Name',
  5563. 'Joining Date',
  5564. 'Gender',
  5565. 'Date Of Birth',
  5566. 'Quit Date',
  5567. 'Designation',
  5568. 'Department',
  5569. 'Business Unit',
  5570. 'Location',
  5571. 'Saving Account Number',
  5572. 'Bank Name',
  5573. 'PAN Number',
  5574. 'PF Number',
  5575. 'ESIC Number',
  5576. 'Office Email',
  5577. 'ESIC Y N',
  5578. 'Emp Fathers Name',
  5579. 'Basic',
  5580. 'House Rent Allowances',
  5581. 'Conveyance Allowances',
  5582. 'Medical',
  5583. 'LTA',
  5584. 'Bonus Allowance',
  5585. 'Laptop Allowance',
  5586. 'Gratuity',
  5587. 'Special Allowances',
  5588. //'Professional Tax',
  5589. 'Statutory ESIC',
  5590. 'Statutory PF',
  5591. 'Total Ctc',
  5592. );
  5593.  
  5594.  
  5595.  
  5596. $roster_type = "payroll-Master-Ctc-Report".$for_date;
  5597. $filenameexport = $roster_type;
  5598. $final_output = array('output' => $output,
  5599. 'cols' => $cols,
  5600. 'filenameexport' => $filenameexport);
  5601. return $final_output;
  5602. }
  5603.  
  5604. public static function getHeadCountMonth($post_data, $tenant_id, $from, $to) {
  5605. //$for_date = date('Y-m', strtotime($from));
  5606. $for_month = date('m', strtotime($from));
  5607. $end_month = date('m', strtotime($to));
  5608. $for_year = date('Y', strtotime($from));
  5609. $end_year = date('Y', strtotime($to));
  5610. $for_month_previous = $for_month - "01";
  5611. if ($for_month_previous == 0) {
  5612. $for_month_previous = $for_month_previous + "12";
  5613. }
  5614. $end_month_previous = $end_month - "01";
  5615. if ($end_month_previous == 0) {
  5616. $end_month_previous = $end_month_previous + "12";
  5617. }
  5618. if ($for_month_previous > 9 && $end_month_previous > 9) {
  5619. $final_previous_date_for = "01-" . $for_month_previous . "-" . $for_year;
  5620. $final_previous_date_end = "31-" . $end_month_previous . "-" . $end_year;
  5621. } else {
  5622. $final_previous_date_for = "01-0" . $for_month_previous . "-" . $for_year;
  5623. $final_previous_date_end = "31-0" . $end_month_previous . "-" . $end_year;
  5624. }
  5625. $return = array();
  5626. $output = array();
  5627. $current_month = date("m");
  5628. $filter = $post_data['filter_id'];
  5629. $total_hc = 0;
  5630. $total_seprated = 0;
  5631. $total_added = 0;
  5632. $previous_hc = 0;
  5633. $total_seprated_previous_month = 0;
  5634. $users_all = UserMongo::model()->getUsersByFilter($filter, $tenant_id, $post_data['active_inactive']);
  5635. $users_all_inactive = UserMongo::model()->getUsersByFilter($filter, $tenant_id, 10); //passing 10 as a parameter to get all active and inactive employee
  5636. if (isset($users_all) && !empty($users_all)) {
  5637. foreach ($users_all as $users) {
  5638. if (isset($users->created->sec) && $users->created->sec >= strtotime($from) && $users->created->sec <= strtotime($to)) {
  5639. $total_added = $total_added + 1;
  5640. }
  5641. if (isset($users->created->sec) && $users->created->sec < strtotime($from)) {
  5642. $previous_hc = $previous_hc + 1;
  5643. }
  5644. }
  5645. }
  5646. if (isset($users_all_inactive) && !empty($users_all_inactive)) {
  5647. foreach ($users_all_inactive as $users_inactive) {
  5648. if (isset($users_inactive->deactivate_date->sec) && $users_inactive->deactivate_date->sec >= strtotime($from) && $users_inactive->deactivate_date->sec <= strtotime($to)) {
  5649. $total_seprated = $total_seprated + 1;
  5650. }
  5651.  
  5652. if (isset($users->created->sec) && $users->created->sec <= strtotime($from)) {
  5653. $previous_hc = $previous_hc + 1;
  5654. }
  5655. if (isset($users_inactive->deactivate_date->sec) && $users_inactive->deactivate_date->sec <= strtotime($final_previous_date_end)) {
  5656. $total_seprated_previous_month = $total_seprated_previous_month + 1;
  5657. }
  5658. }
  5659. }
  5660. $total_hc = (($previous_hc - $total_seprated_previous_month) + $total_added) - $total_seprated;
  5661. $output[] = array(
  5662. ($previous_hc - $total_seprated_previous_month),
  5663. $total_added,
  5664. $total_seprated,
  5665. $total_hc,
  5666. );
  5667. $cols = array(
  5668. 'Opening Head Count',
  5669. 'Addition',
  5670. 'Sepration',
  5671. 'Closing Head Count',
  5672. );
  5673.  
  5674.  
  5675.  
  5676. $roster_type = "payroll-Monthly-Head-Count-Annual";
  5677. $filenameexport = $roster_type;
  5678. $final_output = array('output' => $output,
  5679. 'cols' => $cols,
  5680. 'filenameexport' => $filenameexport);
  5681. return $final_output;
  5682. }
  5683.  
  5684. public static function getLeavesEncashmentBalance($post_data, $tenant_id = null, $from = null, $to = null) {
  5685. //$tenat_leave = Leaves::model()->tenant($tenant_id)->findAll();
  5686. //echo "<pre>"; print_r($tenat_leave); exit("\n exited in " . __FILE__ . " @ " . __LINE__. "</pre>");
  5687. $return = array();
  5688. //$sr_no=1;
  5689. $filter = $post_data['filter_id'];
  5690. $users = UserMongo::model()->getUsersByFilter($filter, $tenant_id, $post_data['active_inactive']);
  5691. $output = array();
  5692. $leaves = Leaves::model()->getTenantLeaveList($tenant_id);
  5693.  
  5694. $index = 0;
  5695. foreach ($users as $key => $user) {
  5696. $employee_number = (isset($user['personal']['employee_no'])) ? $user['personal']['employee_no'] : "N.A.";
  5697. $user_name = $user['personal']['firstname'] . " " . $user['personal']['lastname'];
  5698. $user_post = $user->getCurrentPosition($tenant_id);
  5699. $job_title = $user_post['designation'];
  5700. $department = $user_post['department'];
  5701. $business_unit = $user_post['business_unit'];
  5702. // $action_checkbox = "<input type=\"checkbox\" name=\"roster_action\" value=\"\">";
  5703. $leaves_user_allowed = Leaves::model()->getLeaveList($tenant_id, $user->user_id);
  5704. unset($userleaves);
  5705. foreach ($leaves as $leave_id => $leave) {
  5706. if (array_key_exists($leave_id, $leaves_user_allowed)) {
  5707. $userleaves[] = LeavesHelper::individualEncashmentBalance($user->id, $tenant_id, $leave_id);
  5708. } else {
  5709. $userleaves[] = "N.A.";
  5710. }
  5711. }
  5712. $output[] = array(
  5713. // $action_checkbox,
  5714. $employee_number,
  5715. $user_name,
  5716. $job_title,
  5717. $department,
  5718. $business_unit,
  5719. );
  5720. for ($i = 0; $i < count($userleaves); $i++) {
  5721. array_push($output[$index], $userleaves[$i]);
  5722. }
  5723. $index++;
  5724. } // EOF foreach user
  5725.  
  5726. $cols = array(
  5727. // "<input type=\\\"checkbox\\\" name=\\\"roster_action\\\" value=\\\"\\\">",
  5728. //'Sr No',
  5729. 'Employee ID',
  5730. 'Name',
  5731. 'Job Title',
  5732. 'Department',
  5733. 'Business Unit',
  5734. );
  5735.  
  5736. foreach ($leaves as $leave_id => $leave_name) {
  5737. array_push($cols, $leave_name);
  5738. }
  5739. $roster_type = "Leaves-Encashment";
  5740. $filenameexport = $roster_type;
  5741. $final_output = array('output' => $output,
  5742. 'cols' => $cols,
  5743. 'filenameexport' => $filenameexport);
  5744. return $final_output;
  5745. }
  5746.  
  5747. public static function getReimbursement($post_data, $tenant_id, $from, $to, $type, $name) {
  5748. $output = array();
  5749. $tenant = Tenants::model()->findByPk($tenant_id);
  5750. $subdomain = (isset($tenant->tenant_subdomain) && $tenant->tenant_subdomain != "") ? $tenant->tenant_subdomain : "darwinbox";
  5751. $filter = $post_data['filter_id'];
  5752. $users_all = UserMongo::model()->getUsersByFilter($filter, $tenant_id, $post_data['active_inactive']);
  5753. foreach ($users_all as $key_user => $value_user) {
  5754. $users_array[] = $value_user->id;
  5755. }
  5756. $from_date = new MongoDate(strtotime($from));
  5757. $to_date = new MongoDate(strtotime($to));
  5758. if ($type == UserExpenses::STATUS_COMPENSATED) {
  5759. $criteria = new EMongoCriteria();
  5760. $criteria->status('==', UserExpenses::STATUS_APPROVED);
  5761. $criteria->paid('==', UserExpenses::PAID_YES);
  5762. $criteria->tenant_id('==', $tenant_id);
  5763. $criteria->date('<=', $to_date);
  5764. $criteria->date('>=', $from_date);
  5765. $user_expenses = UserExpenses::model()->findAll($criteria);
  5766. } else {
  5767. $criteria = new EMongoCriteria();
  5768. $criteria->status('==', $type);
  5769. $criteria->paid('==', UserExpenses::PAID_NO);
  5770. $criteria->tenant_id('==', $tenant_id);
  5771. $criteria->date('<=', $to_date);
  5772. $criteria->date('>=', $from_date);
  5773. $user_expenses = UserExpenses::model()->findAll($criteria);
  5774. }
  5775. if (isset($user_expenses) && !empty($user_expenses)) {
  5776. foreach ($user_expenses as $key_reimbursment => $value_reimbursment) {
  5777. if (in_array($value_reimbursment->user_id, $users_array)) {
  5778. $user_mongo_each = UserMongo::model()->tenant($tenant_id)->findByPk($value_reimbursment->user_id);
  5779. $user_post = $user_mongo_each->getCurrentPosition($tenant_id);
  5780. $job_title = (isset($user_post['designation'])) ? $user_post['designation'] : "N.A.";
  5781. $department = (isset($user_post['department'])) ? $user_post['department'] : "N.A.";
  5782. $business_unit = (isset($user_post['business_unit'])) ? $user_post['business_unit'] : "N.A.";
  5783. $full_name = $user_mongo_each->getFullname();
  5784. $employee_id = $user_mongo_each->personal->employee_no;
  5785. $title = (isset($value_reimbursment->title)) ? $value_reimbursment->title : "N.A.";
  5786. $date = (isset($value_reimbursment->date->sec)) ? date('d F Y', $value_reimbursment->date->sec) : "N.A.";
  5787. $item_total = 0;
  5788. $item_name_price = '';
  5789. foreach ($value_reimbursment->items as $key_items => $value_items) {
  5790. $item_name = $value_items['itemName'];
  5791. $item_price = $value_items['itemPrice'];
  5792. $item_name_price = (empty($item_name_price)) ? $item_name . " (" . $item_price . ")" : $item_name_price . ", " . $item_name . " (" . $item_price . ")";
  5793. $item_total += $item_price;
  5794. }
  5795.  
  5796. if (isset($value_reimbursment->paid_by) && $value_reimbursment->paid_by != "") {
  5797. $performed_by = UserMongo::getFullnameById($value_reimbursment->paid_by);
  5798. } else if (isset($value_reimbursment->approved_or_rejected_by) && $value_reimbursment->approved_or_rejected_by != "") {
  5799. $performed_by = UserMongo::getFullnameById($value_reimbursment->approved_or_rejected_by);
  5800. } else {
  5801. $performed_by = "N.A.";
  5802. }
  5803. $link_created = "https://" . $subdomain . ".darwinbox.in/expenses/expenses/view/id/" . $value_reimbursment->id;
  5804. $link = '<a target = "_blank" href = '.$link_created.'>'.$link_created.' </a>';
  5805. $output[] = array(
  5806. $employee_id,
  5807. $full_name,
  5808. $department,
  5809. $job_title,
  5810. $title,
  5811. $date,
  5812. $item_name_price,
  5813. $item_total,
  5814. $name, //status
  5815. $performed_by,
  5816. $link,
  5817. );
  5818. }
  5819. }
  5820. }
  5821. $cols = array(
  5822. 'Employee ID',
  5823. 'Employee Name',
  5824. 'Department',
  5825. 'Designation',
  5826. 'Title',
  5827. 'Date',
  5828. 'Items(Amount)',
  5829. 'Total Amount',
  5830. 'Status',
  5831. 'Performed By',
  5832. 'Link',
  5833. );
  5834.  
  5835.  
  5836.  
  5837. $roster_type = "Reimbursement-Report";
  5838. $filenameexport = $roster_type;
  5839. $final_output = array('output' => $output,
  5840. 'cols' => $cols,
  5841. 'filenameexport' => $filenameexport);
  5842. return $final_output;
  5843. }
  5844.  
  5845. public static function getAnnualLeaveTracker($post_data, $tenant_id) {
  5846. //$year_requested = date('Y', strtotime($from));
  5847. $todays_date = date('Y-m-d');
  5848. $previous_annual_tracker = AnnualLeavesTracker::isNew($todays_date);
  5849. if ($previous_annual_tracker) {
  5850. $user_mongo_data = UserMongo::model()->tenant()->findByAttributes(array('user_id' => Yii::app()->user->id));
  5851. $annual_tracker = new AnnualLeavesTracker;
  5852. $annual_tracker->user_id = Yii::app()->user->id;
  5853. $annual_tracker->user_name = $user_mongo_data->getFullname();
  5854. $user_email = (isset($user_mongo_data->personal->email)) ? $user_mongo_data->personal->email : UserMongo::getUserEmail($user_mongo_data->user_id);
  5855. $annual_tracker->user_email = array('0' => $user_email);
  5856. $annual_tracker->report_created_time = null;
  5857. $annual_tracker->size = null;
  5858. $annual_tracker->tenant_id = $user_mongo_data->tenant_id;
  5859. $annual_tracker->file_path = null;
  5860. $annual_tracker->save();
  5861. } else {
  5862. $message = "you can request this report only onces a DAY";
  5863. }
  5864. /**/
  5865. $previous_annual_tracker = AnnualLeavesTracker::model()->tenant()->findAll();
  5866. $tenant_profile = TenantProfile::model()->tenant()->find();
  5867. foreach ($previous_annual_tracker as $key_annual => $value_annual) {
  5868. //get employee id
  5869. $users = UserMongo::model()->tenant($tenant_id)->findByAttributes(array('user_id'=>$value_annual->user_id));
  5870. $employee_id = $users->personal->employee_no;
  5871. //get employee id
  5872. $status = ($value_annual->status == AnnualLeavesTracker::ANNUALLT_PENDING) ? "Pending" : "Completed";
  5873. $export_requested_time = (isset($value_annual->created_on) && $value_annual->created_on != null) ? date('d F Y @ H:i:s', $value_annual->created_on->sec) : "-";
  5874. $export_completed_time = (isset($value_annual->report_created_time) && $value_annual->report_created_time != null) ? date('d F Y @ H:i:s', $value_annual->report_created_time->sec) : "-";
  5875. if (isset($value_annual->file_path) && $value_annual->file_path != "") {
  5876. $link = "https://" . $tenant_profile->tenant_subdomain . ".darwinbox.in/upload/annualleavesreport/" . $value_annual->file_path;
  5877. $download_link = '<a href = "' . $link . '" target = "_blank"> Click here </a>';
  5878. } else {
  5879. $download_link = "-";
  5880. }
  5881. $output[] = array(
  5882. $employee_id,
  5883. $value_annual->user_name,
  5884. $value_annual->user_email,
  5885. $export_requested_time,
  5886. $export_completed_time,
  5887. $download_link,
  5888. $status,
  5889. );
  5890. }
  5891. $cols = array(
  5892. 'Employee ID',
  5893. 'Export Requested By',
  5894. 'Requested Email',
  5895. 'Export Requested Time',
  5896. 'Export Completed Time',
  5897. 'Download Link',
  5898. 'Status',
  5899. );
  5900.  
  5901.  
  5902.  
  5903. $roster_type = "Annual-Leaves-Requested-Report-List";
  5904. $filenameexport = $roster_type;
  5905. $final_output = array('output' => $output,
  5906. 'cols' => $cols,
  5907. 'filenameexport' => $filenameexport);
  5908. return $final_output;
  5909. /**/
  5910. }
  5911.  
  5912. public static function getcompoffbalance($post_data, $tenant_id, $from, $to) {
  5913. $filter = $post_data['filter_id'];
  5914. $users = UserMongo::model()->getUsersByFilter($filter, $tenant_id, $post_data['active_inactive']);
  5915. foreach ($users as $key_user => $user) {
  5916. $employee_number = (isset($user['personal']['employee_no'])) ? $user['personal']['employee_no'] : "N.A.";
  5917. $user_name = $user['personal']['firstname'] . " " . $user['personal']['lastname'];
  5918. $user_post = $user->getCurrentPosition($tenant_id);
  5919. $job_title = $user_post['designation'];
  5920. $department = $user_post['department'];
  5921. $business_unit = $user_post['business_unit'];
  5922. $compoff_available = $user->getCompoffLeavesavailable();
  5923. $output[] = array(
  5924. $employee_number,
  5925. $user_name,
  5926. $job_title,
  5927. $department,
  5928. $business_unit,
  5929. $compoff_available,
  5930. );
  5931. }
  5932.  
  5933. $cols = array(
  5934. 'Employee ID',
  5935. 'Name',
  5936. 'Job Title',
  5937. 'Department',
  5938. 'Business Unit',
  5939. 'Compoff Balance',
  5940. );
  5941.  
  5942.  
  5943.  
  5944. $roster_type = "Compoff-Balance-Report-List";
  5945. $filenameexport = $roster_type;
  5946. $final_output = array('output' => $output,
  5947. 'cols' => $cols,
  5948. 'filenameexport' => $filenameexport);
  5949. return $final_output;
  5950. /**/
  5951. }
  5952.  
  5953. public static function getcompofftakenused($post_data, $tenant_id, $from, $to) {
  5954. $filter = $post_data['filter_id'];
  5955. $users = UserMongo::model()->getUsersByFilter($filter, $tenant_id, $post_data['active_inactive']);
  5956. foreach ($users as $key_user => $user) {
  5957. $employee_number = (isset($user['personal']['employee_no'])) ? $user['personal']['employee_no'] : "N.A.";
  5958. $user_name = $user['personal']['firstname'] . " " . $user['personal']['lastname'];
  5959. $user_post = $user->getCurrentPosition($tenant_id);
  5960. $job_title = $user_post['designation'];
  5961. $department = $user_post['department'];
  5962. $business_unit = $user_post['business_unit'];
  5963. $compoff_taken = $user->getCompoffLeavestaken();
  5964. $output[] = array(
  5965. $employee_number,
  5966. $user_name,
  5967. $job_title,
  5968. $department,
  5969. $business_unit,
  5970. $compoff_taken,
  5971. );
  5972. }
  5973.  
  5974. $cols = array(
  5975. 'Employee ID',
  5976. 'Name',
  5977. 'Job Title',
  5978. 'Department',
  5979. 'Business Unit',
  5980. 'Compoff Taken/Used',
  5981. );
  5982.  
  5983.  
  5984.  
  5985. $roster_type = "Compoff-Taken-Report-List";
  5986. $filenameexport = $roster_type;
  5987. $final_output = array('output' => $output,
  5988. 'cols' => $cols,
  5989. 'filenameexport' => $filenameexport);
  5990. return $final_output;
  5991. /**/
  5992. }
  5993.  
  5994. public static function getcompoffcredited($post_data, $tenant_id, $from, $to) {
  5995. $filter = $post_data['filter_id'];
  5996. $users = UserMongo::model()->getUsersByFilter($filter, $tenant_id, $post_data['active_inactive']);
  5997. foreach ($users as $key_user => $user) {
  5998. $employee_number = (isset($user['personal']['employee_no'])) ? $user['personal']['employee_no'] : "N.A.";
  5999. $user_name = $user['personal']['firstname'] . " " . $user['personal']['lastname'];
  6000. $user_post = $user->getCurrentPosition($tenant_id);
  6001. $job_title = $user_post['designation'];
  6002. $department = $user_post['department'];
  6003. $business_unit = $user_post['business_unit'];
  6004. $compoff_taken = $user->getCompoffLeavestaken();
  6005. $compoff_available = $user->getCompoffLeavesavailable();
  6006. $compoff_credited = $compoff_taken + $compoff_available;
  6007. $output[] = array(
  6008. $employee_number,
  6009. $user_name,
  6010. $job_title,
  6011. $department,
  6012. $business_unit,
  6013. $compoff_credited,
  6014. );
  6015. }
  6016.  
  6017. $cols = array(
  6018. 'Employee ID',
  6019. 'Name',
  6020. 'Job Title',
  6021. 'Department',
  6022. 'Business Unit',
  6023. 'Compoff credited',
  6024. );
  6025.  
  6026.  
  6027.  
  6028. $roster_type = "Compoff-Credited-Report-List";
  6029. $filenameexport = $roster_type;
  6030. $final_output = array('output' => $output,
  6031. 'cols' => $cols,
  6032. 'filenameexport' => $filenameexport);
  6033. return $final_output;
  6034. /**/
  6035. }
  6036.  
  6037. public static function getcompoffsummary($post_data, $tenant_id, $from, $to) {
  6038. $output = array();
  6039. $filter = $post_data['filter_id'];
  6040. $users = UserMongo::model()->getUsersByFilter($filter, $tenant_id, $post_data['active_inactive']);
  6041. foreach ($users as $key_user => $user) {
  6042. $employee_id = $employee_number = (isset($user['personal']['employee_no'])) ? $user['personal']['employee_no'] : "N.A.";
  6043. $user_name = $user['personal']['firstname'] . " " . $user['personal']['lastname'];
  6044. $user_post = $user->getCurrentPosition($tenant_id);
  6045. $job_title = $user_post['designation'];
  6046. $department = $user_post['department'];
  6047. $business_unit = $user_post['business_unit'];
  6048. $compoff_taken = $user->getCompoffLeavestaken();
  6049. $compoff_available = $user->getCompoffLeavesavailable();
  6050. $compoff_credited = $compoff_taken + $compoff_available;
  6051. $output[] = array(
  6052. $employee_id,
  6053. $user_name,
  6054. $job_title,
  6055. $department,
  6056. $business_unit,
  6057. $compoff_credited,
  6058. $compoff_taken,
  6059. $compoff_available,
  6060. );
  6061. }
  6062.  
  6063. $cols = array(
  6064. 'Employee ID',
  6065. 'Name',
  6066. 'Job Title',
  6067. 'Department',
  6068. 'Business Unit',
  6069. 'Compoff credited',
  6070. 'Compoff taken',
  6071. 'Compoff Balance',
  6072. );
  6073.  
  6074.  
  6075.  
  6076. $roster_type = "Compoff-Summary-Report-List";
  6077. $filenameexport = $roster_type;
  6078. $final_output = array('output' => $output,
  6079. 'cols' => $cols,
  6080. 'filenameexport' => $filenameexport);
  6081. return $final_output;
  6082. /**/
  6083. }
  6084.  
  6085. public static function optionalHolidays($post_data, $tenant_id = null) {
  6086. $return = array();
  6087. $output = array();
  6088. $locations = "";
  6089. $holidays_list = TenantHolidays::model()->tenant()->active()->findAllByAttributes(array('optional' => TenantHolidays::OPTIONAL_TRUE,'date_year' => date('Y')));
  6090. if(isset($holidays_list) && !empty($holidays_list)){
  6091. foreach ($holidays_list as $key_holiday => $value_holiday) {
  6092. $holiday_name = (isset($value_holiday->name)) ? $value_holiday->name : "N.A.";
  6093. if(isset($value_holiday->date,$value_holiday->date_year))
  6094. {
  6095. $date_month = explode('-', $value_holiday->date);
  6096. $date_only = (isset($date_month[1])) ? $date_month[1] : "";
  6097. $month_only = (isset($date_month[0])) ? $date_month[0] : "";
  6098. }
  6099. $holiday_date = (isset($date_only,$month_only) && $month_only != "" && $date_only != "") ? date('d F Y, l',strtotime($date_only."-".$month_only."-".$value_holiday->date_year)) : "N.A.";
  6100. $locations = "";
  6101. if(!empty($value_holiday->for_location)):
  6102. foreach($value_holiday->for_location as $h):
  6103. $tenant_office = TenantOffices::model()->findByPk($h);
  6104. if(!empty($tenant_office)) :
  6105. $locations = (isset($locations) && $locations != "") ? $locations."<br/>".$tenant_office->getLocation() : $tenant_office->getLocation();
  6106. endif;
  6107. endforeach;
  6108. endif;
  6109. $output[] = array(
  6110. $holiday_name,
  6111. $holiday_date,
  6112. $locations,
  6113. );
  6114. } // EOF foreach
  6115. }
  6116. $cols = array(
  6117. 'Holiday Name',
  6118. 'Holiday Date',
  6119. 'Locations',
  6120. );
  6121.  
  6122. $roster_type = "Optional-Holiday-Data";
  6123. $filenameexport = $roster_type;
  6124. $final_output = array('output' => $output,
  6125. 'cols' => $cols,
  6126. 'filenameexport' => $filenameexport);
  6127. return $final_output;
  6128. }
  6129. public static function workanniversary($post_data, $tenant_id = null, $from, $to) {
  6130. $return = array();
  6131. $filter = $post_data['filter_id'];
  6132. $users = UserMongo::model()->getUsersByFilter($filter, $tenant_id, $post_data['active_inactive']);
  6133. $output = array();
  6134. $index = 0;
  6135. foreach ($users as $key => $user) {
  6136. if(isset($user->doj->sec) && $user->doj->sec != ""){
  6137. $todaysDate = date('m-d',$user->doj->sec);
  6138. $year_only = date('Y',$user->doj->sec);
  6139. $openDateBegin = date('m-d', strtotime($from));
  6140. $openDateEnd = date('m-d', strtotime($to));
  6141. if (($todaysDate >= $openDateBegin) && ($todaysDate <= $openDateEnd))
  6142. {
  6143. if($year_only != date('Y'))
  6144. {
  6145. $employee_number = (isset($user['personal']['employee_no'])) ? $user['personal']['employee_no'] : "N.A.";
  6146. $user_name = $user['personal']['firstname'] . " " . $user['personal']['lastname'];
  6147. $user_post = $user->getCurrentPosition($tenant_id);
  6148. $job_title = $user_post['designation'];
  6149. $department = $user_post['department'];
  6150. $business_unit = $user_post['business_unit'];
  6151. $doj = date('d F Y, l',$user->doj->sec);
  6152. $annv_date_create = date('Y')."-".$todaysDate;
  6153. $anniversary_date = date('d F Y, l',strtotime($annv_date_create));
  6154. $output[] = array(
  6155. $employee_number,
  6156. $user_name,
  6157. $job_title,
  6158. $department,
  6159. $business_unit,
  6160. $doj,
  6161. $anniversary_date,
  6162. );
  6163. }
  6164. }
  6165. }
  6166. } // EOF foreach user
  6167. $cols = array(
  6168. 'Employee ID',
  6169. 'Name',
  6170. 'Job Title',
  6171. 'Department',
  6172. 'Business Unit',
  6173. 'Date Of Joining',
  6174. 'Work Anniversary Date',
  6175. );
  6176.  
  6177.  
  6178. $roster_type = "Work Anniversary Report";
  6179. $filenameexport = $roster_type;
  6180. $final_output = array('output' => $output,
  6181. 'cols' => $cols,
  6182. 'filenameexport' => $filenameexport);
  6183. return $final_output;
  6184. }
  6185.  
  6186. public static function getAgeReport($post_data, $tenant_id = null, $from, $to) {
  6187. $return = array();
  6188. $filter = $post_data['filter_id'];
  6189. $users = UserMongo::model()->getUsersByFilter($filter, $tenant_id, $post_data['active_inactive']);
  6190. $output = array();
  6191. foreach ($users as $key => $user) {
  6192. if(isset($user->personal->dob->sec) && $user->personal->dob->sec != ""){
  6193. $age_total = self::calculate_experience(time(), $user->personal->dob->sec);
  6194. $employee_number = (isset($user['personal']['employee_no'])) ? $user['personal']['employee_no'] : "N.A.";
  6195. $user_name = $user['personal']['firstname'] . " " . $user['personal']['lastname'];
  6196. $user_post = $user->getCurrentPosition($tenant_id);
  6197. $job_title = $user_post['designation'];
  6198. $department = $user_post['department'];
  6199. $business_unit = $user_post['business_unit'];
  6200. $dob = date('d F Y, l', $user->personal->dob->sec);
  6201. $age = $age_total['Years']." y ".$age_total['Months']." m ".$age_total['Days']." d";
  6202. $output[] = array(
  6203. $employee_number,
  6204. $user_name,
  6205. $job_title,
  6206. $department,
  6207. $business_unit,
  6208. $dob,
  6209. $age,
  6210. );
  6211. }
  6212. } // EOF foreach user
  6213. $cols = array(
  6214. 'Name',
  6215. 'Job Title',
  6216. 'Department',
  6217. 'Business Unit',
  6218. 'Date Of Birth',
  6219. 'Age',
  6220. );
  6221.  
  6222.  
  6223. $roster_type = "Age Report";
  6224. $filenameexport = $roster_type;
  6225. $final_output = array('output' => $output,
  6226. 'cols' => $cols,
  6227. 'filenameexport' => $filenameexport);
  6228. return $final_output;
  6229. }
  6230. public static function getHiringReport($post_data, $tenant_id = null, $from, $to) {
  6231. $return = array();
  6232. $filter = $post_data['filter_id'];
  6233. $users = UserMongo::model()->getUsersByFilter($filter, $tenant_id, $post_data['active_inactive']);
  6234. $output = array();
  6235. foreach ($users as $key => $user) {
  6236. if(isset($user->doj->sec) && $user->doj->sec != "")
  6237. {
  6238. $todaysDate = date('Y-m-d',$user->doj->sec);
  6239. //$todaysDate=date('Y-m-d', strtotime($todaysDate));
  6240. $openDateBegin = date('Y-m-d', strtotime($from));
  6241. $openDateEnd = date('Y-m-d', strtotime($to));
  6242. if (($todaysDate >= $openDateBegin) && ($todaysDate <= $openDateEnd))
  6243. {
  6244. $user_name = $user['personal']['firstname'] . " " . $user['personal']['lastname'];
  6245. $employee_number = (isset($user['personal']['employee_no'])) ? $user['personal']['employee_no'] : "N.A.";
  6246. $user_post = $user->getCurrentPosition($tenant_id);
  6247. $job_title = $user_post['designation'];
  6248. $department = $user_post['department'];
  6249. $business_unit = $user_post['business_unit'];
  6250. $date_of_joining = date('d F Y, l',$user->doj->sec);
  6251. $output[] = array(
  6252. $employee_number,
  6253. $user_name,
  6254. $job_title,
  6255. $department,
  6256. $business_unit,
  6257. $date_of_joining,
  6258. );
  6259. }
  6260. }
  6261. } // EOF foreach user
  6262. $cols = array(
  6263. 'Employee ID',
  6264. 'Name',
  6265. 'Job Title',
  6266. 'Department',
  6267. 'Business Unit',
  6268. 'Hire Date',
  6269. );
  6270.  
  6271.  
  6272. $roster_type = "Hiring Report";
  6273. $filenameexport = $roster_type;
  6274. $final_output = array('output' => $output,
  6275. 'cols' => $cols,
  6276. 'filenameexport' => $filenameexport);
  6277. return $final_output;
  6278. }
  6279.  
  6280. public static function getTenureReport($post_data, $tenant_id = null) {
  6281. $return = array();
  6282. $filter = $post_data['filter_id'];
  6283. $users = UserMongo::model()->getUsersByFilter($filter, $tenant_id, $post_data['active_inactive']);
  6284. $output = array();
  6285.  
  6286. foreach ($users as $key => $user) {
  6287. if(isset($user->doj->sec) && $user->doj->sec != ""){
  6288. $employee_number = (isset($user['personal']['employee_no'])) ? $user['personal']['employee_no'] : "N.A.";
  6289. $user_name = $user['personal']['firstname'] . " " . $user['personal']['lastname'];
  6290. $user_post = $user->getCurrentPosition($tenant_id);
  6291. $job_title = $user_post['designation'];
  6292. $department = $user_post['department'];
  6293. $business_unit = $user_post['business_unit'];
  6294. $diff_cur_work = self::calculate_experience(time(), $user->doj->sec);
  6295. $total_cur_y = $diff_cur_work['Years'];
  6296. $total_cur_m = $diff_cur_work['Months'];
  6297. $cur_work_ex = $total_cur_y . "y " . $total_cur_m . "m";
  6298.  
  6299. $output[] = array(
  6300. $employee_number,
  6301. $user_name,
  6302. $job_title,
  6303. $department,
  6304. $business_unit,
  6305. $cur_work_ex,
  6306. );
  6307. }
  6308. } // EOF foreach
  6309. $cols = array(
  6310. 'Employee ID',
  6311. 'Name',
  6312. 'Job Title',
  6313. 'Department',
  6314. 'Business Unit',
  6315. 'Tenure',
  6316. );
  6317.  
  6318. $roster_type = "Tenure Report";
  6319. $filenameexport = $roster_type;
  6320. $final_output = array('output' => $output,
  6321. 'cols' => $cols,
  6322. 'filenameexport' => $filenameexport);
  6323. return $final_output;
  6324. }
  6325.  
  6326. public static function getPastWorkExp($post_data, $tenant_id = null) {
  6327. $return = array();
  6328. $filter = $post_data['filter_id'];
  6329. $users = UserMongo::model()->getUsersByFilter($filter, $tenant_id, $post_data['active_inactive']);
  6330. $output = array();
  6331.  
  6332. foreach ($users as $key => $user) {
  6333. $total_past_y = 0;
  6334. $total_past_m = 0;
  6335. $total_cur_y = 0;
  6336. $total_cur_m = 0;
  6337. $total_ex_m = 0;
  6338. $total_ex_y = 0;
  6339. $employee_number = (isset($user['personal']['employee_no'])) ? $user['personal']['employee_no'] : "N.A.";
  6340. $user_name = $user['personal']['firstname'] . " " . $user['personal']['lastname'];
  6341. $user_post = $user->getCurrentPosition($tenant_id);
  6342. $job_title = $user_post['designation'];
  6343. $department = $user_post['department'];
  6344. $business_unit = $user_post['business_unit'];
  6345. $before_company = "";
  6346. if (isset($user['past_work']) && !empty($user['past_work'])) {
  6347. foreach ($user['past_work'] as $key => $work) {
  6348. $diff_work = self::calculate_experience($work['to_date']->sec, $work['from_date']->sec);
  6349. $total_past_y += intval($diff_work['Years']);
  6350. $total_past_m += intval($diff_work['Months']);
  6351. $company_name = (isset($work->company) && $work->company != "") ? ucfirst($work->company)." - " : "N.A.";
  6352. $exp_company = $diff_work['Years'] . "y " . $diff_work['Months'] . "m";
  6353. if(isset($company_name) && $company_name != "N.A."){
  6354. $before_company = (isset($before_company) && $before_company != "") ? $before_company . "<br/>". $company_name ." ". $exp_company : $company_name . $exp_company;
  6355. }
  6356. }
  6357.  
  6358. if ($total_past_m > 12) {
  6359. $total_past_y += intval($total_past_m / 12);
  6360. $total_past_m = $total_past_m % 12;
  6361. }
  6362. $past_work_ex = $total_past_y . "y " . $total_past_m . "m";
  6363. } else {
  6364. $past_work_ex = "";
  6365. }
  6366.  
  6367. $output[] = array(
  6368. $employee_number,
  6369. $user_name,
  6370. $job_title,
  6371. $department,
  6372. $business_unit,
  6373. $before_company,
  6374. $past_work_ex,
  6375. );
  6376. } // EOF foreach
  6377. $cols = array(
  6378. 'Employee ID',
  6379. 'Name',
  6380. 'Job Title',
  6381. 'Department',
  6382. 'Business Unit',
  6383. 'Comapany Name and Experience',
  6384. 'Total Past Experience',
  6385. );
  6386.  
  6387. $roster_type = "Past Work Experience";
  6388. $filenameexport = $roster_type;
  6389. $final_output = array('output' => $output,
  6390. 'cols' => $cols,
  6391. 'filenameexport' => $filenameexport);
  6392. return $final_output;
  6393. }
  6394. public static function getDependentDetails($post_data, $tenant_id = null) {
  6395. $return = array();
  6396. $filter = $post_data['filter_id'];
  6397. $users = UserMongo::model()->getUsersByFilter($filter, $tenant_id, $post_data['active_inactive']);
  6398. $output = array();
  6399.  
  6400. foreach ($users as $key => $user) {
  6401. $employee_number = (isset($user['personal']['employee_no'])) ? $user['personal']['employee_no'] : "N.A.";
  6402. $user_name = $user['personal']['firstname'] . " " . $user['personal']['lastname'];
  6403. $user_post = $user->getCurrentPosition($tenant_id);
  6404. $job_title = $user_post['designation'];
  6405. $department = $user_post['department'];
  6406. $business_unit = $user_post['business_unit'];
  6407. $user_dependent = "";
  6408. if (isset($user['dependents']) && !empty($user['dependents'])) {
  6409. foreach ($user['dependents'] as $key => $dependents) {
  6410. $dep_name = (isset($dependents['first_name'],$dependents['last_name'])) ? ucfirst($dependents['first_name'])." ".$dependents['last_name'] ." - " : "N.A.";
  6411. $dep_relation = (isset($dependents['relation_type'])) ? $dependents['relation_type'] ." - " : "N.A.";
  6412. $get_dep_age = (isset($dependents['dob']->sec)) ? self::calculate_experience(time(), $dependents['dob']->sec) : "N.A.";
  6413. $age_dep = (isset($get_dep_age) && $get_dep_age != "N.A.") ? $get_dep_age['Years']."y ".$get_dep_age['Months']."m" : "N.A.";
  6414. if(isset($dep_name) && $dep_name != "N.A."){
  6415. $user_dependent = (isset($user_dependent) && $user_dependent != "") ? $user_dependent . "<br/>". $dep_name ." ". $dep_relation ." ". $age_dep : $dep_name ." ". $dep_relation ." ". $age_dep;
  6416. }
  6417. }
  6418. } else {
  6419. $user_dependent = "N.A.";
  6420. }
  6421.  
  6422. $output[] = array(
  6423. $employee_number,
  6424. $user_name,
  6425. $job_title,
  6426. $department,
  6427. $business_unit,
  6428. $user_dependent,
  6429. );
  6430. } // EOF foreach
  6431. $cols = array(
  6432. 'Employee ID',
  6433. 'Name',
  6434. 'Job Title',
  6435. 'Department',
  6436. 'Business Unit',
  6437. 'Dependent Detail',
  6438. );
  6439.  
  6440. $roster_type = "Dependent-Data";
  6441. $filenameexport = $roster_type;
  6442. $final_output = array('output' => $output,
  6443. 'cols' => $cols,
  6444. 'filenameexport' => $filenameexport);
  6445. return $final_output;
  6446. }
  6447.  
  6448. public static function getProfileCompletionReport($post_data, $tenant_id = null) {
  6449. $return = array();
  6450. $filter = $post_data['filter_id'];
  6451. $users = UserMongo::model()->getUsersByFilter($filter, $tenant_id, $post_data['active_inactive']);
  6452. $output = array();
  6453.  
  6454. foreach ($users as $key => $user) {
  6455. if(isset($user->doj->sec) && $user->doj->sec != ""){
  6456. $employee_number = (isset($user['personal']['employee_no'])) ? $user['personal']['employee_no'] : "N.A.";
  6457. $user_name = $user['personal']['firstname'] . " " . $user['personal']['lastname'];
  6458. $user_post = $user->getCurrentPosition($tenant_id);
  6459. $job_title = $user_post['designation'];
  6460. $department = $user_post['department'];
  6461. $business_unit = $user_post['business_unit'];
  6462. list ($measures, $unfilled) = $user->getCompletionCount();
  6463. $profile_percent = round(100 - (count($unfilled) / count($measures)) * 100) . "%";
  6464.  
  6465. $output[] = array(
  6466. $employee_number,
  6467. $user_name,
  6468. $job_title,
  6469. $department,
  6470. $business_unit,
  6471. $profile_percent,
  6472. );
  6473. }
  6474. } // EOF foreach
  6475. $cols = array(
  6476. 'Employee ID',
  6477. 'Name',
  6478. 'Job Title',
  6479. 'Department',
  6480. 'Business Unit',
  6481. 'Profile Completion %',
  6482. );
  6483.  
  6484. $roster_type = "Profile-Completion-Data";
  6485. $filenameexport = $roster_type;
  6486. $final_output = array('output' => $output,
  6487. 'cols' => $cols,
  6488. 'filenameexport' => $filenameexport);
  6489. return $final_output;
  6490. }
  6491.  
  6492. public static function getReimbBankSheet($post_data, $tenant_id, $from, $to, $type, $name) {
  6493. $output = array();
  6494. $tenant = Tenants::model()->findByPk($tenant_id);
  6495. $subdomain = (isset($tenant->tenant_subdomain) && $tenant->tenant_subdomain != "") ? $tenant->tenant_subdomain : "darwinbox";
  6496. $filter = $post_data['filter_id'];
  6497. $users_all = UserMongo::model()->getUsersByFilter($filter, $tenant_id, $post_data['active_inactive']);
  6498. foreach ($users_all as $key_user => $value_user) {
  6499. $users_array[] = $value_user->id;
  6500. }
  6501. $from_date = new MongoDate(strtotime($from));
  6502. $to_date = new MongoDate(strtotime($to));
  6503. if ($type == UserExpenses::STATUS_COMPENSATED) {
  6504. $criteria = new EMongoCriteria();
  6505. $criteria->status('==', UserExpenses::STATUS_APPROVED);
  6506. $criteria->paid('==', UserExpenses::PAID_YES);
  6507. $criteria->tenant_id('==', $tenant_id);
  6508. $criteria->date('<=', $to_date);
  6509. $criteria->date('>=', $from_date);
  6510. $user_expenses = UserExpenses::model()->findAll($criteria);
  6511. } else {
  6512. $criteria = new EMongoCriteria();
  6513. $criteria->status('==', $type);
  6514. $criteria->paid('==', UserExpenses::PAID_NO);
  6515. $criteria->tenant_id('==', $tenant_id);
  6516. $criteria->date('<=', $to_date);
  6517. $criteria->date('>=', $from_date);
  6518. $user_expenses = UserExpenses::model()->findAll($criteria);
  6519. }
  6520. if (isset($user_expenses) && !empty($user_expenses)) {
  6521. foreach ($user_expenses as $key_reimbursment => $value_reimbursment) {
  6522. if (in_array($value_reimbursment->user_id, $users_array)) {
  6523. $user_mongo_each = UserMongo::model()->tenant($tenant_id)->findByPk($value_reimbursment->user_id);
  6524. $user_post = $user_mongo_each->getCurrentPosition($tenant_id);
  6525. $job_title = (isset($user_post['designation'])) ? $user_post['designation'] : "N.A.";
  6526. $department = (isset($user_post['department'])) ? $user_post['department'] : "N.A.";
  6527. $business_unit = (isset($user_post['business_unit'])) ? $user_post['business_unit'] : "N.A.";
  6528. $employee_number = (isset($user['personal']['employee_no'])) ? $user['personal']['employee_no'] : "N.A.";
  6529. $full_name = $user_mongo_each->getFullname();
  6530. $title = (isset($value_reimbursment->title)) ? $value_reimbursment->title : "N.A.";
  6531. $date = (isset($value_reimbursment->date->sec)) ? date('d F Y', $value_reimbursment->date->sec) : "N.A.";
  6532. $item_total = 0;
  6533. $item_name_price = '';
  6534. foreach ($value_reimbursment->items as $key_items => $value_items) {
  6535. $item_name = $value_items['itemName'];
  6536. $item_price = $value_items['itemPrice'];
  6537. $item_name_price = (empty($item_name_price)) ? $item_name . " (" . $item_price . ")" : $item_name_price . ", " . $item_name . " (" . $item_price . ")";
  6538. $item_total += $item_price;
  6539. }
  6540.  
  6541. if (isset($value_reimbursment->paid_by) && $value_reimbursment->paid_by != "") {
  6542. $performed_by = UserMongo::getFullnameById($value_reimbursment->paid_by);
  6543. } else if (isset($value_reimbursment->approved_or_rejected_by) && $value_reimbursment->approved_or_rejected_by != "") {
  6544. $performed_by = UserMongo::getFullnameById($value_reimbursment->approved_or_rejected_by);
  6545. } else {
  6546. $performed_by = "N.A.";
  6547. }
  6548. $link_created = "https://" . $subdomain . ".darwinbox.in/expenses/expenses/view/id/" . $value_reimbursment->id;
  6549. $link = '<a target = "_blank" href = '.$link_created.'>'.$link_created.' </a>';
  6550. // bank details
  6551. if (isset($user_mongo_each->banking) && isset($user_mongo_each->banking->bank_name) && $user_mongo_each->banking->bank_name != "" && isset($user_mongo_each->banking->bank_account) && $user_mongo_each->banking->bank_account != "") {
  6552. $account_number = $user_mongo_each->banking->bank_account;
  6553. $account_bank_name = $user_mongo_each->banking->bank_name;
  6554. $account_ifsc = $user_mongo_each->banking->bank_ifsc;
  6555. $account_bank_branch = $user_mongo_each->banking->bank_branch;
  6556. $pan_number = (isset($user_mongo_each->banking->bank_pan_num) && $user_mongo_each->banking->bank_pan_num != "") ? $user_mongo_each->banking->bank_pan_num : "N.A.";
  6557. } else {
  6558. $account_number = "N.A.";
  6559. $account_bank_name = "N.A.";
  6560. $account_ifsc = "N.A.";
  6561. $account_bank_branch = "N.A.";
  6562. $pan_number = "N.A.";
  6563. }
  6564. $output[] = array(
  6565. $employee_number,
  6566. $full_name,
  6567. $department,
  6568. $job_title,
  6569. $title,
  6570. $date,
  6571. $account_bank_name,
  6572. $account_bank_branch,
  6573. $account_number,
  6574. $account_ifsc,
  6575. $pan_number,
  6576. $item_total,
  6577. );
  6578. }
  6579. }
  6580. }
  6581. $cols = array(
  6582. 'Employee ID',
  6583. 'Employee Name',
  6584. 'Department',
  6585. 'Designation',
  6586. 'Reimb Title',
  6587. 'Date',
  6588. 'Bank Name',
  6589. 'Branch Name',
  6590. 'Account Number',
  6591. 'Account IFSC',
  6592. 'PAN Number',
  6593. 'Total Amount',
  6594. );
  6595. $roster_type = "Reimbursement-Bank-Sheet";
  6596. $filenameexport = $roster_type;
  6597. $final_output = array('output' => $output,
  6598. 'cols' => $cols,
  6599. 'filenameexport' => $filenameexport);
  6600. return $final_output;
  6601. }
  6602.  
  6603. public static function getPfReportMonthly($post_data, $tenant_id, $from, $to) {
  6604. $for_date = date('Y-m', strtotime($from));
  6605. $return = array();
  6606. $output = array();
  6607.  
  6608. $current_month = date("m");
  6609. $filter = $post_data['filter_id'];
  6610. $userSalarySlip = UserSalarySlip::model()->tenant($tenant_id)->findAllByAttributes(array('for_month' => $for_date));
  6611. $tenantProfile = TenantProfile::model()->tenant($tenant_id)->find();
  6612. if(!empty($tenantProfile))
  6613. {
  6614. if(isset($tenantProfile->pf_edli) && $tenantProfile->pf_edli == TenantProfile::ACTIVE)
  6615. {
  6616. $edli_value = 6500;
  6617. }
  6618. else{
  6619. if(strtotime($for_date) > strtotime('2014-10'))
  6620. {
  6621. $edli_value = 15000;
  6622. }
  6623. else{
  6624. $edli_value = 6500;
  6625. }
  6626. }
  6627. }
  6628. foreach ($userSalarySlip as $salaryslip) {
  6629. $employees_contribution = 0;
  6630. $edli = 0;
  6631. $employees_contribution_pf = 0;
  6632. $total_pension = 0;
  6633. $voluntary_pf = 0;
  6634. $total_pf = 0;
  6635. $administartive_amount = 0;
  6636. $insurance_fund = 0;
  6637. $inspection_charges = 0;
  6638. $final_amount = 0;
  6639. //$users = UserMongo::model()->tenant($tenant_id)->findByPk($salaryslip->user_id);
  6640. if($post_data['active_inactive'] == 1)
  6641. {
  6642. $users = UserMongo::model()->tenant($tenant_id)->active()->findByPk($salaryslip->user_id);
  6643. }
  6644. else if($post_data['active_inactive'] == 2)
  6645. {
  6646. $users = UserMongo::model()->tenant($tenant_id)->disabled()->findByPk($salaryslip->user_id);
  6647. }
  6648. else
  6649. {
  6650. $users = UserMongo::model()->tenant($tenant_id)->findByPk($salaryslip->user_id);
  6651. }
  6652. if (isset($users) && !empty($users)) {
  6653. $full_name = $users->getFullname();
  6654. $doj = (isset($users->doj->sec))? date('Y-m-d', $users->doj->sec) : 'N.A.';
  6655. $dob = (isset($users->personal->dob->sec) && $users->personal->dob->sec != "") ? date('Y-m-d', $users->personal->dob->sec) : "N.A.";
  6656. $employee_code = (isset($users->personal->employee_no) && $users->personal->employee_no != "") ? $users->personal->employee_no : "N.A.";
  6657. // Calculate Age from Date of Birth
  6658. if($dob != '')
  6659. {
  6660. $from = new DateTime($dob);
  6661. $to = new DateTime('today');
  6662. $age = $from->diff($to)->y;
  6663. }
  6664. else
  6665. {
  6666. $age = 'N.A.';
  6667. }
  6668.  
  6669. // Get employee father name.
  6670. $emp_father_name = '';
  6671. if (isset($users->dependents) && count($users->dependents) > 0)
  6672. {
  6673. foreach ($users->dependents as $key => $value_dependent)
  6674. {
  6675. if ($value_dependent->relation_type == "Father")
  6676. {
  6677. $emp_father_first_name = (isset($value_dependent->first_name))? $value_dependent->first_name : '';
  6678. $emp_father_last_name = (isset($value_dependent->last_name))? $value_dependent->last_name : '';
  6679. $emp_father_name = $emp_father_first_name." ".$emp_father_last_name;
  6680. }
  6681. }
  6682. }
  6683. $emp_father_name = (isset($emp_father_name) && $emp_father_name != "") ? $emp_father_name : "N.A.";
  6684.  
  6685. $office_location = TenantOffices::model()->tenant($tenant_id)->findByAttributes(array('id' => $users->personal->office_location));
  6686. if (isset($office_location) && !empty($office_location) && isset($office_location->city) && $office_location->city != "") {
  6687. $city_name = City::model()->findByPk($office_location->city);
  6688. if (isset($city_name) && !empty($city_name)) {
  6689. $office_location_name = $city_name->name;
  6690. } else {
  6691. $office_location_name = "N.A";
  6692. }
  6693. } else {
  6694. $office_location_name = "N.A";
  6695. }
  6696. foreach ($salaryslip->items as $item) {
  6697. if ($item->variable_name == "basic") {
  6698. if(isset($tenantProfile->is_pf_restricted) && $tenantProfile->is_pf_restricted == TenantProfile::ACTIVE){
  6699. $basic = $item->max_value_month;
  6700. $basic = ($basic > 15000) ? 15000 : $basic;
  6701. }else{
  6702. $basic = $item->max_value_month;
  6703. }
  6704. }
  6705.  
  6706. if ($item->variable_name == "provident_fund") {
  6707. $employees_contribution = $item->max_value_month;
  6708. $employee_pf = (12 * $basic) / 100;
  6709. /*$epf = (float) (($employee_pf / 12) * 3.67);
  6710. $eps = (float) (($employee_pf / 12) * 8.33);*/
  6711. $epf = ($employees_contribution/12) * 3.67;
  6712. $epf = PayrollHelper::roundingValues(Items::ROUND_TO_NEAREST_INTEGER,$epf);
  6713. $eps = PayrollHelper::roundingValues(Items::ROUND_TO_NEAREST_INTEGER,($employees_contribution/12) * 8.33);
  6714. $lop_edli = 0;
  6715. if ($salaryslip->lop > 0) {
  6716. $lop_edli = ($edli_value / $salaryslip->total_working_days) * $salaryslip->lop;
  6717. } else {
  6718. $lop_edli = ($edli_value / $salaryslip->total_working_days) * ($salaryslip->total_working_days - $salaryslip->effective_working_days);
  6719. }
  6720.  
  6721. // Show E. D. L. I. is equal to BASIC if basic < 6500 - KT 9th March 2015
  6722. if($basic < $edli_value )
  6723. {
  6724. $edli = $basic;
  6725. }
  6726. else
  6727. {
  6728. $edli = ($edli_value - $lop_edli);
  6729. }
  6730.  
  6731. $total_pension = ($edli * 8.33) / 100;
  6732. $employees_contribution_pf = ($employees_contribution - $total_pension);
  6733. $voluntary_pf = 0;
  6734. if(strtotime($for_date) >= strtotime('2015-01'))
  6735. {
  6736. $administartive_amount = ($basic * 0.85) / 100;
  6737. }
  6738. else{
  6739. $administartive_amount = ($basic * 1.1) / 100;
  6740. }
  6741. $insurance_fund = ($edli * 0.5) / 100;
  6742. $inspection_charges = ($edli * 0.01) / 100;
  6743. $total_pf = $employees_contribution + $employees_contribution_pf + $total_pension + $voluntary_pf;
  6744. $final_amount = $total_pf + $administartive_amount + $insurance_fund + $inspection_charges;
  6745. }
  6746. }
  6747. $fpf = 0;
  6748. $vpf = 0;
  6749. $edli_charges = 0;
  6750. $employee_total = $employees_contribution + $vpf;
  6751. $employeers_total = $eps +$epf;
  6752. if($employees_contribution > 0)
  6753. {
  6754. $pf_account_number = (isset($users->pf_number) && $users->pf_number != null) ? $users->pf_number : "N.A.";
  6755. $output[] = array(
  6756. $pf_account_number,
  6757. $employee_code,
  6758. $full_name,
  6759. PayrollHelper::roundingValues(Items::ROUND_TO_TWO_DIGITS, $basic),
  6760. PayrollHelper::roundingValues(Items::ROUND_TO_TWO_DIGITS, $employees_contribution),
  6761. PayrollHelper::roundingValues(Items::ROUND_TO_TWO_DIGITS, $vpf),
  6762. PayrollHelper::roundingValues(Items::ROUND_TO_TWO_DIGITS, $employee_total),
  6763. PayrollHelper::roundingValues(Items::ROUND_TO_TWO_DIGITS, $epf),
  6764. PayrollHelper::roundingValues(Items::ROUND_TO_TWO_DIGITS, $eps),
  6765. PayrollHelper::roundingValues(Items::ROUND_TO_TWO_DIGITS, $employeers_total),
  6766. PayrollHelper::roundingValues(Items::ROUND_TO_TWO_DIGITS, $administartive_amount),
  6767. PayrollHelper::roundingValues(Items::ROUND_TO_TWO_DIGITS, $edli),
  6768. PayrollHelper::roundingValues(Items::ROUND_TO_TWO_DIGITS, $insurance_fund),
  6769. PayrollHelper::roundingValues(Items::ROUND_TO_TWO_DIGITS, $inspection_charges),
  6770. );
  6771. }
  6772. }
  6773. }
  6774. $cols = array(
  6775. 'Provident Fund Account No',
  6776. 'Employee Code',
  6777. 'Employee Name',
  6778. 'PF Wages',
  6779. 'Employees EPF',
  6780. 'Employees VPF',
  6781. 'Employees Total',
  6782. 'Employeers EPF',
  6783. 'Employeers EPS',
  6784. 'Employeers Total',
  6785. 'PF Admin Charges',
  6786. 'EDLI Wages',
  6787. 'EDLI Charges',
  6788. 'EDLI Admin Charges',
  6789. );
  6790.  
  6791.  
  6792.  
  6793. $roster_type = "Statutory-PF-Monthly-month".$for_date;
  6794. $filenameexport = $roster_type;
  6795. $final_output = array('output' => $output,
  6796. 'cols' => $cols,
  6797. 'filenameexport' => $filenameexport);
  6798. return $final_output;
  6799. }
  6800. public static function getPfFormSixA($post_data, $tenant_id, $from, $to) {
  6801. $for_date = date('Y-m', strtotime($from));
  6802. $return = array();
  6803. $output = array();
  6804.  
  6805. $current_month = date("m");
  6806. $filter = $post_data['filter_id'];
  6807. $userSalarySlip = UserSalarySlip::model()->tenant($tenant_id)->findAllByAttributes(array('for_month' => $for_date));
  6808. $tenantProfile = TenantProfile::model()->tenant($tenant_id)->find();
  6809. if(!empty($tenantProfile))
  6810. {
  6811. if(isset($tenantProfile->pf_edli) && $tenantProfile->pf_edli == TenantProfile::ACTIVE)
  6812. {
  6813. $edli_value = 6500;
  6814. }
  6815. else{
  6816. if(strtotime($for_date) > strtotime('2014-10'))
  6817. {
  6818. $edli_value = 15000;
  6819. }
  6820. else{
  6821. $edli_value = 6500;
  6822. }
  6823. }
  6824. }
  6825. foreach ($userSalarySlip as $salaryslip) {
  6826. $employees_contribution = 0;
  6827. $edli = 0;
  6828. $employees_contribution_pf = 0;
  6829. $total_pension = 0;
  6830. $voluntary_pf = 0;
  6831. $total_pf = 0;
  6832. $administartive_amount = 0;
  6833. $insurance_fund = 0;
  6834. $inspection_charges = 0;
  6835. $final_amount = 0;
  6836. //$users = UserMongo::model()->tenant($tenant_id)->findByPk($salaryslip->user_id);
  6837. if($post_data['active_inactive'] == 1)
  6838. {
  6839. $users = UserMongo::model()->tenant($tenant_id)->active()->findByPk($salaryslip->user_id);
  6840. }
  6841. else if($post_data['active_inactive'] == 2)
  6842. {
  6843. $users = UserMongo::model()->tenant($tenant_id)->disabled()->findByPk($salaryslip->user_id);
  6844. }
  6845. else
  6846. {
  6847. $users = UserMongo::model()->tenant($tenant_id)->findByPk($salaryslip->user_id);
  6848. }
  6849. if (isset($users) && !empty($users)) {
  6850. $full_name = $users->getFullname();
  6851. $doj = (isset($users->doj->sec))? date('Y-m-d', $users->doj->sec) : 'N.A.';
  6852. $dob = (isset($users->personal->dob->sec) && $users->personal->dob->sec != "") ? date('Y-m-d', $users->personal->dob->sec) : "N.A.";
  6853. $employee_code = (isset($users->personal->employee_no) && $users->personal->employee_no != "") ? $users->personal->employee_no : "N.A.";
  6854. // Calculate Age from Date of Birth
  6855. if($dob != '')
  6856. {
  6857. $from = new DateTime($dob);
  6858. $to = new DateTime('today');
  6859. $age = $from->diff($to)->y;
  6860. }
  6861. else
  6862. {
  6863. $age = 'N.A.';
  6864. }
  6865.  
  6866. // Get employee father name.
  6867. $emp_father_name = '';
  6868. if (isset($users->dependents) && count($users->dependents) > 0)
  6869. {
  6870. foreach ($users->dependents as $key => $value_dependent)
  6871. {
  6872. if ($value_dependent->relation_type == "Father")
  6873. {
  6874. $emp_father_first_name = (isset($value_dependent->first_name))? $value_dependent->first_name : '';
  6875. $emp_father_last_name = (isset($value_dependent->last_name))? $value_dependent->last_name : '';
  6876. $emp_father_name = $emp_father_first_name." ".$emp_father_last_name;
  6877. }
  6878. }
  6879. }
  6880. $emp_father_name = (isset($emp_father_name) && $emp_father_name != "") ? $emp_father_name : "N.A.";
  6881.  
  6882. $office_location = TenantOffices::model()->tenant($tenant_id)->findByAttributes(array('id' => $users->personal->office_location));
  6883. if (isset($office_location) && !empty($office_location) && isset($office_location->city) && $office_location->city != "") {
  6884. $city_name = City::model()->findByPk($office_location->city);
  6885. if (isset($city_name) && !empty($city_name)) {
  6886. $office_location_name = $city_name->name;
  6887. } else {
  6888. $office_location_name = "N.A";
  6889. }
  6890. } else {
  6891. $office_location_name = "N.A";
  6892. }
  6893. foreach ($salaryslip->items as $item) {
  6894. if ($item->variable_name == "basic") {
  6895. $basic = $item->max_value_month;
  6896. }
  6897.  
  6898. if ($item->variable_name == "provident_fund") {
  6899. $employees_contribution = $item->max_value_month;
  6900. $employee_pf = (12 * $basic) / 100;
  6901. /*$epf = (float) (($employee_pf / 12) * 3.67);
  6902. $eps = (float) (($employee_pf / 12) * 8.33);*/
  6903. $epf = ($employees_contribution/12) * 3.67;
  6904. $eps = ($employees_contribution/12) * 8.33;
  6905. $lop_edli = 0;
  6906. if ($salaryslip->lop > 0) {
  6907. $lop_edli = ($edli_value / $salaryslip->total_working_days) * $salaryslip->lop;
  6908. } else {
  6909. $lop_edli = ($edli_value / $salaryslip->total_working_days) * ($salaryslip->total_working_days - $salaryslip->effective_working_days);
  6910. }
  6911.  
  6912. // Show E. D. L. I. is equal to BASIC if basic < 6500 - KT 9th March 2015
  6913. if($basic < $edli_value )
  6914. {
  6915. $edli = $basic;
  6916. }
  6917. else
  6918. {
  6919. $edli = ($edli_value - $lop_edli);
  6920. }
  6921.  
  6922. $total_pension = ($edli * 8.33) / 100;
  6923. $employees_contribution_pf = ($employees_contribution - $total_pension);
  6924. $voluntary_pf = 0;
  6925. if(strtotime($for_date) >= strtotime('2015-01'))
  6926. {
  6927. $administartive_amount = ($basic * 0.85) / 100;
  6928. }
  6929. else{
  6930. $administartive_amount = ($basic * 1.1) / 100;
  6931. }
  6932. $insurance_fund = ($edli * 0.5) / 100;
  6933. $inspection_charges = ($edli * 0.01) / 100;
  6934. $total_pf = $employees_contribution + $employees_contribution_pf + $total_pension + $voluntary_pf;
  6935. $final_amount = $total_pf + $administartive_amount + $insurance_fund + $inspection_charges;
  6936. }
  6937. }
  6938. $fpf = 0;
  6939. $vpf = 0;
  6940. $edli_charges = 0;
  6941. $employee_total = $epf + $fpf + $vpf;
  6942. $employeers_total = $eps +$epf;
  6943. $refund_of_advance = 0;
  6944. $rate_of_higher = 0;
  6945. if($employees_contribution > 0)
  6946. {
  6947. $pf_account_number = (isset($users->pf_number) && $users->pf_number != null) ? $users->pf_number : "N.A.";
  6948. $output[] = array(
  6949. $pf_account_number,
  6950. $employee_code,
  6951. $full_name,
  6952. $basic,
  6953. PayrollHelper::roundingValues(Items::ROUND_TO_TWO_DIGITS, $employees_contribution),
  6954. PayrollHelper::roundingValues(Items::ROUND_TO_TWO_DIGITS, $epf),
  6955. PayrollHelper::roundingValues(Items::ROUND_TO_TWO_DIGITS, $eps),
  6956. $refund_of_advance,
  6957. $rate_of_higher,
  6958. );
  6959. }
  6960. }
  6961. }
  6962. $cols = array(
  6963. 'Provident Fund Account No',
  6964. 'Employee Code',
  6965. 'Employee Name',
  6966. 'Wages retaining allowance (if any ) and D.A. including cash value of food concession paid during the currency period',
  6967. 'Workers Contribution',
  6968. 'Employeers EPF',
  6969. 'Employeers EPS',
  6970. 'Refund of Advances',
  6971. 'Rate of Higher voluntarily contribution if any',
  6972. );
  6973.  
  6974.  
  6975.  
  6976. $roster_type = "Statutory-PF-Form-6A".$for_date;
  6977. $filenameexport = $roster_type;
  6978. $final_output = array('output' => $output,
  6979. 'cols' => $cols,
  6980. 'filenameexport' => $filenameexport);
  6981. return $final_output;
  6982. }
  6983. public static function getPfFormThreeA($post_data, $tenant_id, $from, $to) {
  6984. $for_date = date('Y-m', strtotime($from));
  6985. $return = array();
  6986. $output = array();
  6987.  
  6988. $current_month = date("m");
  6989. $filter = $post_data['filter_id'];
  6990. $userSalarySlip = UserSalarySlip::model()->tenant($tenant_id)->findAllByAttributes(array('for_month' => $for_date));
  6991. $tenantProfile = TenantProfile::model()->tenant($tenant_id)->find();
  6992. $year_to_pass = date('Y') -1;
  6993. $month_list = $tenantProfile->getMonthList('Y-m','M', $year_to_pass);
  6994. if(!empty($tenantProfile))
  6995. {
  6996. if(isset($tenantProfile->pf_edli) && $tenantProfile->pf_edli == TenantProfile::ACTIVE)
  6997. {
  6998. $edli_value = 6500;
  6999. }
  7000. else{
  7001. if(strtotime($for_date) > strtotime('2014-10'))
  7002. {
  7003. $edli_value = 15000;
  7004. }
  7005. else{
  7006. $edli_value = 6500;
  7007. }
  7008. }
  7009. }
  7010. foreach ($month_list as $key => $value)
  7011. {
  7012. $userSalarySlip = UserSalarySlip::model()->tenant($tenant_id)->findAllByAttributes(array('for_month' => $key));
  7013. $for_month = $key;
  7014. $employees_contribution_total = 0.00;
  7015. $epf_total = 0.00;
  7016. $eps_total = 0.00;
  7017. $pension_fund = 0.00;
  7018. $basic = 0;
  7019. if(isset($userSalarySlip) && !empty($userSalarySlip))
  7020. {
  7021. foreach ($userSalarySlip as $salaryslip) {
  7022. $employees_contribution = 0;
  7023. $edli = 0;
  7024. $employees_contribution_pf = 0;
  7025. $total_pension = 0;
  7026. $voluntary_pf = 0;
  7027. $total_pf = 0;
  7028. $administartive_amount = 0;
  7029. $insurance_fund = 0;
  7030. $inspection_charges = 0;
  7031. $final_amount = 0;
  7032. //$users = UserMongo::model()->tenant($tenant_id)->findByPk($salaryslip->user_id);
  7033. if($post_data['active_inactive'] == 1)
  7034. {
  7035. $users = UserMongo::model()->tenant($tenant_id)->active()->findByPk($salaryslip->user_id);
  7036. }
  7037. else if($post_data['active_inactive'] == 2)
  7038. {
  7039. $users = UserMongo::model()->tenant($tenant_id)->disabled()->findByPk($salaryslip->user_id);
  7040. }
  7041. else
  7042. {
  7043. $users = UserMongo::model()->tenant($tenant_id)->findByPk($salaryslip->user_id);
  7044. }
  7045. if (isset($users) && !empty($users)) {
  7046. $full_name = $users->getFullname();
  7047. $doj = (isset($users->doj->sec))? date('Y-m-d', $users->doj->sec) : 'N.A.';
  7048. $dob = (isset($users->personal->dob->sec) && $users->personal->dob->sec != "") ? date('Y-m-d', $users->personal->dob->sec) : "N.A.";
  7049. $employee_code = (isset($users->personal->employee_no) && $users->personal->employee_no != "") ? $users->personal->employee_no : "N.A.";
  7050. // Calculate Age from Date of Birth
  7051. if($dob != '')
  7052. {
  7053. $from = new DateTime($dob);
  7054. $to = new DateTime('today');
  7055. $age = $from->diff($to)->y;
  7056. }
  7057. else
  7058. {
  7059. $age = 'N.A.';
  7060. }
  7061.  
  7062. // Get employee father name.
  7063. $emp_father_name = '';
  7064. if (isset($users->dependents) && count($users->dependents) > 0)
  7065. {
  7066. foreach ($users->dependents as $key => $value_dependent)
  7067. {
  7068. if ($value_dependent->relation_type == "Father")
  7069. {
  7070. $emp_father_first_name = (isset($value_dependent->first_name))? $value_dependent->first_name : '';
  7071. $emp_father_last_name = (isset($value_dependent->last_name))? $value_dependent->last_name : '';
  7072. $emp_father_name = $emp_father_first_name." ".$emp_father_last_name;
  7073. }
  7074. }
  7075. }
  7076. $emp_father_name = (isset($emp_father_name) && $emp_father_name != "") ? $emp_father_name : "N.A.";
  7077.  
  7078. $office_location = TenantOffices::model()->tenant($tenant_id)->findByAttributes(array('id' => $users->personal->office_location));
  7079. if (isset($office_location) && !empty($office_location) && isset($office_location->city) && $office_location->city != "") {
  7080. $city_name = City::model()->findByPk($office_location->city);
  7081. if (isset($city_name) && !empty($city_name)) {
  7082. $office_location_name = $city_name->name;
  7083. } else {
  7084. $office_location_name = "N.A";
  7085. }
  7086. } else {
  7087. $office_location_name = "N.A";
  7088. }
  7089.  
  7090. foreach ($salaryslip->items as $item) {
  7091. if ($item->variable_name == "basic") {
  7092. $basic += $item->max_value_month;
  7093. }
  7094.  
  7095. if ($item->variable_name == "provident_fund") {
  7096. $employees_contribution = $item->max_value_month;
  7097. $employee_pf = (12 * $basic) / 100;
  7098. /*$epf = (float) (($employee_pf / 12) * 3.67);
  7099. $eps = (float) (($employee_pf / 12) * 8.33);*/
  7100. $epf = ($employees_contribution/12) * 3.67;
  7101. $eps = ($employees_contribution/12) * 8.33;
  7102. $lop_edli = 0;
  7103. if ($salaryslip->lop > 0) {
  7104. $lop_edli = ($edli_value / $salaryslip->total_working_days) * $salaryslip->lop;
  7105. } else {
  7106. $lop_edli = ($edli_value / $salaryslip->total_working_days) * ($salaryslip->total_working_days - $salaryslip->effective_working_days);
  7107. }
  7108.  
  7109. if($basic < $edli_value )
  7110. {
  7111. $edli = $basic;
  7112. }
  7113. else
  7114. {
  7115. $edli = ($edli_value - $lop_edli);
  7116. }
  7117.  
  7118. $total_pension = ($edli * 8.33) / 100;
  7119. $employees_contribution_pf = ($employees_contribution - $total_pension);
  7120. $voluntary_pf = 0;
  7121. if(strtotime($for_date) >= strtotime('2015-01'))
  7122. {
  7123. $administartive_amount = ($basic * 0.85) / 100;
  7124. }
  7125. else{
  7126. $administartive_amount = ($basic * 1.1) / 100;
  7127. }
  7128. $insurance_fund = ($edli * 0.5) / 100;
  7129. $inspection_charges = ($edli * 0.01) / 100;
  7130. $total_pf = $employees_contribution + $employees_contribution_pf + $total_pension + $voluntary_pf;
  7131. $final_amount = $total_pf + $administartive_amount + $insurance_fund + $inspection_charges;
  7132. }
  7133. }
  7134. $fpf = 0;
  7135. $vpf = 0;
  7136. $edli_charges = 0;
  7137. $employee_total = $epf + $fpf + $vpf;
  7138. $employeers_total = $eps +$epf;
  7139. $refund_of_advance = 0;
  7140. $rate_of_higher = 0;
  7141. if($employees_contribution > 0)
  7142. {
  7143. $employees_contribution_total += $employees_contribution;
  7144. $epf_total += $epf;
  7145. $eps_total += $eps;
  7146. }
  7147. }
  7148. }
  7149. }
  7150. $pension_fund = ($epf_total > 0) ? "541.00" : "0.00";
  7151. $output[] = array(
  7152. date('M-Y',strtotime($for_month)),
  7153. PayrollHelper::roundingValues(Items::ROUND_TO_TWO_DIGITS,$basic),
  7154. PayrollHelper::roundingValues(Items::ROUND_TO_TWO_DIGITS,$employees_contribution_total),
  7155. PayrollHelper::roundingValues(Items::ROUND_TO_TWO_DIGITS,$epf_total),
  7156. PayrollHelper::roundingValues(Items::ROUND_TO_TWO_DIGITS,$eps_total),
  7157. PayrollHelper::roundingValues(Items::ROUND_TO_TWO_DIGITS,$pension_fund),
  7158. "",
  7159. 0.00,
  7160. "",
  7161. "",
  7162. );
  7163.  
  7164. }
  7165.  
  7166. $cols = array(
  7167. 'Month',
  7168. 'Amount of Wages',
  7169. 'Workers Share EPF.',
  7170. 'Employeers E.P.F. difference between 12% & 8.1/3% (if any)',
  7171. 'Employeers Pension Fund Contribution 8.1/3 %',
  7172. 'Refund of Advances',
  7173. 'No. of days / period of non contributing service (if any)',
  7174. 'Date of Leaving Services (if any)',
  7175. 'Reason for Leaving Services (if any)',
  7176. );
  7177.  
  7178.  
  7179.  
  7180. $roster_type = "Statutory-PF-Form-3A".$for_date;
  7181. $filenameexport = $roster_type;
  7182. $final_output = array('output' => $output,
  7183. 'cols' => $cols,
  7184. 'filenameexport' => $filenameexport);
  7185. return $final_output;
  7186. }
  7187. public static function getAssests($post_data, $tenant_id = null) {
  7188. $return = array();
  7189. $filter = $post_data['filter_id'];
  7190. $users = UserMongo::model()->getUsersByFilter($filter, $tenant_id, $post_data['active_inactive']);
  7191. $output = array();
  7192. foreach ($users as $key => $user) {
  7193. $users_filtered[] = $user->id;
  7194. }
  7195. $assests = AssestManagement::model()->tenant()->findAll();
  7196. foreach($assests as $key_ass => $value_ass)
  7197. {
  7198. $user_details = UserMongo::model()->tenant()->findByAttributes(array('id' => $value_ass->user));
  7199. if(isset($user_details) && in_array($user_details->id, $users_filtered)){
  7200. $employee_number = (isset($user['personal']['employee_no'])) ? $user['personal']['employee_no'] : "N.A.";
  7201. $user_name = $user_details['personal']['firstname'] . " " . $user_details['personal']['lastname'];
  7202. $user_post = $user_details->getCurrentPosition($tenant_id);
  7203. $job_title = $user_post['designation'];
  7204. $department = $user_post['department'];
  7205. $business_unit = $user_post['business_unit'];
  7206. $asset_type = (isset($value_ass->asset_type) && $value_ass->asset_type != "") ? $value_ass->asset_type : "N.A.";
  7207. $serial_number = (isset($value_ass->serial_number) && $value_ass->serial_number != "") ? $value_ass->serial_number : "N.A.";
  7208. $model_number = (isset($value_ass->model_number) && $value_ass->model_number != "") ? $value_ass->model_number : "N.A.";
  7209. $issue_date = (isset($value_ass->issue_date) && $value_ass->issue_date != "") ? date('d-m-Y',strtotime($value_ass->issue_date)) : "N.A.";
  7210. $output[] = array(
  7211. $employee_number,
  7212. $user_name,
  7213. $job_title,
  7214. $department,
  7215. $business_unit,
  7216. $asset_type,
  7217. $serial_number,
  7218. $model_number,
  7219. $issue_date,
  7220. );
  7221. }
  7222. } // EOF foreach
  7223. $cols = array(
  7224. 'Employee ID',
  7225. 'Name',
  7226. 'Job Title',
  7227. 'Department',
  7228. 'Business Unit',
  7229. 'Assest type',
  7230. 'Serial number',
  7231. 'Model number/Type',
  7232. 'Issued date',
  7233. );
  7234.  
  7235. $filenameexport = "Asset Roster";
  7236. $final_output = array('output' => $output,
  7237. 'cols' => $cols,
  7238. 'filenameexport' => $filenameexport);
  7239. return $final_output;
  7240. }
  7241. public static function loadFiltersOthers() {
  7242. $filters = array();
  7243. $userMongo = UserMongo::model()->tenant()->findByAttributes(array('user_id' => Yii::app()->user->id));
  7244. if(Yii::app()->cache->executeCommand("hget", array(Yii::app()->user->getTenantId().":".Yii::app()->user->id,"Owner")) && Yii::app()->session['menu_owner'])
  7245. {
  7246. $filters['ALL'] = array('ALL_0' => 'All Employees');
  7247. $filters['Designations'] = UserDepartments::getAllDepartmentsWithDesignationsNew();
  7248. $filters['Departments'] = UserDepartments::getAllDepartments();
  7249. $filters['Locations'] = TenantOffices::getTenantOfficeLocation();
  7250. $filters['Employee Type'] = TenantUserTypes::getTenantTypes();
  7251. }
  7252. /* if(isset($userMongo) && !empty($userMongo))
  7253. {*/
  7254. elseif($userMongo->checkManager())
  7255. {
  7256. $filters['ALL'] = array('ALL_0' => 'All Reportees');
  7257. $filters['Reportees'] = $userMongo->getManagedUsersForRosters();
  7258. }
  7259. // }
  7260. // $filters['Shift'] = TenantShift::getTenantShiftArray();
  7261. return $filters;
  7262. }
  7263. public static function getESICReport($post_data, $tenant_id, $from, $to)
  7264. {
  7265. $tenant_profile = TenantProfile::model()->tenant()->find();
  7266. $cal_esic_on_gross = (isset($tenant_profile->cal_esic_on_gross))? $tenant_profile->cal_esic_on_gross : 0;
  7267.  
  7268. $for_date = date('Y-m', strtotime($from));
  7269. $return = array();
  7270. $output = array();
  7271. $employees_contribution = "N.A.";
  7272. $employeers_contribution = "N.A.";
  7273. $total = "N.A.";
  7274. $total_no_days = "N.A.";
  7275. $current_month = date("m");
  7276. $filter = $post_data['filter_id'];
  7277. $userSalarySlip = UserSalarySlip::model()->tenant($tenant_id)->findAllByAttributes(array('for_month' => $for_date));
  7278. foreach ($userSalarySlip as $salaryslip) {
  7279. $users = UserMongo::model()->tenant($tenant_id)->findByPk($salaryslip->user_id);
  7280. // Getting user gross salary
  7281. $gross_salary = $salaryslip->total_gross;
  7282.  
  7283. $total_transactions = (isset($salaryslip->total_transactions))? $salaryslip->total_transactions : 0;
  7284. $user_transaction_esic = UserTransaction::getTotalTransactionsOtEsic($salaryslip->user_id, $salaryslip->for_month, $salaryslip->tenant_id);
  7285. // Minus Extra payment from gross salary if any
  7286. if($total_transactions > 0){
  7287. $gross_salary = $gross_salary - $total_transactions;
  7288. $gross_salary = $gross_salary + $user_transaction_esic; //esic gross has only OT no other extra payments are affecting gross
  7289. }
  7290.  
  7291. if (isset($users) && !empty($users)) {
  7292. $cal_esic = false;
  7293. foreach ($salaryslip->items as $item) {
  7294. /* if ($item->type == Items::ITEM_TYPE_INCOME) {
  7295. $all_items_total += $item->max_value_month;
  7296. } */
  7297. if ($item->variable_name == "esic") {
  7298. $cal_esic = true;
  7299. $employees_contribution_sal = $item->max_value_month;
  7300. }
  7301. if ($item->variable_name == "basic") {
  7302. $basic = $item->max_value_month;
  7303. }
  7304. if($item->variable_name == 'provident_fund')
  7305. {
  7306. $pf = $item->max_value_month;
  7307. }
  7308. }
  7309. if ($cal_esic) {
  7310. $all_items_total = 0;
  7311. $full_name = $users->getFullname();
  7312. $employee_id = $users->personal->employee_no;
  7313. $doj = date('Y-m-d', $users->doj->sec);
  7314. $employees_contribution = $employees_contribution_sal;
  7315. $original_esic = $employees_contribution / 0.0175;
  7316. $employeers_contribution = number_format($original_esic * 0.0475);
  7317. $total = number_format($employees_contribution + $employeers_contribution);
  7318.  
  7319. // Calculate "GROSS + PF (Employeer) + EMPLOYEERS ESIC"
  7320. // If checkbox in Payroll setting is checked for "Calculate ESIC on Gross"
  7321. // if($cal_esic_on_gross == TenantProfile::ACTIVE)
  7322. // {
  7323. // $gross_salary = $gross_salary + $pf + $employeers_contribution;
  7324. // }
  7325.  
  7326. $esic_account_number = (isset($users->esic_number) && $users->esic_number != null) ? $users->esic_number : "N.A.";
  7327. $total_no_days = (isset($salaryslip->effective_working_days)) ? $salaryslip->effective_working_days : "N.A.";
  7328. $output[] = array(
  7329. $employee_id,
  7330. $esic_account_number,
  7331. $full_name,
  7332. $total_no_days,
  7333. PayrollHelper::roundingValues(Items::ROUND_TO_TWO_DIGITS, $gross_salary),
  7334. "",
  7335. "",
  7336. );
  7337. }
  7338. }
  7339. }
  7340. $cols = array(
  7341. 'Employee ID',
  7342. 'IP Number(10Digits)',
  7343. 'IP Name(Only alphabets and space)',
  7344. 'No of Days for which wages paid/payable during the month',
  7345. 'Total Monthly Wages',
  7346. 'Reason Code for Zero workings days(numeric only; provide 0 for all other reasons- Click on the link for reference)',
  7347. 'Last Working Day( Format DD/MM/YYYY or DD-MM-YYYY)',
  7348. );
  7349.  
  7350.  
  7351.  
  7352. $roster_type = "Payroll-ESIC-Report-month".$for_date;
  7353. $filenameexport = $roster_type;
  7354. $final_output = array('output' => $output,
  7355. 'cols' => $cols,
  7356. 'filenameexport' => $filenameexport);
  7357. return $final_output;
  7358. }
  7359.  
  7360. public static function getEsicStatement($post_data, $tenant_id, $from, $to){
  7361. $tenant_profile = TenantProfile::model()->tenant()->find();
  7362. $cal_esic_on_gross = (isset($tenant_profile->cal_esic_on_gross))? $tenant_profile->cal_esic_on_gross : 0;
  7363. $count_i = 1;
  7364. $for_date = date('Y-m', strtotime($from));
  7365. $return = array();
  7366. $output = array();
  7367. $employees_contribution = "N.A.";
  7368. $employeers_contribution = "N.A.";
  7369. $total = "N.A.";
  7370. $total_no_days = "N.A.";
  7371. $current_month = date("m");
  7372. $filter = $post_data['filter_id'];
  7373. $userSalarySlip = UserSalarySlip::model()->tenant($tenant_id)->findAllByAttributes(array('for_month' => $for_date));
  7374. foreach ($userSalarySlip as $salaryslip) {
  7375. //$users = UserMongo::model()->tenant($tenant_id)->findByPk($salaryslip->user_id);
  7376. // if($post_data['active_inactive'] == 1){
  7377. // $users = UserMongo::model()->tenant($tenant_id)->active()->findByPk($salaryslip->user_id);
  7378. // }
  7379. // else if($post_data['active_inactive'] == 2){
  7380. // $users = UserMongo::model()->tenant($tenant_id)->disabled()->findByPk($salaryslip->user_id);
  7381. // }
  7382. // else{
  7383. $users = UserMongo::model()->tenant($tenant_id)->findByPk($salaryslip->user_id);
  7384. //}
  7385. // Getting user gross salary
  7386. $gross_salary = $salaryslip->total_gross;
  7387. $total_transactions = (isset($salaryslip->total_transactions))? $salaryslip->total_transactions : 0;
  7388. $user_transaction_esic = UserTransaction::getTotalTransactionsOtEsic($salaryslip->user_id, $salaryslip->for_month, $salaryslip->tenant_id);
  7389. // Minus Extra payment from gross salary if any
  7390. if($total_transactions > 0){
  7391. $gross_salary = $gross_salary - $total_transactions;
  7392. $gross_salary = $gross_salary + $user_transaction_esic; //esic gross has only OT no other extra payments are affecting gross
  7393. }
  7394. if (isset($users) && !empty($users)) {
  7395. $cal_esic = false;
  7396. foreach ($salaryslip->items as $item) {
  7397. /* if ($item->type == Items::ITEM_TYPE_INCOME) {
  7398. $all_items_total += $item->max_value_month;
  7399. } */
  7400. if ($item->variable_name == "esic") {
  7401. $cal_esic = true;
  7402. $employees_contribution_sal = $item->max_value_month;
  7403. }
  7404. if ($item->variable_name == "basic") {
  7405. $basic = $item->max_value_month;
  7406. }
  7407. if($item->variable_name == 'provident_fund')
  7408. {
  7409. $pf = $item->max_value_month;
  7410. }
  7411. }
  7412. if ($cal_esic) {
  7413. $all_items_total = 0;
  7414. $full_name = $users->getFullname();
  7415. $doj = date('Y-m-d', $users->doj->sec);
  7416. $employee_code = (isset($users->personal->employee_no) && $users->personal->employee_no != "") ? $users->personal->employee_no : "N.A.";
  7417. $employees_contribution = $employees_contribution_sal;
  7418. $original_esic = $employees_contribution / 0.0175;
  7419. $employeers_contribution = number_format($original_esic * 0.0475);
  7420. $total = number_format($employees_contribution + $employeers_contribution);
  7421. // Calculate "GROSS + PF (Employeer) + EMPLOYEERS ESIC"
  7422. // If checkbox in Payroll setting is checked for "Calculate ESIC on Gross"
  7423. //if($cal_esic_on_gross == TenantProfile::ACTIVE){
  7424. //$gross_salary = $gross_salary + $pf + $employeers_contribution;
  7425. //}
  7426.  
  7427. $esic_account_number = (isset($users->esic_number) && $users->esic_number != null) ? $users->esic_number : "N.A.";
  7428. $total_no_days = (isset($salaryslip->effective_working_days)) ? $salaryslip->effective_working_days : "N.A.";
  7429. $output[] = array(
  7430. $count_i,
  7431. $employee_code,
  7432. $esic_account_number,
  7433. $full_name,
  7434. $total_no_days,
  7435. PayrollHelper::roundingValues(Items::ROUND_TO_NEAREST_INTEGER, $gross_salary),
  7436. PayrollHelper::roundingValues(Items::ROUND_TO_HIGEST_INTEGER, $employees_contribution),
  7437. PayrollHelper::roundingValues(Items::ROUND_TO_TWO_DIGITS, $employeers_contribution),
  7438. );
  7439. $count_i++;
  7440. }
  7441. }
  7442. }
  7443. $cols = array(
  7444. 'SI No',
  7445. 'Employee No',
  7446. 'Insurance No',
  7447. 'Name Of Insured Person',
  7448. 'Days Worked',
  7449. 'ESI Gross',
  7450. 'Employees Contribution',
  7451. 'Employeers Contribution',
  7452. );
  7453.  
  7454.  
  7455.  
  7456. $roster_type = "Payroll-ESIC-Report-month".$for_date;
  7457. $filenameexport = $roster_type;
  7458. $final_output = array('output' => $output,
  7459. 'cols' => $cols,
  7460. 'filenameexport' => $filenameexport);
  7461. return $final_output;
  7462. }
  7463. public static function getPFReportMonthNew($post_data, $tenant_id, $from, $to) {
  7464. $for_date = date('Y-m', strtotime($from));
  7465. $return = array();
  7466. $output = array();
  7467.  
  7468. $current_month = date("m");
  7469. $filter = $post_data['filter_id'];
  7470. $userSalarySlip = UserSalarySlip::model()->tenant($tenant_id)->findAllByAttributes(array('for_month' => $for_date));
  7471. $tenantProfile = TenantProfile::model()->tenant($tenant_id)->find();
  7472. if(!empty($tenantProfile))
  7473. {
  7474. if(isset($tenantProfile->pf_edli) && $tenantProfile->pf_edli == TenantProfile::ACTIVE){
  7475. $edli_value = 6500;
  7476. }
  7477. else{
  7478. if(strtotime($for_date) > strtotime('2014-10')){
  7479. $edli_value = 15000;
  7480. }
  7481. else{
  7482. $edli_value = 6500;
  7483. }
  7484. }
  7485. }
  7486. foreach ($userSalarySlip as $salaryslip) {
  7487. $employees_contribution = 0;
  7488. $edli = 0;
  7489. $employees_contribution_pf = 0;
  7490. $total_pension = 0;
  7491. $voluntary_pf = 0;
  7492. $total_pf = 0;
  7493. $administartive_amount = 0;
  7494. $insurance_fund = 0;
  7495. $inspection_charges = 0;
  7496. $final_amount = 0;
  7497. $basic_eps = 0;
  7498. $accountnooneepf = 0;
  7499. $accountnotenepf = 0;
  7500. $accountnotwo = 0;
  7501. $accountnotwentyone = 0;
  7502. $accountnotwentytwo = 0;
  7503. //$users = UserMongo::model()->tenant($tenant_id)->findByPk($salaryslip->user_id);
  7504. if(isset($post_data['active_inactive']) && $post_data['active_inactive'] == 1)
  7505. {
  7506. $users = UserMongo::model()->tenant($tenant_id)->active()->findByPk($salaryslip->user_id);
  7507. }
  7508. else if(isset($post_data['active_inactive']) && $post_data['active_inactive'] == 2)
  7509. {
  7510. $users = UserMongo::model()->tenant($tenant_id)->disabled()->findByPk($salaryslip->user_id);
  7511. }
  7512. else
  7513. {
  7514. $users = UserMongo::model()->tenant($tenant_id)->findByPk($salaryslip->user_id);
  7515. }
  7516. if (isset($users) && !empty($users)) {
  7517. $full_name = $users->getFullname();
  7518. $doj = (isset($users->doj->sec))? date('d/m/Y', $users->doj->sec) : 'N.A.';
  7519. $date_of_exit = (isset($users->deactivate_date->sec))? date('d/m/Y', $users->deactivate_date->sec) : 'N.A.';
  7520. $date_of_exit_month = (isset($users->deactivate_date->sec))? date('Y-m', $users->deactivate_date->sec) : 'N.A.';
  7521. $dob = (isset($users->personal->dob->sec) && $users->personal->dob->sec != "") ? date('d/m/Y', $users->personal->dob->sec) : "N.A.";
  7522. $doj = (isset($users->doj->sec) && $users->doj->sec != "") ? date('d/m/Y', $users->doj->sec) : "N.A.";
  7523. $doj_month = (isset($users->doj->sec) && $users->doj->sec != "") ? date('Y-m', $users->doj->sec) : "N.A.";
  7524. $employee_code = (isset($users->personal->employee_no) && $users->personal->employee_no != "") ? $users->personal->employee_no : "N.A.";
  7525. $gender = (isset($users->personal->gender) && $users->personal->gender == UserPersonal::GENDER_MALE) ? "M" : "F";
  7526. // Calculate Age from Date of Birth
  7527. // if($dob != '')
  7528. // {
  7529. // $from = new DateTime($dob);
  7530. // $to = new DateTime('today');
  7531. // $age = $from->diff($to)->y;
  7532. // }
  7533. // else
  7534. // {
  7535. // $age = 'N.A.';
  7536. // }
  7537.  
  7538. // Get employee father name.
  7539. $emp_father_name = '';
  7540. $emp_husband_name = '';
  7541. $display_realation_name = '';
  7542.  
  7543. if (isset($users->dependents) && count($users->dependents) > 0)
  7544. {
  7545. foreach ($users->dependents as $key => $value_dependent)
  7546. {
  7547. if ($value_dependent->relation_type == "Father")
  7548. {
  7549. $emp_father_first_name = (isset($value_dependent->first_name))? $value_dependent->first_name : '';
  7550. $emp_father_last_name = (isset($value_dependent->last_name))? $value_dependent->last_name : '';
  7551. $emp_father_name = $emp_father_first_name." ".$emp_father_last_name;
  7552. }
  7553. if ($value_dependent->relation_type == "Husband")
  7554. {
  7555. $emp_husband_first_name = (isset($value_dependent->first_name))? $value_dependent->first_name : '';
  7556. $emp_husband_last_name = (isset($value_dependent->last_name))? $value_dependent->last_name : '';
  7557. $emp_husband_name = $emp_father_first_name." ".$emp_father_last_name;
  7558. }
  7559. }
  7560. }
  7561. if(isset($emp_husband_name) && $emp_husband_name != ""){
  7562. $display_realation_name = (isset($emp_husband_name) && $emp_husband_name != "") ? $emp_husband_name : "N.A.";
  7563. $relation_type = 'S';
  7564. }else{
  7565. $display_realation_name = (isset($emp_father_name) && $emp_father_name != "") ? $emp_father_name : "N.A.";
  7566. $relation_type = (isset($emp_father_name) && $emp_father_name != "") ? 'F' : "N.A.";
  7567. }
  7568.  
  7569. $office_location = TenantOffices::model()->tenant($tenant_id)->findByAttributes(array('id' => $users->personal->office_location));
  7570. if (isset($office_location) && !empty($office_location) && isset($office_location->city) && $office_location->city != "") {
  7571. $city_name = City::model()->findByPk($office_location->city);
  7572. if (isset($city_name) && !empty($city_name)) {
  7573. $office_location_name = $city_name->name;
  7574. } else {
  7575. $office_location_name = "N.A";
  7576. }
  7577. } else {
  7578. $office_location_name = "N.A";
  7579. }
  7580. foreach ($salaryslip->items as $item) {
  7581. if ($item->variable_name == "basic") {
  7582. if(isset($tenantProfile->is_pf_restricted) && $tenantProfile->is_pf_restricted == TenantProfile::ACTIVE){
  7583. $basic = $item->max_value_month;
  7584. $basic = ($basic > 15000) ? 15000 : $basic;
  7585. }else{
  7586. $basic = $item->max_value_month;
  7587. }
  7588. }
  7589.  
  7590. if ($item->variable_name == "provident_fund") {
  7591. // basic basic_eps 3 conditions
  7592. // if age is greater than 58 years then 0 else basic
  7593. // if not existing PF member and basic > 15000 then basic_eps = 0
  7594. // if basic > 15000 then basic_eps = 15000 as max limit is 15000
  7595. $age = RandomHelper::CalculateAge(date('Y-m-d',$users->personal->dob->sec));
  7596. $basic_eps = $basic;
  7597. if($age > 58){
  7598. $basic_eps = 0;
  7599. }
  7600. if(isset($user->existing_pf_member) && $user->existing_pf_member == 0 && $basic > 15000){
  7601. $basic_eps = 0;
  7602. }
  7603. if($basic > 15000){
  7604. $basic_eps = 15000;
  7605. }
  7606. // basic basic_eps 3 conditions
  7607.  
  7608. $employees_contribution = $item->max_value_month;
  7609.  
  7610. $eps_contribution = ($basic_eps > 0) ? ($basic_eps * 8.33)/100 : 0;
  7611. $eps_contribution = PayrollHelper::roundingValues(Items::ROUND_TO_HIGEST_INTEGER,$eps_contribution);
  7612.  
  7613. $diff_epf_eps = $employees_contribution - $eps_contribution;
  7614.  
  7615. $lop_days = $salaryslip->lop;
  7616.  
  7617. $arrear_basic = 0; //differnece of basic after salary increment
  7618.  
  7619. $arrears_epf_wages = 0;
  7620.  
  7621. $arrears_epf_ee_wages = 0;
  7622.  
  7623. $arrears_epf_er_wages = 0;
  7624.  
  7625. $arrears_eps = 0;
  7626.  
  7627. if(strtotime($for_date) != strtotime($doj_month)){
  7628. $display_realation_name = "";
  7629. $relation_type = "";
  7630. $dob = "";
  7631. $gender = "";
  7632. $doj = "";
  7633. }
  7634. if(isset($date_of_exit) && strtotime($for_date) == strtotime($date_of_exit_month)){
  7635. $reason_of_exit = "C";
  7636. }else{
  7637. $date_of_exit = "";
  7638. $reason_of_exit = "";
  7639. }
  7640. // $employee_pf = (12 * $basic) / 100;
  7641. // $epf = ($employees_contribution/12) * 3.67;
  7642. // $eps = ($employees_contribution/12) * 8.33;
  7643. $lop_edli = 0;
  7644. if ($salaryslip->lop > 0) {
  7645. $lop_edli = ($edli_value / $salaryslip->total_working_days) * $salaryslip->lop;
  7646. } else {
  7647. $lop_edli = ($edli_value / $salaryslip->total_working_days) * ($salaryslip->total_working_days - $salaryslip->effective_working_days);
  7648. }
  7649.  
  7650. // Show E. D. L. I. is equal to BASIC if basic < 6500 - KT 9th March 2015
  7651. if($basic < $edli_value){
  7652. $edli = $basic;
  7653. }
  7654. else{
  7655. $edli = ($edli_value - $lop_edli);
  7656. }
  7657.  
  7658. // $total_pension = ($edli * 8.33) / 100;
  7659. // $employees_contribution_pf = ($employees_contribution - $total_pension);
  7660. // $voluntary_pf = 0;
  7661. // if(strtotime($for_date) >= strtotime('2015-01'))
  7662. // {
  7663. // $administartive_amount = ($basic * 0.85) / 100;
  7664. // }
  7665. // else{
  7666. // $administartive_amount = ($basic * 1.1) / 100;
  7667. // }
  7668. // $insurance_fund = ($edli * 0.5) / 100;
  7669. // $inspection_charges = ($edli * 0.01) / 100;
  7670. // $total_pf = $employees_contribution + $employees_contribution_pf + $total_pension + $voluntary_pf;
  7671. // $final_amount = $total_pf + $administartive_amount + $insurance_fund + $inspection_charges;
  7672. }
  7673. }
  7674.  
  7675. // Do not show the row if $employees_contribution is ZERO
  7676. if($employees_contribution > 0)
  7677. {
  7678.  
  7679. // Account no1 EPF(employee total pf + employeers diff btw epf and eps)
  7680. $accountnooneepf += ($employees_contribution + $diff_epf_eps);
  7681. // Account no1 EPF(employee total pf + employeers diff btw epf and eps)
  7682. //Account number 10 = sum of all emp EPS
  7683. $accountnotenepf += $eps_contribution;
  7684. //Account number 10 = sum of all emp EPS
  7685. //Account number 2 = PF admin charges
  7686. $accountnotwo += ($basic * 0.85) / 100;
  7687. //Account number 2 = PF admin charges
  7688. //Account number 21 = 0.5% on edli wages
  7689. $accountnotwentyone += ($edli * 0.5) / 100;
  7690. //Account number 21 = 0.5% on edli wages
  7691. //Account number 22 = 0.01% on edli wages
  7692. $accountnotwentytwo += ($edli * 0.01) / 100;
  7693. //Account number 22 = 0.01% on edli wages
  7694.  
  7695. $pf_account_number = (isset($users->pf_number) && $users->pf_number != null) ? $users->pf_number : "N.A.";
  7696. $employee_code_pf_exp = explode('/', $pf_account_number);
  7697. $employee_code_pf = (isset($employee_code_pf_exp[4]) && $employee_code_pf_exp[4] != "") ? $employee_code_pf_exp[4] : "";
  7698. $total_pension = ($edli * 8.33) / 100;
  7699. $employees_contribution_pf = ($employees_contribution - $total_pension);
  7700. $voluntary_pf = 0;
  7701. if(strtotime($for_date) >= strtotime('2015-01'))
  7702. {
  7703. $administartive_amount = ($basic * 0.85) / 100;
  7704. }
  7705. else{
  7706. $administartive_amount = ($basic * 1.1) / 100;
  7707. }
  7708. $insurance_fund = ($edli * 0.5) / 100;
  7709. $inspection_charges = ($edli * 0.01) / 100;
  7710. $total_pf = $employees_contribution + $employees_contribution_pf + $total_pension + $voluntary_pf;
  7711. $final_amount = $total_pf + $administartive_amount + $insurance_fund + $inspection_charges;
  7712. $output[] = array(
  7713. $employee_code_pf,
  7714. $full_name,
  7715. $basic,
  7716. $basic_eps,
  7717. $employees_contribution,
  7718. $eps_contribution,
  7719. $diff_epf_eps,
  7720. PayrollHelper::roundingValues(Items::ROUND_TO_TWO_DIGITS, $edli),
  7721. PayrollHelper::roundingValues(Items::ROUND_TO_TWO_DIGITS, $administartive_amount),
  7722. PayrollHelper::roundingValues(Items::ROUND_TO_TWO_DIGITS, $insurance_fund),
  7723. PayrollHelper::roundingValues(Items::ROUND_TO_TWO_DIGITS, $inspection_charges),
  7724. );
  7725. }
  7726. }
  7727. }
  7728. $cols = array(
  7729. 'Employee Code',
  7730. 'Employee Name',
  7731. 'EPF Wages', //that month earned basic
  7732. 'EPS Wages', // basic amount 3 conditions
  7733. 'EPF Contribution (EE Share)',
  7734. 'EPS Contribution due',
  7735. 'Diff EPF and EPS contribution (ER share)',
  7736. 'EDLI Wages',
  7737. 'PF Admin Charges',
  7738. 'EDLI Charges',
  7739. 'EDLI Admin Charges',
  7740. );
  7741.  
  7742.  
  7743.  
  7744. $roster_type = "payroll-PF-Report-month".$for_date;
  7745. $filenameexport = $roster_type;
  7746. $final_output = array('output' => $output,
  7747. 'cols' => $cols,
  7748. 'filenameexport' => $filenameexport);
  7749. return $final_output;
  7750. }
  7751. public static function flexiPayroll($post_data, $tenant_id = null,$from,$to,$status) {
  7752. $return = array();
  7753. $filter = $post_data['filter_id'];
  7754. $users = UserMongo::model()->getUsersByFilter($filter, $tenant_id, $post_data['active_inactive']);
  7755. $output = array();
  7756. $user_array = array();
  7757. foreach ($users as $key => $user) {
  7758. $user_array[] = $user->user_id;
  7759. }
  7760. $final_cycle_start = new MongoDate(strtotime($from));
  7761. $final_cycle_end = new MongoDate(strtotime($to));
  7762. $criteria = new EMongoCriteria();
  7763. $criteria->updated_on('>=', $final_cycle_start);
  7764. $criteria->updated_on('<=', $final_cycle_end);
  7765. $criteria->status('==', $status);
  7766. $criteria->income_flexi('==', OtherClaims::FLEXI);
  7767. $criteria->tenant_id('==', Yii::app()->user->getTenantId());
  7768. $claims = OtherClaims::model()->findAll($criteria);
  7769. if(isset($claims) && !empty($claims)){
  7770. foreach ($claims as $key_claims => $value_claims) {
  7771. if(in_array($value_claims->user_id, $user_array)){
  7772. $user = $users[$value_claims->user_id];
  7773. $user_name = $user['personal']['firstname'] . " " . $user['personal']['lastname'];
  7774. $employee_number = $user['personal']['employee_no'];
  7775. $user_post = $user->getCurrentPosition($tenant_id);
  7776. $job_title = $user_post['designation'];
  7777. $department = $user_post['department'];
  7778. $business_unit = $user_post['business_unit'];
  7779. $output[] = array(
  7780. $employee_number,
  7781. $user_name,
  7782. $job_title,
  7783. $department,
  7784. $business_unit,
  7785. str_replace("_", " ",$value_claims->type),
  7786. $value_claims->bill_amount,
  7787. date('d-m-Y',$value_claims->created->sec),
  7788. date('d-m-Y',$value_claims->updated_on->sec),
  7789. );
  7790. }
  7791. } // EOF foreach
  7792. }
  7793. $cols = array(
  7794. 'Employee ID',
  7795. 'Name',
  7796. 'Job Title',
  7797. 'Department',
  7798. 'Business Unit',
  7799. 'Flexi Component',
  7800. 'Bill Amount',
  7801. 'Claim Date',
  7802. 'Approved Date',
  7803. );
  7804.  
  7805. $roster_type = "Experience Report";
  7806. $filenameexport = $roster_type;
  7807. $final_output = array('output' => $output,
  7808. 'cols' => $cols,
  7809. 'filenameexport' => $filenameexport);
  7810. return $final_output;
  7811. }
  7812. public static function pulsereports($post_data, $tenant_id = null,$from,$to) {
  7813. if(Yii::app()->cache->executeCommand("hget", array(Yii::app()->user->getTenantId().":".Yii::app()->user->id,"Owner")) && Yii::app()->session['menu_owner']) {
  7814. $return = array();
  7815. $filter = $post_data['filter_id'];
  7816. $users = UserMongo::model()->getUsersByFilter($filter, $tenant_id, $post_data['active_inactive']);
  7817. $output = array();
  7818. $user_array = array();
  7819. foreach ($users as $key => $user) {
  7820. $user_array[] = $user->id;
  7821. }
  7822. $from_start = new MongoDate(strtotime($from));
  7823. $to_end = new MongoDate(strtotime($to));
  7824. $criteria = new EMongoCriteria();
  7825. $criteria->created('>=', $from_start);
  7826. $criteria->created('<=', $to_end);
  7827. $criteria->tenant_id('==', Yii::app()->user->getTenantId());
  7828. $pulse = PulsePosts::model()->findAll($criteria);
  7829. if(isset($pulse) && !empty($pulse)){
  7830. foreach ($pulse as $key_pulse => $value_pulse) {
  7831. if(in_array($value_pulse->user_id, $user_array)){
  7832. if(isset($value_pulse->is_anonymous) && $value_pulse->is_anonymous == PulsePosts::SHOW){
  7833. $user = UserMongo::model()->tenant()->findByPk($value_pulse->user_id);
  7834. $user_name = $user['personal']['firstname'] . " " . $user['personal']['lastname'];
  7835. $employee_number = $user['personal']['employee_no'];
  7836. $user_post = $user->getCurrentPosition($tenant_id);
  7837. $job_title = $user_post['designation'];
  7838. $department = $user_post['department'];
  7839. $business_unit = $user_post['business_unit'];
  7840. }else{
  7841. $employee_number = "Anonymous";
  7842. $user_name = "Anonymous";
  7843. $job_title = "Anonymous";
  7844. $department = "Anonymous";
  7845. $business_unit = "Anonymous";
  7846. }
  7847. $output[] = array(
  7848. $employee_number,
  7849. $user_name,
  7850. $job_title,
  7851. $department,
  7852. $business_unit,
  7853. $value_pulse->pulse_smile,
  7854. $value_pulse->reason,
  7855. date('d-m-Y',$value_pulse->created->sec),
  7856. );
  7857. }
  7858. } // EOF foreach
  7859. }
  7860. $cols = array(
  7861. 'Employee ID',
  7862. 'Name',
  7863. 'Job Title',
  7864. 'Department',
  7865. 'Business Unit',
  7866. 'Pulse',
  7867. 'Comment',
  7868. 'Post Date',
  7869. );
  7870.  
  7871. $roster_type = "Pulse Report";
  7872. $filenameexport = $roster_type;
  7873. $final_output = array('output' => $output,
  7874. 'cols' => $cols,
  7875. 'filenameexport' => $filenameexport);
  7876. return $final_output;
  7877. }
  7878. }
  7879. public static function DepartmentStructure($post_data, $tenant_id = null, $user_id = null) {
  7880. $return = array();
  7881. $filter = $post_data['filter_id'];
  7882. $users = UserMongo::model()->getUsersByFilter($filter, $tenant_id, $post_data['active_inactive']);
  7883. $output = array();
  7884. $l4_true = $l5_true = $l6_true = $l7_true = $l8_true = $l9_true = false;
  7885. $index = 0;
  7886. foreach ($users as $key => $user) {
  7887. $user_name = $user['personal']['firstname'] . " " . $user['personal']['lastname'];
  7888. $employee_number = (isset($user['personal']['employee_no'])) ? $user['personal']['employee_no'] : "N.A.";
  7889. $location = TenantOffices::getTenantOfficeLocationsNameWithCountryById($user->personal->office_location,$user->tenant_id);
  7890. $user_post = $user->getCurrentPosition($tenant_id);
  7891. $job_title = $user_post['designation'];
  7892. $department = $user_post['department'];
  7893. $business_unit = $user_post['business_unit'];
  7894. $department_id = $user_post['department_id'];
  7895. $l1 = $l2 = $l3 = $l4 = $l5 = $l6 = $l7 = $l8 = $l9 = "";
  7896. $dep_status = array();
  7897. $department_details = UserDepartments::model()->tenant()->findByPk($department_id);
  7898. if(isset($department_details->parent_department) && !empty($department_details->parent_department)){
  7899. $l1_dept = UserDepartments::model()->tenant()->findByPk($department_details->parent_department);
  7900. $l1 = $l1_dept->department_name;
  7901. $dep_status[] = $l1_dept->department_name;
  7902. if(isset($l1_dept->parent_department) && !empty($l1_dept->parent_department)){
  7903. $l2_dept = UserDepartments::model()->tenant()->findByPk($l1_dept->parent_department);
  7904. $l2 = $l2_dept->department_name;
  7905. $dep_status[] = $l2_dept->department_name;
  7906. if(isset($l2_dept->parent_department) && !empty($l2_dept->parent_department)){
  7907. $l3_dept = UserDepartments::model()->tenant()->findByPk($l2_dept->parent_department);
  7908. $l3 = $l3_dept->department_name;
  7909. $dep_status[] = $l3_dept->department_name;
  7910. if(isset($l3_dept->parent_department) && !empty($l3_dept->parent_department)){
  7911. $l4_true = true;
  7912. $l4_dept = UserDepartments::model()->tenant()->findByPk($l3_dept->parent_department);
  7913. $l4 = $l4_dept->department_name;
  7914. $dep_status[] = $l4_dept->department_name;
  7915. if(isset($l4_dept->parent_department) && !empty($l4_dept->parent_department)){
  7916. $l5_true = true;
  7917. $l5_dept = UserDepartments::model()->tenant()->findByPk($l4_dept->parent_department);
  7918. $l5 = $l5_dept->department_name;
  7919. $dep_status[] = $l5_dept->department_name;
  7920. if(isset($l5_dept->parent_department) && !empty($l5_dept->parent_department)){
  7921. $l6_true = true;
  7922. $l6_dept = UserDepartments::model()->tenant()->findByPk($l5_dept->parent_department);
  7923. $l6 = $l6_dept->department_name;
  7924. $dep_status[] = $l6_dept->department_name;
  7925. if(isset($l6_dept->parent_department) && !empty($l6_dept->parent_department)){
  7926. $l7_true = true;
  7927. $l7_dept = UserDepartments::model()->tenant()->findByPk($l6_dept->parent_department);
  7928. $l7 = $l7_dept->department_name;
  7929. $dep_status[] = $l7_dept->department_name;
  7930. if(isset($l7_dept->parent_department) && !empty($l7_dept->parent_department)){
  7931. $l8_true = true;
  7932. $l8_dept = UserDepartments::model()->tenant()->findByPk($l7_dept->parent_department);
  7933. $l8 = $l8_dept->department_name;
  7934. $dep_status[] = $l8_dept->department_name;
  7935. if(isset($l8_dept->parent_department) && !empty($l8_dept->parent_department)){
  7936. $l9_true = true;
  7937. $l9_dept = UserDepartments::model()->tenant()->findByPk($l8_dept->parent_department);
  7938. $l9 = $l9_dept->department_name;
  7939. $dep_status[] = $l9_dept->department_name;
  7940. }
  7941. }
  7942. }
  7943. }
  7944. }
  7945. }
  7946. }
  7947. }
  7948. }
  7949. $output[] = array(
  7950. // $action_checkbox,
  7951. $employee_number,
  7952. $user_name,
  7953. $job_title,
  7954. $business_unit,
  7955. $location,
  7956. //$department,
  7957. );
  7958. $new=0;
  7959. $dep_status = array_reverse($dep_status);
  7960. if(isset($dep_status) && !empty($dep_status)){
  7961. foreach ($dep_status as $key_each_dep => $value_each_dep) {
  7962. array_push($output[$index], $value_each_dep);
  7963. $new++;
  7964. }
  7965. }
  7966. array_push($output[$index], $department);
  7967. for ($p=($new+1); $p <= 9 ; $p++) {
  7968. array_push($output[$index], "");
  7969. }
  7970. $index++;
  7971. } // EOF foreach user
  7972.  
  7973. $cols = array(
  7974. 'Employee ID',
  7975. 'Name',
  7976. 'Job Title',
  7977. 'Business Unit',
  7978. 'Office Location',
  7979. 'Level 1',
  7980. 'Level 2',
  7981. 'Level 3',
  7982. );
  7983.  
  7984. //if(isset($l4_true) && $l4_true) {
  7985. array_push($cols, 'Level 4');
  7986. //}
  7987. //if(isset($l5_true) && $l5_true) {
  7988. array_push($cols, 'Level 5');
  7989. //}
  7990. //if(isset($l6_true) && $l6_true) {
  7991. array_push($cols, 'Level 6');
  7992. //}
  7993. //if(isset($l7_true) && $l7_true) {
  7994. array_push($cols, 'Level 7');
  7995. //}
  7996. //if(isset($l8_true) && $l8_true) {
  7997. array_push($cols, 'Level 8');
  7998. //}
  7999. //if(isset($l9_true) && $l9_true) {
  8000. array_push($cols, 'Level 9');
  8001. //}
  8002. $roster_type = "Department-Level-Wise-Report";
  8003. $filenameexport = $roster_type;
  8004. $final_output = array('output' => $output,
  8005. 'cols' => $cols,
  8006. 'filenameexport' => $filenameexport);
  8007. return $final_output;
  8008. }
  8009. public static function ItDeclaration($post_data, $tenant_id = null, $user_id = null) {
  8010. $return = array();
  8011. $filter = $post_data['filter_id'];
  8012. $users = UserMongo::model()->getUsersByFilter($filter, $tenant_id, $post_data['active_inactive']);
  8013. $output = array();
  8014. $header_array = array();
  8015. $index = 0;
  8016. $year = '2016';
  8017. $get_format = UserItDeclaration::model()->tenant(Yii::app()->user->getTenantId())->find();
  8018. foreach ($get_format->items as $key_each_item => $value_each_item) {
  8019. $header_array[$value_each_item->label] = $value_each_item->label;
  8020. }
  8021. if(isset($header_array) && !empty($header_array)){
  8022. foreach ($users as $key => $user) {
  8023. $declaration_user= array();
  8024. $declaration = UserItDeclaration::model()->tenant(Yii::app()->user->getTenantId())->user($user->id)->forYear($year)->find();
  8025. if(isset($declaration) && !empty($declaration)){
  8026. foreach ($declaration->items as $key_each_item_dec => $value_each_item_dec) {
  8027. $declaration_user[$value_each_item_dec->label] = $value_each_item_dec->declared_value;
  8028. }
  8029. $user_name = $user['personal']['firstname'] . " " . $user['personal']['lastname'];
  8030. $employee_number = (isset($user['personal']['employee_no'])) ? $user['personal']['employee_no'] : "N.A.";
  8031. $location = TenantOffices::getTenantOfficeLocationsNameWithCountryById($user->personal->office_location,$user->tenant_id);
  8032. $user_post = $user->getCurrentPosition($tenant_id);
  8033. $job_title = $user_post['designation'];
  8034. $department = $user_post['department'];
  8035. $business_unit = $user_post['business_unit'];
  8036. $output[] = array(
  8037. $employee_number,
  8038. $user_name,
  8039. $business_unit,
  8040. $job_title,
  8041. $department,
  8042. $location,
  8043. );
  8044. if(isset($declaration_user) && !empty($declaration_user)){
  8045. foreach ($declaration_user as $key_eu => $value_eu) {
  8046. if($key_eu != "PF"){
  8047. array_push($output[$index], $value_eu);
  8048. }
  8049. }
  8050. }
  8051. $index++;
  8052. } // EOF foreach user
  8053. }
  8054. }
  8055.  
  8056. $cols = array(
  8057. 'Employee ID',
  8058. 'Name',
  8059. 'Business Unit',
  8060. 'Job Title',
  8061. 'Department',
  8062. 'Office Location',
  8063. );
  8064. if(isset($header_array) && !empty($header_array)){
  8065. foreach ($header_array as $key_head => $value_head) {
  8066. if($value_head != "PF"){
  8067. array_push($cols, $value_head);
  8068. }
  8069. }
  8070. }
  8071. $roster_type = "IT Declaration";
  8072. $filenameexport = $roster_type;
  8073. $final_output = array('output' => $output,
  8074. 'cols' => $cols,
  8075. 'filenameexport' => $filenameexport);
  8076. return $final_output;
  8077. }
  8078. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement