Commit 974abb1f authored by Reinhold Kainhofer's avatar Reinhold Kainhofer
Browse files

Move export format functionality to the view, fix VM2, etc.

parent f6f69234
......@@ -17,7 +17,8 @@ if( !defined( '_JEXEC' ) ) die( 'Direct Access to '.basename(__FILE__).' is not
* http://www.open-tools.net
*/
if(!class_exists('VmController'))require(VMPATH_ADMIN.DS.'helpers'.DS.'vmcontroller.php');
defined ('VMPATH_ADMIN') or define ('VMPATH_ADMIN', JPATH_VM_ADMINISTRATOR);
if(!class_exists('VmController')) require(VMPATH_ADMIN.DS.'helpers'.DS.'vmcontroller.php');
/**
......@@ -58,17 +59,34 @@ class VirtuemartControllerEuRecap extends VmController {
$this->display();
}
function export(){
vRequest::setVar('controller', $this->_cname);
vRequest::setVar('view', $this->_cname);
// vRequest::setVar('layout', $layout);
function export($layout='export'){
$viewName = $this->_cname;
vRequest::setVar('controller', $viewName);
vRequest::setVar('view', $viewName);
vRequest::setVar('layout', $layout);
vRequest::setVar('task', $layout);
// vRequest::setVar('format', 'raw');
// $japp = &JApplication::getInstance("site"); // fetches the current application
// $japp->setTemplate("", null); // sets an empty template, disables the default one
// $document = &JFactory::getDocument(); // gets the document, that the user wants
// $document->setType("raw"); // sets its type to raw
// JRequest::setVar("format", "raw"); // this one is not obligatory, but my component uses this in the view later
// $document = JDocument::getInstance('raw'); //this new instance is a raw document object
// $viewType = $document->getType();
// // $viewname below is set in jinput or as you named it
// $view = $this->getView($viewName, $viewType);
// // $this->input->set('view', $viewName);
// $this->input->set('view', $viewName);
$document = JFactory::getDocument();
// $document->setType('raw');
$viewType = $document->getType();
$view = $this->getView($this->_cname, $viewType);
$view = $this->getView($viewName, $viewType);
// $view->setLayout($layout);
JFactory::getApplication()->enqueueMessage("Export function in controller", 'warning');
$view->setLayout($layout);
$this->display();
}
......
......@@ -9,8 +9,10 @@ if( !defined( '_JEXEC' ) ) die( 'Direct Access to '.basename(__FILE__).' is not
*
* @package VirtueMart
* @subpackage Plugins
* @author Christopher Roussel
* @author Reinhold Kainhofer, Open Tools
*/
defined ('VMPATH_ADMIN') or define ('VMPATH_ADMIN', JPATH_VM_ADMINISTRATOR);
defined ('VMPATH_PLUGINLIBS') or define ('VMPATH_PLUGINLIBS', JPATH_VM_PLUGINS);
if (!class_exists('vmExtendedPlugin')) require(VMPATH_PLUGINLIBS . DS . 'vmextendedplugin.php');
class plgVmExtendedEuRecap extends vmExtendedPlugin {
......@@ -75,7 +77,7 @@ class plgVmExtendedEuRecap extends vmExtendedPlugin {
}
/**
* A helper function for the plugin installer: In VM 3.0.? the onVmAdminMenuItems trigger was added, which allows to dynamically
* A helper function for the plugin installer: In VM 3.0.? the onVmAdminMenuItems trigger might added, which allows to dynamically
* add admin menu items to the the backend. In earlier versions, we need to hardcode the menu item to the database. This function
* decides whether the database entry is needed and if so, it adds it (otherwise it removes it, just in case).
*/
......@@ -84,7 +86,9 @@ class plgVmExtendedEuRecap extends vmExtendedPlugin {
$db = JFactory::getDBO();
$db->setQuery("SELECT `id` FROM `#__virtuemart_adminmenuentries` WHERE `view` = 'eurecap'");
$exists = $db->loadResult();
if (version_compare($vmver, '3.0.3', 'lt')) {
// $need_db_entry = version_compare($vmver, '3.0.3', 'lt');
$need_db_entry = true;
if ($need_db_entry) {
if (!$exists) {
// Before VM 3.0.3 => Need database entry (in the "Orders" section):
$q = "INSERT INTO `#__virtuemart_adminmenuentries` (`module_id`, `name`, `link`, `depends`, `icon_class`, `ordering`, `published`, `tooltip`, `view`, `task`) VALUES
......
......@@ -3,7 +3,7 @@ defined('_JEXEC') or die('Restricted access');
/**
* Installation script for the plugin
*
* @copyright Copyright (C) 2013-2014 Reinhold Kainhofer, office@open-tools.net
* @copyright Copyright (C) 2015 Reinhold Kainhofer, office@open-tools.net
* @license GPL v3+, http://www.gnu.org/copyleft/gpl.html
*/
defined('DS') or define('DS', DIRECTORY_SEPARATOR);
......@@ -89,6 +89,10 @@ class plgVmExtendedEuRecapInstallerScript
*/
public function uninstall(JAdapterInstance $adapter)
{
$db = JFactory::getDBO();
$q = "DELETE FROM `#__virtuemart_adminmenuentries` WHERE `view` = 'eurecap' AND `task` = '' AND `module_id` = 2";
$db->setQuery($q);
$db->query();
// // Remove plugin table
// $db =& JFactory::getDBO();
// $db->setQuery('DROP TABLE IF EXISTS `#__virtuemart_shopper_plg_ordernumber`;');
......
......@@ -22,7 +22,8 @@
<folder>controllers</folder>
<folder>models</folder>
<folder>views</folder>
<folder>helpers</folder>
<folder>fields</folder>
<folder>elements</folder>
</files>
<scriptfile>eurecap.script.php</scriptfile>
<languages folder="language">
......@@ -38,10 +39,10 @@
<field name="order_status" type="orderstatus" default="C,S" multiple="multiple" label="VMEXT_EU_RECAP_ORDERSTATUS" description="VMEXT_EU_RECAP_ORDERSTATUS_DESC "/>
<field name="shopper_groups" type="vmshoppergroups" multiple="multiple" label="VMEXT_EU_RECAP_SHOPPERGROUP" description="VMEXT_EU_RECAP_SHOPPERGROUP_DESC" />
<field name="vatid_userfield" type="vmuserfields" label="VMEXT_EU_RECAP_VATID_USERFIELD" multiple="multiple" default="opc_vat" description="VMEXT_EU_RECAP_VATID_USERFIELD_DESC" />
<field name="include_taxed_orders" type="radio" default="0" class="btn-group btn-group-yesno" label="VMEXT_EU_RECAP_INCLUDE_TAXED" description="VMEXT_EU_RECAP_INCLUDE_TAXED_DESC" >
<!-- <field name="include_taxed_orders" type="radio" default="0" class="btn-group btn-group-yesno" label="VMEXT_EU_RECAP_INCLUDE_TAXED" description="VMEXT_EU_RECAP_INCLUDE_TAXED_DESC" >
<option value="1">JYES</option>
<option value="0">JNO</option>
</field>
</field>-->
<field name="include_free" type="radio" default="0" class="btn-group btn-group-yesno" label="VMEXT_EU_RECAP_INCLUDE_FREE" description="VMEXT_EU_RECAP_INCLUDE_FREE_DESC" >
<option value="1">JYES</option>
<option value="0">JNO</option>
......@@ -59,11 +60,12 @@
<!-- <option value="payment">VMEXT_EU_RECAP_TAXATION_MOMENT_PAYMENT</option> -->
<option value="invoice">VMEXT_EU_RECAP_TAXATION_MOMENT_INVOICE</option>
</field>
<field name="export_format" type="list" default="full" label="VMEXT_EU_RECAP_EXPORT_FORMAT" description="VMEXT_EU_RECAP_EXPORT_FORMAT_DESC" >
<!-- <field name="export_format" type="list" default="full" label="VMEXT_EU_RECAP_EXPORT_FORMAT" description="VMEXT_EU_RECAP_EXPORT_FORMAT_DESC" >
<option value="full">VMEXT_EU_RECAP_EXPORT_FULL</option>
<option value="AT_xml">VMEXT_EU_RECAP_EXPORT_AT_XML</option>
<option value="DE_csv">VMEXT_EU_RECAP_EXPORT_DE_CSV</option>
</field>
<option value="SK_xml">VMEXT_EU_RECAP_EXPORT_SK_XML</option>
</field>-->
<field name="vendor_vatid" type="text" scope="com_virtuemart" default="" label="VMEXT_EU_RECAP_VENDOR_VATID" description="VMEXT_EU_RECAP_VENDOR_VATID_DESC"/>
<field name="taxnr" type="text" scope="com_virtuemart" default="" label="VMEXT_EU_RECAP_TAXNR" description="VMEXT_EU_RECAP_TAXNR_DESC"/>
</fieldset>
......@@ -78,10 +80,10 @@
<param name="order_status" type="vmorderstates" default="C,S" multiple="multiple" label="VMEXT_EU_RECAP_ORDERSTATUS" description="VMEXT_EU_RECAP_ORDERSTATUS_DESC "/>
<param name="shopper_groups" type="vmshoppergroups" multiple="multiple" label="VMEXT_EU_RECAP_SHOPPERGROUP" description="VMEXT_EU_RECAP_SHOPPERGROUP_DESC" />
<param name="vatid_userfield" type="vmuserfields" label="VMEXT_EU_RECAP_VATID_USERFIELD" multiple="multiple" default="opc_vat" description="VMEXT_EU_RECAP_VATID_USERFIELD_DESC" />
<param name="include_taxed_orders" type="radio" default="0" class="btn-group btn-group-yesno" label="VMEXT_EU_RECAP_INCLUDE_TAXED" description="VMEXT_EU_RECAP_INCLUDE_TAXED_DESC" >
<!-- <param name="include_taxed_orders" type="radio" default="0" class="btn-group btn-group-yesno" label="VMEXT_EU_RECAP_INCLUDE_TAXED" description="VMEXT_EU_RECAP_INCLUDE_TAXED_DESC" >
<option value="1">JYES</option>
<option value="0">JNO</option>
</param>
</param>-->
<param name="include_free" type="radio" default="0" class="btn-group btn-group-yesno" label="VMEXT_EU_RECAP_INCLUDE_FREE" description="VMEXT_EU_RECAP_INCLUDE_FREE_DESC" >
<option value="1">JYES</option>
<option value="0">JNO</option>
......@@ -98,11 +100,6 @@
<!-- <option value="payment">VMEXT_EU_RECAP_TAXATION_MOMENT_PAYMENT</option> -->
<option value="invoice">VMEXT_EU_RECAP_TAXATION_MOMENT_INVOICE</option>
</param>
<param name="export_format" type="list" default="full" label="VMEXT_EU_RECAP_EXPORT_FORMAT" description="VMEXT_EU_RECAP_EXPORT_FORMAT_DESC" >
<option value="full">VMEXT_EU_RECAP_EXPORT_FULL</option>
<option value="AT_xml">VMEXT_EU_RECAP_EXPORT_AT_XML</option>
<option value="DE_csv">VMEXT_EU_RECAP_EXPORT_DE_CSV</option>
</param>
<param name="vendor_vatid" type="text" scope="com_virtuemart" default="" label="VMEXT_EU_RECAP_VENDOR_VATID" description="VMEXT_EU_RECAP_VENDOR_VATID_DESC"/>
<param name="taxnr" type="text" scope="com_virtuemart" default="" label="VMEXT_EU_RECAP_TAXNR" description="VMEXT_EU_RECAP_TAXNR_DESC"/>
</params>
......
......@@ -5,8 +5,10 @@ COM_VIRTUEMART_EU_RECAP="EU Sales Report"
; COM_VIRTUEMART_EU_RECAP="EU Recapitulative Statement"
VMEXT_EU_RECAP_SETTINGS_TITLE="Configuration of the EU Sales Report"
VMEXT_EU_RECAP_VIEW_TITLE_DATE="EU Sales Report for the period from %s to %s"
VMEXT_EU_RECAP_VIEW_EXPLANATION="EU-based businesses selling to other businesses providing a valid EU VAT ID do not have to charge VAT for these sales (&quot;reverse charge&quot;). However, merchants regularly have to report those untaxed sales by submitting a list of VAT IDs and the total order amount for each VAT ID in the so-called EU Sales report or EU Recapitulative Statement. This component helps extracting and exporting this list. It is your responsibility to cross-check the generated file for correctness. We are not tax advisors and cannot take any responsibility for wrong submissions."
VMEXT_EU_RECAP_LIST_MONTH="Period"
VMEXT_EU_RECAP_LIST_PERIOD="Period: "
VMEXT_EU_RECAP_LIST_YEAR="Year"
; VMEXT_EU_RECAP_RECHECK_EUVATID="(Re-)Check EU VAT IDs"
......@@ -14,13 +16,15 @@ VMEXT_EU_RECAP_SETTINGS="Settings"
COM_VIRTUEMART_EU_RECAP_SETTINGS="Settings"
COM_VIRTUEMART_EU_RECAP_LIST="Report"
VMEXT_EU_RECAP_EXPORT="Export"
VMEXT_EU_RECAP_EXPORT_FULL="Full dataset (country-independend), CSV format"
VMEXT_EU_RECAP_EXPORT_FULL="Full dataset (country-independent), CSV format"
VMEXT_EU_RECAP_EXPORT_AT_XML="Austrian XML format"
VMEXT_EU_RECAP_EXPORT_DE_CSV="German CSV format"
VMEXT_EU_RECAP_EXPORT_SK_XML="Slovak XML format"
VMEXT_EU_RECAP_EXPORT_TB_FULL="Export (full, csv)"
VMEXT_EU_RECAP_EXPORT_TB_AT_XML="Export (AT, xml)"
VMEXT_EU_RECAP_EXPORT_TB_DE_CSV="Export (DE, csv)"
VMEXT_EU_RECAP_EXPORT_TB_SK_XML="Export (SK, xml)"
VMEXT_EU_RECAP_FORM_NOTFOUND="Configuration form not available"
......@@ -36,7 +40,7 @@ VMEXT_EU_RECAP_INCLUDE_TAXED="Include sales that were taxed"
VMEXT_EU_RECAP_INCLUDE_TAXED_DESC="Select whether to also include sales where VAT was charged, even though a (possibly invalid) VATID was given."
VMEXT_EU_RECAP_INCLUDE_FREE="Include free orders"
VMEXT_EU_RECAP_INCLUDE_FREE_DESC="Select whether all orders are included or only orders with an order total larger than 0. In the first case, all free orders will also be included."
VMEXT_EU_RECAP_EXPORT_FORMAT="Export format"
VMEXT_EU_RECAP_EXPORT_FORMAT="Default export format"
VMEXT_EU_RECAP_EXPORT_FORMAT_DESC="Select the format for the data export. Several countries have their own custom format that needs to be used to import the report into the official tax rporting system."
VMEXT_EU_RECAP_REPORTSETTINGS="General Settings for the EU Sales Report"
VMEXT_EU_RECAP_FREQUENCY="Frequency of the Report"
......
......@@ -5,8 +5,10 @@ COM_VIRTUEMART_EU_RECAP="EU Sales Report"
; COM_VIRTUEMART_EU_RECAP="EU Recapitulative Statement"
VMEXT_EU_RECAP_SETTINGS_TITLE="Configuration of the EU Sales Report"
VMEXT_EU_RECAP_VIEW_TITLE_DATE="EU Sales Report for the period from %s to %s"
VMEXT_EU_RECAP_VIEW_EXPLANATION="EU-based businesses selling to other businesses providing a valid EU VAT ID do not have to charge VAT for these sales (&quot;reverse charge&quot;). However, merchants regularly have to report those untaxed sales by submitting a list of VAT IDs and the total order amount for each VAT ID in the so-called EU Sales report or EU Recapitulative Statement. This component helps extracting and exporting this list. It is your responsibility to cross-check the generated file for correctness. We are not tax advisors and cannot take any responsibility for wrong submissions."
VMEXT_EU_RECAP_LIST_MONTH="Period"
VMEXT_EU_RECAP_LIST_PERIOD="Period: "
VMEXT_EU_RECAP_LIST_YEAR="Year"
; VMEXT_EU_RECAP_RECHECK_EUVATID="(Re-)Check EU VAT IDs"
......@@ -14,13 +16,15 @@ VMEXT_EU_RECAP_SETTINGS="Settings"
COM_VIRTUEMART_EU_RECAP_SETTINGS="Settings"
COM_VIRTUEMART_EU_RECAP_LIST="Report"
VMEXT_EU_RECAP_EXPORT="Export"
VMEXT_EU_RECAP_EXPORT_FULL="Full dataset (country-independend), CSV format"
VMEXT_EU_RECAP_EXPORT_FULL="Full dataset (country-independent), CSV format"
VMEXT_EU_RECAP_EXPORT_AT_XML="Austrian XML format"
VMEXT_EU_RECAP_EXPORT_DE_CSV="German CSV format"
VMEXT_EU_RECAP_EXPORT_SK_XML="Slovak XML format"
VMEXT_EU_RECAP_EXPORT_TB_FULL="Export (full, csv)"
VMEXT_EU_RECAP_EXPORT_TB_AT_XML="Export (AT, xml)"
VMEXT_EU_RECAP_EXPORT_TB_DE_CSV="Export (DE, csv)"
VMEXT_EU_RECAP_EXPORT_TB_SK_XML="Export (SK, xml)"
VMEXT_EU_RECAP_FORM_NOTFOUND="Configuration form not available"
......@@ -36,7 +40,7 @@ VMEXT_EU_RECAP_INCLUDE_TAXED="Include sales that were taxed"
VMEXT_EU_RECAP_INCLUDE_TAXED_DESC="Select whether to also include sales where VAT was charged, even though a (possibly invalid) VATID was given."
VMEXT_EU_RECAP_INCLUDE_FREE="Include free orders"
VMEXT_EU_RECAP_INCLUDE_FREE_DESC="Select whether all orders are included or only orders with an order total larger than 0. In the first case, all free orders will also be included."
VMEXT_EU_RECAP_EXPORT_FORMAT="Export format"
VMEXT_EU_RECAP_EXPORT_FORMAT="Default export format"
VMEXT_EU_RECAP_EXPORT_FORMAT_DESC="Select the format for the data export. Several countries have their own custom format that needs to be used to import the report into the official tax rporting system."
VMEXT_EU_RECAP_REPORTSETTINGS="General Settings for the EU Sales Report"
VMEXT_EU_RECAP_FREQUENCY="Frequency of the Report"
......
......@@ -135,7 +135,8 @@ class VirtuemartModelEuRecap extends VmModel {
if ($settings['include_free']==0) {
$where[] = "`o`.`order_total` > 0";
}
if ($settings['include_taxed_orders']==0) {
$include_taxed_orders = vRequest::getVar('include_taxed_orders', 0);
if (!$include_taxed_orders) {
$where[] = "`o`.`order_tax` = 0";
}
$where[] = '`ui`.`address_type` = "BT"';
......@@ -247,5 +248,24 @@ class VirtuemartModelEuRecap extends VmModel {
$listHTML = JHtml::_ ('select.genericlist', $options, 'year', 'size="7" class="inputbox" onchange="this.form.submit();" ', 'text', 'value', $selected);
return $listHTML;
}
public function renderExportFormatList($pathes=array(), $selected='full') {
jimport('joomla.filesystem.folder');
$templates = array();
foreach ($pathes as $tmplpath) {
if (!JFolder::exists($tmplpath)) continue;
$templates = array_merge($templates, JFolder::files($tmplpath, 'export_.*\.php'));
}
sort($templates, SORT_STRING);
$templates = array_unique($templates);
foreach ($templates as $tmpl) {
$value = substr($tmpl, 7, -4); // Cut off export_ and .php
$options[] = JHtml::_('select.option', vmText::_('VMEXT_EU_RECAP_EXPORT_' . strtoupper($value)), $value);
}
$listHTML = JHtml::_ ('select.genericlist', $options, 'export_format', 'size="7" class="inputbox" ', 'text', 'value', $selected);
return $listHTML;
}
}
......@@ -63,8 +63,9 @@ class VirtuemartModelEuRecap_config extends VmModel {
$registry->loadString($settings_str);
// Take the settings and load all missing values from the defaults in the xml file:
$settings = $registry->toArray();
$form = JForm::getInstance('eurecap-vmconfig', $path, array(), false, '//vmconfig | //config[not(//vmconfig)]');
// $form = vmPlugin::loadConfigForm($path, 'eurecap');
$form = vmPlugin::loadConfigForm($path, 'eurecap');
$form->bind(array('settings'=>$settings));
$fieldSets = $form->getFieldsets();
foreach ($fieldSets as $name => $fieldSet) {
......
......@@ -26,23 +26,38 @@ $myCurrencyDisplay = CurrencyDisplay::getInstance();
?>
<pre><?php print_r(vRequest::getRequest()); ?></pre>
<form action="index.php" method="post" name="adminForm" id="adminForm">
<?php echo $this->addStandardHiddenToForm(); ?>
<div id="header">
<h2><?php echo vmText::sprintf('VMEXT_EU_RECAP_VIEW_TITLE_DATE', vmJsApi::date( $this->from_period, 'LC',true) , vmJsApi::date( $this->until_period, 'LC',true) ); ?></h2>
<p><?php echo vmText::_('VMEXT_EU_RECAP_VIEW_EXPLANATION'); ?> </p>
<div id="filterbox">
<table>
<tr>
<td align="left" width="100%">
<?php if ($this->frequency<12) {
echo vmText::_('VMEXT_EU_RECAP_LIST_MONTH') . $this->period_lists['month_list'];
} ?>
<?php echo vmText::_('VMEXT_EU_RECAP_LIST_YEAR') . $this->period_lists['year_list'];
<table width="100%">
<tr width="100%">
<td align="left">
<?php
echo vmText::_('VMEXT_EU_RECAP_LIST_PERIOD');
if ($this->frequency<12) {
echo $this->period_lists['month_list'];
}
echo $this->period_lists['year_list'];
if(VmConfig::get('multix','none')!='none'){
$vendorId = vRequest::getInt('virtuemart_vendor_id',1);
echo ShopFunctions::renderVendorList($vendorId,false);
} ?>
<button class="btn btn-small" onclick="this.form.submit();"><?php echo vmText::_('COM_VIRTUEMART_GO'); ?>
} ?><br>
<label><input type="checkbox" <?php if ($this->include_taxed_orders) { ?>checked <?php } ?> name="include_taxed_orders" value="true" style=" vertical-align: middle; position: relative; bottom: 1px;">&nbsp;&nbsp;&nbsp;<?php echo vmText::_('VMEXT_EU_RECAP_INCLUDE_TAXED'); ?></label>
</td>
<td align="left" width="5%">
<button class="btn btn-small" name="Go" onclick="this.form.task.value=''; this.form.submit();"><?php echo vmText::_('COM_VIRTUEMART_GO'); ?></button>
</td>
<td width="30%"></td>
<td align="right" width>
<?php echo $this->export_format_list; ?>
<button class="btn btn-small" name="format" value="raw" onclick="this.form.task.value='export'; this.form.submit();"><?php echo vmText::_('VMEXT_EU_RECAP_EXPORT'); ?>
</button>
</td>
</tr>
......@@ -75,9 +90,11 @@ $myCurrencyDisplay = CurrencyDisplay::getInstance();
<th>
<?php echo $this->sort('`sum_order_total`', 'VMEXT_EU_RECAP_ORDERTOTALS') ; ?>
</th>
<?php if ($this->include_taxed_orders) { ?>
<th>
<?php echo $this->sort('`sum_order_tax`', 'VMEXT_EU_RECAP_ORDERTAXES') ; ?>
</th>
<?php } ?>
</tr>
</thead>
<tbody>
......@@ -130,9 +147,11 @@ $myCurrencyDisplay = CurrencyDisplay::getInstance();
<td align="right">
<?php echo $myCurrencyDisplay->priceDisplay($r['sum_order_total']); ?>
</td>
<?php if ($this->include_taxed_orders) { ?>
<td align="right">
<?php echo $myCurrencyDisplay->priceDisplay($r['sum_order_tax']); ?>
</td>
<?php } ?>
</tr>
<?php
$i = 1-$i;
......@@ -149,7 +168,6 @@ $myCurrencyDisplay = CurrencyDisplay::getInstance();
</table>
</div>
<?php echo $this->addStandardHiddenToForm(); ?>
</form>
<?php AdminUIHelper::endAdminArea(); ?>
......
......@@ -22,6 +22,7 @@ if(!defined('VM_VERSION') or VM_VERSION < 3){
// VM2 has class VmView instead of VmViewAdmin:
if(!class_exists('VmView')) require(VMPATH_ADMIN.DS.'helpers'.DS.'vmview.php');
class VmViewAdmin extends VmView {}
defined ('VMPATH_PLUGINLIBS') or define ('VMPATH_PLUGINLIBS', JPATH_VM_PLUGINS);
} else {
if(!class_exists('VmViewAdmin')) require(VMPATH_ADMIN.DS.'helpers'.DS.'vmviewadmin.php');
}
......@@ -119,6 +120,16 @@ class VirtuemartViewEuRecap extends VmViewAdmin {
// $bar->appendButton('Link', 'export', 'VMEXT_EU_RECAP_FULLEXPORT', 'index.php?option=com_virtuemart&view=eurecap&task=export&format=raw&layout=export_full&month='.$month.'&year='.$year);
$bar->appendButton('Link', 'export', 'VMEXT_EU_RECAP_EXPORT_TB_' . $settings['export_format'], 'index.php?option=com_virtuemart&view=eurecap&task=export&format=raw&layout=export&month='.$month.'&year='.$year);
$user = JFactory::getUser();
if($user->authorise('core.admin', 'com_virtuemart') or $user->authorise('core.manager', 'com_virtuemart')){
$vendorId = vRequest::getInt('virtuemart_vendor_id');
} else {
$vendorId = VmConfig::isSuperVendor();
}
$vendorModel = VmModel::getModel('vendor');
$vendor = $vendorModel->getVendor($vendorId);
$vendor->vendorFields = $vendorModel->getVendorAddressFields($vendorId);
$this->assignRef('vendor', $vendor);
$this->frequency = $settings['frequency'];
$period_list = array();
......@@ -131,12 +142,15 @@ class VirtuemartViewEuRecap extends VmViewAdmin {
$this->assignRef('from', $model->from);
$this->assignRef('until', $model->until);
$this->include_taxed_orders = vRequest::getVar('include_taxed_orders', 0);
$this->addStandardDefaultViewLists($model);
$euIntracommunityRevenue = $model->getEuRecap();
$this->assignRef('report', $euIntracommunityRevenue);
$this->assignRef('export_format', $settings['export_format']);
$this->export_format_list = $model->renderExportFormatList($this->_path['template'], $settings['export_format']);
// $this->assignRef('export_format', $settings['export_format']);
$pagination = $model->getPagination();
$this->assignRef('pagination', $pagination);
......@@ -152,7 +166,8 @@ class VirtuemartViewEuRecap extends VmViewAdmin {
$path = VMPATH_ROOT .DS. 'plugins' .DS. 'vmextended' . DS . $this->getName() . DS . $this->getName() . '.xml';
if (file_exists($path)){
$form = vmPlugin::loadConfigForm($path, $this->getName());
// $form = vmPlugin::loadConfigForm($path, $this->getName());
$form = JForm::getInstance($this->getName().'-vmconfig', $path, array(), false, '//vmconfig | //config[not(//vmconfig)]');
// load config
$eurecapSettingsModel = VmModel::getModel("eurecap_config");
......
......@@ -63,6 +63,22 @@ class VirtuemartViewEuRecap extends VmViewAdmin {
$this->assignRef('settings', $settings);
$user = JFactory::getUser();
if($user->authorise('core.admin', 'com_virtuemart') or $user->authorise('core.manager', 'com_virtuemart')){
$vendorId = vRequest::getInt('virtuemart_vendor_id');
} else {
$vendorId = VmConfig::isSuperVendor();
}
$vendorModel = VmModel::getModel('vendor');
$vendor = $vendorModel->getVendor($vendorId);
$vendor->vendorFields = $vendorModel->getVendorAddressFields($vendorId);
$this->assignRef('vendor', $vendor);
$oldformat = isset($settings['export_format'])?$settings['export_format']:'full';
$settings['export_format'] = vRequest::getVar('export_format', $oldformat);
if ($oldformat != $settings['export_format'])
$settingsModel->saveConfig(array('settings'=>$settings));
$this->assignRef('export_format', $settings['export_format']);
parent::display($tpl);
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment