コード例 #1
0
 function getInvoicePDF($orderDetails = 0, $viewName = 'invoice', $layout = 'invoice', $format = 'html', $force = false)
 {
     // 		$force = true;
     $path = VmConfig::get('forSale_path', 0);
     if (empty($path)) {
         vmError('No path set to store invoices');
         return false;
     } else {
         $path .= shopFunctions::getInvoiceFolderName() . DS;
         if (!file_exists($path)) {
             vmError('Path wrong to store invoices, folder invoices does not exist ' . $path);
             return false;
         } else {
             if (!is_writable($path)) {
                 vmError('Cannot store pdf, directory not writeable ' . $path);
                 return false;
             }
         }
     }
     $orderModel = VmModel::getModel('orders');
     $invoiceNumberDate = array();
     if (!$orderModel->createInvoiceNumber($orderDetails['details']['BT'], $invoiceNumberDate)) {
         return 0;
     }
     if (!empty($invoiceNumberDate[0])) {
         $invoiceNumber = $invoiceNumberDate[0];
     } else {
         $invoiceNumber = FALSE;
     }
     if (!$invoiceNumber or empty($invoiceNumber)) {
         vmError('Cant create pdf, createInvoiceNumber failed');
         return 0;
     }
     if (shopFunctions::InvoiceNumberReserved($invoiceNumber)) {
         return 0;
     }
     $path .= preg_replace('/[^A-Za-z0-9_\\-\\.]/', '_', 'vm' . $layout . '_' . $invoiceNumber . '.pdf');
     if (file_exists($path) and !$force) {
         return $path;
     }
     //We come from the be, so we need to load the FE langauge
     VmConfig::loadJLang('com_virtuemart', true);
     $this->addViewPath(JPATH_VM_SITE . DS . 'views');
     $view = $this->getView($viewName, $format);
     $this->writeJs = false;
     $view->addTemplatePath(JPATH_VM_SITE . DS . 'views' . DS . $viewName . DS . 'tmpl');
     $vmtemplate = VmConfig::get('vmtemplate', 0);
     if (!empty($vmtemplate) and $vmtemplate == 'default') {
         if (JVM_VERSION == 2) {
             $q = 'SELECT `template` FROM `#__template_styles` WHERE `client_id`="0" AND `home`="1"';
         } else {
             $q = 'SELECT `template` FROM `#__templates_menu` WHERE `client_id`="0" AND `menuid`="0"';
         }
         $db = JFactory::getDbo();
         $db->setQuery($q);
         $templateName = $db->loadResult();
     } else {
         $templateName = shopFunctionsF::setTemplate($vmtemplate);
     }
     if (!empty($templateName)) {
         $TemplateOverrideFolder = JPATH_SITE . DS . "templates" . DS . $templateName . DS . "html" . DS . "com_virtuemart" . DS . "invoice";
         if (file_exists($TemplateOverrideFolder)) {
             $view->addTemplatePath($TemplateOverrideFolder);
         }
     }
     $view->invoiceNumber = $invoiceNumberDate[0];
     $view->invoiceDate = $invoiceNumberDate[1];
     $view->orderDetails = $orderDetails;
     $view->uselayout = $layout;
     $view->showHeaderFooter = false;
     $vendorModel = VmModel::getModel('vendor');
     $virtuemart_vendor_id = 1;
     //We could set this automatically by the vendorId stored in the order.
     $vendor = $vendorModel->getVendor($virtuemart_vendor_id);
     $metadata = array('title' => JText::sprintf('COM_VIRTUEMART_INVOICE_TITLE', $vendor->vendor_store_name, $view->invoiceNumber, $orderDetails['details']['BT']->order_number), 'keywords' => JText::_('COM_VIRTUEMART_INVOICE_CREATOR'));
     return VmPdf::createVmPdf($view, $path, 'F', $metadata);
 }
