Example #1
0
 /**
  * the singleton pattern
  *
  * @return SoEventManager_Controller_SoEvent
  */
 public static function getInstance()
 {
     if (self::$_instance === NULL) {
         self::$_instance = new self();
     }
     return self::$_instance;
 }
Example #2
0
 /**
  * Returns registry data of addressbook.
  * @see Tinebase_Application_Json_Abstract
  * 
  * @return mixed array 'variable name' => 'data'
  */
 public function getRegistryData()
 {
     $filter = new Tinebase_Model_ImportExportDefinitionFilter(array(array('field' => 'plugin', 'operator' => 'equals', 'value' => 'Billing_Import_BankCsv')));
     $importDefinitions = Tinebase_ImportExportDefinition::getInstance()->search($filter);
     //print_r($importDefinitions);
     try {
         $defaultDefinitionArray = Tinebase_ImportExportDefinition::getInstance()->getByName('bank_import_csv')->toArray();
     } catch (Tinebase_Exception_NotFound $tenf) {
         if (count($importDefinitions) > 0) {
             $defaultDefinitionArray = $importDefinitions->getFirstRecord()->toArray();
         } else {
             Tinebase_Core::getLogger()->warn(__METHOD__ . '::' . __LINE__ . ' No import definitions found for Banks');
             $defaultDefinitionArray = array();
         }
     }
     $registryData = array('Order' => Billing_Controller_Order::getInstance()->getRegistryData(), 'StockLocation' => Billing_Controller_StockLocation::getInstance()->getRegistryData(), 'PaymentMethods' => $this->getPaymentMethodsAsSimpleArray(), 'Context' => $this->getContextsAsSimpleArray(), 'ArticleGroups' => Billing_Controller_ArticleGroup::getInstance()->getArticleGroupsAsSimpleArray(), 'DebitorGroups' => Billing_Controller_DebitorGroup::getInstance()->getDebitorGroupsAsSimpleArray(), 'ArticleSeriess' => Billing_Controller_ArticleSeries::getInstance()->getArticleSeriessAsSimpleArray(), 'AccountSystems' => Billing_Controller_AccountSystem::getInstance()->getAccountSystemsAsSimpleArray(), 'AccountClasss' => Billing_Controller_AccountClass::getInstance()->getAccountClasssAsSimpleArray(), 'defaultBankImportDefinition' => $defaultDefinitionArray, 'importDefinitions' => array('results' => $importDefinitions->toArray(), 'totalcount' => count($importDefinitions)));
     return $registryData;
 }
