<?php
/*
 * @component Calc Builder 
 * @copyright Copyright (C) January 2017. 
 * @license GPL 3.0 
 * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. 
 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 
 * See the GNU General Public License for more details. 
 * See <http://www.gnu.org/licenses/>. 
 * More info www.moonsoft.es 
 * gestion@moonsoft.es
 */

// No direct access
defined ( '_JEXEC' ) or die ( 'Restricted access' );
class CalcbuilderControllerCalcbuilder extends CalcbuilderController {
	/**
	 * constructor (registers additional tasks to methods)
	 * 
	 * @return void
	 */
	function __construct() {
		parent::__construct ();
	}
	
	/**
	 * display the edit form
	 * 
	 * @return void
	 */
	function show() {
		JSession::checkToken ( 'request' ) or die ( 'Invalid Token' );
		// Check security field
		$session = JFactory::getSession ();
		$inputname = $session->get ( 'CB_SS_225541' );
		$valss = MSHelper::__requestGetVarWrapper ( $inputname, null );
		if ($valss != null) {
			JError::raiseError ( 500, JText::_ ( 'INTERNAL SERVER ERROR' ) );
		}
		MSHelper::__requestSetVarWrapper ( 'layout', 'default' );
		MSHelper::__requestSetVarWrapper ( 'view', 'calcbuilder' );
		parent::display ();
	}
	function showPdf() {
		JSession::checkToken ( 'request' ) or die ( 'Invalid Token' );
		MSHelper::__requestSetVarWrapper ( 'layout', 'pdf' );
		MSHelper::__requestSetVarWrapper ( 'view', 'calcbuilder' );
		parent::display ();
	}
	function showExcel() {
		JSession::checkToken ( 'request' ) or die ( 'Invalid Token' );
		MSHelper::__requestSetVarWrapper ( 'layout', 'excel' );
		MSHelper::__requestSetVarWrapper ( 'view', 'calcbuilder' );
		parent::display ();
	}
	function sendEmail() {
		JSession::checkToken ( 'request' ) or die ( 'Invalid Token' );
		MSHelper::__requestSetVarWrapper ( 'layout', 'email' );
		MSHelper::__requestSetVarWrapper ( 'view', 'calcbuilder' );
		parent::display ();
	}
	function calcinline() {
		JSession::checkToken ( 'request' ) or die ( 'Invalid Token' );
		MSHelper::__requestSetVarWrapper ( 'layout', 'calcinline' );
		MSHelper::__requestSetVarWrapper ( 'view', 'calcbuilder' );
		parent::display ();
	}
	
	function calcsqlinline(){
		JSession::checkToken ( 'request' ) or die ( 'Invalid Token' );
		MSHelper::__requestSetVarWrapper ( 'layout', 'calcsqlinline' );
		MSHelper::__requestSetVarWrapper ( 'view', 'calcbuilder' );
		parent::display ();
	}
	
	function upload() {
		// Error with token
		$model = $this->getModel ();
		$res = $model->upload ();
		return $res ? '0' : '1';
	}
	
	/*SHPInit*/
	function getVMProductId(){
		JSession::checkToken('request') or die( 'Invalid Token' );
		MSHelper::__requestSetVarWrapper( 'layout', 'vmproduct'  );
		MSHelper::__requestSetVarWrapper( 'view', 'calcbuilder' );
		parent::display();
	}
	function hikaplugin(){
		JSession::checkToken('request') or die( 'Invalid Token' );
		MSHelper::__requestSetVarWrapper( 'layout', 'hikaplugin'  );
		MSHelper::__requestSetVarWrapper( 'view', 'calcbuilder' );
		parent::display();
	}	
	/*SHPEnd*/
	
}

?>