コード例 #2
0
 /**
  * This function sets the right template on the view
  * @author Max Milbers
  */
 function setVmTemplate($view, $catTpl = 0, $prodTpl = 0, $catLayout = 0, $prodLayout = 0)
 {
     //Lets get here the template set in the shopconfig, if there is nothing set, get the joomla standard
     $template = VmConfig::get('vmtemplate', 'default');
     $db = JFactory::getDBO();
     //Set specific category template
     if (!empty($catTpl) && empty($prodTpl)) {
         if (is_Int($catTpl)) {
             $q = 'SELECT `category_template` FROM `#__virtuemart_categories` WHERE `virtuemart_category_id` = "' . (int) $catTpl . '" ';
             $db->setQuery($q);
             $temp = $db->loadResult();
             if (!empty($temp)) {
                 $template = $temp;
             }
         } else {
             $template = $catTpl;
         }
     }
     //Set specific product template
     if (!empty($prodTpl)) {
         if (is_Int($prodTpl)) {
             $q = 'SELECT `product_template` FROM `#__virtuemart_products` WHERE `virtuemart_product_id` = "' . (int) $prodTpl . '" ';
             $db->setQuery($q);
             $temp = $db->loadResult();
             if (!empty($temp)) {
                 $template = $temp;
             }
         } else {
             $template = $prodTpl;
         }
     }
     shopFunctionsF::setTemplate($template);
     //Lets get here the layout set in the shopconfig, if there is nothing set, get the joomla standard
     if (JRequest::getWord('view') == 'virtuemart') {
         $layout = VmConfig::get('vmlayout', 'default');
         $view->setLayout(strtolower($layout));
     } else {
         //Set specific category layout
         if (!empty($catLayout) && empty($prodLayout)) {
             if (is_Int($catLayout)) {
                 $q = 'SELECT `layout` FROM `#__virtuemart_categories` WHERE `virtuemart_category_id` = "' . (int) $catLayout . '" ';
                 $db->setQuery($q);
                 $temp = $db->loadResult();
                 if (!empty($temp)) {
                     $layout = $temp;
                 }
             } else {
                 $layout = $catLayout;
             }
         }
         //Set specific product layout
         if (!empty($prodLayout)) {
             if (is_Int($prodLayout)) {
                 $q = 'SELECT `layout` FROM `#__virtuemart_products` WHERE `virtuemart_product_id` = "' . (int) $prodLayout . '" ';
                 $db->setQuery($q);
                 $temp = $db->loadResult();
                 if (!empty($temp)) {
                     $layout = $temp;
                 }
             } else {
                 $layout = $prodLayout;
             }
         }
     }
     if (!empty($layout)) {
         $view->setLayout(strtolower($layout));
     }
 }
