Пример #1
0
 /**
  * Get last period of fiscal year and first period of the next fiscal year
  *
  * @param array $input
  * 	An array as follows: array(id => $id);
  *
  * @return array
  *  An array as follows: array( 'id' = $id, 'month' => $month, 'end_date' => $endDate)
  */
 public function getBalanceAccountsClosingPeriods(array $input)
 {
     $organizationId = $this->AuthenticationManager->getCurrentUserOrganization('id');
     $fiscalYearId = $this->FiscalYear->lastFiscalYearByOrganization($organizationId);
     if ($fiscalYearId == $input['id']) {
         return json_encode(array('info' => $this->Lang->get('decima-accounting::period-management.invalidFiscalYear')));
     }
     $period = json_decode($this->getLastPeriodOfFiscalYear($input), true);
     $FiscalYear = $this->FiscalYear->byId($input['id']);
     $FiscalYear = $this->FiscalYear->byYearAndByOrganization($FiscalYear->year + 1, $organizationId);
     $period2 = $this->Period->firstPeriodbyOrganizationAndByFiscalYear($this->AuthenticationManager->getCurrentUserOrganizationId(), $FiscalYear->id)->toArray();
     $period2['endDate'] = $this->Carbon->createFromFormat('Y-m-d', $period2['end_date'])->format($this->Lang->get('form.phpShortDateFormat'));
     unset($period2['end_date']);
     $period2['month'] = $period2['month'] . ' - ' . $this->Lang->get('decima-accounting::period-management.' . $period2['month']);
     return json_encode(array('id0' => $period['id'], 'month0' => $period['month'], 'endDate0' => $period['endDate'], 'id1' => $period2['id'], 'month1' => $period2['month'], 'endDate1' => $period2['endDate'], 'fiscalYearId' => $FiscalYear->id));
 }
 /**
  * Echo grid data in a jqGrid compatible format
  *
  *
  * @return JSON encoded string
  *  A string as follows:
  *	In case of success: {"year" : $year}
  */
 public function getNextFiscalYear()
 {
     $fiscalYearId = $this->FiscalYear->lastFiscalYearByOrganization($this->AuthenticationManager->getCurrentUserOrganizationId());
     $FiscalYear = $this->FiscalYear->byId($fiscalYearId);
     return json_encode(array('fiscalYear' => $FiscalYear->year + 1));
 }