Exemplo n.º 1
0
 private function createSupplyReceipt()
 {
     $receipt = $this->_supplyReceiptController->get($this->receiptId);
     $receiptPositions = $this->_supplyReceiptController->getSupplyOrderPositions($this->receiptId)->toArray();
     $receiptSumValues = $this->_supplyReceiptController->getSupplyReceiptSumValues($this->receiptId);
     $receiptId = $receipt->id;
     $this->map[] = $receiptId;
     $orderId = $receipt->__get('supply_order_id');
     $order = Billing_Controller_SupplyOrder::getInstance()->get($orderId);
     $contact = $order->__get('creditor_id')->__get('contact_id');
     $contactId = $contact['id'];
     $contact = Addressbook_Controller_Contact::getInstance()->get($contactId);
     $this->count += 1;
     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);
     $data = $this->getData($receipt->__get('type'), array('contact' => $contact, 'receipt' => $receipt, 'order' => $order, 'creditor' => $order->__get('creditor_id'), 'positions' => $receiptPositions, 'sums' => $receiptSumValues, 'currentuser' => Tinebase_Core::getUser(), 'user' => $receipt->__get('created_by')), $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/receipt/{$receiptId}/odt/temp");
     if ($this->printJobStorage->fileExists("//in/receipt/{$receiptId}/odt/temp")) {
         $inFile = $this->printJobStorage->resolvePath("//in/receipt/{$receiptId}/odt/temp");
         $outFile = $this->printJobStorage->getCreateIfNotExist("//out/result/{$receiptId}/pdf/final");
         $this->pdfServer->convertDocumentToPdf($inFile, $outFile);
     }
 }
Exemplo n.º 2
0
 public function saveSupplyOrder($recordData)
 {
     return $this->_save($recordData, Billing_Controller_SupplyOrder::getInstance(), 'SupplyOrder');
 }