private function createReceipt() { try { $receipt = $this->_receiptController->get($this->receiptId); //$receiptPositions = $this->_receiptController->getOrderPositions($this->receiptId)->toArray(); $receiptPositions = $receipt->getPositions()->toArray(); if (!$receipt->isMonition()) { $receiptSumValues = $this->_receiptController->getReceiptSumValues($this->receiptId); } else { $receiptSumValues = array(); } $orderId = $receipt->__get('order_id'); $order = Billing_Controller_Order::getInstance()->get($orderId); $contact = $order->__get('debitor_id')->__get('contact_id'); $contactId = $contact['id']; $contact = Addressbook_Controller_Contact::getInstance()->get($contactId); $receiptId = $receipt->id; $this->map[$contactId][] = $receiptId; $this->sortedMap[] = array($contactId => $receiptId); $this->count += 1; $templateId = $this->templateId; if (!Billing_Custom_Template::isToPrint($receipt, $this->matchReceiptType($receipt->__get('type')), &$templateId)) { --$this->count; } // get data for template from custom template $replaceTextBlocks = $this->templateController->getTextBlocks($templateId); $user = $receipt->__get('created_by'); $userContact = Addressbook_Controller_Contact::getInstance()->getContactByUserId($user->getId()); $data = $this->getData($receipt->__get('type'), array('contact' => $contact, 'receipt' => $receipt, 'order' => $order, 'debitor' => $order->__get('debitor_id'), 'positions' => $receiptPositions, 'sums' => $receiptSumValues, 'user' => Tinebase_Core::get(Tinebase_Core::USER), 'currentuser' => Tinebase_Core::getUser(), 'user' => $receipt->__get('created_by'), 'userContact' => $userContact), $replaceTextBlocks); $tempInFile = $this->tempFilePath . md5(serialize($receipt) . microtime()) . '_in.odt'; $tempOutFile = $this->tempFilePath . md5(serialize($receipt) . microtime()) . '_out.odt'; $this->templateController->renderTemplateToFile($templateId, $data, $tempInFile, $tempOutFile, $replaceTextBlocks); // move file into storage: cleans up tempfile at once $this->printJobStorage->moveIn($tempOutFile, "//in/{$contactId}/{$receiptId}/odt/temp"); //$watermarkFile = '/srv/www/vhosts/dev/projects/sopen/web/vdst/customize/data/template/documents/preview.pdf'; if (!$this->preview && !$this->copy) { $receipt->__set('print_date', new Zend_Date(strftime('%Y-%m-%d'))); $receipt->flatten(); $this->_receiptController->update($receipt); } if (Membership_Api_JobManager::getInstance()->hasJob()) { Membership_Api_JobManager::getInstance()->updateJobFromArray(array('job_name2', 'PRINTING... ' . $count)); } } catch (Exception $e) { throw $e; // //echo $e->__toString(); //throw new Billing_Exception_Order("Creating receipt document failed. - order: ".$this->receiptId, 0, $e); } }
public function downloadJobErrorFile($jobId) { $job = Membership_Api_JobManager::getInstance()->loadJob($jobId); $data = $job->getData(); $errorFileName = $data['exportErrorFileName']; $downloadFileName = 'ERROR-' . $data['downloadFileName']; $contentType = $data['exportFileContentType']; header("Pragma: public"); header("Cache-Control: max-age=0"); header('Content-Disposition: attachment; filename=' . $downloadFileName); header("Content-Description: csv File"); header("Content-type: {$contentType}"); readfile($errorFileName); }