Пример #1
0
 static function &balanceDetails($studentID = null)
 {
     // always do per academic year
     // which goes from Sept (09) - June (06)
     $currentYear = date('Y');
     $startYear = $endYear = $currentYear;
     $startMonth = '09';
     if ($m < 9) {
         $startYear--;
     }
     $startDate = "{$startYear}{$startMonth}01";
     $endDate = date('Ymd');
     // first get all the dynamic charges
     $dynamicDetails =& self::signoutDetails($startDate, $endDate, true, false, false, $studentID);
     require_once 'SFS/Utils/ExtendedCareFees.php';
     $feeDetails = SFS_Utils_ExtendedCareFees::feeDetails($startDate, $endDate, null, false, false, $studentID);
     $completeDetails = CRM_Utils_Array::crmArrayMerge($dynamicDetails, $feeDetails);
     foreach ($completeDetails as $id => &$value) {
         if (!empty($value['doNotCharge'])) {
             $value['blockCharge'] = 0;
         }
         $value['totalCharges'] = CRM_Utils_Array::value('blockCharge', $value, 0) + CRM_Utils_Array::value('charges', $value, 0);
         $value['blockCharges'] = CRM_Utils_Array::value('blockCharge', $value, 0) + CRM_Utils_Array::value('ecCharges', $value, 0);
         $value['totalPayments'] = CRM_Utils_Array::value('payments', $value, 0) + CRM_Utils_Array::value('refunds', $value, 0);
         if ($value['totalCharges'] == 0 && $value['totalPayments'] == 0) {
             unset($completeDetails[$id]);
             continue;
         }
         if ($value['totalCharges'] >= $value['totalPayments']) {
             $value['balanceDue'] = $value['totalCharges'] - $value['totalPayments'];
             $value['balanceCredit'] = 0;
         } else {
             $value['balanceCredit'] = 0;
             $value['balanceCredit'] = $value['totalPayments'] - $value['totalCharges'];
         }
     }
     return $completeDetails;
 }
Пример #2
0
 function browse($id, $startDate, $endDate, $actionPermission)
 {
     require_once 'SFS/Utils/ExtendedCare.php';
     require_once 'SFS/Utils/ExtendedCareFees.php';
     $this->view($id, $startDate, $endDate, $actionPermission, true);
     if (date('Ymd') <= date('Ymd', strtotime($endDate))) {
         $endDateNew = date('Ymd');
     } else {
         $endDateNew = date('Ymd', mktime(0, 0, 0, date('m', strtotime($endDate)), date('t', strtotime($endDate)), date('Y', strtotime($endDate))));
         if (date('Ymd') <= $endDateNew) {
             $endDateNew = date('Ymd');
         }
     }
     $details = SFS_Utils_ExtendedCareFees::feeDetails($startDate, $endDateNew, null, false, true, $id, null);
     $feeDetails = array_pop($details);
     $monthlySignout = SFS_Utils_ExtendedCare::signoutDetailsPerMonth($startDate, $endDate, $id);
     if (!empty($feeDetails) && $actionPermission) {
         foreach ($feeDetails['details'] as $key => $value) {
             $feeDetails['details'][$key]['action'] = CRM_Core_Action::formLink(self::actionLinks(), null, array('objectID' => $key, 'id' => $id, 'object' => 'fee'));
         }
     }
     $this->assign_by_ref('feeDetail', $feeDetails);
     if (!empty($monthlySignout)) {
         $detailLink = array(CRM_Core_Action::VIEW => array('name' => ts('View Details'), 'url' => CRM_Utils_System::currentPath(), 'qs' => 'reset=1&action=view&id=%%id%%&year=%%year%%&month=%%month%%', 'title' => ts('View Details')));
         foreach ($monthlySignout as $month => $detail) {
             $monthlySignout[$month]['action'] = CRM_Core_Action::formLink($detailLink, null, array('id' => $id, 'year' => $detail['year'], 'month' => $detail['month']));
         }
     }
     $this->assign_by_ref('monthlySignout', $monthlySignout);
     // get remaining balance
     $balanceDetails = SFS_Utils_ExtendedCare::balanceDetails($id);
     if (!empty($balanceDetails)) {
         $balanceDetails = array_pop($balanceDetails);
         $this->assign_by_ref('balanceDetails', $balanceDetails);
     } else {
         $this->assign('balanceDetails', null);
     }
     if ($actionPermission) {
         $addBlockUrl = CRM_Utils_System::url(CRM_Utils_System::currentPath(), "reset=1&id={$id}&action=add&object=signout");
         $addFeeUrl = CRM_Utils_System::url(CRM_Utils_System::currentPath(), "reset=1&id={$id}&action=add&object=fee");
         $this->assign('addActivityBlock', $addBlockUrl);
         $this->assign('addFeeEntity', $addFeeUrl);
     }
 }