<?php

/**
 * @version        1.9.7
 * @package        Joomla
 * @subpackage     Edocman
 * @author         Tuan Pham Ngoc
 * @copyright      Copyright (C) 2011 - 2024 Ossolution Team
 * @license        GNU/GPL, see LICENSE.php
 */

// No direct access.
defined('_JEXEC') or die();
use Joomla\CMS\Language\Text;

class EDocmanControllerImport extends EDocmanController
{
	/**
	 * Import documents from a specific folder
	 *
	 * @return bool|void
	 */
	public function save()
	{
		$model = $this->getModel('import');
		$data  = $this->input->post->getData();
		if($model->store($data))
		{
			$url = 'index.php?option=com_edocman&view=documents';
			$msg = Text::_('EDOCMAN_DOCUMENTS_IMPORTED');
			$this->setRedirect($url, $msg);
		}
		else
		{
			$url = 'index.php?option=com_edocman&view=import';
			$msg = Text::_('EDOCMAN_YOU_SHOULD_SELECT_CATEGORY_FIRST');
			$this->setRedirect($url, $msg);
		}
	}

	/**
	 * Cancel import action, redirect user to documents management screen
	 *
	 * @return bool|void
	 */
	public function cancel()
	{
		$this->setRedirect('index.php?option=com_edocman&view=documents');
	}
}
