/** * method to execute the aggregate process * it's called automatically by the cli main controller */ public function execute() { $possibleOptions = array('type' => false, 'stamp' => false, 'page' => true, 'size' => true); if (($options = $this->_controller->getInstanceOptions($possibleOptions)) === FALSE) { return; } $this->_controller->addOutput("Loading aggregator"); $aggregator = Billrun_Aggregator::getInstance($options); $this->_controller->addOutput("Aggregator loaded"); if ($aggregator) { $this->_controller->addOutput("Loading data to Aggregate..."); $aggregator->load(); $this->_controller->addOutput("Starting to Aggregate. This action can take a while..."); $aggregator->aggregate(); $this->_controller->addOutput("Finish to Aggregate."); } else { $this->_controller->addOutput("Aggregator cannot be loaded"); } }
public function execute() { Billrun_Factory::log()->log("Execute recreate invoices", Zend_Log::INFO); $request = $this->getRequest()->getRequest(); // supports GET / POST requests if (empty($request['account_id'])) { return $this->setError('Please supply at least one account id', $request); } $billrun_key = Billrun_Util::getPreviousBillrunKey(Billrun_Util::getBillrunKey(time())); // Warning: will convert half numeric strings / floats to integers $account_ids = array_unique(array_diff(Billrun_Util::verify_array(explode(',', $request['account_id']), 'int'), array(0))); if ($account_ids) { $options = array('autoload' => 0, 'stamp' => $billrun_key); $customer_aggregator_options = array('override_accounts' => $account_ids, 'bulk_account_preload' => 0); $customerOptions = array('type' => 'customer', 'aggregator' => $customer_aggregator_options); $customerAgg = Billrun_Aggregator::getInstance(array_merge($options, $customerOptions)); $customerAgg->load(); $successfulAccounts = $customerAgg->aggregate(); } else { return $this->setError('Illegal aids', $request); } $this->getController()->setOutput(array(array('status' => 1, 'desc' => 'success', 'input' => $request, 'successfulAccounts' => $successfulAccounts))); return TRUE; }