<?php
/**
 * @version        1.11.6
 * @package        Joomla
 * @subpackage     EDocman
 * @author         Tuan Pham Ngoc
 * @copyright      Copyright (C) 2011 - 2025 Ossolution Team
 * @license        GNU/GPL, see LICENSE.php
 */
 
use Joomla\CMS\HTML\HTMLHelper;
use Joomla\CMS\Language\Text;
use Joomla\CMS\Router\Route;
use Joomla\CMS\Toolbar\Toolbar;
use Joomla\CMS\Layout\FileLayout;
use Joomla\CMS\Filesystem\File;
use Joomla\CMS\Factory;
use Joomla\CMS\Uri\Uri;

HTMLHelper::_('bootstrap.tooltip');
if(!EdocmanHelper::isJoomla4())
{
	HTMLHelper::_('formbehavior.chosen', 'select');
}
$user	        = Factory::getApplication()->getIdentity();
$userId	        = $user->id;
$listOrder	    = $this->state->filter_order;
$listDirn	    = $this->state->filter_order_Dir;
$saveOrder	    = $listOrder == 'tbl.ordering';
$config 	    = $this->config;

$toolbar        = Toolbar::getInstance('toolbar');

if(!EdocmanHelper::isJoomla4())
{
	$layout         = new FileLayout('joomla.toolbar.popup');
	// Render the popup button
	$dhtml          = $layout->render(array('doTask' => 'movingcategory', 'name' => 'movingcategory', 'text' => Text::_('EDOCMAN_MOVE'), 'class' => 'icon-move'));
	$toolbar->appendButton('Custom', $dhtml, 'btn');
	$dhtml          = $layout->render(array('doTask' => 'movingcategory1', 'name' => 'movingcategory1', 'text' => Text::_('EDOCMAN_MOVE_ADD_CAT'), 'class' => 'icon-list'));
	$toolbar->appendButton('Custom', $dhtml );
}

// Add a batch button
if ($user->authorise('core.admin', 'com_edocman'))
{
    $title = Text::_('JTOOLBAR_BATCH');

    // Instantiate a new JLayoutFile instance and render the batch button
    $layout     = new FileLayout('joomla.toolbar.batch');
    $dhtml      = $layout->render(array('title' => $title));
    $toolbar->appendButton('Custom', $dhtml, 'batch');
}
if($this->indexer == 1 && !EdocmanHelper::isJoomla4())
{
	$toolbar->appendButton('Standard','remove',Text::_('EDOCMAN_EXCLUDE_INDEXING'),'document.excluding_indexing',true);
}


if ($saveOrder)
{
	$saveOrderingUrl = 'index.php?option=com_edocman&task=document.save_order_ajax';
	HTMLHelper::_('sortablelist.sortable', 'documentList', 'adminForm', strtolower($listDirn), $saveOrderingUrl);
}


$customOptions = array(
	'filtersHidden'       => true,
	'defaultLimit'        => Factory::getApplication()->get('list_limit', 20),
	'searchFieldSelector' => '#filter_search',
	'orderFieldSelector'  => '#filter_full_ordering'
);
HTMLHelper::_('searchtools.form', '#adminForm', $customOptions);

$bootstrapHelper		= $this->bootstrapHelper;
$rowFluidClass			= $bootstrapHelper->getClassMapping('row-fluid');
$span12Class			= $bootstrapHelper->getClassMapping('span12');
?>

<script type="text/javascript">
    /*
	Joomla.submitbutton = function(task)
	{

		if (task == 'add') 
		{			
			var form = document.adminForm ;
			if (form.filter_category_id.value == 0)
			{
				alert("<?php echo Text::_('EDOCMAN_CHOOSE_CAT_TO_ADD_DOCUMENTS'); ?>");
			}
		}
	}
	*/
