Example #1
0
 public function getLeaveBalance($userId = null)
 {
     if (is_null($userId)) {
         $userId = $this->getId();
     }
     $userLeaveAccount = new Application_Model_UserLeaveAccount();
     $leaveType = new Application_Model_LeaveType();
     $leaveType = $leaveType->fetchAll();
     foreach ($leaveType as $lt) {
         //current financial year 20011-04-01 00:00:00 to 2012-03-31 00:00:00
         $credited = $userLeaveAccount->getBalanceLeave($lt->getId(), 'credit', $userId);
         $debited = $userLeaveAccount->getBalanceLeave($lt->getId(), 'debit', $userId);
         $balance = $credited - $debited;
         $arrLaveBalance[] = array("id" => $lt->getId(), "title" => $lt->getTitle(), "debited" => $debited, "credited" => $credited, "balance" => $balance);
     }
     return $arrLaveBalance;
 }