コード例 #3
0
ファイル: view.html.php プロジェクト: sergy444/joomla
 public function display($tpl = null)
 {
     $vendorId = JRequest::getInt('vendorid', 1);
     $vendorModel = VmModel::getModel('vendor');
     $vendorModel->setId(1);
     $vendor = $vendorModel->getVendor();
     if (!class_exists('shopFunctionsF')) {
         require JPATH_VM_SITE . DS . 'helpers' . DS . 'shopfunctionsf.php';
     }
     if (VmConfig::get('enable_content_plugin', 0)) {
         shopFunctionsF::triggerContentPlugin($vendor, 'vendor', 'vendor_store_desc');
         shopFunctionsF::triggerContentPlugin($vendor, 'vendor', 'vendor_terms_of_service');
     }
     $this->assignRef('vendor', $vendor);
     $document = JFactory::getDocument();
     if (!VmConfig::get('shop_is_offline', 0)) {
         $categoryModel = VmModel::getModel('category');
         $productModel = VmModel::getModel('product');
         $ratingModel = VmModel::getModel('ratings');
         $productModel->withRating = $ratingModel->showRating();
         $products = array();
         $categoryId = JRequest::getInt('catid', 0);
         $categoryChildren = $categoryModel->getChildCategoryList($vendorId, $categoryId);
         $categoryModel->addImages($categoryChildren, 1);
         $this->assignRef('categories', $categoryChildren);
         if (!class_exists('CurrencyDisplay')) {
             require JPATH_VM_ADMINISTRATOR . DS . 'helpers' . DS . 'currencydisplay.php';
         }
         $currency = CurrencyDisplay::getInstance();
         $this->assignRef('currency', $currency);
         $products_per_row = VmConfig::get('homepage_products_per_row', 3);
         $featured_products_rows = VmConfig::get('featured_products_rows', 1);
         $featured_products_count = $products_per_row * $featured_products_rows;
         if (!empty($featured_products_count) and VmConfig::get('show_featured', 1)) {
             $products['featured'] = $productModel->getProductListing('featured', $featured_products_count);
             $productModel->addImages($products['featured'], 1);
         }
         $latest_products_rows = VmConfig::get('latest_products_rows');
         $latest_products_count = $products_per_row * $latest_products_rows;
         if (!empty($latest_products_count) and VmConfig::get('show_latest', 1)) {
             $products['latest'] = $productModel->getProductListing('latest', $latest_products_count);
             $productModel->addImages($products['latest'], 1);
         }
         $topTen_products_rows = VmConfig::get('topTen_products_rows');
         $topTen_products_count = $products_per_row * $topTen_products_rows;
         if (!empty($topTen_products_count) and VmConfig::get('show_topTen', 1)) {
             $products['topten'] = $productModel->getProductListing('topten', $topTen_products_count);
             $productModel->addImages($products['topten'], 1);
         }
         $recent_products_rows = VmConfig::get('recent_products_rows');
         $recent_products_count = $products_per_row * $recent_products_rows;
         $recent_products = $productModel->getProductListing('recent');
         if (!empty($recent_products_count) and VmConfig::get('show_recent', 1) and !empty($recent_products)) {
             $products['recent'] = $productModel->getProductListing('recent', $recent_products_count);
             $productModel->addImages($products['recent'], 1);
         }
         $this->assignRef('products', $products);
         if (!class_exists('Permissions')) {
             require JPATH_VM_ADMINISTRATOR . DS . 'helpers' . DS . 'permissions.php';
         }
         $showBasePrice = Permissions::getInstance()->check('admin');
         //todo add config settings
         $this->assignRef('showBasePrice', $showBasePrice);
         //		$layoutName = VmConfig::get('vmlayout','default');
         $layout = VmConfig::get('vmlayout', 'default');
         $this->setLayout($layout);
         // Add feed links
         if ($products && (VmConfig::get('feed_featured_published', 0) == 1 or VmConfig::get('feed_topten_published', 0) == 1 or VmConfig::get('feed_latest_published', 0) == 1)) {
             $link = '&format=feed&limitstart=';
             $attribs = array('type' => 'application/rss+xml', 'title' => 'RSS 2.0');
             $document->addHeadLink(JRoute::_($link . '&type=rss', FALSE), 'alternate', 'rel', $attribs);
             $attribs = array('type' => 'application/atom+xml', 'title' => 'Atom 1.0');
             $document->addHeadLink(JRoute::_($link . '&type=atom', FALSE), 'alternate', 'rel', $attribs);
         }
     } else {
         $this->setLayout('off_line');
     }
     $error = JRequest::getInt('error', 0);
     //Todo this may not work everytime as expected, because the error must be set in the redirect links.
     if (!empty($error)) {
         $document->setTitle(JText::_('COM_VIRTUEMART_PRODUCT_NOT_FOUND') . JText::sprintf('COM_VIRTUEMART_HOME', $vendor->vendor_store_name));
     } else {
         if (empty($vendor->customtitle)) {
             $app = JFactory::getApplication();
             $menus = $app->getMenu();
             $menu = $menus->getActive();
             if ($menu) {
                 $menuTitle = $menu->params->get('page_title');
                 if (empty($menuTitle)) {
                     $menuTitle = JText::sprintf('COM_VIRTUEMART_HOME', $vendor->vendor_store_name);
                 }
                 $document->setTitle($menuTitle);
             } else {
                 $title = JText::sprintf('COM_VIRTUEMART_HOME', $vendor->vendor_store_name);
                 $document->setTitle($title);
             }
         } else {
             $document->setTitle($vendor->customtitle);
         }
         if (!empty($vendor->metadesc)) {
             $document->setMetaData('description', $vendor->metadesc);
         }
         if (!empty($vendor->metakey)) {
             $document->setMetaData('keywords', $vendor->metakey);
         }
         if (!empty($vendor->metarobot)) {
             $document->setMetaData('robots', $vendor->metarobot);
         }
         if (!empty($vendor->metaauthor)) {
             $document->setMetaData('author', $vendor->metaauthor);
         }
     }
     $template = VmConfig::get('vmtemplate', 0);
     shopFunctionsF::setTemplate($template);
     parent::display($tpl);
 }
