eurecap.php 2.82 KB
Newer Older
Reinhold Kainhofer's avatar
Reinhold Kainhofer committed
1
2
3
4
5
6
7
8
<?php
if( !defined( '_JEXEC' ) ) die( 'Direct Access to '.basename(__FILE__).' is not allowed.' );

/**
*
* @package VirtueMart
* @subpackage EU Recapitulative Statement
* @copyright Copyright (C) 2015 Open Tools, Reinhold Kainhofer.
9
* @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.txt
Reinhold Kainhofer's avatar
Reinhold Kainhofer committed
10
11
12
13
14
15
16
17
* VirtueMart is free software. This version may have been modified pursuant
* to the GNU General Public License, and as distributed it includes or
* is derivative of works licensed under the GNU General Public License or
* other free or open source software licenses.
*
* http://www.open-tools.net
*/

18
19
defined ('VMPATH_ADMIN') or define ('VMPATH_ADMIN', JPATH_VM_ADMINISTRATOR);
if(!class_exists('VmController')) require(VMPATH_ADMIN.DS.'helpers'.DS.'vmcontroller.php');
Reinhold Kainhofer's avatar
Reinhold Kainhofer committed
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39


/**
 * Report Controller
 *
 * @package	VirtueMart
 * @subpackage Report
 * @author Open Tools, Reinhold Kainhofer
 */
class VirtuemartControllerEuRecap extends VmController {

	/**
	 * Report Controller Constructor
	 */
	function __construct(){
		parent::__construct();
		// Add the proper view pathes...
		$this->addViewPath(JPATH_PLUGINS.DS . 'vmextended' . DS . 'eurecap' . DS . 'views');
	}

40
41
42
43
44
	public function cancel(){
		$msg = vmText::_('VMEXT_EU_RECAP_CANCELLED');
		$this->setRedirect($this->redirectPath, $msg, 'message');
	}

Reinhold Kainhofer's avatar
Reinhold Kainhofer committed
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
	function settings($layout='settings'){

		vRequest::setVar('controller', $this->_cname);
		vRequest::setVar('view', $this->_cname);
		vRequest::setVar('layout', $layout);

		$document = JFactory::getDocument();
		$viewType = $document->getType();
		$view = $this->getView($this->_cname, $viewType);

		$view->setLayout($layout);

		$this->display();
	}

60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
	function display($layout='') {
		if (vRequest::getVar('format')=='raw') {
			// Raw forman means "Export"!!!
			// Ideally, we would use an export task, but unfortunately
			// we cannot both set format=raw and task=export in the export
			// button. format=raw MUST be set, because otherwise a HTML
			// document is initialized by default!
			$layout = 'export';

			$viewName = $this->_cname;
			vRequest::setVar('controller', $viewName);
			vRequest::setVar('view', $viewName);
			vRequest::setVar('layout', $layout); // Set the layout to export!

			$document = JFactory::getDocument();
			$viewType = $document->getType();
			$view = $this->getView($viewName, $viewType);
			$view->writeJs = false;
			$view->setLayout($layout);
		}
Reinhold Kainhofer's avatar
Reinhold Kainhofer committed
80

81
		return parent::display($layout);
Reinhold Kainhofer's avatar
Reinhold Kainhofer committed
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
	}

	/**
	 * Handle the save task
	 */
	function save($data = 0){
		vRequest::vmCheckToken();
		$data = vRequest::getPost();
		$model = VmModel::getModel('eurecap_config');
		$model->saveConfig($data);

		$msg = vmText::_('COM_VIRTUEMART_CONFIG_SAVED');
		$redir = $this->redirectPath;
		if(vRequest::getCmd('task') == 'apply'){
			$redir = $redir . '&task=settings';
		}
		$this->setRedirect($redir, $msg);

	}
}
// pure php no closing tag