</script>
<?php
if(EdocmanHelper::isJoomla4())
{
	$searchBtnClass = "btn-primary";
	$cancelSearchBtnClass = "btn-secondary";
	HTMLHelper::_('draggablelist.draggable');
	Factory::getApplication()->getDocument()->getWebAssetManager()
					->useScript('table.columns')
					->useScript('multiselect');
}
else
{
	$searchBtnClass = "";
	$cancelSearchBtnClass = "";
	HTMLHelper::_('behavior.multiselect');
}

?>
<form action="<?php echo Route::_('index.php?option=com_edocman&view=documents'); ?>" method="post" name="adminForm" id="adminForm">
	<div class="<?php echo $rowFluidClass;?>">
		<div class="<?php echo $span12Class;?>">
			<?php
			if(EdocmanHelper::isJoomla4())
			{
			?>
				<div class="js-stools" role="search">
					<div class="js-stools-container-bar">
						<div id="filter-bar" class="btn-toolbar">
							<div class="btn-group">
								<div class="input-group input-append">
									<input type="text" name="filter_search" id="filter_search" placeholder="<?php echo Text::_('JSEARCH_FILTER'); ?>" value="<?php echo $this->escape($this->state->filter_search); ?>" class="hasTooltip input-medium form-control" title="<?php echo HTMLHelper::tooltipText('EDOCMAN_FILTER_SEARCH_DOCUMENTS_DESC'); ?>" inputmode="search" aria-describedby="filter_search-desc"/>
									
									<button type="submit" class="btn <?php echo $searchBtnClass;?> hasTooltip" title="<?php echo HTMLHelper::tooltipText('JSEARCH_FILTER_SUBMIT'); ?>"><span class="icon-search"></span></button>
									
								</div>
							</div>
							<div class="btn-group">
								<button type="button" class="btn btn-primary js-stools-btn-filter">
									Filter Options	<span class="icon-angle-down" aria-hidden="true"></span>
								</button>
								<button type="button" class="btn <?php echo $cancelSearchBtnClass; ?> hasTooltip js-stools-btn-clear" title="<?php echo HTMLHelper::tooltipText('JSEARCH_FILTER_CLEAR'); ?>" onclick="document.getElementById('filter_search').value='';document.getElementById('creator').value='';document.getElementById('filter_category_id').value='0';document.getElementById('filter_state').value='';document.getElementById('filter_orphan_state').value='';document.getElementById('filter_missing_files').value='-1';this.form.submit();"><span class="icon-remove"></span></button>
							</div>
							<div class="ordering-select">
								<div class="js-stools-field-list">
									<?php
									echo $this->pagination->getLimitBox();
									?>
								</div>
							</div>
						</div>
					</div>
					<div class="js-stools-container-filters clearfix <?php echo $this->showFilterForm;?>">
						<div class="js-stools-field-filter">
							<?php
								echo $this->lists['creator'];
							?>
						</div>
						<div class="js-stools-field-filter">
							<?php
								//echo $this->lists['filter_category_id'];
								
									echo EdocmanHelper::getChoicesJsSelect($this->lists['filter_category_id']);
								
							?>
						</div>
						<?php
						if ($this->config->activate_multilingual_feature)
						{
							?>
							<div class="js-stools-field-filter">
							<?php
								echo $this->lists['filter_language'];
							?>
							</div>
							<?php
						}
						?>
						<div class="js-stools-field-filter">
						<?php
							echo $this->lists['filter_state'];
						?>
						</div>
						<div class="js-stools-field-filter">
						<?php
							echo $this->lists['filter_orphan_state'];
						?>
						</div>
						<?php
						if(!EdocmanHelper::isDropBoxTurnedOn() && !EDocmanHelper::isAmazonS3TurnedOn() && !EDocmanHelper::isGdriveTurnedOn())
						{
						?>
							<div class="js-stools-field-filter">
							<?php
								echo $this->lists['filter_missing_files'];
							?>
							</div>
						<?php
						}
						?>
						<div class="js-stools-field-filter">
							<?php echo HTMLHelper::_('calendar', Factory::getApplication()->getInput()->getString('start_date',''), 'start_date', 'start_date','%Y-%m-%d', array('class' => 'input-small form-control ishort','placeholder' => Text::_('JGLOBAL_FIELD_PUBLISH_UP_LABEL'))) ; ?>
						</div>
						<div class="js-stools-field-filter">
							<?php echo HTMLHelper::_('calendar', Factory::getApplication()->getInput()->getString('end_date',''), 'end_date', 'end_date','%Y-%m-%d', array('class' => 'input-small form-control ishort', 'placeholder' => Text::_('JGLOBAL_FIELD_PUBLISH_DOWN_LABEL'))) ; ?>
						</div>
						<div class="js-stools-field-filter">
							<?php echo $this->lists['filter_created_on']; ?>
						</div>
					</div>
				</div>
			<?php
			}
			else
			{
			?>
				<div class="js-stools clearfix" role="search">
					<div class="clearfix">
						<div class="js-stools-container-bar">
							<div id="filter-bar" class="js-stools-container-bar">
								<div class="btn-wrapper input-append">
									<input type="text" name="filter_search" id="filter_search" placeholder="<?php echo Text::_('JSEARCH_FILTER'); ?>" value="<?php echo $this->escape($this->state->filter_search); ?>" class="hasTooltip input-medium form-control" title="<?php echo HTMLHelper::tooltipText('EDOCMAN_FILTER_SEARCH_DOCUMENTS_DESC'); ?>" inputmode="search" aria-describedby="filter_search-desc"/>
									
									<button type="submit" class="btn <?php echo $searchBtnClass;?> hasTooltip" title="<?php echo HTMLHelper::tooltipText('JSEARCH_FILTER_SUBMIT'); ?>"><span class="icon-search"></span></button>
									
								</div>
								<div class="btn-wrapper">
									<button type="button" class="btn hasTooltip js-stools-btn-filter">
										Filter Options	<span class="caret" aria-hidden="true"></span>
									</button>
									<button type="button" class="btn <?php echo $cancelSearchBtnClass; ?> hasTooltip js-stools-btn-clear" title="<?php echo HTMLHelper::tooltipText('JSEARCH_FILTER_CLEAR'); ?>" onclick="document.getElementById('filter_search').value='';document.getElementById('creator').value='';document.getElementById('filter_category_id').value='0';document.getElementById('filter_state').value='';document.getElementById('filter_orphan_state').value='';document.getElementById('filter_missing_files').value='-1';document.getElementById('filter_created_on').value='0';this.form.submit();"><span class="icon-remove"></span></button>
								</div>
							</div>
						</div>
						<div class="js-stools-container-list hidden-phone hidden-tablet shown">
							<div class="js-stools-field-list">
								<?php
								echo $this->pagination->getLimitBox();
								?>
							</div>
						</div>
					</div>
					<div class="js-stools-container-filters clearfix <?php echo $this->showFilterForm;?>">
						<div class="js-stools-field-filter">
							<?php
								echo $this->lists['creator'];
							?>
						</div>
						<div class="js-stools-field-filter">
							<?php
								echo $this->lists['filter_category_id'];
							?>
						</div>
						<?php
						if ($this->config->activate_multilingual_feature)
						{
							?>
							<div class="js-stools-field-filter">
							<?php
								echo $this->lists['filter_language'];
							?>
							</div>
							<?php
						}
						?>
						<div class="js-stools-field-filter">
						<?php
							echo $this->lists['filter_state'];
						?>
						</div>
						<div class="js-stools-field-filter">
						<?php
							echo $this->lists['filter_orphan_state'];
						?>
						</div>
						<?php
						if(!EdocmanHelper::isDropBoxTurnedOn() && !EDocmanHelper::isAmazonS3TurnedOn() && !EDocmanHelper::isGdriveTurnedOn())
						{
						?>
							<div class="js-stools-field-filter">
							<?php
								echo $this->lists['filter_missing_files'];
							?>
							</div>
						<?php
						}
						?>
						<div class="js-stools-field-filter">
							<?php echo HTMLHelper::_('calendar', Factory::getApplication()->getInput()->getString('start_date',''), 'start_date', 'start_date','%Y-%m-%d', array('class' => 'input-small form-control ishort','placeholder' => Text::_('JGLOBAL_FIELD_PUBLISH_UP_LABEL'))) ; ?>
						</div>
						<div class="js-stools-field-filter">
							<?php echo HTMLHelper::_('calendar', Factory::getApplication()->getInput()->getString('end_date',''), 'end_date', 'end_date','%Y-%m-%d', array('class' => 'input-small form-control ishort', 'placeholder' => Text::_('JGLOBAL_FIELD_PUBLISH_DOWN_LABEL'))) ; ?>
						</div>
						<div class="js-stools-field-filter">
							<?php echo $this->lists['filter_created_on']; ?>
						</div>
					</div>
				</div>
			<?php
			}
			?>
		</div>

		<table class="adminlist table table-striped" id="documentList">
			<thead>
				<tr>
					<th width="2%" class="w-1 center">
						<input type="checkbox" name="toggle" value="" onclick="Joomla.checkAll(this);" />
					</th>
					<th scope="col" width="2%" class="w-1 nowrap center hidden-phone">
						<?php echo HTMLHelper::_('searchtools.sort', '', 'tbl.ordering', $listDirn, $listOrder, null, 'asc', 'JGRID_HEADING_ORDERING', 'icon-menu-2'); ?>
					</th>
					<th scope="col" width="5%" class="w-1">
						<?php echo HTMLHelper::_('searchtools.sort',  'JSTATUS', 'tbl.published', $listDirn, $listOrder); ?>
					</th>
					<td scope="col" width="1%" class="w-1">

					</td>
					<th scope="col" style="text-align: left;" width="25%" class="w-3 d-md-table-cell">
						<?php echo HTMLHelper::_('searchtools.sort',  'EDOCMAN_TITLE', 'tbl.title', $listDirn, $listOrder); ?>
					</th>
					<?php
					if(!EdocmanHelper::isJoomla4()) {
					?>
					<th scope="col" style="text-align: left;" width="5%">
						<?php echo Text::_('EDOCMAN_OWNER'); ?>
					</th>
					<?php } ?>
					<th scope="col" width="13%" style="text-align: left;" class="w-3 d-md-table-cell">
						<?php echo HTMLHelper::_('searchtools.sort',  'EDOCMAN_CATEGORY', 'cat.title', $listDirn, $listOrder); ?>
					</th>
					<?php
					if ($this->config->activate_multilingual_feature)
					{
						?>
						<th class="center" width="7%">
							<?php echo HTMLHelper::_('searchtools.sort',  'JFIELD_LANGUAGE_LABEL', 'tbl.language', $this->state->filter_order_Dir, $this->state->filter_order ); ?>
						</th>
						<?php
					}
					?>
					<?php
						if ($this->config->show_uploader_name_in_document_mamangement)
						{
						?>
							<th width="5%">
								<?php echo HTMLHelper::_('searchtools.sort',  'EDOCMAN_UPLOADER', 'uc.username', $listDirn, $listOrder); ?>
							</th>
						<?php
						}
					?>
					
					
					<th scope="col" width="4%" class="w-2 d-md-table-cell">
						<?php echo HTMLHelper::_('searchtools.sort',  'EDOCMAN_HITS', 'hits', $listDirn, $listOrder); ?>
					</th>
					<th scope="col" width="4%" class="w-2 d-md-table-cell">
						<?php echo HTMLHelper::_('searchtools.sort',  'EDOCMAN_DOWNLOADS_STATISTIC', 'downloads', $listDirn, $listOrder); ?>
					</th>
					
					<th scope="col" width="7%" class="center" class="w-3 d-md-table-cell">
						<?php echo HTMLHelper::_('searchtools.sort',  'JGRID_HEADING_ACCESS', 'access', $listDirn, $listOrder); ?>
					</th>
					<?php
					if($this->indexer == 1){
						?>
						<th width="10%" class="center" class="w-1">
							<?php echo Text::_('EDOCMAN_INDEX_CONTENT'); ?>
						</th>
						<?php
					}
					?>
					<th width="1%" class="nowrap center" class="w-1">
						<?php
						echo Text::_('EDOCMAN_DOWNLOAD');
						?>
					</th>
					<th width="1%" class="nowrap center" class="w-1">
						<?php echo HTMLHelper::_('searchtools.sort',  'JGRID_HEADING_ID', 'tbl.id', $listDirn, $listOrder); ?>
					</th>
				</tr>
			</thead>
			<tfoot>
				<tr>
					<?php
						if ($this->config->show_uploader_name_in_document_mamangement)
						{
							$cols = 13;
						}
						else
						{
							$cols = 12;
						}
						if($this->indexer == 1){
							$cols++;
						}
					?>
					<td colspan="<?php echo $cols; ?>">
						<?php echo $this->pagination->getListFooter(); ?>
					</td>
				</tr>
			</tfoot>
			<tbody>
			<?php
			require_once JPATH_ROOT.'/components/com_edocman/helper/file.class.php' ;
			foreach ($this->items as $i => $item) :
				$user		= Factory::getApplication()->getIdentity();
				$ordering	= ($listOrder == 'tbl.ordering');
				$canEdit	= $user->authorise('core.edit',			'com_edocman.document.'.$item->id);
				$coreAdmin	= $user->authorise('core.admin',		'com_edocman');
				$canCheckin	= $user->authorise('core.admin', 		'com_checkin') || $item->checked_out == $userId || $item->checked_out == 0;
				$canEditOwn	= $user->authorise('core.edit.own',		'com_edocman.document.'.$item->id) && $item->created_user_id == $userId;
				$canChange	= $user->authorise('core.edit.state',	'com_edocman.document.'.$item->id) && $canCheckin;
				$item->data = new EDocman_File($item->id,$item->filename, $config->get('documents_path'));
				?>
				<tr class="row<?php echo $i % 2; ?>">
					<td class="center">
						<?php echo HTMLHelper::_('grid.id', $i, $item->id); ?>
					</td>
					<td class="order nowrap center hidden-phone">
						<?php
						$iconClass = '';
						if (!$canChange)
						{
							$iconClass = ' inactive';
						}
						elseif (!$saveOrder)
						{
							$iconClass = ' inactive tip-top hasTooltip" title="' . HTMLHelper::tooltipText('JORDERINGDISABLED');
						}
						?>
						<span class="sortable-handler<?php echo $iconClass ?>">
							<?php
							if(EdocmanHelper::isJoomla4())
							{
							?>
								<span class="icon-ellipsis-v"></span>
							<?php
							}
							else
							{
							?>
								<span class="icon-menu"></span>
							<?php 
							}	
							?>
						</span>
						<?php if ($canChange && $saveOrder) : ?>
							<input type="text" style="display:none;" name="order[]" size="5" value="<?php echo $item->ordering; ?>" />
						<?php endif; ?>
					</td>
					<td class="center">
						<div class="btn-group">
							<?php echo HTMLHelper::_('jgrid.published', $item->published, $i, 'documents.', $canChange, 'cb'); ?>
						</div>
					</td>
					<td class="center" style="padding-top:12px;font-size:16px;padding-left:0px !important;padding-right:0px !important;color:#5871a9;">
						<?php EDocmanHelperHtml::showFileIcon($item->data); ?>
					</td>
					<td style="padding-bottom:2px !important;">
						<?php if ($item->checked_out) : ?>
						<?php echo HTMLHelper::_('jgrid.checkedout', $i, $item->editor, $item->checked_out_time, 'documents.', $canCheckin); ?>
						<?php endif; ?>
							<a href="<?php echo Route::_('index.php?option=com_edocman&task=document.edit&id='.$item->id);?>" class="documentTitle">
								<?php echo $item->title; ?>
							</a>
							<?php
							if($config->get('enable_rating'))
							{
								EdocmanHelper::showDocumentRating($item->id, 0);
							}
							?>
						<?php
						if(($item->publish_down != "") && ($item->publish_down != "0000-00-00 00:00:00") && (strtotime($item->publish_down) < time()))
						{
							?>
							<span class="expired"><?php echo Text::_('EDOCMAN_EXPIRED');?></span>
							<?php
						}
                        elseif($item->publish_down != "" && $item->publish_down != "0000-00-00 00:00:00")
                        {
                            $unpublished_date = EDocmanHelper::calculateExpiredDates($item->publish_down);
                            if($unpublished_date != "")
                            {
                                ?>
                                <span class="expired"><?php printf(Text::_('EDOCMAN_EXPIRE_IN'),$unpublished_date);?></span>
                                <?php
                            }
                        }
						if(!EDocmanHelper::isDropBoxTurnedOn() && !EDocmanHelper::isGdriveTurnedOn() && !EDocmanHelper::isAmazonS3TurnedOn())
						{
                            if(!file_exists($config->get('documents_path').'/'.$item->filename))
                            {
                                ?>
                                <span class="filemissing"><?php echo Text::_('EDOCMAN_FILE_MISSING');?></span>
                                <?php
                            }
                        }
						?>
						<p class="smallsub" style="color:grey;margin:0px !important;font-size:11px;">
							<?php echo Text::sprintf('JGLOBAL_LIST_ALIAS', $this->escape($item->alias)); ?>
						</p>
						<p class="smallsub" style="color:grey;margin:0px !important;font-size:11px;">
							<?php echo Text::_('EDOCMAN_CREATED_ON').': '. $item->created_time; ?>
						</p>
						<p class="smallsub" style="color:grey;margin:0px !important;font-size:11px;">
							<?php
							if(($item->name == "") and ($item->document_url != ""))
							{
								echo Text::_('EDOCMAN_REMOTE_PATH');
							}
							else
							{
								echo $item->original_filename;
								$itemdata = new EDocman_File($item->id, $item->filename, $this->config->documents_path);
								if ($itemdata->size != "")
								{
									echo " - " . $itemdata->size;
								}
							}
							?>
						</p>
					</td>
					<?php
					if(!EdocmanHelper::isJoomla4()) {
					?>
					<td>
						<?php 
						if($item->user_ids != "")
						{
							?>
							<p class="smallsub">
								<?php
								$users = explode(",", trim($item->user_ids));
								$userArr = array();
								foreach($users as $u)
								{
									$user = Factory::getUser($u);
									$userArr[] = $user->name;
								}
								echo implode(", ", $userArr);
								?>
							</p>
							<?php
						}
						?>
					</td>
					<?php 
					}
					?>
					<td>
						<?php echo $item->category_title ; ?>
					</td>
					<?php
						if ($this->config->show_uploader_name_in_document_mamangement)
						{
						?>
							<td>
								<?php echo $item->username; ?>
							</td>
						<?php
						}
					?>
					<?php
					if ($this->config->activate_multilingual_feature)
					{
						?>
						<td class="center">
							<?php 
							if($item->language == "*")
							{
								echo Text::_("JALL");
							}
							else
							{
								echo $item->language;
							}
						?>
						</td>
						<?php
					}
					?>
					
					<td class="center">
						<?php echo (int)$item->hits ; ?>
					</td>
					<td class="center">
						<?php echo (int)$item->downloads ; ?>
					</td>
					
					<td class="center">
						<?php
                        if($item->accesspicker == 0) {
                            echo $item->access_level;
                        }else{
                            echo EDocmanHelper::getAccessGroup(1, $item->id);
                        } ?>
					</td>
					<?php
					if($this->indexer == 1)
					{
						?>
						<td class="center">
							<?php
							if($item->exclude_indexing == 1)
							{
								?>
								<span style="font-size:11px;">
									<a href="index.php?option=com_edocman&task=document.document_remove_exclude_indexing&id=<?php echo $item->id;?>" title="<?php echo Text::_('EDOCMAN_EXCLUDE_INDEXING_REMOVING');?>" style="color:red;">
										<?php echo Text::_('EDOCMAN_EXCLUDE_INDEXING');?>
									</a>
								</span>
								<?php
							}
							else
							{
								$ext = strtolower(EdocmanHelper::getExt($item->filename)) ;
								if($item->indexed_content != "")
								{
									if ($ext == 'pdf' || $ext == 'doc' || $ext == 'docx' || $ext == 'xls' || $ext == 'xlsx')
									{
										?>
										<a href="index.php?option=com_edocman&task=document.indexcontent&id=<?php echo $item->id?>" title="<?php echo Text::_('EDOCMAN_CLICK_TO_REINDEX_CONTENT');?>">
										<?php
									}
									?>
										<i class="icon-ok"></i>
									<?php
									if ($ext == 'pdf' || $ext == 'doc' || $ext == 'docx' || $ext == 'xls' || $ext == 'xlsx')
									{
										?>
										</a>
										<?php
									}
								}else{
									
									if ($ext == 'pdf' || $ext == 'doc' || $ext == 'docx' || $ext == 'xls' || $ext == 'xlsx')
									{
										?>
										<a href="index.php?option=com_edocman&task=document.indexcontent&id=<?php echo $item->id?>" title="<?php echo Text::_('EDOCMAN_CLICK_TO_INDEX_CONTENT');?>">
										<?php
									}
									?>
										<i class="icon-unpublish" style="color:<?php echo $color;?> !important;"></i>
									<?php
									if ($ext == 'pdf' || $ext == 'doc' || $ext == 'docx' || $ext == 'xls' || $ext == 'xlsx')
									{
										?>
										</a>
										<?php
									}
								}
							}
							?>
						</td>
						<?php
					}
					?>
					<td class="center">
						<a title="<?php echo Text::_('EDOCMAN_DOWNLOAD');?>" href="index.php?option=com_edocman&task=document.download&id=<?php echo $item->id; ?>">
							<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-download" viewBox="0 0 16 16">
							  <path d="M.5 9.9a.5.5 0 0 1 .5.5v2.5a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-2.5a.5.5 0 0 1 1 0v2.5a2 2 0 0 1-2 2H2a2 2 0 0 1-2-2v-2.5a.5.5 0 0 1 .5-.5"/>
							  <path d="M7.646 11.854a.5.5 0 0 0 .708 0l3-3a.5.5 0 0 0-.708-.708L8.5 10.293V1.5a.5.5 0 0 0-1 0v8.793L5.354 8.146a.5.5 0 1 0-.708.708z"/>
							</svg>
						</a>
						&nbsp;&nbsp;
						<a title="<?php echo Text::_('EDOCMAN_COPY_DOWNLOAD_LINK');?>" href="<?php echo Uri::root()?>index.php?option=com_edocman&task=document.download&id=<?php echo $item->id; ?>" id="download_link<?php echo $item->id?>">
							<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" fill="currentColor" class="bi bi-copy" viewBox="0 0 16 16">
								<path fill-rule="evenodd" d="M4 2a2 2 0 0 1 2-2h8a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2zm2-1a1 1 0 0 0-1 1v8a1 1 0 0 0 1 1h8a1 1 0 0 0 1-1V2a1 1 0 0 0-1-1zM2 5a1 1 0 0 0-1 1v8a1 1 0 0 0 1 1h8a1 1 0 0 0 1-1v-1h1v1a2 2 0 0 1-2 2H2a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h1v1z"/>
							</svg>
						</a>
						<script type="text/javascript">
						jQuery(document).ready(function() {
							jQuery('#download_link<?php echo $item->id?>').click(function (e){
								e.preventDefault();
								var copyText = jQuery(this).attr('href');

								// Sử dụng API Clipboard
								navigator.clipboard.writeText(copyText).then(function() {
									alert("<?php echo Text::_('OS_DOWNLOAD_LINK_HAS_JUST_BEEN_COPIED_TO_YOUR_CLIPBOARD');?>");
								}, function(err) {
									console.error('Could not copy text: ', err);
								});
							});
						});
						</script>
					</td>
					<td class="center">
						<?php echo (int) $item->id; ?>
					</td>
				</tr>
				<?php endforeach; ?>
			</tbody>
		</table>
		<input type="hidden" name="task" value="" />
		<input type="hidden" name="boxchecked" value="0" />
		<input type="hidden" name="filter_order" value="<?php echo $listOrder; ?>" />
		<input type="hidden" name="filter_order_Dir" value="<?php echo $listDirn; ?>" />

		<input type="hidden" id="filter_full_ordering" name="filter_full_ordering" value="" />
		<?php echo HTMLHelper::_('form.token'); ?>
	</div>

    <div class="modal hide fade" id="modal-movingcategory">
        <div class="modal-header">
            <button type="button" role="presentation" class="close" data-dismiss="modal">x</button>
            <h3><?php echo Text::_('EDOCMAN_MOVING_CATEGORY');?></h3>
        </div>
        <div class="modal-body">
            <?php echo Text::_('EDOCMAN_PLEASE_SELECT_CATEGORY_THAT_YOU_WANT_TO_MOVE_DOCUMENTS_TO');?>
            <BR />
            <BR />
            <?php echo $this->lists['moving_category_id']; ?>
        </div>
        <div class="modal-footer">
            <button class="btn btn-info" type="button" onclick="javascript:submitForm();">
                <?php echo Text::_('JSUBMIT'); ?>
            </button>
            <button class="btn" type="button" data-dismiss="modal">
                <?php echo Text::_('JCANCEL'); ?>
            </button>
        </div>
    </div>
	<div class="modal hide fade" id="modal-movingcategory1">
        <div class="modal-header">
            <button type="button" role="presentation" class="close" data-dismiss="modal">x</button>
            <h3><?php echo Text::_('EDOCMAN_MOVING_ADDITIONAL_CATEGORY');?></h3>
        </div>
        <div class="modal-body">
            <?php echo Text::_('EDOCMAN_PLEASE_SELECT_ADDITIONAL_CATEGORY_THAT_YOU_WANT_TO_MOVE_DOCUMENTS_TO');?>
            <BR />
            <BR />
            <?php echo $this->lists['moving_category_id1']; ?>
        </div>
        <div class="modal-footer">
            <button class="btn btn-info" type="button" onclick="javascript:submitForm1();">
                <?php echo Text::_('JSUBMIT'); ?>
            </button>
            <button class="btn" type="button" data-dismiss="modal">
                <?php echo Text::_('JCANCEL'); ?>
            </button>
        </div>
    </div>
    <?php //Load the batch processing form if user is allowed ?>
    <?php if (Factory::getApplication()->getIdentity()->authorise('core.admin', 'com_edocman')) : ?>
        <?php echo HTMLHelper::_(
            'bootstrap.renderModal',
            'collapseModal',
            array(
                'title' => Text::_('EDOCMAN_BATCH_OPTIONS'),
                'footer' => $this->loadTemplate('batch_footer')
            ),
            $this->loadTemplate('batch_body')
        ); ?>
    <?php endif;?>
</form>

<script type="text/javascript">
    function submitForm(){
        var form = document.adminForm;
        form.task.value = "document.movingcategory";
        form.submit();
    }
	function submitForm1(){
        var form = document.adminForm;
        form.task.value = "document.movingcategory1";
        form.submit();
    }
	<?php
	if(EdocmanHelper::isJoomla4())
	{
	?>
		jQuery("button").removeClass("btn").addClass("btn");
	<?php } ?>
</script>
