예제 #1
0
 public function __construct($order)
 {
     parent::__construct();
     $moneyHelper = new Kwf_View_Helper_Money();
     $dateHelper = new Kwf_View_Helper_Date();
     $data = Kwf_Component_Data_Root::getInstance()->getComponentByDbId($order->checkout_component_id);
     $this->SetMargins(20, 15, 20);
     $this->setPrintHeader(false);
     $this->setPrintFooter(false);
     $this->SetAutoPageBreak(true);
     $this->AddPage();
     $this->SetFont("Arial", "", 9);
     if ($order->title) {
         $order->title .= " ";
     }
     $this->MultiCell(0, 0, $order->title . $order->firstname . " " . $order->lastname, 0, 'L');
     $this->MultiCell(0, 0, "\n" . $data->trlKwf('Order Number') . ":\n{$order->order_number}\n" . "\n" . $data->trlKwf('Customer Number') . ":\n{$order->customer_number}\n" . "\n" . $data->trlKwf('Invoice Number') . ":\n{$order->invoice_number}\n" . "\n" . $data->trlKwf('Invoice Date') . ":\n" . $dateHelper->date($order->invoice_date), 0, 'L');
     foreach ($order->getProductsData() as $item) {
         $text = $item->amount . "x " . $item->text;
         foreach ($item->additionalOrderData as $d) {
             if ($d['class'] != 'amount') {
                 $text .= ", {$d['name']} {$d['value']}";
             }
         }
         $this->MultiCell(120, 0, $data->trlStaticExecute($text), 0, 'L');
         $this->MultiCell(35, 0, $moneyHelper->money($item->price), 0, 'R');
     }
     foreach ($order->getSumRows() as $addSumRow) {
         if (isset($addSumRow['class']) && $addSumRow['class'] == 'totalAmount') {
             $this->MultiCell(0, 0, $data->trlStaticExecute($addSumRow['text']) . " " . $moneyHelper->money($addSumRow['amount']), 0, 'L');
         }
     }
 }
예제 #2
0
 public function timestamp($date)
 {
     if (!$date) {
         return '-';
     }
     $timeHelper = new Kwf_View_Helper_Time();
     $time = $timeHelper->time($date);
     $dateHelper = new Kwf_View_Helper_Date();
     $date = $dateHelper->date($date);
     return trlcKwf('time', 'On') . ' ' . $date . ' ' . trlcKwf('time', 'at') . ' ' . $time;
 }
예제 #3
0
 public function getTemplateVars(Kwf_Component_Renderer_Abstract $renderer)
 {
     $ret = parent::getTemplateVars($renderer);
     $ret['posts'] = array();
     $rows = $this->getChildModel()->fetchAll($this->_getSelect());
     foreach ($rows as $row) {
         $id = $row->component_id . '-' . $row->id;
         $post = Kwf_Component_Data_Root::getInstance()->getComponentByDbId($id);
         if ($post) {
             $dateHelper = new Kwf_View_Helper_Date();
             $linktexts = array();
             $page = $post->getPage();
             while ($page) {
                 $linktexts[] = $page->name;
                 $page = $page->getParentPage();
             }
             $post->linktext = $dateHelper->date($post->row->create_time) . ': ' . implode(' » ', array_reverse($linktexts));
             $ret['posts'][] = $post;
         }
     }
     return $ret;
 }
예제 #4
0
 public function jsonXlsAction()
 {
     Kwf_Util_MemoryLimit::set(768);
     set_time_limit(600);
     // 10 minuten
     if (!isset($this->_permissions['xls']) || !$this->_permissions['xls']) {
         throw new Kwf_Exception("XLS is not allowed.");
     }
     $data = $this->_getExportData(Kwf_Grid_Column::SHOW_IN_XLS, 'xls', 640);
     $xls = new PHPExcel();
     $xls->getProperties()->setCreator("Vivid Planet Software GmbH");
     $xls->getProperties()->setLastModifiedBy("Vivid Planet Software GmbH");
     $xls->getProperties()->setTitle("KWF Excel Export");
     $xls->getProperties()->setSubject("KWF Excel Export");
     $xls->getProperties()->setDescription("KWF Excel Export");
     $xls->getProperties()->setKeywords("KWF Excel Export");
     $xls->getProperties()->setCategory("KWF Excel Export");
     $xls->setActiveSheetIndex(0);
     $sheet = $xls->getActiveSheet();
     // setting width for each column
     $colIndex = 0;
     $renderer = array();
     foreach ($this->_columns as $column) {
         if (!($column->getShowIn() & Kwf_Grid_Column::SHOW_IN_XLS)) {
             continue;
         }
         if (is_null($column->getHeader())) {
             continue;
         }
         if ($column->getXlsWidth()) {
             $width = $column->getXlsWidth();
         } else {
             if ($column->getWidth()) {
                 $width = round($column->getWidth() / 6, 1);
             } else {
                 $width = 15;
             }
         }
         $sheet->getColumnDimension($this->_getColumnLetterByIndex($colIndex))->setWidth($width);
         $renderer[$colIndex] = $column->getRenderer();
         $colIndex++;
     }
     $helperDate = new Kwf_View_Helper_Date();
     $helperDateTime = new Kwf_View_Helper_DateTime();
     foreach ($data as $row => $cols) {
         // row ist index, das andre nicht, passt aber trotzdem so
         // da ja in der ersten Zeile der Header steht
         foreach ($cols as $col => $text) {
             $cell = $this->_getColumnLetterByIndex($col) . ($row + 1);
             if (is_array($text)) {
                 $text = implode(', ', $text);
             }
             // make header bold
             if ($row == 0) {
                 $sheet->getStyle($cell)->getFont()->setBold(true);
             }
             // TODO: Zeilenumbrüche
             $textType = gettype($text);
             $cellType = PHPExcel_Cell_DataType::TYPE_STRING;
             if ($textType == 'boolean') {
                 $cellType = PHPExcel_Cell_DataType::TYPE_BOOL;
             }
             if ($textType == 'integer' || $textType == 'double' || $textType == 'float') {
                 $cellType = PHPExcel_Cell_DataType::TYPE_NUMERIC;
             }
             if ($textType == 'NULL') {
                 $cellType = PHPExcel_Cell_DataType::TYPE_NULL;
             }
             // datum umformatieren
             if (strlen($text) == 10 && preg_match('/^[0-9]{4,4}-[0-9]{2,2}-[0-9]{2,2}$/', $text)) {
                 $text = $helperDate->date($text);
             } else {
                 if (strlen($text) == 19 && preg_match('/^[0-9]{4,4}-[0-9]{2,2}-[0-9]{2,2} [0-9]{2,2}:[0-9]{2,2}:[0-9]{2,2}$/', $text)) {
                     $text = $helperDateTime->dateTime($text);
                 }
             }
             $sheet->setCellValueExplicit($cell, $text, $cellType);
             if ($renderer[$col] == 'clickableLink') {
                 $sheet->getCell($cell)->getHyperlink()->setUrl($text);
             }
         }
         $this->_progressBar->next(1, trlKwf('Writing data. Please be patient.'));
     }
     // write the file
     $downloadkey = uniqid();
     if (class_exists('XMLWriter')) {
         $objWriter = PHPExcel_IOFactory::createWriter($xls, 'Excel2007');
         $objWriter->save('temp/' . $downloadkey . '.xlsx');
     } else {
         $objWriter = PHPExcel_IOFactory::createWriter($xls, 'Excel5');
         $objWriter->save('temp/' . $downloadkey . '.xls');
     }
     $this->_progressBar->finish();
     $this->view->downloadkey = $downloadkey;
 }