コード例 #4
0
ファイル: view.html.php プロジェクト: lenard112/cms
 public function display($tpl = null)
 {
     $vendorId = vRequest::getInt('vendorid', 1);
     $vendorModel = VmModel::getModel('vendor');
     $vendorIdUser = VmConfig::isSuperVendor();
     $vendorModel->setId($vendorId);
     $vendor = $vendorModel->getVendor();
     if (!class_exists('shopFunctionsF')) {
         require JPATH_VM_SITE . DS . 'helpers' . DS . 'shopfunctionsf.php';
     }
     if (VmConfig::get('enable_content_plugin', 0)) {
         shopFunctionsF::triggerContentPlugin($vendor, 'vendor', 'vendor_store_desc');
         shopFunctionsF::triggerContentPlugin($vendor, 'vendor', 'vendor_terms_of_service');
     }
     $app = JFactory::getApplication();
     $menus = $app->getMenu();
     $menu = $menus->getActive();
     $this->assignRef('vendor', $vendor);
     $document = JFactory::getDocument();
     if (!VmConfig::get('shop_is_offline', 0)) {
         vmJsApi::jPrice();
         //if($vendorIdUser){
         //$user = JFactory::getUser();
         if ($vendorIdUser) {
             $add_product_link = JURI::root() . 'index.php?option=com_virtuemart&tmpl=component&view=product&task=edit&virtuemart_product_id=0&manage=1';
             $add_product_link = $this->linkIcon($add_product_link, 'COM_VIRTUEMART_PRODUCT_FORM_NEW_PRODUCT', 'edit', false, false);
         } else {
             $add_product_link = "";
         }
         $this->assignRef('add_product_link', $add_product_link);
         //}
         $categoryModel = VmModel::getModel('category');
         $productModel = VmModel::getModel('product');
         $ratingModel = VmModel::getModel('ratings');
         $productModel->withRating = $this->showRating = $ratingModel->showRating();
         $this->products = array();
         $categoryId = vRequest::getInt('catid', 0);
         $categoryChildren = $categoryModel->getChildCategoryList($vendorId, $categoryId);
         $categoryModel->addImages($categoryChildren, 1);
         $this->assignRef('categories', $categoryChildren);
         if (!class_exists('CurrencyDisplay')) {
             require JPATH_VM_ADMINISTRATOR . DS . 'helpers' . DS . 'currencydisplay.php';
         }
         $currency = CurrencyDisplay::getInstance();
         $this->assignRef('currency', $currency);
         $products_per_row = VmConfig::get('homepage_products_per_row', 3);
         $featured_products_rows = VmConfig::get('featured_products_rows', 1);
         $featured_products_count = $products_per_row * $featured_products_rows;
         if (!empty($featured_products_count) and VmConfig::get('show_featured', 1)) {
             $this->products['featured'] = $productModel->getProductListing('featured', $featured_products_count);
             $productModel->addImages($this->products['featured'], 1);
         }
         $latest_products_rows = VmConfig::get('latest_products_rows');
         $latest_products_count = $products_per_row * $latest_products_rows;
         if (!empty($latest_products_count) and VmConfig::get('show_latest', 1)) {
             $this->products['latest'] = $productModel->getProductListing('latest', $latest_products_count);
             $productModel->addImages($this->products['latest'], 1);
         }
         $topTen_products_rows = VmConfig::get('topTen_products_rows');
         $topTen_products_count = $products_per_row * $topTen_products_rows;
         if (!empty($topTen_products_count) and VmConfig::get('show_topTen', 1)) {
             $this->products['topten'] = $productModel->getProductListing('topten', $topTen_products_count);
             $productModel->addImages($this->products['topten'], 1);
         }
         $recent_products_rows = VmConfig::get('recent_products_rows');
         $recent_products_count = $products_per_row * $recent_products_rows;
         $recent_products = $productModel->getProductListing('recent');
         if (!empty($recent_products_count) and VmConfig::get('show_recent', 1) and !empty($recent_products)) {
             $this->products['recent'] = $productModel->getProductListing('recent', $recent_products_count);
             $productModel->addImages($this->products['recent'], 1);
         }
         if ($this->products) {
             $currency = CurrencyDisplay::getInstance();
             $this->assignRef('currency', $currency);
             $display_stock = VmConfig::get('display_stock', 1);
             $showCustoms = VmConfig::get('show_pcustoms', 1);
             if ($display_stock or $showCustoms) {
                 if (!$showCustoms) {
                     foreach ($this->products as $pType => $productSeries) {
                         foreach ($productSeries as $i => $productItem) {
                             $productItem->stock = $productModel->getStockIndicator($productItem);
                         }
                     }
                 } else {
                     $customfieldsModel = VmModel::getModel('Customfields');
                     if (!class_exists('vmCustomPlugin')) {
                         require JPATH_VM_PLUGINS . DS . 'vmcustomplugin.php';
                     }
                     foreach ($this->products as $pType => $productSeries) {
                         foreach ($productSeries as $i => $productItem) {
                             if (!empty($productItem->customfields)) {
                                 $product = clone $productItem;
                                 $customfields = array();
                                 foreach ($productItem->customfields as $cu) {
                                     $customfields[] = clone $cu;
                                 }
                                 $customfieldsSorted = array();
                                 $customfieldsModel->displayProductCustomfieldFE($product, $customfields);
                                 $product->stock = $productModel->getStockIndicator($product);
                                 foreach ($customfields as $k => $custom) {
                                     if (!empty($custom->layout_pos)) {
                                         $customfieldsSorted[$custom->layout_pos][] = $custom;
                                         unset($customfields[$k]);
                                     }
                                 }
                                 $customfieldsSorted['normal'] = $customfields;
                                 $product->customfieldsSorted = $customfieldsSorted;
                                 unset($product->customfields);
                                 $this->products[$pType][$i] = $product;
                             } else {
                                 $productItem->stock = $productModel->getStockIndicator($productItem);
                                 $this->products[$pType][$i] = $productItem;
                             }
                         }
                     }
                 }
             }
         }
         $user = JFactory::getUser();
         $showBasePrice = ($user->authorise('core.admin', 'com_virtuemart') or $user->authorise('core.manage', 'com_virtuemart') or VmConfig::isSuperVendor());
         $this->assignRef('showBasePrice', $showBasePrice);
         $layout = VmConfig::get('vmlayout', 'default');
         $this->setLayout($layout);
         $productsLayout = VmConfig::get('productsublayout', 'products');
         if (empty($productsLayout)) {
             $productsLayout = 'products';
         }
         $this->productsLayout = empty($menu->query['productsublayout']) ? $productsLayout : $menu->query['productsublayout'];
         // Add feed links
         if ($this->products && (VmConfig::get('feed_featured_published', 0) == 1 or VmConfig::get('feed_topten_published', 0) == 1 or VmConfig::get('feed_latest_published', 0) == 1)) {
             $link = '&format=feed&limitstart=';
             $attribs = array('type' => 'application/rss+xml', 'title' => 'RSS 2.0');
             $document->addHeadLink(JRoute::_($link . '&type=rss', FALSE), 'alternate', 'rel', $attribs);
             $attribs = array('type' => 'application/atom+xml', 'title' => 'Atom 1.0');
             $document->addHeadLink(JRoute::_($link . '&type=atom', FALSE), 'alternate', 'rel', $attribs);
         }
     } else {
         $this->setLayout('off_line');
     }
     $error = vRequest::getInt('error', 0);
     //Todo this may not work everytime as expected, because the error must be set in the redirect links.
     if (!empty($error)) {
         $document->setTitle(vmText::_('COM_VIRTUEMART_PRODUCT_NOT_FOUND') . vmText::sprintf('COM_VIRTUEMART_HOME', $vendor->vendor_store_name));
     } else {
         if (empty($vendor->customtitle)) {
             if ($menu) {
                 $menuTitle = $menu->params->get('page_title');
                 if (empty($menuTitle)) {
                     $menuTitle = vmText::sprintf('COM_VIRTUEMART_HOME', $vendor->vendor_store_name);
                 }
                 $document->setTitle($menuTitle);
             } else {
                 $title = vmText::sprintf('COM_VIRTUEMART_HOME', $vendor->vendor_store_name);
                 $document->setTitle($title);
             }
         } else {
             $document->setTitle($vendor->customtitle);
         }
         if (!empty($vendor->metadesc)) {
             $document->setMetaData('description', $vendor->metadesc);
         }
         if (!empty($vendor->metakey)) {
             $document->setMetaData('keywords', $vendor->metakey);
         }
         if (!empty($vendor->metarobot)) {
             $document->setMetaData('robots', $vendor->metarobot);
         }
         if (!empty($vendor->metaauthor)) {
             $document->setMetaData('author', $vendor->metaauthor);
         }
     }
     $template = VmConfig::get('vmtemplate', 0);
     shopFunctionsF::setTemplate($template);
     parent::display($tpl);
 }