Example #3
0
 public function printFibu($filters, $data, $accountBookingFilters)
 {
     set_time_limit(0);
     ignore_user_abort(true);
     $definition = Billing_Custom_PrintFibuDefinition::create($filters, $data, $accountBookingFilters);
     $action = $definition->getPrintAction();
     $filters = $definition->getFilters();
     $filter = new Billing_Model_AccountSystemFilter($filters, 'AND');
     $paging = new Tinebase_Model_Pagination(array('sort' => 'number', 'dir' => 'ASC'));
     if ($action == 'PRINT_ACTION_STATEMENT') {
         $accountIds = $this->search($filter, $paging, false, true);
         $beginDate = $definition->getStartDate(new Zend_Date());
         $beginSaldoDate = $definition->getStartDate(new Zend_Date());
         $beginSaldoDate->subDay(1);
         $endDate = $definition->getEndDate(new Zend_Date());
         $processArray = array();
         foreach ($accountIds as $accountId) {
             $account = $this->get($accountId);
             $accountBookingFilters = $definition->getAccountBookingFilters();
             $accountBookingFilters[] = array('field' => 'account_system_id', 'operator' => 'AND', 'value' => array(array('field' => 'id', 'operator' => 'equals', 'value' => $accountId)));
             $accountBookingFilters[] = array('field' => 'booking_date', 'operator' => 'afterOrAt', 'value' => $beginDate->toString('yyyy-MM-dd'));
             $accountBookingFilters[] = array('field' => 'booking_date', 'operator' => 'beforeOrAt', 'value' => $endDate->toString('yyyy-MM-dd'));
             $accountBookingFilter = new Billing_Model_AccountBookingFilter($accountBookingFilters, 'AND');
             $paging = new Tinebase_Model_Pagination(array('sort' => array('booking_date', 'booking_id'), 'dir' => 'ASC'));
             $accountBookingIds = Billing_Controller_AccountBooking::getInstance()->search($accountBookingFilter, $paging, false, true);
             $count = count($accountBookingIds);
             $account = $this->get($accountId);
             $credSum = 0;
             $debSum = 0;
             $aBeginSaldoFilter = array();
             $select = null;
             $aBeginSaldo = $this->getSummation(array(), null, $beginSaldoDate, array($accountId), &$select);
             $values = Billing_Custom_PrintFibuHelper::accountBookingsToExternalArray($accountBookingIds, &$debSum, &$credSum);
             //exit;
             $beginSaldo = $aBeginSaldo['total'] + $account->__get('begin_credit_saldo') - $account->__get('begin_debit_saldo');
             $beginSaldoS = $beginSaldo < 0 ? number_format(abs($beginSaldo), 2, ',', '.') : '';
             $beginSaldoH = $beginSaldo >= 0 ? number_format(abs($beginSaldo), 2, ',', '.') : '';
             $endSaldo = $beginSaldo + $credSum - $debSum;
             $endSaldoS = $endSaldo < 0 ? number_format(abs($endSaldo), 2, ',', '.') : '';
             $endSaldoH = $endSaldo >= 0 ? number_format(abs($endSaldo), 2, ',', '.') : '';
             $resultSum = $endSaldo - $beginSaldo;
             $resultF = number_format($resultSum, 2, ',', '.');
             $processArray[] = array('values' => $values, 'sums' => array(), 'header' => array('number' => $account->__get('number'), 'name' => $account->__get('name'), 'begin_saldo' => number_format($beginSaldo, 2, ',', '.'), 'begin_saldo_h' => $beginSaldoH, 'begin_saldo_s' => $beginSaldoS, 'end_saldo' => number_format($endSaldo, 2, ',', '.'), 'end_saldo_h' => $endSaldoH, 'end_saldo_s' => $endSaldoS, 'change_sum' => $resultF, 'begin_date' => $beginDate->toString('dd.MM.yyyy'), 'end_date' => $endDate->toString('dd.MM.yyyy'), 'deb_sum_f' => $debSum != 0 ? number_format($debSum, 2, ',', '.') : '', 'cred_sum_f' => $credSum != 0 ? number_format($credSum, 2, ',', '.') : '', 'count' => $count));
         }
     } elseif ($action == 'PRINT_ACTION_ADD1') {
         $beginDate = $definition->getStartDate(new Zend_Date());
         $period = $beginDate->get(Zend_Date::YEAR);
         $values = $this->getDonationAndMemberFeeSums($period, $definition, &$fixValues, &$resultArray);
         $processArray[] = array('values' => $resultArray, 'sums' => array(), 'header' => $fixValues);
     } elseif ($action == 'PRINT_ACTION_ADD2') {
         $beginDate = $definition->getStartDate(new Zend_Date());
         $period = $beginDate->get(Zend_Date::YEAR);
         $values = $this->printLists($period, $definition, &$processArray);
     } else {
         // get account classes
         $classes = Billing_Controller_AccountClass::getInstance()->getAll('key', 'ASC');
         $processArray = array();
         $arr = array();
         foreach ($classes as $class) {
             // get accounts within class
             try {
                 $classAccounts = $this->getByClassId($class->getId());
             } catch (Exception $e) {
                 continue;
             }
             $result = $this->getSusaSummation(null, $class->getId(), $definition->getSusaBeginDate(), $definition->getSusaEndDate());
             /**
             * 
             * 
             				from_begin and actual 
             				array(
             					'total' => $total['credit_total'] - $total['debit_total'],
             					'debit_total' => $total['debit_total'],
             					'credit_total' => $total['credit_total'],
             					'totalcount' => $totalCount
             				)
             * 
             */
             $arr[] = array('class' => $class->__get('key') . ' ' . $class->__get('name'), 'account' => '', 'total1' => $result['from_begin']['total'] != 0 ? number_format($result['from_begin']['total'], 2, ',', '.') : '', 'debit_total1' => $result['from_begin']['debit_total'] != 0 ? number_format($result['from_begin']['debit_total'], 2, ',', '.') : '', 'credit_total1' => $result['from_begin']['credit_total'] != 0 ? number_format($result['from_begin']['credit_total'], 2, ',', '.') : '', 'totalcount1' => $result['from_begin']['totalcount'] != 0 ? number_format($result['from_begin']['totalcount'], 2, ',', '.') : '', 'total2' => $result['actual']['total'] != 0 ? number_format($result['actual']['total'], 2, ',', '.') : '', 'debit_total2' => $result['actual']['debit_total'] != 0 ? number_format($result['actual']['debit_total'], 2, ',', '.') : '', 'credit_total2' => $result['actual']['credit_total'] != 0 ? number_format($result['actual']['credit_total'], 2, ',', '.') : '', 'totalcount2' => $result['actual']['totalcount'] != 0 ? number_format($result['actual']['totalcount'], 2, ',', '.') : '');
             foreach ($classAccounts as $account) {
                 $result = $this->getSusaSummation($account->getId(), null, $definition->getSusaBeginDate(), $definition->getSusaEndDate());
                 $arr[] = array('class' => '', 'account' => $account->__get('number') . ' ' . $account->__get('name'), 'total1' => $result['from_begin']['total'] != 0 ? number_format($result['from_begin']['total'], 2, ',', '.') : '', 'debit_total1' => $result['from_begin']['debit_total'] != 0 ? number_format($result['from_begin']['debit_total'], 2, ',', '.') : '', 'credit_total1' => $result['from_begin']['credit_total'] != 0 ? number_format($result['from_begin']['credit_total'], 2, ',', '.') : '', 'totalcount1' => $result['from_begin']['totalcount'] != 0 ? number_format($result['from_begin']['totalcount'], 2, ',', '.') : '', 'total2' => $result['actual']['total'] != 0 ? number_format($result['actual']['total'], 2, ',', '.') : '', 'debit_total2' => $result['actual']['debit_total'] != 0 ? number_format($result['actual']['debit_total'], 2, ',', '.') : '', 'credit_total2' => $result['actual']['credit_total'] != 0 ? number_format($result['actual']['credit_total'], 2, ',', '.') : '', 'totalcount2' => $result['actual']['totalcount'] != 0 ? number_format($result['actual']['totalcount'], 2, ',', '.') : '');
             }
         }
         $processArray[] = array('values' => $arr, 'sums' => array(), 'header' => array());
     }
     $outputType = 'pdf';
     try {
         $outputType = $definition->getOutputType();
     } catch (Exception $e) {
     }
     if (in_array($action, array('PRINT_ACTION_ADD2')) && $outputType == "excel") {
         Billing_Controller_Excel::getInstance()->export($processArray, $definition);
     } else {
         Billing_Controller_PrintFibu::getInstance()->printResult($processArray, $definition);
     }
 }