示例#1
0
 public function getPrint($session_id)
 {
     $trx = Transaction::where('sessionId', $session_id)->get()->toArray();
     $pay = Payment::where('sessionId', $session_id)->get()->toArray();
     $tab = array();
     foreach ($trx as $t) {
         $tab[$t['SKU']]['description'] = $t['productDetail']['itemDescription'];
         $tab[$t['SKU']]['qty'] = isset($tab[$t['SKU']]['qty']) ? $tab[$t['SKU']]['qty'] + 1 : 1;
         $tab[$t['SKU']]['tagprice'] = $t['productDetail']['priceRegular'];
         $tab[$t['SKU']]['total'] = isset($tab[$t['SKU']]['total']) ? $tab[$t['SKU']]['total'] + $t['productDetail']['priceRegular'] : $t['productDetail']['priceRegular'];
     }
     $tab_data = array();
     $gt = 0;
     foreach ($tab as $k => $v) {
         $tab_data[] = array(array('value' => $v['description'], 'attr' => 'class="left"'), array('value' => $v['qty'], 'attr' => 'class="center"'), array('value' => Ks::idr($v['tagprice']), 'attr' => 'class="right"'), array('value' => Ks::idr($v['total']), 'attr' => 'class="right"'));
         $gt += $v['tagprice'];
     }
     $tab_data[] = array('', '', '', Ks::idr($gt));
     $header = array('things to buy', 'unit', 'tagprice', array('value' => 'price to pay', 'attr' => 'style="text-align:right"'));
     $attr = array('class' => 'table', 'id' => 'transTab', 'style' => 'width:100%;', 'border' => '0');
     $t = new HtmlTable($tab_data, $attr, $header);
     $tr_tab = $t->build();
     $viewmodel = Template::where('type', 'invoice')->where('status', 'active')->first();
     return DbView::make($viewmodel)->field('body')->with('transtab', $tr_tab)->with('trx', $trx)->with('pay', $pay);
 }
示例#2
0
文件: Page.php 项目: Grapheme/amway
 public function block($slug = false, $field = 'content', $variables = array(), $force_compile = true)
 {
     if (!$slug || !@count($this->blocks) || !@is_object($this->blocks[$slug])) {
         return false;
     }
     #Helper::tad($this);
     $block = null;
     $content_container = false;
     if (isset($this->blocks[$slug]->metas[Config::get('app.locale')])) {
         $content_container = $this->blocks[$slug]->metas[Config::get('app.locale')];
         $block = $this->blocks[$slug];
     } elseif (isset($this->blocks[$slug]->content)) {
         $content_container = $this->blocks[$slug];
     } elseif (isset($this->blocks[$slug]->meta) && !is_null($this->blocks[$slug]->meta)) {
         $content_container = $this->blocks[$slug]->meta;
     }
     if (!$content_container) {
         return '';
     }
     #dd($content_container);
     #Helper::dd($this->blocks[$slug]->meta->content);
     ## Without blade syntax compile
     #return $this->blocks[$slug]->meta->content;
     ## Force template compile
     if ($force_compile) {
         $content_container->updated_at = date('Y-m-d H:i:s');
     }
     ## Without updated_at - COMPILE ONLY ONCE!
     #unset($this->blocks[$slug]->meta->updated_at);
     #Helper::ta($content_container);
     #Helper::ta($block);
     if (isset($block) && is_object($block) && isset($block->template)) {
         if ($block->template == '') {
             ## Return compiled field of the model
             return DbView::make($content_container)->field($field)->with($variables)->render();
         } else {
             if (View::exists(Helper::layout('blocks.' . $block->template))) {
                 $content = json_decode($content_container->content, true);
                 $content_container->content = $content;
                 #Helper::ta($content);
                 #dd(extract($content));
                 return View::make(Helper::layout('blocks.' . $block->template), $content);
             }
         }
     }
     return null;
 }
 public function getPreview($template, $type = null)
 {
     $tmpl = Template::find($template)->first();
     if (!is_null($type) && $type != 'pdf') {
         $content = DbView::make($tmpl)->field('body')->render();
         return $content;
     } else {
         //return PDF::loadView('print.brochure',array('prop'=>$prop))
         //    ->stream('download.pdf');
         $tmpl = $tmpl->toArray();
         return PDF::loadView('brochuretmpl.' . $template, array('prop' => $prop, 'contact' => $contact, 'roi3' => $roi3, 'roi5' => $roi5))->setOption('margin-top', $tmpl['margin-top'])->setOption('margin-left', $tmpl['margin-left'])->setOption('margin-right', $tmpl['margin-right'])->setOption('margin-bottom', $tmpl['margin-bottom'])->setOption('dpi', $tmpl['dpi'])->setPaper($tmpl['paper-size'])->stream($prop['propertyId'] . '.pdf');
         //return PDF::html('print.brochure',array('prop' => $prop), 'download.pdf');
     }
 }
 /**
  * @author SL
  * @param Template $template
  * @param array $data
  * @return string
  */
 public function getView(Template $template, array $data)
 {
     return \DbView::make($template)->field('html')->with($data)->render();
 }